akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
class ART{//Articulation Pionts. kansetsuten
	public:
	int n;
	vvi G;
	vector<bool>visit;
	vi prenum,parent,lowest;
	int co;
	ART(int size){
		n=size;
		G=vvi(n);
		prenum=parent=lowest=vi(n);
	}
	void add_edge(int a,int b){
		G[a].pb(b);
		G[b].pb(a);
	}
	void dfs(int now,int pre){
		prenum[now]=lowest[now]=co;
		co++;
		visit[now]=true;
		int next;
		rep(i,G[now].size()){
			next=G[now][i];
			if(!visit[next]){
				parent[next]=now;
				dfs(next,now);
				lowest[now]=min(lowest[now],lowest[next]);
			}else if(next!=pre)lowest[now]=min(lowest[now],prenum[next]);
		}
	}
	void art(){
		visit=vector<bool>(n);
		co=1;
		dfs(0,-1);//0==root
		set<int>ap;
		int np=0;
		loop(i,1,n){
			int p=parent[i];
			if(!p)np++;
			else if(prenum[p]<=lowest[i])ap.insert(p);
		}
		if(np>1)ap.insert(0);
		for(set<int>::iterator it=ap.begin();it!=ap.end();it++)
			cout<<(*it)<<endl;
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	ART art(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		art.add_edge(a,b);
	}
	art.art();
}

Measured memory_bytes: 2672
// AOJ DPL_4_B Coin Combination Problem II
// 2018.5.11 bal4u
 
#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}

long long inLL()
{
    long long n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}

#define MAX  ((1<<20)+5)

long long a[42]; int w;
long long s1[42][MAX]; int w1[42];
long long s2[42][MAX]; int w2[42];

int binarysearch_upper(long long *a, long long x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l+r) >> 1;
		if (a[m] <= x) l = m + 1; else r = m;
    }
	return l;
}

int binarysearch_lower(long long *a, long long x, int r)
{
	int m, l = 0;

    while (l < r) {
        m = (l+r) >> 1;
        if (a[m] < x) l = m + 1; else r = m;
    }
	return l;
}

int cmp(long long *a, long long *b)
{
	if (*a < *b) return -1;
	return (*a != *b);
}

long long combi(int n, int k)
{
	long long ans;

	if (s1[n][k]) return s1[n][k];
	if ((k << 1) > n) k = n-k;
	if (k == 0) ans = 1;
	else if (k == 1) ans = n;
	else ans = combi(n-1, k) + combi(n-1, k-1);
	return s1[n][k] = ans;
}

int main()
{
	int N, K, i, j, k, m1, m2, n, lim;
	long long L, R, x, y, ans;

	N = in(), K = in(), L = inLL(), R = inLL();

	w = 0;
	x = y = inLL(); if (y + K-1 <= R) a[w++] = y;
	for (i = 1; i < N; i++) {
		x = inLL();
		if (x != y) y = 0;
		if (x + K-1 <= R) a[w++] = x;
	}

	// identical a[i]
	if (x == y) {
		if (w >= K && (y = x*K) >= L && y <= R) printf("%lld\n", combi(w, K));
		else puts("0");
		return 0;
	}

	m1 = w / 2, lim = 1 << m1;
	for (i = 0; i < lim; i++) {
		x = 0, n = 0;
		for (j = 0; ; j++) {
			if (j == m1) { s1[n][w1[n]++] = x; break; }
			if ((i >> j) & 1) {
				x += a[j];
				if (++n > K) break;
			}
		}
	}

	m2 = w - m1, lim = 1 << m2;
		for (i = 0; i < lim; i++) {
		x = 0, n = 0;
		for (j = 0; ; j++) {
			if (j == m2) { s2[n][w2[n]++] = x; break; }
			if ((i >> j) & 1) {
				x += a[j+m1];
				if (++n > K) break;
			}
		}
	}

	for (i = 0; i <= K; i++) qsort(s2[i], w2[i], sizeof(long long), cmp);

	ans = 0;
	for (i = 0; i <= K; i++) {
		k = K-i;
		for (j = 0; j < w1[i]; j++) {
			y = R-s1[i][j];
			if (y >= 0) {
				ans += n = (long long)binarysearch_upper(s2[k], y, w2[k]);
				x = L-s1[i][j];
				if (x > 0) ans -= (long long)binarysearch_lower(s2[k], x, n);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    if(n%1000==0)cout << 0 << endl;
    else cout << 1000-n%1000 << endl;
}


Measured memory_bytes: 3644
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;

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

    string w;
    cin >> w;

    map<char, int> m;
    for (int i = 0; i < w.size(); i++) {
        m[w[i]]++;
    }

    bool ans = true;
    for (auto &&i : m) {
        if (i.second & 1) {
            ans = false;
            break;
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main() {
  int A, B, n;
  cin >> A >> B;
  n = 0;
  
  for (int i = A; i <= B; i++){
    int a, b, c, d, e;
    a = i % 10;
    b = (i - a) % 100 / 10;
    c = (i - a - b * 10) % 1000 / 100;
    d = (i - a - b * 10 - c * 100) % 10000 / 1000;
    e = (i - a - b * 10 - c * 100 - d *1000) % 100000 / 10000;
    
    if (a == e && b==d){
      n++;
    }
    else {
    }
  }
  
  cout << n << endl;
  
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
x = sum(a)
b = list(map(int,input().split()))
for i in range(n):
    if (a[i] < b[i]):
        tmp = b[i] - a[i]
        a[i + 1] = a[i + 1] - tmp
        a[i] = 0
        if (a[i + 1] < 0):
            a[i + 1] = 0
    else:
        a[i] = a[i] - b[i]

print(x - sum(a))


Measured memory_bytes: 24012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n;
  cin >> n;
  ll a[n];
  
  rep(i,n) cin >> a[i];
  ll ans=(a[0]-1LL);
  ll k=1LL;
  rep1(i,n-1){
    //    cout << ans << endl;
    if(a[i]<=k+1) k= max(a[i],k);
    else{
      ans+=(a[i]-1)/(k+1);
    }
    //    cout << ans << endl;
  }
  cout << ans << endl;

  
  return 0;
    

}


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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	rep(i,100){
		c=c-b;
		
		if(c<1){
			cout<<"Yes"<<endl;
			return 0;
		}
		a=a-d;
		
		if(a<1){
			cout<<"No"<<endl;
			return 0;
		}

	}
}

Measured memory_bytes: 3632
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 100010 
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
struct edge{int to,lt;}e[N<<1]; int in[N],cnt;
void add(int x,int y)
{
	e[++cnt].to=y; e[cnt].lt=in[x]; in[x]=cnt;
	e[++cnt].to=x; e[cnt].lt=in[y]; in[y]=cnt;
}
int f[N],d[N],sz[N],qwq[N],n,p,q,len,gg,nxt[N];
void dfs(int x,int fr)
{
	d[x]=x; f[x]=1;
	for(int i=in[x];i;i=e[i].lt)
	{
		int y=e[i].to; if(y==fr)	continue; dfs(y,x);
		if(f[y]+f[x]>len) len=f[y]+f[x],p=d[x],q=d[y];
		if(f[y]+1>f[x]) f[x]=f[y]+1,d[x]=d[y];
	}
}
void dfs2(int x,int fr)
{
	sz[x]=qwq[x]=1; if(gg)	return; int dd=0;
	for(int i=in[x];i;i=e[i].lt)
	{
		int y=e[i].to; if(y==fr)	continue;
		dfs2(y,x); if(sz[y]>1)	dd++,nxt[x]=y; else qwq[x]++;
		sz[x]+=sz[y]; 
	}
	if(dd>1)	gg=1;
}
int a[N],b[N],g[N];
int main()
{
	n=read(); for(int i=1;i<n;i++)	add(read(),read());
	dfs(1,0); dfs2(p,0); int tot=0; if(gg)	return puts("-1"),0;
	for(int i=p;i;i=nxt[i])	g[++tot]=qwq[i];
	g[++tot]=1; int ss=0; g[tot-1]--;
	for(int i=1;i<=tot;i++)
	{
		++ss; a[ss+g[i]-1]=ss; 
		for(int x=2;x<=g[i];x++)	++ss,a[ss-1]=ss;
	}
	reverse(g+1,g+tot+1); ss=0;
	for(int i=1;i<=tot;i++)
	{
		++ss; b[ss+g[i]-1]=ss;
		for(int x=2;x<=g[i];x++)	++ss,b[ss-1]=ss;
	}
	int owo=1;
	for(int i=1;i<=n;i++)	if(a[i]!=b[i]){owo=a[i]<b[i]; break;}
	if(owo)	for(int i=1;i<=n;i++)	printf("%d ",a[i]);
	else	for(int i=1;i<=n;i++)	printf("%d ",b[i]);
	return 0;
}

Measured memory_bytes: 12032
#include<iostream>
#include<string>
using namespace std;
int main() {
	string a;
	int b;
	int cord[4][13]={0};
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a == "S") {
			cord[0][b-1] = 1;
		}
		if (a == "H") {
			cord[1][b-1] = 1;
		}
		if (a == "C") {
			cord[2][b-1] = 1;
		}
		if (a == "D") {
			cord[3][b-1] = 1;
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (cord[i][j] == 0) {
				if (i == 0) {
					cout << "S" << " " << j + 1 << endl;
				}
				if (i == 1) {
					cout << "H" << " " << j + 1 << endl;
				}
				if (i == 2) {
					cout << "C" << " " << j + 1 << endl;
				}
				if (i == 3) {
					cout << "D" << " " << j + 1 << endl;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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; }
const long long INF = 1LL << 60;

int main()
{
    int a, b, c;
    vector<int> A;
    cin >> a >> b >> c;
    A.push_back(a);
    A.push_back(b);
    A.push_back(c);
    sort(A.rbegin(), A.rend());
    int d = A.front();
    if ((a + b + c) % 2 != (d * 3) % 2)
    {
        cout << ((d + 1) * 3 - (a + b + c)) / 2 << endl;
    }
    else if ((a + b + c) % 2 == (d * 3) % 2)
    {
        cout << (d * 3 - (a + b + c)) / 2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	ll ans = 0LL;
	for(int i = 0; i < n - 1; ++i) {
		if( a[i] > a[i + 1] ) {
			ans += (a[i] - a[i + 1]);
			a[i + 1] += (a[i] - a[i + 1]);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4752
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

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

  int P[10], Q[10];
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  uint p = 0;
  uint n = 1;
  for (int i = 0; i < N; i++) {
    p += P[i] * n;
    n *= 10;
  }

  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }
  uint q = 0;
  n = 1;
  for (int i = 0; i < N; i++) {
    q += Q[i] * n;
    n *= 10;
  }

  vector<int> a;
  for (int i = 1; i <= N; i++) {
    a.push_back(i);
  }

  vector<int> b;
  do {
    uint v = 0;
    uint n = 1;
    for (int i = 0; i < N; i++) {
      v += a[i] * n;
      n *= 10;
    }
    b.push_back(v);
  } while(next_permutation(a.begin(), a.end()));

  int pi = 0, qi = 0;
  for (int i = 0; i < b.size(); i++) {
    // cout << b[i] << endl;
    if (b[i] == p) pi = i;
    if (b[i] == q) qi = i;
  }

  // cout << pi << endl;
  // cout << qi << endl;
  cout << abs(pi - qi) << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main() {
    int x;cin>>x;
    if(x>=2000) cout<<"1"<<endl;
    else{
        bool result=false;
        for(int i=1;i<22;i++){
            if(x>=100*i && x<=105*i) result=true;
        }
        if(result) cout<<"1"<<endl;
        else cout<<"0"<<endl;
    }
}

Measured memory_bytes: 256
def main():
    s = input()
    nagasa = len(s)

    for i in range(nagasa):
        if i % 2 == 0 and s[i] == "L":
            print("No")
            exit()
        elif i % 2 != 0 and s[i] == "R":
            print("No")
            exit()
    print("Yes")

    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 61768
//Finding Missing Cardsの解答例（宗藤作/2018）
//できるだけ、コメントを丁寧に書いています。（検索で出てくるものは、アルゴリズムがわかりづらいものが多いので）

#include <iostream>
using namespace std;
int main(){

int num;			//「トランプ」の読み込み回数を代入する変数
int spade[14] ; 		//spade[0]からspade[13]までの、14個の配列変数を用意
int heart[14] ; 		//heart[0]からheart[13]までの、14個の配列変数を用意
int club[14] ;		//club[0]からclub[13]までの、14個の配列変数を用意
int diamond[14] ;		//diamond[0]からdiamond[13]までの、14個の配列変数を用意
char card_type[2] ;	//カードがS,H,C,Dのどれであるかを代入する、文字列変数（1文字分）
int card_number;		//カードの番号(1～12)を代入する変数

//配列変数spade,heart,club,diamondの初期化(全てを一度、0にする)
	for(int i=0 ; i <= 13; i =i + 1){
		spade[i] = 0;
		heart[i] = 0;
		club[i] = 0; 
		diamond[i] = 0;
	}

//カード情報の読み込み
cin>>num;	//1行目の数字を変数numに読み込み、回数を代入する
	for(int i=0 ; i <= num; i =i + 1){	//「トランプ」をnum回、読み込む
		cin >> card_type[0] ;	// 変数card_typeに、S,H,C,Dのどれかを代入する
		cin >> card_number;	//変数card_numberに、カード番号を格納する

		if( card_type[0] == 'S'){ spade[card_number] = 1 ; } 		//S numberなら、spade[card_number]を0から1にする
		if( card_type[0] == 'H'){ heart[card_number] = 1 ; }		//H numberなら、heart[card_number]を0から1にする
		if( card_type[0] == 'C'){ club[card_number] = 1 ; }		//C numberなら、club[card_number]を0から1にする
		if( card_type[0] == 'D'){ diamond[card_number] = 1 ; }	//D numberなら、diamond[card_number]を0から1にする
	}

//カード情報の出力
	//スペード分( spade[1]～spade[13]の値を、spade[1]... spade[2]...と1刻みでチェックし、0であれば「S 数字」と出力する。 )
	for(int i=1 ; i <= 13; i =i + 1){
		if ( spade[i] == 0){cout << "S" << " " << i << endl;}
	}

	//ハート分( heart[1]～heart[13]の値を、heart[1]... heart[2]...と1刻みでチェックし、0であれば「H 数字」と出力する。 )
	for(int i=1 ; i <= 13; i =i + 1){
		if ( heart[i] == 0){cout << "H" << " " << i << endl;}
	}

	//クラブ分( club[1]～club[13]の値を、club[1]... club[2]...と1刻みでチェックし、0であれば「C 数字」と出力する。 )
	for(int i=1 ; i <= 13; i =i + 1){
		if ( club[i] == 0){cout << "C" << " " << i << endl;}
	}

	//ダイヤ分( diamond[1]～diamond[13]の値を、diamond[1]... diamond[2]...と1刻みでチェックし、0であれば「D 数字」と出力する。 )
	for(int i=1 ; i <= 13; i =i + 1){
		if ( diamond[i] == 0){cout << "D" << " " << i << endl;}
	}

    return 0;
}





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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int a = s.size();

    for(int i=0;i<a;i++){
        cout << "x";
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

  if(n % 2){
    cout << "No" << endl;
    return 0;
  }

  rep(i, n/2){
    if(s[i] != s[n/2 + i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(void)
{
     
    double r,area,len;
 
    scanf("%lf",&r);
 
    len = 2 * r * M_PI;
    area = r * r * M_PI;
 
    printf("%f %f",area,len);
    return 0;
 
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
using namespace std;
char MAP[107];
int N;
int judge(int x)
{
    int cnt = 0, ans = 0, flag = 0;
    for (int i = x - 1; i >= 1; i--)
    {
        if (MAP[i] == 'B')
        {
            cnt++;
        }
        if (MAP[i] == 'W')
        {
            ans = max(ans, cnt);
        }
        if (MAP[i] == '.')
            break;
    }
    cnt = 0;
    for (int i = x + 1; i <= N; i++)
    {
        if (MAP[i] == 'B')
        {
            cnt++;
        }
        if (MAP[i] == 'W')
        {
            ans = max(ans, cnt);
        }
        if (MAP[i] == '.')
            break;
    }
    int flag_rgt = 0;
    for (int i = x + 1; i <= N; i++)
    {
        if (MAP[i] == 'B')
        {
            flag_rgt = 1;
        }
        if (MAP[i] == 'W')
        {
            continue;
        }
        else
            break;
    }
    for (int i = x - 1; i >= 1; i--)
    {
        if (MAP[i] == 'B')
        {
            if (flag_rgt)
                return -1;
        }
        if (MAP[i] == 'W')
        {
            continue;
        }
        else
        {
            break;
        }
    }
    return ans;
}
int main()
{
    cin >> N;
    cin >> MAP + 1;
    int answer = 0;
    for (int i = 1; i <= N; i++)
    {
        if (MAP[i] == '.')

        {
            answer = max(answer, judge(i));
            //cout << i << "'s judge is " << judge(i) << endl;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, k;
    cin >> n >> k;

    if(k == 0) {
        out(n*n);
        re0;
    }

    ll ans = 0;
    exrep(b, k+1, n) {
        ll c = n/b;
        ll d = n%b;
        ans += c*(b-k) + max(0LL, d-k+1);
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i, j, k, max;
  int num, tmp;

  scanf("%d", &max);
  int array[max];
  for(i = 0; i < max; i++){
    scanf("%d", &array[i]);
  }

  if(max < 3) num = 0;
  else{
      for(i = 0; i < max; i++){
        for(j = i + 1; j < max; j++){
          if(array[i] < array[j]){
            tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;
          }
        }
      } 
      for(i = 0; i < max; i++){
        for(j = i + 1; j < max; j++){
          for(k = j + 1; k < max; k++){
            if(array[i] != array[j] && array[j] != array[k] && array[k] != array[i] && array[i] < array[j] + array[k])
            num++;
          }
        }
      }
  }

  printf("%d\n", num);

  return 0;
}





Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  ll n;
  cin >> n;
  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }
 
  ll ans = 0, d = 10;
  while (d <= n) {
    ans += n / d;
    d *= 5;
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main()
{
	int num1=0,num2=0,num3=0,num4=0,test1[100],test2[100][100],test3[100];
	
	cin>>num1>>num2;
	for(int i=0;i<num2;i++){
		cin>>test1[i];
	}
	for(int q=0;q<num2;q++){
		for(int w=0;w<num1;w++){
			cin>>test2[q][w];
		}
	}
	for(int u=0;u<num1;u++){
		test3[u]=0;
	}
	for(int e=0;e<num2;e++){
		for(int r=0;r<num1;r++){
			if(test2[e][r]==test1[e]){
				test3[r]=test3[r]+1;
				if(test1[e]==r+1){
					for(int t=0;t<num1;t++){
						if(test1[e]!=test2[e][t]){
							test3[r]=test3[r]+1;
						}
					}
				}
			}
		}
	}
	for(int y=0;y<num1;y++){
		cout<<test3[y];
		cout<<"\n";
	}
	return 0;
}

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

using namespace std;

const int maxn = 2e5+9;
int A[maxn];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) scanf("%d",&A[i]);
    while(k--)
    {
        int B[maxn];
        memset(B,0,sizeof(B));
        for(int i=1;i<=n;i++)
        {
            int l = max(1,i-A[i]);
            int r = min(n,i+A[i]);
            //差分
            B[l]++;
            B[r+1]--;
        }
        //差分应用
        int flag = 1;
        for(int i=1;i<=n;i++)
        {
            A[i] = A[i-1] + B[i];
            if(A[i]!=n) flag = 0;
        }
        //剪枝
        if(flag) break;
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ",A[i]);
    }
    return 0;
}


Measured memory_bytes: 5336
#include<cstdio>
#include<cstring>
const int N=8005,A=8000;
int x,y,n,i,j,z;
bool aax[2][N],bb[2][N],aay[2][N],flag,*ax=aax[1],*ay=aay[1],*t=bb[1],fl;
char c[N];
int main(){
	scanf("%s%d%d",c+1,&x,&y);c[strlen(c+1)+1]='T';ax[0]=ay[0]=1;
	for(i=1;c[i];++i)
		if(c[i]=='T'){
			if(fl){
				memcpy(bb,aay,sizeof bb);memset(aay,0,sizeof aay);
				for(j=-A;j<=A;++j)
					if(t[j])ay[j+z]=ay[j-z]=1;
			}else{
				memcpy(bb,aax,sizeof bb);memset(aax,0,sizeof aax);
				for(j=-A;j<=A;++j)
					if(t[j]){
						ax[j+z]=1;
						if(flag)ax[j-z]=1;
					}
			}
			flag=1;fl^=1;z=0;
		}else ++z;
	return puts(ax[x] && ay[y]?"Yes":"No"),0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int n,m;
	cin>>n>>m;
	cout<<(n-1)*(m-1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
void solve()
{
       ll n,k;
       cin>>n>>k;
       ll arr[n],i;
       for(i=0;i<n;i++)
       	cin>>arr[i];
       ll dp[n+2],j;
       for(i=0;i<=n+1;i++)
       	dp[i]=10000000000;
       dp[0]=0;
       for(i=0;i<n;i++)
       {
       	for(j=i+1;j<=i+k&&j<n;j++)
       	{
       		dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
       	}
       }
       cout<<dp[n-1];
}
int main()
{
    fast();
    {
      solve();
    }
    return 0;
}


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

int main(){
  string S; cin >> S;
  for(int i=0;i<S.size()-1;i++){
    if(S.at(i) == S.at(i+1)){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}


Measured memory_bytes: 256
k = int(input())
if k==1 or k==7:
  print(1)
elif k%2==0:
  print(-1)
else:
  cnt = 1
  pre = 7
  while(True):
    surp = (pre*10+7)%k
    cnt += 1
    if surp==0:
      break
    if cnt>1000000:
      cnt = -1
      break
    pre = surp
  print(cnt)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >>W;
  string s;
  for(int i = 0;i<W+2;i++){
	cout << "#";
  }
  	cout << endl;  
  for(int i = 0;i<H;i++){
	cin >> s;
    cout << "#"<<s<<"#"<<endl;
  }
  for(int i = 0;i<W+2;i++){
	cout << "#";
  }
  	cout << endl;  
return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long K, std::vector<long long> A){
    for(int i=K;i<N;i++){
        if(A[i-K] < A[i]){
            cout << YES << "\n";
        }else{
            cout <<NO <<"\n";
        }
    }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


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

int main(){

    int n;
    cin >> n;

    double dans=0.0;
    double ians=0;

    rep(i,n){
        string u;
        double x;
        cin >> x >> u;
        if(u=="JPY"){
            ians+=x;
        }else{
            dans+=x;
        }
    }

    cout << (double)ians+dans*380000.0 <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

int main() {
  //
  ll n;
  cin >> n;
  vl a(n), b(n);
  ll suma = 0, sumb = 0;
  rep(i, n) {
    cin >> a[i];
    suma += a[i];
  }
  ll shortage = 0;
  ll tmp = 0;
  priority_queue<ll> sats;
  rep(i, n) {
    cin >> b[i];
    if (a[i] < b[i]) {
      shortage += (b[i] - a[i]);
      tmp++;
    } else {
      sats.push(a[i] - b[i]);
    }
    sumb += b[i];
  }
  if (suma < sumb) {
    cout << -1 << endl;
    return 0;
  }
  while (shortage > 0) {
    ll next = sats.top();
    sats.pop();
    tmp++;
    shortage -= next;
  }

  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h;
    while(cin >> h){
        if(h==0){
            return 0;
        }
        vector<vector<int>> a(h,vector<int>(5));
        int sum=0;
        for(int i=h-1;i>=0;i--){
            for(int j=0;j<5;j++){
                cin >> a[i][j];
                sum+=a[i][j];
            }
        }
        bool f=true;
        while(f){
            f=false;
            for(int i=0;i<h;i++){
                int cnt=1;
                for(int j=0;j<5;j++){
                    if(j){
                        if(a[i][j]>0&&a[i][j]==a[i][j-1]){
                            cnt++;
                        }
                        else{
                            if(cnt>=3){
                                for(int k=j-cnt;k<j;k++){
                                    a[i][k]=0;
                                    f=true;
                                }
                            }
                            cnt=1;
                        }
                    }
                }
                if(cnt>=3){
                    for(int j=5-cnt;j<5;j++){
                        a[i][j]=0;
                        f=true;
                    }
                }
            }
            for(int x=0;x<10;x++){
                for(int i=1;i<h;i++){
                    for(int j=0;j<5;j++){
                        if(a[i-1][j]==0){
                            a[i-1][j]=a[i][j];
                            a[i][j]=0;
                        }
                    }
                }
            }
        }
        int res=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<5;j++){
                res+=a[i][j];
            }
        }
        cout << sum-res << endl;
    }
}


Measured memory_bytes: 3044
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;

int n;

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

  cin >> n;
  vint v(n);
  vint c(n);
  REP(i, n) scan(v[i]);
  REP(i, n) scan(c[i]);

  vint vc(n);
  REP(i, n) vc[i]=v[i]-c[i];
  int sum=0;
  REP(i, n){
    if(vc[i]>0) sum+=vc[i];
  }

  cout << sum << endl;

  return 0;
}


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

int main() {
  int K, S;
  cin >> K >> S;
  
  int count = 0;
  for (int X = 0; X <= K; X++) {
    for (int Y = 0; Y <= K; Y++) {
      int Z = S - X - Y;
      if (0 <= Z && Z <= K) {
        count++;
      }
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_COST = 50010;
const int MAX_D = 25;
const int INF = 1e7;

void coinDP(int d, int *coins, int *dp){
  REP(i, MAX_COST + 1) dp[i] = INF;
  dp[0] = 0;
  REP(i, d)
    FOR(j, coins[i], MAX_COST+ 1)
      dp[j] = min(dp[j], dp[j - coins[i]] + 1);
}

int main() {
  int N, M, coins[MAX_D], dp[MAX_COST + 1]; cin >>N >>M;
  REP(i, M) cin >>coins[i];
  coinDP(M, coins, dp);
  cout <<dp[N] <<endl;
  return 0;
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
	//Enter your code here Tanmay:)
	int n,a;
	cin>>n>>a;
	if(n%a==0)
		cout<<n/a;
	else
		cout<<(n/a)+1;

}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
/*
int eulortotent(int n)
     {
    //Enter your code here Tanmay:)
    int total=n;
        for(int p=2;p*p<=n;p++)
        {
            if (n%p==0)
        {
            total /= p;
            total *= (p-1);
            while ( n % p == 0 ) 
                n /= p;
        }
    }

    if(n>1)
    {
        total/=n;
        total*=(n-1);
    }

  return total;
}
*/

Measured memory_bytes: 256
#!/usr/bin/perl -w
my ($h,$w)=split(/ /,<>);
my ($j,$i,$m,$x,$y,@line,@sq,@sub);
for($i=0;$i<$h;$i++){
    @line=split(//,<>);
    
    for($j=0;$j<$w;$j++){

       if($line[$j] eq "#"){
            $sq[$i][$j]="#";
            push @sub,"$i $j";
        }else{
            $sq[$i][$j]=0;
        }
    }
    splice @line,0;
}
for($m=0;$m<@sub;$m++){
    ($i,$j)=split(/ /,$sub[$m]);
    for($x=$i-1;$x<=$i+1;$x++){       
        for($y=$j-1;$y<=$j+1;$y++){
            if($x==-1 || $x>=$h || $y>=$w){
                last;
                }
            unless($sq[$x][$y] eq "#" || $y==-1){
                $sq[$x][$y]++;
                }
        }
    }

}

for($i=0;$i<$h;$i++){  
    for($j=0;$j<$w;$j++){
        print $sq[$i][$j];
    }
    print "\n";
}

Measured memory_bytes: 896
n = int(input())
Taro, Hanako = 0, 0
for _ in range(n):
    a, b = input().split()
    li = sorted(list((a, b)))
    if a == b:
        Taro += 1
        Hanako += 1
    elif a == li[1]:
        Taro += 3
    else:
        Hanako += 3
print("{} {}".format(Taro,Hanako))

Measured memory_bytes: 7612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		while (true) {
			// 人数入力
			int intNum = scanner.nextInt();
			int intInput[] = new int[intNum + 1];

			if (intNum == 0) {
				break;
			}
			// 得点合計値の初期化
			double intSum = 0;
			for (int intI = 0; intI < intNum; intI++) {
				// 得点入力と合計値計算
				int intScore = scanner.nextInt();
				intInput[intI] = intScore;
				intSum += intScore;
			}
			// System.out.println(dbSum);
			double dbAverage = (double)(intSum / intNum);
			// System.out.println(dbAverage);
			double dbHensaSum = 0;
			for (int intJ = 0; intJ < intNum; intJ++) {
				double dbHensa = (double)(intInput[intJ] - dbAverage);
				// System.out.println(dbHensa);
				double dbHensa2 = Math.pow(dbHensa, 2);
				dbHensaSum += dbHensa2;
			}
			// System.out.println(dbHensaSum);
			double dbBunsan = (double)(dbHensaSum / intNum);

			double dbStandard = Math.sqrt(dbBunsan);

			System.out.println(String.format("%.8f", dbStandard));
		}
	}

}



Measured memory_bytes: 31648
/**
 *    author:  tourist
 *    created: 21.01.2020 03:59:23       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a <= b) {
    cout << "Impossible" << endl;
    return 0;
  }
  int n = a + b;
  auto Ask = [&](int x, int y) {
    cout << "? " << x << " " << y << endl;
    string ans;
    cin >> ans;
    return (ans == "Y");
  };
  vector<int> st;
  for (int i = 0; i < n; i++) {
    if (st.empty()) {
      st.push_back(i);
    } else {
      if (Ask(st.back(), i)) {
        st.push_back(i);
      } else {
        st.pop_back();
      }
    }
  }
  int fair = st.back();
  string res(n, '0');
  for (int i = 0; i < n; i++) {
    if (Ask(fair, i)) {
      res[i] = '1';
    }
  }
  cout << "! " << res << endl;
  return 0;
}


Measured memory_bytes: 724
#Stack
class Node:
    def __init__(self, data):
        self.next = None
        self.data = data

class Stack:
    def __init__(self):
        self.top = None
    
    def push(self,data):
        node = Node(data)
        if self.top==None:
            self.top = node
        else:
            node.next = self.top
            self.top = node
            
    def pop(self):
        if self.top==None:
            return
        else:
            out = self.top
            self.top = self.top.next
            return out

def calc_rpn(x):
    if x=="+" or x=="-" or x=="*":
        a = stack.pop().data
        b = stack.pop().data
        if x=="+":
            stack.push(b + a)
        elif x=="-":
            stack.push(b - a)
        elif x=="*":
            stack.push(b * a)
        
    else:
        stack.push(int(x))

inp = list(input().split())
stack = Stack()

for x in inp:
    calc_rpn(x)
print(stack.pop().data)


Measured memory_bytes: 5600
N = int(input())
D = [list(map(int,input().split())) for x in range(N)]
flag = ""

for p in range(N):
    if D[p][0] == D[p][1]:
        flag += "1"
    else:
        flag += "0"

if "111" in flag:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9200
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric> // next_parmutation

using namespace std;

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  int a[55], b[55], c[55], d[55];
  for(int i = 0; i < q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i]; 
    a[i] --; 
    b[i] --;
  }

  vector<int> vec(n+m, 1);
  for(int i = 0; i < m; i++) vec.at(i) = 0;

  int ans = 0;

  //順列生成
  do{
    int zero_cnt = 1;
    int score = 0;
    vector<int> A;

    for(int i = 0; i < n+m-1; i++){
      if(vec[i] == 0) zero_cnt++;
      else A.push_back(zero_cnt);
    }

      for(int i = 0; i < q; i++){
        if(A[b[i]] - A[a[i]] == c[i]) score += d[i];
      }

      ans = max(ans, score);
    }while(next_permutation(vec.begin(), vec.end()));

cout << ans << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<string> pat = {"SS", "SW", "WS", "WW"};
    for(string x : pat){
        vector<char> ans(n);
        ans[0] = x[0];
        ans[1] = x[1];
        for(int i = 1; i < n - 1; i++){
            if(ans[i] == 'S'){
                if(s[i] == 'o') ans[i + 1] = ans[i - 1];
                else{
                    if(ans[i - 1] == 'S') ans[i + 1] = 'W';
                    else ans[i + 1] = 'S';
                }
            }else{
                if(s[i] == 'x') ans[i + 1] = ans[i - 1];
                else{
                    if(ans[i - 1] == 'S') ans[i + 1] = 'W';
                    else ans[i + 1] = 'S';
                }
            }
        }
        if(ans[n - 1] == 'S' && s[n - 1] == 'o' && ans[n - 2] != ans[0]) continue;
        if(ans[n - 1] == 'S' && s[n - 1] == 'x' && ans[n - 2] == ans[0]) continue;
        if(ans[n - 1] == 'W' && s[n - 1] == 'o' && ans[n - 2] == ans[0]) continue;
        if(ans[n - 1] == 'W' && s[n - 1] == 'x' && ans[n - 2] != ans[0]) continue;
        if(ans[0] == 'S' && s[0] == 'o' && ans[n - 1] != ans[1]) continue;
        if(ans[0] == 'S' && s[0] == 'x' && ans[n - 1] == ans[1]) continue;
        if(ans[0] == 'W' && s[0] == 'o' && ans[n - 1] == ans[1]) continue;
        if(ans[0] == 'W' && s[0] == 'x' && ans[n - 1] != ans[1]) continue;
        rep(i, n) cout << ans[i];
        cout << endl;
        return 0;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),
        a[i] -= i;
    sort(a+1,a+n+1);
    long long ans = 0;
    for(int i=1;i<=n;i++){
        ans += abs(a[i] - a[(n+1)/2]);
    }
    cout << ans;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) cin >> p[i];
  sort(p.begin(), p.end());
  int sum = 0;
  for (int i = 0; i < K; i++) sum += p[i];
  cout << sum << endl;
  return 0;
}

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

using namespace std;

int main()
{
	int n;
	int a[100000];
	int cnt=0;
	bool flag=true;
	long long sum=0;
	int t=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n-1;i++)
	{
		sum += a[i];
		if(2*sum < a[i+1])
		{
			t=i+1;
			flag=false;
		}
	}
	if(flag==true)
	{
		t=0;
	}
	cnt=n-t;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
s = input()
lenS = len(s)
a = z = -1

for i in range(lenS):
    if s[i] == 'A':
        a = i
        break

for i in range(lenS-1, -1, -1):
    if s[i] == 'Z':
        z = i
        break

print(z-a+1)

Measured memory_bytes: 40912
module Main where

import Data.List
import qualified Data.Map.Strict as Map
import Control.Monad
import Data.Ord

main = do
    putStrLn =<< solve <$> readInts

readInts :: IO [Int]
readInts = ((map read) . words) <$> getLine


solve :: [Int] -> String
solve [a, b]
    | a == b = "Yes"
    | otherwise = "No"



Measured memory_bytes: 508
#include <bits/stdc++.h>
 
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int k,s;
    cin>>k>>s;
    int ans=0;
    for(int a=0;a<=k;a++){
        for(int b=0;b<=k;b++){
            if((s-a-b)<=k && (s-a-b)>=0){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
    int a, b;
    cin >> a >> b;
    if (b%a == 0) {
        cout << a + b << endl;
    }
    else {
        cout << b - a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
 int n; cin>>n;
 double sum=0;
 REP(i,n){
   double a; cin>>a;
    sum+=1/a;
 }
 std::cout << std::fixed;
std::cout << std::setprecision(7)<<1/sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
#define MOD 1000000007
using namespace std;

int main() {
	int n, k;
	int cen = 1000, ans = 0;
	cin >> n;
	vector<int>a(n);
	REP(i, n) {
		cin >> a[i];
	}
	int m = *min_element(a.begin(), a.end());
	int M = *max_element(a.begin(), a.end());
	for (int i = m; i <= M; i++) {
		int num = 0;
		REP(j, n) {
			num += i - a[j];
		}
		num = abs(num);
		if (cen > num) {
			cen = num;
			k = i;
		}
	}
	REP(i, n) {
		ans += pow(a[i] - k, 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
<?php

while (true) {
    fscanf(STDIN, '%d %d', $n, $x);

    if (isEnd($n, $x)) { break; };

    $count = 0;
    for ($i = 1; $i <= ($x / 3); $i ++) {
        for ($j = $i + 1; $j <= (($x - $i) / 2); $j++) {
            $remainder = $x - ($i + $j);
            if ($n < $remainder || $remainder <= $j) { continue; }

            $count++;
        }
    }
    $result[] = $count;
}

echo implode(PHP_EOL, $result), PHP_EOL;

function isEnd($n, $x)
{
    return !($n || $x);
}

Measured memory_bytes: 6612
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0295

x = input()
c1 = int(x.split(" ")[0])
c5 = int(x.split(" ")[1])
c10 = int(x.split(" ")[2])
c50 = int(x.split(" ")[3])
c100 = int(x.split(" ")[4])
c500 = int(x.split(" ")[5])
if (c1 + 5 * c5 + 10 * c10 + 50 * c50 + 100 * c100 + 500 * c500) < 1000:
	print("0")
else:
	print("1")

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

using namespace std;
typedef long long ll;

int main()
{
    int N;
    int h[100001];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    ll dp[100001] = {0};
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++)
    {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[N - 1] << endl;
    // system("pause");
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;
void yn(bool b){
  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return;
}
int main() {
  string s;
  cin >> s;
  yn(s[0] == '7' || s[1] == '7' || s[2] == '7');
  return 0;
}


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

int n, m, x, a, first=0, last=0;

int main(){
    cin >> n >> m >> x;
    for(int i=0; i<m; i++){
        cin >> a;
        a<x? first++:last++;
    }
    cout << min(first, last) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }
    ll ans = 0;
    rep(i, n){
        if(i % 2 == 0 && vec[i] % 2 == 1){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3624
def main():
    N = int(input())
    A = [list(map(int,input().split())) for _ in range(2)]

    right = 0
    under = 0
    ans = A[0][0] + A[1][N-1]
    temp = 0
    for i in range(N):
        for j in range(1,i+1):
            temp += A[0][j]

        for k in range(i,N-1):
            temp += A[1][k]

        judge = A[0][0] + A[1][N-1] + temp
        if judge > ans:
            ans = judge

        judge = 0
        temp = 0

    return ans

print(main())


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int main() {
	int sum = 0;
	vector<int> a(3);
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int m = max(a[0], max(a[1], a[2]));
	if (sum % 2 == 3 * m % 2) {
		cout << (3 * m - sum) / 2 << endl;
	}
	else {
		cout << (3 * m + 3 - sum) / 2 << endl;
	}
 
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

H, W, K = map(int, input().split())
c = [input()[:-1] for _ in range(H)]
ans = 0

for S in range(1<<H):
    for T in range(1<<W):
        cnt = 0
        
        for i in range(H):
            for j in range(W):
                if (S>>i)&1 or (T>>j)&1:
                    continue
                
                if c[i][j]=='#':
                    cnt += 1
        
        if cnt==K:
            ans += 1

print(ans)

Measured memory_bytes: 73652