akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

#define MAX 1000
#define AMAX 100

class Team{
    public:
    int id, aff, acc, pen;
    Team( int i = 0, int f = 0, int a = 0, int p = 0 ):
	id(i), aff(f), acc(a), pen(p){}

    bool operator < ( const Team &t ) const {
	if ( acc == t.acc ){
	    if ( pen == t.pen ) {
		return id < t.id;
	    } else return pen < t.pen;
	} else return acc > t.acc;
    }
};

Team T[MAX];
int n;

void compute(){
    sort( T, T + n );
    int selected[AMAX] = {0};
    
    int nselected = 0;

    for ( int i = 0; i < n; i++ ){
	int aff = T[i].aff;
	int id = T[i].id;
	if ( nselected < 10 ){
	    if ( selected[aff] < 3 ){
		nselected++;
		selected[aff]++;
		cout << id << endl;
	    }
	} else if ( nselected < 20 ){
	    if ( selected[aff] < 2 ){
		nselected++;
		selected[aff]++;
		cout << id << endl;
	    }
	} else if ( nselected < 26 ){
	    if ( selected[aff] == 0 ){
		nselected++;
		selected[aff]++;
		cout << id << endl;
	    }
	}
    }
}

main(){
    while ( cin >> n &&  n ){
	for ( int i = 0; i < n; i++ ){
	    cin >> T[i].id >> T[i].aff >> T[i].acc >> T[i].pen;
	   
	}
	compute();
    }
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = max({2 * a - 1, 2 * b - 1, a + b});
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// by DenyTianly
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>

using namespace std;

#define iScf(n) scanf("%d", &n)
#define dug() printf("ok!\n")
#define iNxtL() puts("")
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define nrep(i, val, n) for(int i = val; i < n; i++)
#define mst(a, n) memset(a, n, sizeof(a))
#define ipq priority_queue
typedef pair<int, int> pii;
typedef long long LL;
typedef unsigned long long ULL;

const int inf = 1 << 26;
const LL INF = 1LL << 60;

inline void quick_IO() { ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); }
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar())
		if(ch == '-') f = -f;

	for(; ch >= '0' && ch <= '9'; ch = getchar())
		x = x*10+ch-'0';

	return x*f;
}

int quick_pow(int a, int b) {	// calculate a^b
	if(b == 1) return a;
	int temp = quick_pow(a, b/2);
	if(b&1) return temp*temp*a;
	else return temp*temp;
}

// Don't hack me, please ~
// #define _Isopen_File_
// #define _Is_Close_STD_

const int aa = 1e6;
int v[aa];

int main(){

#ifdef _Isopen_File_
	freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
#endif

#ifdef _Is_Close_STD_
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif

	int w, a, b;
	scanf("%d %d %d", &w, &a, &b);
	int x1, y1, x2, y2;
	x1 = a; y1 = a+w; x2 = b; y2 = b+w;
	for ( int i = x1; i <= y1; i++) v[i] = 1;
	int fg = 0;
	for ( int i = x2; i <= y2; i ++ ) if(v[i]) { fg = 1; break; }
	if(fg) puts("0");
	else {
		int t1 = abs(x2-y1);
		int t2 = abs(y2-x1);
		printf("%d\n", min(t1, t2));
	}

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main() {
	int t;
	// cin >> t;
    t = 1;

	while(t--) {
		int x, n;
        cin >> x >> n;
        
        vector<int> arr(n);
        for(auto &v: arr)
            cin >> v;
        
        if(n == 0) {
            cout << x << endl;
            return 0;
        }
        
        int dif = 0;
        while(true) {
            if(find(arr.begin(), arr.end(), x-dif) == arr.end()) {
                cout << (x-dif) << endl;
                return 0;
            }
            if(find(arr.begin(), arr.end(), x+dif) == arr.end()) {
                cout << (x+dif) << endl;
                return 0;
            }
            
            ++dif;
        }
	}

	return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int ans = 0;
    int max = 0;
    for(int i = 0; i < N; i++){
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      if(max < a){
        max = a;
        ans = a+b;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 49144
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var a, b string

func main() {
	sc.Split(bufio.ScanWords)
	a, b = nextStr(), nextStr()

	s, _ := strconv.Atoi(a + b)

	for i := 4; i <= s/2; i++ {
		if i*i == s {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")

}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == ',')
            s[i] = ' ';
    }
    cout << s << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  string a;
  cin >> a;
  if(a[1] == a[2]){
    if(a[0] == a[1]|| a[3] == a[2]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
if K == 1 or N == 0 or N == K or N%K==0:
    print(0)
elif K == 0:
    print(N)
elif N == 1 or N == K-1 or K == N-1 or N%K==1:
    print(1)
elif N > K:
    res = abs(N - (K*(N//K)))
    if abs(res - K) < res:
        print(abs(res-K))
    else:
        print(res)
elif K > N:
    if abs(K-N) < N:
        print(abs(K-N))
    else:
        print(N)

Measured memory_bytes: 3064
import itertools

N, M, Q = list(map(int, input().split()))

route = [[0 for i in range(N+1)] for j in range(N+1)]

for i in range(M):
    L, R = list(map(int, input().split()))
    route[L][R] += 1

for i in range(1, N):
    route[i] = list(itertools.accumulate(route[i]))

for i in range(2, N+1):
    for j in range(1, N+1):
        route[i][j] += route[i-1][j]

for i in range(Q):
    p, q = list(map(int, input().split()))
    print(route[q][q]-route[p-1][q]-route[q][p-1]+route[p-1][p-1])


Measured memory_bytes: 13660
#include<stdio.h>
#define min(x,y) ((x<y)?x:y)
int main(){
    int a,b,c,d,e;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    printf("%d\n",min(a,min(b,c))+min(d,e)-50);
    return 0;
}

Measured memory_bytes: 592
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def s(A):
 for i in range(n-1):
  if A[i][1]==A[i+1][1]and A[i][2]>A[i+1][2]:return'Not s'
 return'S'
n=int(input())
A=[(e[0],int(e[2:]),i)for i,e in enumerate(sys.stdin)]
k(A,0,n-1)
for e in[[s(A)+'table']]+A:print(*e[:2])


Measured memory_bytes: 21120
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_L=2e5;
const ll INF=1e18;
ll A[MAX_L],L;
ll dp[MAX_L+1][5];
int main(){
	cin>>L;
	REP(i,L){
		cin>>A[i];
	}
	REP(i,5)dp[L][i]=0;
	for(int n=L-1;n>=0;n--){
		for(int i=4;i>=0;i--){
			if(i==0 || i==4){
				dp[n][i]=A[n]+dp[n+1][i];
			}else if(i==2){
				dp[n][i]=(A[n]%2==1 ? 0 : 1)+dp[n+1][i];
			}else{
				ll num;
				if(A[n]==0){
					num=2;
				}else if(A[n]%2==0){
					num=0;
				}else{
					num=1;
				}
				dp[n][i]=num+dp[n+1][i];
			}
			if(i<4){
				dp[n][i]=min(dp[n][i],dp[n][i+1]);
			}
		}
	}
	cout<<dp[0][0]<<endl;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const ll inf = numeric_limits<ll>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N, K;
  cin >> N >> K;

  int h[100000+5];
  rep(i, N) cin >> h[i];

  ll cost[100000+5];
  rep(i, N) cost[i] = inf;
  cost[0] = 0;
  rep(i, N){
    REP(j, 1, K+1){
      if(i+j>=N) break;
      cost[i+j] = min(cost[i+j], cost[i] + abs(h[i] - h[i+j]));
    }
  }

  cout << cost[N-1] << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 1408
#include<stdio.h> 
#include<stdlib.h> 
 
typedef struct gihu_n_8_de{ 
  struct gihu_n_8_de *right; 
  struct gihu_n_8_de *left; 
  struct gihu_n_8_de *parent; 
  int key; 
}*Node; 

#define NIL NULL 
 
Node root; 
int asdfijejif =0; 
int asdfijejif2 = 0;

Node t_8_M(Node );
Node Search(Node , int );
Node treeSuccessor(Node );
void treeDelete(Node );
void inorder(Node );
void preorder(Node );
void insert(int );

  
int main(){ 
  int n, i, x; 
  char com[20]; 
  scanf("%d", &n); 
  for ( i = 0; i < n; i++ ){ 
    scanf("%s", com); 
    if ( com[0] == 'f' ){ 
      scanf("%d", &x); 
      Node t = Search(root, x); 
      if ( t != NIL ){ 
        printf("yes\n");  
        
      } 
      else { 
        printf("no\n"); 
        
      } 
    } 
    else if ( com[0] == 'i' ){ 
      scanf("%d", &x); 
      insert(x); 
    }  
    
    
    else if ( com[0] == 'p' ){ 
      
      inorder(root); 
      printf("\n"); 
      preorder(root); 
      printf("\n"); 
      asdfijejif = 0; 
      
    } 
    else if ( com[0] == 'd' ){ 
      scanf("%d", &x); 
      treeDelete(Search(root, x)); 
    } 
  } 
  
  return 0; 
} 



Node t_8_M(Node x){ 
  while (x->left != NIL){ 
    x = x->left; 
  } 
  return x; 
} 

 

Node Search(Node u, int k){ 
  while(u !=NIL && k !=u->key){ 
    if(k < u->key){ 
      u = u->left; 
      
    } 
    
    else u = u->right; 
  } 
  return u; 
  
} 



Node treeSuccessor(Node x){ 
  Node y; 
  if(x->right != NIL){ 
    return t_8_M(x->right); 
  } 
  y = x->parent; 
  
  while(y != NIL && x == y->right){ 
    x = y; 
    y = y->parent; 
  } 
  return y; 
} 

void treeDelete(Node z){ 
  Node y;  
  Node x; 
  
  if(z->left == NIL || z->right == NIL){ 
    y = z; 
  } 
  else { 
    y = treeSuccessor(z); 
  } 
  
  if(y->left != NIL){ 
    x = y->left; 
  }  
  else { 
    x = y->right; 
  } 
  
  if(x != NIL){ 
    x->parent = y->parent; 
  } 
  if(y->parent == NIL){ 
    root = x; 
  } 
  else if(y == y-> parent ->left){ 
    y->parent->left =x; 
  } 
  else y-> parent -> right = x; 
  
   
  if(y != z){ 
    z->key = y->key; 
  }  
  
} 

void insert(int k){ 
  Node y = NIL; 
  Node x = root; 
  Node z; 
  
  z = malloc(sizeof(struct gihu_n_8_de)); 
  z->key = k; 
  z->left = NIL; 
  z->right = NIL; 
 
  while(x != NIL){ 
    y = x; 
    if(z->key < x->key){ 
      x = x->left; 
    } 
    else x = x->right;  
  } 
  z->parent = y; 
 
  if(y == NIL){ 
    root = z; 
  } 
  else if (z->key < y->key){ 
    y->left = z; 
  } 
  
  else y->right = z; 
} 

void inorder(Node u){ 
  if(u != NIL){ 
    inorder(u->left); 
    printf(" "); 
    printf("%d",u->key); 
    inorder(u->right); 
  } 
  
} 
 
 
 
 
void preorder(Node u){ 
  
  
  if (u != NIL) { 
    printf(" "); 
    printf("%d",u->key);  
    preorder(u->left); 
      preorder(u->right); 
      
      
      
  } 
} 



Measured memory_bytes: 20496
#include<cstdio>
using namespace std;
typedef long long int ll;

int N, M;
int num[33];

int main(){
	scanf("%d %d", &N, &M);
	for(int i = 0; i < N; i++){
		int K;
		scanf("%d", &K);
		for(int i = 0; i < K; i++){
			int A;
			scanf("%d", &A);
			A--;
			num[A]++;
		}
	}
	int res = 0;
	for(int i = 0; i < M; i++){
		if(num[i] == N) res++;
	}
	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
int gcd(int x, int y){
	int buf;
	if(x<y){buf=x; x=y; y=buf;}
	while(1){
		buf=x%y;
		x=y;
		y=buf;
		if(!y){return(x);}
	}
}

int main(void){
	int n, a[100000], i, l[100000], r[100000], ans;
	for(scanf("%d", &n), i=0; i<n; scanf("%d", a+i++));
	for(l[0]=a[0], i=1; i<n; ++i){l[i]=gcd(l[i-1], a[i]);}
	for(r[n-1]=a[n-1], i=n-2; i>=0; --i){r[i]=gcd(r[i+1], a[i]);}
	for(ans=r[1], i=1; i<n-1; ++i){int buf=gcd(l[i-1], r[i+1]); ans=(ans<buf)?buf:ans;}
	ans=(ans<l[n-2])?l[n-2]:ans;
	printf("%d\n", ans);
	return(0);
}

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

long long tag_name[3];

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

    for(int i=0; i < n; i++){
        long long tmp;
        cin >> tmp;
        if(tmp%4 == 0) tag_name[2] += 1;
        else if(tmp%2 == 0) tag_name[1] += 1;
        else tag_name[0] += 1;
    }

    //tag3で消す
    if(tag_name[2] == 1) n -= 2;
    else if(tag_name[2] > 1) n -= (tag_name[2] + 1);
    //tag3自身を消す
    n -= tag_name[2];

    //tag2で消す
    n -= (tag_name[1] / 2) * 2;

    //for debug
    //for(int i=0; i < n; i++) cout << tag_name[i] << endl;

    if(n <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

signed main() {
  int N;
  cin >> N;
  
  vector<int> kisu(101000, 0);
  vector<int> gusu(101000, 0);
  int A;
  for( int i = 0; i < N; i++ ){
    cin >> A;
    if( i % 2 == 0 ){
      kisu.at(A)++;
    }else{
      gusu.at(A)++;
    }
  }
  
  int k1 = 0; //奇数で一番よく出てくる数が計何個か
  int k2 = 0;
  int g1 = 0;
  int g2 = 0;
  int k1suu = 0; //奇数で一番よく出てくる数は何か
  int k2suu = 0;
  int g1suu = 0;
  int g2suu = 0;
  
  for( int i = 0; i <= 100000; i++ ){
    if( k1 < kisu.at(i) ){
      k1 = kisu.at(i);
      k1suu = i;
    }
    if( g1 < gusu.at(i) ){
      g1 = gusu.at(i);
      g1suu = i;
    }
  }
  
  for( int i = 0; i <= 100000; i++ ){
    if( k2 < kisu.at(i) && i != k1suu ){
      k2 = kisu.at(i);
      k2suu = i;
    }
    if( g2 < gusu.at(i) && i != g1suu ){
      g2 = gusu.at(i);
      g2suu = i;
    }
  }
  
  int ans = 0;
  if( k1suu != g1suu ){
    ans = N - k1 - g1;
  }else{
    ans = min( N-k1-g2, N-k2-g1 );
  }
  cout << ans << endl;
  
  
  
}


Measured memory_bytes: 1792
import fractions
from functools import reduce
def main():
    N, X = map(int, input().split())
    x = list(map(int, input().split()))
    x.append(X)
    x.sort()
    l = []
    for i in range(N):
        l.append(x[i+1]-x[i])
    print(reduce(fractions.gcd, l))
main()


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

#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n,m;
  cin>>n>>m;
  vector<in> h(n);
  rep(i,n)
    cin>>h.at(i);
  vector<bool> ans(n,true);
  
  //vector<vector<int>> G(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    //G.at(a).push_back(b);
    if(h.at(a-1)<=h.at(b-1))
      ans.at(a-1)=false;
    if(h.at(b-1)<=h.at(a-1))
      ans.at(b-1)=false;
  }
  in sum=0;
  rep(i,n){
    if(ans.at(i)){
      sum++;
      //cout<<i<<endl;
    }
  }
  cout<<sum<<endl;
  
}

Measured memory_bytes: 4052
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                int N=sc.nextInt();
                int[]a=new int[N];
                int sum=0;
                for(int i=0;i<N;i++){
                        a[i]=sc.nextInt();
                }
                int iro=a[0];
                for(int i=1;i<N;i++){
                        if(iro==a[i]){
                                sum++;
                                iro=N+1;
                        }else{
                        iro=a[i];}
                }
                System.out.println(sum);
                


                
        }
        
        
        

		
	
}


Measured memory_bytes: 21332
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
typedef pair<int, int> P;
const int INF = 1000000000;
const int MOD = 1000000007;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };



int main()
{

	ll i,j,k,l,m,flag,cc,sum,N,M;
	flag = 0;
	sum = 0;
	char A[101];
	char B[101];
	char C[101];
	cin >> N>>A >> B >> C;
	ll ans = 0;
	REP(i, 0, N) {
		if (A[i] == B[i] && B[i] == C[i]) {
			;
		}
		else if (A[i]==B[i]||B[i]==C[i]||C[i]==A[i]) {
			ans++;
		}
		else {
			ans += 2;
		}
	}
	output(ans);
	return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j,n,a[5][105];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[0][i]);
	for(i=0;i<n;i++)
	scanf("%d",&a[1][i]);
	int sum=0,kum,maxx=0;
	for(i=1;i<n;i++)
		a[0][i]+=a[0][i-1];
	a[1][0]+=a[0][0];
	for(i=1;i<n;i++)
		a[1][i]+=a[0][i]>a[1][i-1]?a[0][i]:a[1][i-1];
	printf("%d\n",a[1][n-1]);
	return 0;
}

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

int main()
{
	int n, k;
	int b[18];

	cin >> n >> k;

	for (int i = 0; i < k; i++)
		cin >> b[i];

	for (long j = 0; j < (1 << k); j++) {
		long d = 0;

		for (int u = 0; u < k; u++) {
			if(j & (1 << u))
				d += (1 << b[u]);
		}

		cout << d << ":";

		for (int s = 0; s < k; s++) {
			if (j & (1 << s))
				cout << " " << b[s];
		}

		cout << endl;
	}

	return 0;
}


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

int main(){
	int n;
	cin >> n;
	double total_money = 0;
	for (int i = 0; i < n; i++) {
		double tmp;
		cin >> tmp;
		total_money += tmp;
	}
	cout << int(total_money / n) << endl;
}


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


int main(){
    int n,cnt = 0;
    string s,t;
    bool flag = false;
    cin >> n >> s;
    
    rep(i,0,n){
        cin >> t;
        flag = false;
        
        rep(j,1,t.size()+2){
            rep(k,0,t.size()){
                rep(l,0,s.size()){
                  	if(k+l*j >= t.size()) break;
                  
                  
                    if(s[l] != t[k+l*j]){
                        break;
                    }
                    else if(l == s.size()-1){
                        flag = true;
                        cnt++;
                        break;
                    }
                }
                
                if(flag){
                    break;
                }
                
            }
            
            if(flag){
                break;
            }
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3140
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
ld A,B,H,M;
inline void solve(void){
  in(A,B,H,M);
  out(sqrt(A*A+B*B-2*A*B*cos(2.0*((60*H+M)/720.0-M/60.0)*M_PI)));
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 4108
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int a = Integer.parseInt(sc.get());
		System.out.println(a + a * a + a * a* a);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

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

    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << a + b;
    } else if (a > b) {
        cout << a + (a - 1);
    } else {
        cout << b + (b - 1);
    }
}

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

int main()
{
  ll h, w; cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];
  rep(i, w+2) cout << "#";
  cout << endl;
  rep(i, h) {
    cout << "#";
    cout << a[i];
    cout << "#" << endl;
  }
  rep(i, w+2) cout << "#";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
	Scanner sc;
	int p;
	int[] a;
	int[] fac;
	int[] ans;

	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		p = sc.nextInt();
		a = new int[p];
		for (int i = 0; i < p; i++) a[i] = sc.nextInt();
		fac = new int[p];
		fac[0] = 1;
		for (int i = 1; i < p; i++) fac[i] = (fac[i-1] * i)%p;
		
		ans = new int[p];
		int[] mipow = new int[p];
		for (int i = 0; i < p; i++) mipow[i] = 1;
		
		for (int j = p-1; j >= 0; j--) {
			int k = 0;
			if (j == 0)
				for (int i = 0; i < p; i++) k = (k + a[i]) % p;
			for (int i = 0; i < p; i++) {
				k = (k + (p - a[i] * nCr(p-1, j) % p * mipow[i] % p) % p) % p;
				mipow[i] = mipow[i] * (p-i) % p;
			}
			ans[j] = k;
		}
		System.out.println(Arrays.stream(ans).mapToObj(n -> String.valueOf(n)).collect(Collectors.joining(" ")));
		System.out.flush();
	}
	
	private int nCr(int n, int r) {
		return fac[n] * inv(fac[r]) % p * inv(fac[n-r]) % p;
	}

	private int inv(int a) {
		int x0 = 1, x1 = 0;
		int y0 = 0, y1 = 1;
		int b = p;
	
		while (b != 0) {
			int q = a / b;
			int r = a % b;
			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;
	
			a = b; b = r;
			x0 = x1; x1 = x2;
			y0 = y1; y1 = y2;
		}
	
	    return x0;
	}

	public static void main(String[] args) {
		new Main().calc();
	}

}

Measured memory_bytes: 31108
#include <bits/stdc++.h>
using namespace std;
int main(){
string X, Y, Z;
cin >> X >> Y >> Z; 
char S = toupper(X.at(0)); 
  char T = toupper(Y.at(0)); 
  char U = toupper(Z.at(0)); 
cout << S << T << U << endl; 
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define spn setprecision
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int cp(string &a,string &b){
	int len=0;
	for(int i = 0;  i < min(a.length(),b.length()); i++){
		if(a[i]==b[i]){
			len++;
		}
		else{
			break;
		}
	}
	return len;
}
ll nc2(int &n){
	ll ans=n;
	ans*=n-1;
	ans/=2;
	return ans;
}
const int upperlimit = 1e6;
const int mod = 1e9+7;
int arr[101];
int main() {
	int a,b,ab,x,y,ans=0,temp;
	sd(a);
	sd(b);
	sd(ab);
	sd(x);
	sd(y);
	if(2*ab<a+b){
		temp=min(x,y);
		x-=temp;
		y-=temp;
		ans+=2*temp*ab;
		if(2*ab<a){
			ans+=2*x*ab;
			x=0;
		}
		if(2*ab<b){
			ans+=y*2*ab;
			y=0;
		}
	}
	ans+=x*a;
	ans+=y*b;
	pd(ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){

  int a, b;
  scanf("%d %d", &a, &b);

  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    printf("Possible\n");
  else
    printf("Impossible\n");

  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main()
{
    int N;
    cin >> N;
    int m = 0;
    ll sum = 0;
    REP(i, N)
    {
        cin >> A[i];
        if (A[i] < 0)
            m++;
        A[i] = abs(A[i]);
        sum += A[i];
    }
    sort(A, A + N);
    if (m % 2 == 1)
        sum -= 2 * A[0];
    cout << sum << endl;
    return 0;
}

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

string a(int aa, int b) {
  if(aa <= 8 && b <= 8) {
    return "Yay!";
  }
  return ":(";

}

int main() {
  int aa, b;
  cin >> aa >> b;
  cout << a(aa, b);
}

 

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
vector<int> vec(200000, 0);
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N), B, C;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		vec[A[i]]++;
	}
	
	vec.erase(remove_if(vec.begin(), vec.end(), [](int x) { return x == 0; }), vec.end());
	sort(vec.begin(), vec.end());
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	int ans = 0;

	if (A.size() > K) {
		for (int i = 0; i < A.size() - K; i++) {
			ans += vec[i];
		}
	}

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

Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N, a;
  double M;
  cin >> N >> M;
  int ans = 0;
  vector<int> vec(N);

  for (int i = 0; i < N; i++){
    cin >> a;
    vec.at(i) = a;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  int sum = accumulate(vec.begin(), vec.end(), 0);
  double d = 1/(4*M);

  for (int i = 0; i < M; i++) {
    int cnt = vec.at(i);
    if(cnt < sum*d){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3736
/*
Author : N_o_o_B
Created : July 11 2020 17:30:23 
*/
#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 TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;


    int l,r,d;
    cin >> l >> r >> d;
    int ans = r/d - (l-1)/d;
    cout << ans << endl;


    time_taken();
    return 0;
}

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

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

void primeFactor(ll val, map<ll,ll> &primeList){
  if(val<1){
    return;
  }
  for(int i=2;i*i<val;i++){
    while(val%i==0){
      primeList[i]++;
      val/=i;
    }
  }
  if(val!=1){
    primeList[val]=1;
  }
  return;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n,m,k;cin>>n>>m>>k;
  vector<ll> a(n+1),b(m+1);
  a[0]=0;
  b[0]=0;
  for(int i=1;i<n+1;i++){
    ll val;cin>>val;
    a[i]=a[i-1]+val;
  }
  for(int i=1;i<m+1;i++){
    ll val;cin>>val;
    b[i]=b[i-1]+val;
  }
  int ans=0;
  int cnt=m;
  for(int i=0;i<n+1;i++){
    for(int j=cnt;j>=0;j--){
      if(a[i]+b[j]<=k){
        cnt=j;
        ans=max(ans,i+j);
        break;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 6404
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<cassert>
#include<functional>
typedef long long ll;

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	int length;
	int minj;
	int count = 0;
	
	std::cin >> length;
	std::vector<int> input(length);
	for (int i = 0; i < length; i++){
		std::cin >> input[i];
	}

	for (int i = 0; i < length; i++){
		minj = i;
		for (int j = i; j < length; j++){
			if (input[minj] > input[j]){
				minj = j;
			}
		}
		if (i != minj){
			std::swap(input[minj], input[i]);
			count++;
		}
	}

	for (int i = 0; i < length; i++){
		std::cout << input[i];
		if (i != length - 1){
			std::cout << ' ';
		}
		else{
			std::cout << '\n';
		}
	}
	std::cout << count << '\n';

	return 0;
}


Measured memory_bytes: 3212
# -*- coding: utf-8 -*-

import numpy
import scipy

N, A, B = map(int, input().split())

sumsum = 0
for n in range(N):
    s = str(n+1)
    sum = 0
    for a in list(s):
        sum += int(a)
    #print(sum)

    if A<= sum <= B:
        sumsum += n+1
        #print(" {}".format(n+1))
print(sumsum)

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

struct sweep {
    int xl,xr;
    ll y;
    int f;
    const bool operator<(const sweep& cmp) const {
        return y<cmp.y;
    }
} line[200005];

struct segtree {
    int sl,sr;
    int cover;
    ll len;
} S[6179475];

int n;
int cnt,sid=1;
ll ans;

void update(int id,int l,int r,int ql,int qr,int v) {
    if (ql==l && qr==r) {
        S[id].cover+=v;
        if (S[id].cover) S[id].len=r-l+1;
        else {
            int res=0;
            if (S[id].sl) res+=S[S[id].sl].len;
            if (S[id].sr) res+=S[S[id].sr].len;
            S[id].len=res;
        }
        return;
    }
    int m=l+r>>1;
    if (qr<=m) {
        if (!S[id].sl) S[id].sl=sid++;
        update(S[id].sl,l,m,ql,qr,v);
    }
    else if (ql>m) {
        if (!S[id].sr) S[id].sr=sid++;
        update(S[id].sr,m+1,r,ql,qr,v);
    }
    else {
        if (!S[id].sl) S[id].sl=sid++;
        update(S[id].sl,l,m,ql,m,v);
        if (!S[id].sr) S[id].sr=sid++;
        update(S[id].sr,m+1,r,m+1,qr,v);
    }
    if (S[id].cover) S[id].len=r-l+1;
    else {
        int res=0;
        if (S[id].sl) res+=S[S[id].sl].len;
        if (S[id].sr) res+=S[S[id].sr].len;
        S[id].len=res;
    }
}

int main() {
    cin>>n;
    for (int i=0;i<n;i++) {
        int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2;
        line[cnt].xl=min(x1,x2);
        line[cnt].xr=max(x1,x2);
        line[cnt].y=min(y1,y2);
        line[cnt].f=1;
        ++cnt;
        line[cnt].xl=min(x1,x2);
        line[cnt].xr=max(x1,x2);
        line[cnt].y=max(y1,y2);
        line[cnt].f=-1;
        ++cnt;
    }
    sort(line,line+cnt);
    for (int i=0;i<cnt-1;i++) {
        update(0,-1e9,1e9,line[i].xl,line[i].xr-1,line[i].f);
        ans+=(line[i+1].y-line[i].y)*S[0].len;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 5784
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#define LL long long
#define rint register int
#define MAXN 1000005
#define P 998244353
#define INF 0x3f3f3f3f
using namespace std;

int x;

int gcd(int x, int y)
{
    return y?gcd(y, x%y):x;
}

int main()
{
    scanf("%d", &x);
    printf("%d\n", 360/gcd(360, x));
    return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
int h, w,ans;
string as;
int main () 
{
    cin>>h>>w;
    for (int i = 1; i <= h; ++i) {
        cin>>as;
        for (int j = 0; j <= w-1; ++j) {
            if (as[j]=='#'){
			ans++;
			
			} 
        }
    }
   	
    cout<<((ans == h + w - 1) ? "Possible" : "Impossible");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long max;
  cin >> max;
  long prev = 0;
  long result = 0;
  for(long i=0; max > i;i++) {
    long num;
    cin >> num;
    if(i == 0) {
      prev = num;
      continue;
    }
    if(prev > num) {
      result += prev - num;
    }
    prev = prev > num ? prev : num;
  }
  cout << result << endl;

  return 0;
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int h;
        cin >> h;
        if (h >= K) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
const int N=100000+5;
int a[N];
int n;
int sum[N];
int main()
{
    cin>>n;
    int ans=0;
    a[0]=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    a[n+1]=0;
    for(int i=1;i<=n+1;i++)
        ans+=abs(a[i]-a[i-1]);
    for(int i=1;i<=n;i++)
        sum[i]=abs(a[i]-a[i+1])+abs(a[i]-a[i-1])-abs(a[i-1]-a[i+1]);
    for(int i=1;i<=n;i++)
        cout<<ans-sum[i]<<endl;
    return 0;
}


Measured memory_bytes: 2048
#include<cstdio>
#include<algorithm>
#include<map>
#include<cstring>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long LL;

map<pair <string,string>,LL> cnt;
const int maxn = 50;
char s[maxn];

int main()
{
    int n; scanf("%d",&n);
    scanf("%s",s);
    for(int i = 0;i < (1 << n);i++)
	{ 
        string s1 = "",s2 = "";
        for(int j = 0;j < n;j++)
		{
            if(i & (1 << j)) s1 += s[j]; 
            else s2 += s[j];
        }
        cnt[make_pair(s1,s2)]++; 
    }
    LL sum = 0;
    for(int i = 0;i < (1 << n);i++)
	{ 
        string s1 = "",s2 = "";
        for(int j = n - 1;j >= 0;j--)
		{
            if(i & (1 << j)) s2 += s[j + n]; 
            else s1 += s[j + n]; 
        }
        sum += cnt[make_pair(s1,s2)]; 
    }
    printf("%lld\n",sum);
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i;
	cin >> n;
	int cnt4 = 0, cnt2 = 0, cnt1 = 0;
	for (i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a % 4 == 0) {
			cnt4++;
		}
		else if (a % 2 == 0) {
			cnt2++;
		}
		else {
			cnt1++;
		}
	}
	if (cnt4 >= cnt1) {
		cout << "Yes" << endl;
	}
	else if (cnt1 == cnt4 + 1 && cnt2 == 0) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			if (a == 0)
				break;
			double sum = 0;
			int[] b = new int[a];
			for (int i = 0; i < a; i++) {
				b[i] = scanner.nextInt();
				sum += b[i];
			}
			double m = sum / a;
			double aa = 0;
			for (int i = 0; i < a; i++) {
				aa += Math.pow(b[i] - m, 2) / a;
			}
			System.out.println(Math.sqrt(aa));

		}

	}
}

Measured memory_bytes: 23768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	ll N, X;
	cin >> N >> X;
	ll A[100000];
	rep(i, N) cin >> A[i];

	ll kotae = 0;
	rep(i, N - 1) {
		ll herasu = max(0ll, A[i] + A[i + 1] - X);
		kotae += herasu;
		if (herasu > 0) {
			if (A[i + 1] >= herasu) A[i + 1] -= herasu;
			else { A[i + 1] = 0; }
		}
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1024