akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 1000

int lcs(char *b,char *c){
  int a[N+1][N+1];
  int m,n,i,j,maxl=0;
  char str1[N],str2[N];
  m=strlen(b);
  n=strlen(c);

  str1[0]=' ';
  str2[0]=' ';
  strcpy(&str1[1],b);
  strcpy(&str2[1],c);
  for(i=0;i<=m;i++) a[i][0] = 0;
  for(j=1;j<=n;j++) a[0][j] = 0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(str1[i]==str2[j]) a[i][j] = a[i-1][j-1]+1;
      else a[i][j] = max(a[i-1][j],a[i][j-1]);

      maxl=max(maxl,a[i][j]);
    }

  }
  return maxl;
}

int max(int x,int y){
  int m;
  if(x>y) m=x;
  else m=y;
  return m;
}

int main(){
  char str1[N],str2[N];
  int n,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str1);
    scanf("%s",str2);

    printf("%d\n",lcs(str1,str2));

  }

  return 0;

}


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

using ll = long long;

int main() {
    int N;  cin >> N;
    ll ans = 0;
    for (ll a = 1; a * a <= N; ++a) {
        for (ll b = 1; a * b < N; ++b) {
            ll c = N - a * b;
            if (c >= 1) {
                if (a == b) ++ans;
                else if (a < b) ans += 2;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    set<char> st;
    rep(i,n){
        char c;
        cin >> c;
        st.insert(c);
    }
    if (st.size() == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;

void push(int A);
int pop(void);

int S[1000];
int Top = 0;

int main(void) {

	char str[100];
	int a, b;
	Top = 0;
	while (scanf("%s", str) != -1) {

		if (str[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (str[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (str[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(str));
		}
	}
	printf("%d\n", pop());

	return 0;
}

void push(int A) {
	S[++Top] = A;
}

int pop(void) {
	Top--;
	return S[Top+1];
}


Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>

#define INF 1000000

using namespace std;

int main(void)
{
	int p, q, r;
	int ans = INF;
	p = q = r = 0;

	cin >> p >> q >> r;
	ans = min(ans, p + q);
	ans = min(ans, q + r);
	ans = min(ans, r + p);

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

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  string S;
  cin >> N >> S;

  vector<int> cntE(N, 0), cntW(N, 0);
  for(int i = 1; i < N; ++i) cntW[i] = cntW[i - 1] + (S[i - 1] == 'W');
  for(int i = N - 2; i >= 0; --i) cntE[i] = cntE[i + 1] + (S[i + 1] == 'E');

  int ret = N;
  REP(i,N) ret = min(ret, cntE[i] + cntW[i]);
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 3076
//package Test;

import java.util.*;

public class Main {

    static class Solution {

        void solve(int t){
            System.out.println(t == 1 ? 0 : 1);
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int t = scanner.nextInt();
        Solution solution = new Solution();
        solution.solve(t);

    }
}


Measured memory_bytes: 35700
A, B = map(int, input().split())


def F(C):
    num = (C + 1) // 2
    if C % 2 == 0:
        if num % 2 == 0:
            return C
        else:
            return 1 ^ C
    else:
        if num % 2 == 0:
            return 0
        else:
            return 1


print(F(A - 1) ^ F(B))

print()


Measured memory_bytes: 2940
import sys
import math
input = lambda: sys.stdin.readline().rstrip()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def main():
    a, b, c, d = map(int, input().split())
    a_cnt, b_cnt = 0, 0
    a -= 1
    a_cnt = a - ((a//c + a//d) - a // lcm(c, d))
    b_cnt = b - ((b//c + b//d) - b // lcm(c, d))
    print(b_cnt - a_cnt)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9152
def main():
    N = int(input())
    ans = [0] * 100000

    for i in range(1, 100):
        for j in range(1, 100):
            for k in range(1, 100):
                tmp = i ** 2 + j ** 2 + k ** 2 + i*j + j*k + k*i
                ans[tmp] += 1
    for i in range(N):
        print(ans[i+1])


if __name__ == '__main__':
    main()

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W));
  for(int i=0;i<H;i++){
  	for(int j=0;j<W;j++){
    cin >> a.at(i).at(j);
    }
  }
  vector<vector<int>> data(H, vector<int>(W));
  for(int i=0;i<H;i++){
    int count=0;
  		for(int j=0;j<W;j++){
      		if(a.at(i).at(j) == '#') count++;
		 }
      if(count>=1) for(int k=0;k<W;k++) data.at(i).at(k) +=1;
  }

  for(int j=0;j<W;j++){
    int count=0;
  		for(int i=0;i<H;i++){
      		if(a.at(i).at(j) == '#') count++;
		 }
      if(count>=1) for(int k=0;k<H;k++) data.at(k).at(j) +=1;
  }
  
  for(int i=0;i<H;i++){
    int count=0;//開業のため追加
  	for(int j=0;j<W;j++){
    if(data.at(i).at(j)>=2) cout <<  a.at(i).at(j);
    if(a.at(i).at(j) == '#') count++;//開業のため追加
    }
   if(count>=1) cout << endl;//開業のため追加
  }
} 

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));  

  $ans = 0;
  $flg = false;
  for ($i=0; $i<$n; $i++) {
    if($a[$i] == $i+1){
      if($flg == false){      
        $ans++;
        $flg = true;
      }else{
        $flg = false;
      }
    }else{
      $flg = false;
    }    
  }
 echo $ans;

Measured memory_bytes: 25644
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

namespace MATH
{
	const int n = (int) 1e7;

	int p[n + 5], pri[n + 5], pri_cnt = 0;

	inline void init()
	{
		p[1] = 1;
		for(int i = 2; i <= n; ++i)
		{
			if(!p[i]) p[i] = i, pri[++pri_cnt] = i;
			for(int j = 1; j <= pri_cnt && i * pri[j] <= n; ++j)
			{
				p[i * pri[j]] = pri[j];
				if(i % pri[j] == 0) break;
			}
		}
	}
}

const int MAXN = 500;

int n;

inline void input()
{
	n = read<int>();
}

inline void solve()
{
	if(n == 2) { puts("4 7\n23 10"); return; }

	static int col[MAXN + 5][MAXN + 5];
	static LL a[MAXN + 5][MAXN + 5];
	for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) col[i][j] = (i + j) & 1;
	for(int i = 0; i <= n + 1; ++i) for(int j = 0; j <= n + 1; ++j) a[i][j] = 1;

	static unordered_map<int, int> id0, id1;
	int cnt = 0;

	for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) if(col[i][j] == 0)
	{
		if(!id0.count(i + j)) id0[i + j] = ++cnt;
		a[i][j] *= MATH::pri[id0[i + j]];
	}

	for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) if(col[i][j] == 0)
	{
		if(!id1.count(i - j)) id1[i - j] = ++cnt;
		a[i][j] *= MATH::pri[id1[i - j]];
	}

	auto lcm = [] (LL x, LL y) { return x / __gcd(x, y) * y; };

	for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j) if(col[i][j] == 1)
	{
		a[i][j] = lcm(a[i][j], a[i - 1][j]);
		a[i][j] = lcm(a[i][j], a[i + 1][j]);
		a[i][j] = lcm(a[i][j], a[i][j - 1]);
		a[i][j] = lcm(a[i][j], a[i][j + 1]);
		++a[i][j];
	}

	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j)
			printf("%lld%c", a[i][j], j == n ? '\n' : ' ');
}

int main()
{
#ifdef K_ON
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	MATH::init();
	input();
	solve();

	return 0;
}




Measured memory_bytes: 49536
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int x) {
	if (x < 0) {
		return -x;
	}
	return x;
}

void m_sort(int a[], int tmp[], int left, int right);
void m_sort(int a[], int tmp[], int left, int right);
void sort(int a[], int total) {
	int tmp;
	for (int i = 0; i < total; i++) {
		for (int j = i + 1; j < total; j++) {
			if (a[i] < a[j]) {
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}

}

void mergeSort(int a[], int tmp[], int size)
{
	m_sort(a, tmp, 0, size - 1);
}
void merge(int a[], int tmp[], int left, int mid, int right)
{
	int i, left_end, num_elements, tmp_pos;

	left_end = mid - 1;
	tmp_pos = left;
	num_elements = right - left + 1; // 要素 

	while ((left <= left_end) && (mid <= right))
	{
		if (a[left] <= a[mid])
		{
			tmp[tmp_pos] = a[left];
			tmp_pos = tmp_pos + 1;
			left = left + 1;
		}
		else
		{
			tmp[tmp_pos] = a[mid];
			tmp_pos = tmp_pos + 1;
			mid = mid + 1;
		}
	}


	while (left <= left_end)
	{
		tmp[tmp_pos] = a[left];
		left = left + 1;
		tmp_pos = tmp_pos + 1;
	}

	while (mid <= right)
	{
		tmp[tmp_pos] = a[mid];
		mid = mid + 1;
		tmp_pos = tmp_pos + 1;
	}


	for (i = 0; i <= num_elements; i++)
	{
		a[right] = tmp[right];
		right = right - 1;
	}
}
void m_sort(int a[], int tmp[], int left, int right)
{
	int mid;

	if (right > left)
	{
		mid = (right + left) / 2;
		m_sort(a, tmp, left, mid);
		m_sort(a, tmp, mid + 1, right);

		merge(a, tmp, left, mid + 1, right);
	}
}



long long  H, W, ans, N,x,y, A,X[8002],Y[8002],xnum,ynum, num,sum,B,now,chain[100000];
string s,t,tt,ss;
int d[100], c[100];
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	mergeSort(d, c, N);
	ans = 0;
	H = 101;
	for (int i = N - 1; i >= 0; i--) {
		if (H > d[i]) {
			ans++;
			H = d[i];
		}
	}
	cout << ans << endl;
	return 0;
}




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

typedef long long int ll;
typedef pair<ll,ll> P;
//cout<<fixed<<setprecision(15);

int c[6][6];

int main(){
    int n;
    cin>>n;
    cout<<(100000000-n)%1000<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n; cin >> n;
    int F[105][5][2];
    ll P[105][15];
    for(int i=0;i<n;i++){
        for(int j=0;j<5;j++){
            for(int k=0;k<2;k++){
                cin >> F[i][j][k];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=10;j++){
            cin >> P[i][j];
        }
    }

    ll ans = -100100100100100100;
    int shift[5][2];
    for(int m=0;m<(1<<10);m++){
        int cnt = 0;
        for(int i=0;i<5;i++){
            for(int j=0;j<2;j++) shift[i][j] = 0;
        }

        for(int j=0;j<10;j++){
            cnt += (m >> j) & 1;
            shift[j/2][j%2] = (m >> j) & 1;
        }
        if(cnt < 1) continue;

        int count[105];
        for(int i=0;i<n;i++) count[i] = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<10;j++){
                count[i] += (shift[j/2][j%2] & F[i][j/2][j%2]);
            }
        }

        ll rep = 0;
        for(int i=0;i<n;i++) rep += P[i][count[i]];

        ans = max(ans, rep);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
vector<int>e[N];
int f[N],n,i,a;
void dfs(int u){
	for(int&v:e[u])dfs(v),v=f[v];
	sort(e[u].begin(),e[u].end());
	for(int i=0,a=e[u].size();i<a;++i)f[u]=max(f[u],a-i+e[u][i]);
}
int main(){
	scanf("%d",&n);
	for(i=2;i<=n;++i)scanf("%d",&a),e[a].push_back(i);
	dfs(1);printf("%d\n",f[1]);
	return 0;
}

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

#define LLINF (1LL<<60)
typedef long long ll;

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

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    vector<int> d(N);
    rep(i,N) cin >> d[i];
    
    vector<bool> isar(101,false);
    //-----------------------------------
    rep(i,N) isar[d[i]]=true;
    int ans=0;
    rep(i,101) if(isar[i])ans++;

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

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){

    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	int n = to!int(chomp(s));
	int ans = 1;
	for(int i=1;i<=n;i++)
	    ans += i; 
	writeln(ans);
    }

}

Measured memory_bytes: 2436
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
using namespace std;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int n;
	int a[200005],b[200005];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	if(n%2==0){
		int c=0;
		for(int i=n;i>=2;i-=2){
			c++;
			b[c]=a[i];
		}
		for(int i=1;i<=n-1;i+=2){
			c++;
			b[c]=a[i];
		}
		for(int i=1;i<=n;i++)
		cout<<b[i]<<" ";
	}
	else{
		int c=0;
		for(int i=n;i>=1;i-=2){
			c++;
			b[c]=a[i];
		}
		for(int i=2;i<=n-1;i+=2){
			c++;
			b[c]=a[i];
		}
		for(int i=1;i<=n;i++)
		cout<<b[i]<<" ";
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 3712
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# define Rep(i,a,b) for(int i=a;i<=b;i++)
# define _Rep(i,a,b) for(int i=a;i>=b;i--)
# define mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=1e5+5;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}
int n;
int main()
{
	read(n);
	printf("%lf\n",1.*((n+1)/2)/n);
	return 0;
}

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

int main(){
  int N,v[50];
  cin>>N;
  for (int i(0);i<N;i++) cin>>v[i];
  sort(v,v+N);
  double ans(0);
  double a = v[0];
  for (int i(1);i<N;i++){
    a = (a+v[i])/2;
    ans+=a;
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int m,f,r;
    while(scanf("%d %d %d",&m,&f,&r) && ((m != -1 || f != -1|| r != -1))){
        if(m == -1 || f == -1){
            printf("F\n");
        } else if( m+f >= 80){
            printf("A\n");
        } else if(m+f >= 65 && m+f < 80 ){
            printf("B\n");
        } else if(m+f >= 50 && m+f < 65){
            printf("C\n");
        } else if(m+f >= 30 && m+f < 50){
            if(r >= 50){
                printf("C\n");
            } else {
                printf("D\n");
            }
        } else if(m+f < 30){
            printf("F\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2608
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;


int yakusuu(int n) {
    int res = 0;
    for(int i=1; i*i<=n; i++) {
        if(i*i == n) res++;
        else if(n % i == 0) res += 2;
    }
    return res;
}

int main() {
    int n, res = 0; cin >> n;
    Rep(i, 1, n+1) {
        if(i % 2 == 0) continue;
        if(yakusuu(i) == 8) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 764
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdint>

int main() {
  int N;
  scanf("%d", &N);

  std::vector<int> a(3*N);
  for (int &a_: a)
    scanf("%d", &a_);

  std::sort(a.begin(), a.end(), std::greater<int>());
  intmax_t res=0;
  for (int i=0; i<N; ++i)
    res += a[i<<1|1];

  printf("%jd\n", res);
}


Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

template<class T>T gcd(T a, T b){if(a<b){a^=b;b^=a;a^=b;}return b?gcd(b,a%b):a;}
template<class T>T lcm(T a, T b){return a/gcd(a,b)*b;}

ll N,M;
ll a[100000];

int main(){
    cin>>N>>M;
    rep(i,N){
        cin>>a[i];
        a[i]/=2;
    }

    ll l=1;
    rep(i,N){
        l=lcm(l,a[i]);
        if(l>M){
            cout<<0<<endl;
            return 0;
        }
    }

    bool b=true;
    rep(i,N){
        b&=(l/a[i])&1;
    }
    if(!b){
        cout<<0<<endl;
        return 0;
    }

    ll ans=(M/l+1)/2;
    cout<<ans<<endl;
}

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

int s[30][5];

P operator+(P a, int d) {
	rep(i, d) {
		if (!~s[a.first][a.second + 1]) {
			a.first++; a.second = 0;
		}
		else a.second++;
	}
	return a;
}
int main() {
	int m;
	while (scanf("%d", &m), m) {
		vector<P>v;
		rep(i, m) {
			memset(s, -1, sizeof(s));
			int id; scanf("%d", &id);
			int f = 1; bool b = 0;
			while (f <= 9) {
				scanf("%d", &s[f][b]);
				if (s[f][b] == 10) {
					f++; b = 0;
				}
				else {
					if (b)f++;
					b = !b;
				}
			}
			scanf("%d%d", &s[10][0], &s[10][1]);
			if (s[10][0] == 10 || s[10][1] == 10 || s[10][0] + s[10][1] == 10)scanf("%d", &s[10][2]);
			P p(1, 0);
			while (p.first <= 9) {
				if (!p.second&&s[p.first][p.second] == 10) {
					P a = p + 1, b = p + 2;
					s[p.first][p.second] += s[a.first][a.second] + s[b.first][b.second];
				}
				if (p.second&& s[p.first][p.second - 1] + s[p.first][p.second] == 10) {
					P a = p + 1;
					s[p.first][p.second] += s[a.first][a.second];
				}
				p = p + 1;
			}
			int cnt = 0;
			for (int i = 1; i <= 10; i++)rep(j, 3) {
				if (~s[i][j])cnt += s[i][j];
			}
			v.push_back(P(cnt, id));
		}
		sort(v.begin(), v.end(), [](P a, P b) {
			if (a.first != b.first)return a.first > b.first;
			return a.second < b.second;
		});
		for (auto p : v) {
			printf("%d %d\n", p.second, p.first);
		}
	}
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,M,b,l;
cin>>N>>M;
map<int,int>m;
for(int i=0;i<M;i++){
    cin>>l>>b;
    m[l]++;
    m[b]++;
}
for(int i=1;i<=N;i++){
    cout<<m[i]<<endl;
}
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var h = new List<int>();
        var input = Console.ReadLine().Split(" ");
        h.Add(0);
        for(int i = 0; i < N; i++)
        {
            h.Add(int.Parse(input[i]));
        }

        var dp = new int[N + 1];
        dp[1] = 0;

        for(int i = 1; i < N; i++)
        {
            if (i == 1)
            {
                dp[i + 1] = dp[i] + Math.Abs(h[i] - h[i + 1]);
            }
            else
            {
                var a = dp[i - 1] + Math.Abs(h[i - 1] - h[i + 1]);
                var b = dp[i] + Math.Abs(h[i] - h[i + 1]);
                dp[i + 1] = Math.Min(a, b);
            }
        }

        Console.WriteLine(dp[N]);
    }
}


Measured memory_bytes: 36108
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll a;
  string s;
  cin >> a >> s;

  ll b = (s[0] - '0') * 100 + (s[2] - '0')* 10 + (s[3]-'0');

  cout << (a * b)/100 << endl;
  
  

  return 0;
}


Measured memory_bytes: 3624
def bfs(field,H,W,start_x,start_y,tmp_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    que = []
    que.append([start_x,start_y])
    INF = 1000000
    min_path = [[INF] * W for i in range(H)]
    min_path[start_y][start_x] = 0
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < W and 0 <= ny < H and field[ny][nx] != "X" and min_path[ny][nx] == INF:
                min_path[ny][nx] = min_path[current[1]][current[0]] + 1
                if field[ny][nx] == tmp_N: # at the same cheese-power number
                    return nx,ny,min_path[ny][nx]
                else:
                    que.append([nx,ny])

def getField():
    matrix = []
    first = input().strip()
    H,W,N = map(int,first.split())
    for i in range(H):
        row = list(input().strip())
        for j in range(W):
            if row[j].isdigit():
                row[j] = int(row[j])
        matrix.append(row)
    return matrix,H,W,N

def getStart(field):
    for y in range(len(field)):
        for x in range(len(field[0])):
            if field[y][x] == "S":
                return x,y

def main():
    matrix,H,W,N = getField()
    sx,sy = getStart(matrix)
    distance = 0
    for k in range(N):
        if k != 0:
            tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,tmps[0],tmps[1],k+1)
            distance += tmp_dist
            tmps = [tmp_x,tmp_y]
        else:
            tmp_x,tmp_y,tmp_dist = bfs(matrix,H,W,sx,sy,k+1)
            distance += tmp_dist
            tmps = [tmp_x,tmp_y]
    print(distance)


if __name__=='__main__':
    main()

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    string s, t;
    cin >> s >> t;
    if (s == t.substr(0, (int)t.size()-1)) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main() {
	static char s[5];
	int n, i;

	scanf("%s", s);
	n = 0;
	for (i = 0; i < 4; i++)
		n = s[i] == '+' ? n + 1 : n - 1;
	printf("%d\n", n);
	return 0;
}


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			List<Tuple<int, bool>>[] syou = new List<Tuple<int, bool>>[n];
			for (int i = 0; i < n; i++) {
				int m = cin.Int();
				syou[i] = new List<Tuple<int, bool>>();
				for (int j = 0; j < m; j++) {
					int x = cin.Int() - 1;
					int y = cin.Int();

					syou[i].Add(new Tuple<int, bool>(x, y == 1));
				}
			}

			long ans = 0;
			for (int i = 0; i < 1 << n; i++) {
				int[] syoujiki = new int[n];
				bool ok = true;
				int cnt = 0;
				for (int j = 0; j < n; j++) {
					if (((1 << j) & i) != 0) {
						if (syoujiki[j] == -1) {
							ok = false;
							break;
						}
						syoujiki[j] = 1;

						++cnt;
						foreach (var next in syou[j]) {
							if (next.Item2) {
								if (syoujiki[next.Item1] == -1) {
									ok = false;
									break;
								}
								syoujiki[next.Item1] = 1;
							} else {
								if (syoujiki[next.Item1] == 1) {
									ok = false;
									break;
								}
								syoujiki[next.Item1] = -1;
							}
						}
					} else {
						if (syoujiki[j] == 1) {
							ok = false;
							break;
						}
						syoujiki[j] = -1;
					}
				}

				if (ok) {
					ans = Math.Max(ans, cnt);
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 15316
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


void solve() {
	int n, m; cin >> n >> m; if (n == 0 and m == 0) exit(0);
	vector<bitset<500>> vs(n); for (int i = 0; i < n; i++) cin >> vs[i];
	int res = 0;
	if (n < m) {
		for (int S = 0; S < (1 << n); S++) {
			int cnt = 0;
			bitset<500> f;
			for (int i = 0; i < n; i++) {
				if (S >> i & 1) {
					cnt++;
					f ^= vs[i];
				}
			}
			if (f.count() == 0) chmax(res, cnt);
		}
	}
	else {
		vector<vector<int>> dp(2, vector<int>(1 << m, -1));
		int cur = 0;
		int nxt = 1;
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			int S = vs[i].to_ulong();
			for (int i = 0; i < (1 << m); i++) dp[nxt][i] = -1;
			for (int T = 0; T < (1 << m); T++) {
				if (dp[cur][T] == -1) continue;
				chmax(dp[nxt][T], dp[cur][T]);
				chmax(dp[nxt][T ^ S], dp[cur][T] + 1);
			}
			swap(cur, nxt);
		}
		chmax(res, dp[cur][0]);
	}
	cout << res << "\n";
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int kkt = 89;
	while (kkt) {
		solve();
	}

}



Measured memory_bytes: 60452
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
// typedef pair<int, int> P;
struct edge
{
	int num, d, c;
	bool operator < (const edge &x) const {
		if(d != x.d) return d > x.d;
		else return c > x.c;
	}
};
const int inf = 1e9;
const int maxn = 1e4+5;
pair<int, int> d[maxn];
std::vector<edge> G[maxn];

int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	//freopen("in.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	while(cin >> n >> m && n){
		int u, v, w, c;
		// cout << n << ' ' << m << endl;
		for(int i = 1; i <= n; i++){
			G[i].clear();
		}
		for(int i = 0; i < m; i++){
			cin >> u >> v >> w >> c;
			G[u].push_back({v,w,c});
			G[v].push_back({u,w,c});
		}
		for(int i = 1; i <= n; i++){
			d[i] = make_pair(inf, inf);
		}
		// int d[1] = 0;
		priority_queue<edge> q;
		q.push({1, 0, 0}); 
		int ans = 0;
		while(!q.empty()){
			edge cur = q.top(); q.pop();
			// cout << cur.d << endl;
			if(d[cur.num] < make_pair(cur.d, cur.c)) continue;
			int k = cur.num;
			d[k] = make_pair(cur.d, cur.c);
			for(edge i : G[k]){
				pair<int, int> temp = d[k];
				temp = make_pair(d[k].first + i.d, i.c);
				if(temp < d[i.num]){
					d[i.num] = temp;
					q.push({i.num, d[i.num].first, i.c});
					// cout << d[k]+i.d << ' ';
				} 
			}
			// cout << endl;
			ans += cur.c; 
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 5100
import java.util.*;

class Main {
    public static void main(String[] args) {
        String[] week = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        for(int i=0; i<7; i++){
            if(S.equals(week[i])){
                System.out.println(7-i);
            }
        }
    }
}

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

using namespace std;

map< char, int > declaration;
map< pair< char, int >, int > assignment;

int expression(string &s, int &idx, int now)
{
  char array_name = s[idx];
  if(isalpha(array_name)) {
    ++idx;
    ++idx;
    int get = expression(s, idx, now);
    if(declaration[array_name] <= get) throw (now);
    if(!assignment.count({array_name, get})) throw (now);
    ++idx;
    return (assignment[{array_name, get}]);
  } else {
    int ret = 0;
    while(isdigit(s[idx])) ret = ret * 10 - '0' + s[idx++];
    return (ret);
  }
}


void exec(string &s, int now)
{
  char array_name = s[0];
  int ptr = 2;
  if(s.find('=') == string::npos) {
    declaration.emplace(array_name, expression(s, ptr, now));
  } else {
    int number = expression(s, ptr, now);
    if(declaration[array_name] <= number) throw (now);
    ptr += 2;
    int get = expression(s, ptr, now);
    assignment[{array_name, number}] = get;
  }
}

int main()
{
  string S[1005];
  while(cin >> S[0], S[0] != ".") {
    for(int i = 1; S[i - 1] != "."; ++i) {
      cin >> S[i];
    }

    try {
      for(int i = 0; S[i] != "."; i++) {
        exec(S[i], i + 1);
      }
      throw 0;
    } catch(int x) {
      cout << x << endl;
    }

    declaration.clear();
    assignment.clear();
  }
}

Measured memory_bytes: 3352
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N = int(readline())
    if N == 0:
        return False
    M = int(readline())
    K = int(readline())
    D = int(readline())
    P = [list(map(int, readline().strip())) + [0] for i in range(D)]
    INF = (10, 0); GL = (-1, 0)
    X = [INF]*N
    X[K-1] = GL
    for i in range(D-1, -1, -1):
        Pi = P[i]
        for j in range(N-1):
            if Pi[j]:
                X[j], X[j+1] = X[j+1], X[j]
            elif 0 == Pi[j-1] == Pi[j+1]:
                if X[j] == GL:
                    X[j+1] = (i, j)
                if X[j+1] == GL:
                    X[j] = (i, j)
    if X[M-1] == GL:
        write("0\n")
    elif X[M-1] == INF:
        write("1\n")
    else:
        x, y = X[M-1]
        write("%d %d\n" % (x+1, y+1))
    return True
while solve():
    ...


Measured memory_bytes: 5620
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

a, b = inl()

if b % a == 0:
    print(a + b)
else:
    print(b-a)


Measured memory_bytes: 3572
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

struct Point{double x, y;};

vector<pair<double, double> > A;

void Koch(int n, Point a, Point b){
    if(n == 0) return;
    Point s, t, u;
    double th = M_PI / 3.0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = cos(th) * (t.x - s.x) - sin(th) * (t.y - s.y) + s.x;
    u.y = sin(th) * (t.x - s.x) + cos(th) * (t.y - s.y) + s.y;

    Koch(n-1, a, s);
    cout << setprecision(8) << s.x << " " << s.y << endl;
    Koch(n-1, s, u);
    cout << setprecision(8) << u.x << " " << u.y << endl;
    Koch(n-1, u, t);
    cout << setprecision(8) << t.x << " " << t.y << endl;
    Koch(n-1, t, b);
}

int main(){
    int n;
    cin >> n;
    Point a, b;
    a.x = a.y = b.y = 0.0;
    b.x = 100.0;
    cout << fixed;
    cout << setprecision(8) << a.x << " " << a.y << endl;
    Koch(n, a, b);
    cout << setprecision(8) << b.x << " " << b.y << endl;
    return 0;
}
    


Measured memory_bytes: 3272
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

vector<vector<int>> m;

bool possible(int s,int pre,int count){
    bool ans = false;
    if(count == 2){
        if(s == 1) return true;
        else return false;
    } 
    for(auto num : m[s]){
        if(num != pre) ans |= possible(num,s,count+1); 
    }
    return ans;
}

int main(){
    int N,M;
    cin >> N >> M;
    m.resize(N+1);
    for(int i = 0; i < M; i++){
        int a,b;
        cin >> a >> b;
        m[a].emplace_back(b);
        m[b].emplace_back(a);
    }
    if(possible(N,-1,0)) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 12016
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer a = sc.nextInt();
		Integer b = sc.nextInt();
		Integer c = sc.nextInt();
		Integer x = sc.nextInt();
		Integer count = 0;
		
		for(int ia = 0; ia <= a; ia ++) {
			for(int ib = 0; ib <= b; ib ++) {
				for(int ic = 0; ic <= c; ic ++) {
					int total = ia * 500 + ib * 100 + ic * 50;
					if(total == x) {
						count ++;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <string.h>
/*
static struct{
	unsigned h : 1;
}obj[100000001];
*/
long A[200200];
  /* �z��̗v�f���������� */
void Swap(long int x[ ], long int i, long int j)
{
    long int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

  /* �N�C�b�N�\�[�g���s�� */
void QSort(long x[ ], long int left, long int right)
{
    long int i, j;
    long int pivot;

    i = left;                      /* �\�[�g����z��̈�ԏ������v�f�̓Y�� */
    j = right;                     /* �\�[�g����z��̈�ԑ傫���v�f�̓Y�� */

    pivot = x[(left + right) / 2]; /* ��l��z��̒����t�߂ɂƂ� */

    while (1) {                    /* �������[�v */

        while (x[i] < pivot)       /* pivot ���傫���l�� */
            i++;                   /* �o��܂� i �𑝉������� */

        while (pivot < x[j])       /* pivot ��菬�����l�� */
            j--;                   /*  �o��܂� j ������������ */
        if (i >= j)                /* i >= j �Ȃ� */
            break;                 /* �������[�v���甲���� */

        Swap(x, i, j);             /* x[i] �� x[j]������ */
        i++;                       /* ���̃f�[�^ */
        j--;
    }

    if (left < i - 1)              /* ��l�̍��� 2 �ȏ�v�f������� */
        QSort(x, left, i - 1);     /* ���̔z��� Q �\�[�g���� */
    if (j + 1 <  right)            /* ��l�̉E�� 2 �ȏ�v�f������� */
        QSort(x, j + 1, right);    /* �E�̔z��� Q �\�[�g���� */
}



int main()
{
	long i,N,tmp;
	i=0;
	scanf("%ld",&N);
	//for(i=0;i<100010100;i++)obj[i].h=0;
	for(i=0;i<N;i++){
		scanf("%ld",&A[i]);
	}
	QSort(A,0,N-1);
	
	for(i=0;i<N-1;i++){
		if(A[i]==A[i+1]){
			printf("NO\n");
			return 0;
		}
	}
	
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1664
(deftype uint32 () '(unsigned-byte 32))

(defun solve (n k h)
  (let ((costs (make-array n :element-type 'uint32)))
    (loop for i from 0 below n
          do (setf (aref costs i)
                   (loop for d from 1 to k
                         minimize (+ (aref costs (max 0 (- i d)))
                                     (abs (- (aref h (max 0 (- i d)))
                                             (aref h i)))))))
    (aref costs (1- n))))

#-swank
(let* ((n (read))
       (k (read))
       (h (make-array n :element-type 'uint32)))
  (loop for i from 0 below n
        do (setf (aref h i) (read)))
  (format t "~A~%" (solve n k h)))


Measured memory_bytes: 57828
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int D, G;
    cin >> D >> G;
    vector<int>p(D), c(D);
    for (int i = 0; i < D; i++)cin >> p[i] >> c[i];

    int ans = 100000;
    for (int i = 0; i < (1 << D); i++) {
        int point = 0, problem = 0;
        for (int j = 0; j < D; j++) {
            if ((i >> j) & 1) {
                point += ((j + 1) * 100 * p[j]) + c[j];
                problem += p[j];
            }
        }
        if (point >= G) {
            ans = min(ans, problem);
            continue;
        }
        for (int j = D-1; j >= 0; j--) {
            if (!((i >> j) & 1)) {
                int n = ((G - point) + ((j + 1) * 100) - 1) / ((j + 1) * 100);
                if (n < p[j]) {
                    problem += n;
                    ans = min(ans, problem);
                    break;
                }
            }

        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
char x[100];
int main(void){
    cin>>x;
    bool ok=true;
    int n=0;
    if(x[n]=='A'){
        n++;
    }
    if(x[n]!='K')ok=false;
    else n++;
    if(x[n]!='I')ok=false;
    else n++;
    if(x[n]!='H')ok=false;
    else n++;
    if(x[n]=='A'){
        n++;
    }
    if(x[n]!='B')ok=false;
    else n++;
    if(x[n]=='A'){
        n++;
    }
    if(x[n]!='R')ok=false;
    else n++;
    if(strlen(x)>n&&!(x[n]=='A'&&strlen(x)==n+1))ok=false;
    if(ok)cout<<"YES\n";
    else cout<<"NO\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int ans = 0;
		String str = scan.next();
		for(int i=0;i<str.length()/2;i++) {
			if(str.charAt(i) != str.charAt(str.length()-1-i)) {
				ans += 1;
			}
		}
		System.out.println(ans);
	}

}




Measured memory_bytes: 23764
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

set<ll> divisor(ll n){
    set<ll> s;
    for(ll i = 1; i*i <= n; i++){
        if(n % i == 0){
            s.insert(i);
            s.insert(n/i);
        }
    }
    return s;
}

int main(){
    ll n; cin >> n;
    set<ll> div = divisor(n-1);
    set<ll> div2 = divisor(n);
    ll ans = div.size()-1;
    for(ll u : div2){
        if(u == 1) continue;
        ll k = n;
        while(k % u == 0) k /= u;
        if(k%u == 1) ans++;
    }
    cout << ans << endl;
}


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

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

  vector<bool> a(4);
  for (int i = 0; i < s.size(); i ++) {
    if (s.at(i) == 'N') {
      a.at(0) = true;
    } else if (s.at(i) == 'S') {
      a.at(1) = true;
    } else if (s.at(i) == 'W') {
      a.at(2) = true;
    } else {
      a.at(3) = true;
    }
  }

  string ans;
  if ((a.at(0) && a.at(1)) && (a.at(2) && a.at(3))) {
    ans = "Yes";
  } else if ((a.at(0) && a.at(1)) && (!a.at(2) && !a.at(3))) {
    ans = "Yes";
  } else if ((!a.at(0) && !a.at(1)) && (a.at(2) && a.at(3))) {
    ans = "Yes";
  } else {
    ans = "No";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt(); // 頂点
		int m = sc.nextInt(); // 辺
		int[][] dist = new int[n + 1][n + 1];
		int[] a = new int[m];
		int[] b = new int[m];
		int[][] edge = new int[n + 1][n + 1];
		boolean[][] count = new boolean[n + 1][n + 1];
		int ans = 0;

		for (int i = 0; i < n+1; i++) {
			Arrays.fill(edge[i], 1000);
				edge[i][i] = 0;
		}

		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			edge[b[i]][a[i]] = edge[a[i]][b[i]] = sc.nextInt();
		}

		for (int i = 1; i < n + 1; i++) {
			for (int j = 1; j < n + 1; j++) {
				dist[i][j] = edge[i][j];
			}
		}
		// ワーシャルフロイド法で最短距離を計算
		for (int k = 1; k < n + 1; k++) {
			for (int i = 1; i < n + 1; i++) {
				for (int j = 1; j < n + 1; j++) {
					dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
		for (int i = 0; i < m; i++) {
			for (int s = 1; s < n + 1; s++) {
				for (int t = 1; t < n + 1; t++) {
					if (dist[s][t] == dist[s][a[i]] + edge[a[i]][b[i]] + dist[b[i]][t]) {
						count[a[i]][b[i]]= true;
					}
				}
			}
		}
		for (int i = 0; i < m; i++) {
			if (count[a[i]][b[i]])
				ans++;
		}
		System.out.println(m - ans);
	}
}


Measured memory_bytes: 14768
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;

typedef pair<int, int> pii;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> c(10, vector<int>(10));
	for (int i = 0; i < 10;i++) {
		for (int j = 0; j < 10;j++) {
			cin >> c[i][j];
		}
	}

	vector<int> d(10,1000000);
	vector<int> isChecked(10, false);
	d[1] = 0;
	priority_queue<pii,vector<pii>,greater<pii>> pq;
	pq.push(make_pair(0,1));
	while (!pq.empty()) {
		int v = pq.top().second;
		pq.pop();
		if (!isChecked[v]) {
			for (int i = 0; i < 10;i++) {
				if (d[v] + c[i][v] < d[i]) {
					d[i] = d[v] + c[i][v];
					pq.push(make_pair(d[i],i));
				}
			}
			isChecked[v] = true;
			//cout << v << endl;
		}
	}
	

	ll ans = 0;
	for (int i = 0; i < h;i++) {
		for (int j = 0;j < w;j++) {
			int a;
			cin >> a;
			if (a != -1) {
			
				ans += d[a];
				//cout << a << " " << ans << endl;
			}
		}
	}
	cout << ans << endl;

}


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

const ll INF = 1e18L + 10;

template<typename T>
void self_min(T &a, T b)
{
	a = min(a, b);
}

int main() {
	int n, w;
	cin >> n >> w;
	vector<int> weight(n), value(n);
	for(int i = 0; i < n; i++)
	{
		cin >> weight[i] >> value[i];
	}
	int sum_value = 0;
	for(int i : value)
	{
		sum_value += i;
	}
	vector<ll> dp(sum_value + 1, INF);
	dp[0] = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = sum_value - value[i]; j >= 0; j--)
		{
			self_min(dp[j + value[i]], weight[i] + dp[j]);
		}
	}
	ll sol = 0;
	for(int i = 0; i <= sum_value; i++)
	{
		if(dp[i] <= w)
			sol = max(sol, (ll) i);
	}
	cout << sol << "\n";
	
	return 0;
}

Measured memory_bytes: 1024
N,D = map(int, input().split())
X  = []
for n in range(N):
    x = list(map(int, input().split()))
    X.append(x)
    
import numpy as np
def distance(a,b):
    dis = 0
    for i in range(D):
        dis += (a[i]-b[i])**2
    return np.sqrt(dis)

count = 0
for i in range(N):
    for j in range(1,N-i):
        if distance(X[i],X[i+j]).is_integer():
            count += 1
print(count)

Measured memory_bytes: 12496