akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template<int p = 1000000007>
class Z {
	ll x;
public:
	Z(ll X) :x((X + p) % p) { ; }
	Z() :x(0) { ; }
	Z &operator=(ll y) {
		return *this = Z(y);
	}
	Z operator-() const {
		return Z(-x);
	}
	Z operator+(ll y) const {
		return Z(x + y);
	}
	Z &operator+=(ll y) {
		return *this = *this + y;
	}
	Z operator-(ll y) const {
		return Z(x - y);
	}
	Z &operator-=(ll y) {
		return *this = *this - y;
	}
	Z operator*(ll y) const {
		return Z(x * y);
	}
	Z &operator*=(ll y) {
		return *this = *this * y;
	}
	Z operator/(ll y) const {
		return *this * Z(y).pow(p - 2);
	}
	Z &operator/=(ll y) const {
		return *this = *this / y;
	}
	Z operator+(const Z &r) const {
		return *this + r.x;
	}
	Z &operator+=(const Z &r) {
		return *this += r.x;
	}
	Z operator-(const Z &r) const {
		return *this - r.x;
	}
	Z &operator-=(const Z &r) {
		return *this -= r.x;
	}
	Z operator*(const Z &r) const {
		return *this * r.x;
	}
	Z &operator*=(const Z &r) {
		return *this *= r.x;
	}
	Z operator/(const Z &r) const {
		return *this / r.x;
	}
	Z &operator/=(const Z &r) {
		return *this /= r.x;
	}
	Z pow(int i) {
		if (i == 0) return Z(1);
		if (i % 2) return *this * pow(i - 1);
		Z tmp = pow(i / 2);
		return tmp * tmp;
	}
	ll get() {
		return x;
	}
};

const int p = 998244353;

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

	int N, S;
	cin >> N >> S;
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	Z<p> res(0);
	vector<Z<p>> q(S + 1);
	REP(i, N) {
		q[0] += 1;
		vector<Z<p>> q2(S + 1);
		REP(j, S + 1) {
			q2[j] += q[j];
			if (j + A[i] <= S) q2[j + A[i]] += q[j];
		}
		q = q2;
		res += q[S];
	}
	cout << res.get() << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, K;
  scanf("%d %d", &N, &K);

  // solve
  int i = 0, j = 0;
  if (K > (N - 1) * (N - 2) / 2) {
    printf("-1\n");
  } else {
    vector<int> us, vs;
    // create spoke
    for (int i = 1; i < N; i++) {
      us.push_back(0);
      vs.push_back(i);
    }
    // connect leaves
    int cnt = (N - 1) * (N - 2) / 2, i = 1, j = 2;
    while (cnt > K) {
      us.push_back(i);
      vs.push_back(j);
      cnt--;
      j++;
      if (j >= N) {
        i++;
        j = i + 1;
      }
    }
    const int M = us.size();
    printf("%d\n", M);
    for (int i = 0; i < M; i++) {
      printf("%d %d\n", us[i] + 1, vs[i] + 1);
    }
  }
  
  return 0;
}


Measured memory_bytes: 384
n = int(input())
flg = False
tmp = 0
ans = 0
for i in range(n):
	a, b = map(int, input().split())
	if not flg and a == b:
		tmp = 1
		flg = True
	elif flg and a == b:
		tmp += 1
	else:
		tmp = 0
	ans = max(ans, tmp)
print("Yes" if ans >= 3 else "No")


Measured memory_bytes: 9180
from collections import deque
import numpy as np

n = int(input())
a = deque(map(int, input().split()))
a.appendleft(0)
a.append(0)
a = np.array(a)

sum = sum([abs(a[i + 1] - a[i]) for i in range(len(a) - 1)])
ans = 0

for i in range(n):
    ans = sum
    ans = ans - abs(a[i + 1] - a[i]) - abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i])
    print(ans)

Measured memory_bytes: 22912
import sys
import numpy as np

s = input()

while True:
    if (s != s[::-1]):
        print("No")
        break
    end = (len(s)-1) // 2
    e1 = s[:end]
    if (e1 != e1[::-1]):
        print("No")
        break
    start = (len(s)+3) // 2 - 1
    e2 = s[start:]
    if (e2 != e2[::-1]):
        print("No")
        break
    print("Yes")
    break

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

using namespace std;

using bellman_cost = long long;

template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Vertex
{
	T cost;
	bool valid = false;
	Vertex(T v1) : cost(v1) {}
	Vertex() {}
};
using vertex = Vertex<bellman_cost>;

template<class T>
struct Edge
{
	int to;
	T cost;
	Edge(int t, T c) : to(t), cost(c) {}
	Edge() {}
};
using edge = Edge<bellman_cost>;
using graph = Graph<vertex, edge>;

template<class T, class V, class E>
void Bellmanford(Graph<V, E>& G, int s, T INF_COST)
{
	auto &v = G.v;
	auto &e = G.e;
	for (auto& vv : v) vv.cost = INF_COST, vv.valid = false;
	v[s].cost = 0;
	v[s].valid = true;
	for (int i = 0; i + 1 < (int) v.size(); i++) {
		for (int j = 0; j < (int) v.size(); j++) {
			for (auto& x: e[j]) {
				if (v[j].cost == INF_COST) continue;
				v[x.to].cost = min(v[x.to].cost, v[j].cost + x.cost);
				v[x.to].valid = true;
			}
		}
	}
	auto valid_check = [&](auto f, int pos) {
		if (!v[pos].valid) return;
		v[pos].valid = false;
		for (auto& y: e[pos]) {
			f(f, y.to);
		}
	};
	for (int i = 0; i < (int) v.size(); i++) {
		for (auto& x: e[i]) {
			if (v[i].cost == INF_COST) continue;
			if (v[x.to].cost > v[i].cost + x.cost) {
				valid_check(valid_check, x.to);
			}
		}
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	graph g(N);
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		g.add_edge(a-1, b-1, -c);
	}
	Bellmanford(g, 0, LLONG_MAX);
	if (g.v[N-1].valid) cout << -g.v[N-1].cost << endl;
	else cout << "inf" << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
  int i = 0, tmp;
  char array[100];
  int stack[99];

  while(scanf("%s",array) != EOF){
    if ( array[0] == '+' ){
      tmp = 0;
      tmp += stack[i];
      stack[i] = 0;
      i -= 1;
      tmp += stack[i];
      
      stack[i] = tmp;
      
    }
    else if ( array[0] == '-' ){
      tmp = 0;
      tmp -= stack[i];
      stack[i] = 0;
      i -= 1;
      tmp += stack[i];
      
      stack[i] = tmp;
    }
    else if ( array[0] == '*' ){
      tmp = 1;
      tmp = tmp * stack[i];
      stack[i] = 0; 
      i -= 1;
      tmp = tmp * stack[i];

      stack[i] = tmp;
    }
    else {
      i++;
      stack[i] = atoi(array);
    }
  }

  printf("%d\n", stack[i]);
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){


*/
signed main(){
  string a,b;
  cin>>a>>b;
  int c,d;
  cin>>c>>d;
  string e;
  cin>>e;
  if(e==a)
    cout<<c-1<<" "<<d<<endl;
  else

    cout<<c<<" "<<d-1<<endl;
}
  


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
#define N 100009
#define LL long long
#define INF 0x7fffffff
#define mymin(x,y) (x>=y?y:x)
#define mymax(x,y) (x>=y?x:y)
LL input[N], out[N];
int main() {
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	LL n;
	LL sum = 0;
	cin >> n;
	for (LL i = 1; i <= n; i++) {
		cin >> input[i % n];
		sum += input[i % n];
	}
	out[1] = 0;
	for (LL i = 0; i < n; i++) {
		out[(i * 2 + 1 + 2) % n] = out[(i * 2 + 1) % n]
			+ (input[(i * 2 + 2) % n] - input[(i * 2 + 1) % n]) * 2;
	}
	for (LL i = 0; i < n; i++) {
		sum -= out[i];
	}
	for (LL i = 0; i < n; i++) {
		out[i] += (sum / n);
	}
	for (LL i = 1; i <= n; i++) {
		cout << out[i % n] << " ";
	}
	return 0;
}

Measured memory_bytes: 5128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

#define MAX 1000010
#define INF (1<<29)

int N,X;
int a[30],dp[MAX];
bool isprime[MAX];

void sieve(){
  int i,j;

  rep(i,MAX) isprime[i] = true;
  isprime[0] = isprime[1] = false;
  for(i = 2; i*i <= MAX; i++) if(isprime[i]){
    for(j = 2*i; j <= MAX; j += i) isprime[j] = false;
  }
}

int main(){
  int i,j,k;

  sieve();

  for(;;){
    scanf("%d %d",&N,&X); if(N == 0 && X == 0) break;
    rep(i,N) scanf("%d",&a[i]);

    rep(i,MAX) dp[i] = INF;
    dp[0] = 0;

    int res = 0;
    rep(i,N){
      for(j = 0; j <= X; j++) if(j - a[i] >= 0 && dp[j] > dp[j - a[i]] + 1){
        dp[j] = dp[j - a[i]] + 1;
        if(isprime[j]) res = max(res, j);
      }
    }

    if(res == 0) cout << "NA" << endl; else cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 5768
// 0002.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
int main()
{
	int a, b;
	while (cin>>a>>b)
	{
		int ans = 0;
		int c = a + b;
		while (c > 0) {
			c /=(int) 10; ans += 1;
		}cout<<ans<<endl;
	}
	return 0;

}

Measured memory_bytes: 3012
#include <stdio.h>

int sum(int *turu,int *kame,int sum,int leg){
  int turu_tem=(sum*4-leg*1)/2;
  int kame_tem=(1*leg-2*sum)/2;
  if(leg%2==1)
    return 1;
  if(turu_tem<0 || kame_tem<0)
    return 1;
  *turu=turu_tem;
  *kame=kame_tem;
  return 0;
}
int main(void){
  int x=0;
  int y=0;
  int turu,kame;
  scanf("%d %d",&x,&y);
  if(sum(&turu,&kame,x,y))
    printf("No\n");
  else
    printf("Yes\n");
}


Measured memory_bytes: 1660
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
	//cout << fixed << setprecision(12);
	int N, M, tmp;
	cin >> N >> M;
	int ans = N;
	for (int i = 0; i < M; i++) {
		cin >> tmp;
		ans -= tmp;
	}
	if (ans < -1) ans = -1;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3632
import sys

N, M, X, Y = map(int, input().split())
xx = list(map(int, input().split()))
yy = list(map(int, input().split()))

for z in range(X+1, Y+1):
    if all(x < z for x in xx) and all(y >= z for y in yy):
        print('No War')
        sys.exit()

print('War')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long

#define DEBUG (0)

int main()
{
  int k = 0;
  cin >> k;
  /* 初期値は1桁データ */
  vector<ll> data = {1,2,3,4,5,6,7,8,9};

  /* "keta+1"桁目データ追加 *//* "keta"桁データdataを10倍して下一桁目にa(=data/10)とするとa-1,a,a+1を追加 */
  int keta;
  for(keta = 0; keta <= 9; keta++){
    int datanum = data.size();
#if DEBUG
    cout << "[" << keta+1 <<"]data.size():" << data.size() << "\n";
#endif
    for(int i = 0; i < datanum; i++){
      /*keta-1桁データのみ */
      if(data[i] >= ((ll)pow((double)10,(double)keta))){
        /* 3桁データを10倍して下一桁データ追加: ex)12->121,122,123 */
        ll amari = data[i]%10; /* amari:1〜9 */
        ll adddata = 0;

        /* a-1 を追加 */
        if(amari > 0){
          adddata = data[i]*10 + (amari - 1);
          data.push_back(adddata);
        }
        /* aを追加 */
        adddata = data[i]*10 + (amari);
        data.push_back(adddata);

        /* a+1 を追加 */
        if(amari < 9){
          adddata = data[i]*10 + (amari + 1);
          data.push_back(adddata);
        }

      }
    }
  }

  cout << data[k-1] << "\n";

#if DEBUG
  cout << "data.size():" << data.size() << "\n";
  for(int i = 0; i < data.size(); i++){
    cout << "data[" << i << "]: " << data[i] << "\n";
  }
#endif  

#if 0 /* 範囲for文サンプルプログラム */
  cout << "============================" << "\n";
  int score[5] = {1, 2, 3, 4, 5};
  for(int s : score)
  {
      cout << s << endl;
  }

  vector<int> count{1, 2, 3, 4, 5};
  for(auto&& x : count) {
      cout << x << endl;
  }    
#endif
}

Measured memory_bytes: 7024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;

int main()
{
	long long int X, money = 100, i=1; 

	cin >> X;


	while(true){
		money *= 1.01;
		if(money >= X){
			break;
		}
		i++;
	}


	
	cout << i;

	return 0;
	
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9+7;
const ll nax = 1e5+7;
const ll INF = 1e18;

ll n,k,a[102];
ll dp[102][nax],BIT[102][nax];

void update(ll id,ll x,ll val){
	for (ll i=x;i<nax;i=i|(i+1)) BIT[id][i]=(BIT[id][i]+val)%mod;
}

ll sum(ll id,ll x){
	ll res=0;
	for (ll i=x;i>=0;i=(i&(i+1))-1) res=(res+BIT[id][i])%mod;
	return res;
}

int main(){
//	freopen("input.inp","r",stdin);
//	freopen("output.out","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin>>n>>k;
	
	for (ll i=0;i<n;++i) cin>>a[i];
	
	dp[0][0]=1;
	update(0,0,1);
	for (ll i=0;i<n;++i){
		for (ll j=0;j<=k;++j){
			dp[i+1][j]=((dp[i+1][j]+sum(i,j)- ((j>a[i])? sum(i,j-a[i]-1) : 0))%mod+mod)%mod;
			update(i+1,j,dp[i+1][j]);
		}
	}
	
	cout<<dp[n][k];
}

Measured memory_bytes: 159848
////By Vlgd
//#include<bits/stdc++.h>
//using namespace std;
//const int N=100000001;
//bool E[N];
//void prime(){
//	for(int i=0;i<N;i++) E[i]=true; 
//	E[0]=E[1]=false;
//	for(int i=2;i*i<=N;i++){
//		if(E[i]){
//			int j=2*i;
//			while(j<=N){
//				E[j]=false;
//				j+=i;
//			}
//		}
//	}
//} 
//int main(){
//	int n,x,cnt=0;scanf("%d",&n);
//	prime();
//	for(int i=0;i<n;i++){
//		scanf("%d",&x);
//		if(E[x]) cnt++;
//	}
//	printf("%d\n",cnt);
//}
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=100000001;
//bool E[N];
bool prime(int n){
	int i;
	if(n<2) return false;
	else if(n==2) return true;
	if(n%2==0) return false;
	for(int i=3;i*i<=n;i++) if(n%i==0) return false;
	return true;
} 
int main(){
	int n,x,cnt=0;scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(prime(x)) cnt++;
	}
	printf("%d\n",cnt);
}


Measured memory_bytes: 3184
#include <iostream>
#include <math.h>
using namespace std;
int x[1001],y[1001];
int w,h,n,cnt;

void check(int k){
	int a=x[k+1]-x[k];
	int b=y[k+1]-y[k];
	if(a*b>=0){
		if(fabs(a)>fabs(b)){
			cnt+=fabs(a);
		}else{
			cnt+=fabs(b);
		}
	}else{
		cnt+=fabs(a)+fabs(b);
	}
}



int main(){
	cin >> w>>h >>n;
	for(int i=0;i<n;i++){
		cin >> x[i]>>y[i];
	}
	cnt=0;
	for(int i=0;i<n-1;i++){
		check(i);
	}
	cout << cnt<<endl;
	return 0;
}

Measured memory_bytes: 3068
package main

import (
	"fmt"
	"sort"
)

type city struct {
	o int
	p int
	y int
}

type cities []city

func (cs cities) Len() int           { return len(cs) }
func (cs cities) Swap(i, j int)      { cs[i], cs[j] = cs[j], cs[i] }
func (cs cities) Less(i, j int) bool { return cs[i].y < cs[j].y }

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	cs := make(cities, m)
	for i := 0; i < m; i++ {
		cs[i].o = i
		fmt.Scan(&cs[i].p, &cs[i].y)
	}

	sort.Sort(cs)
	mp := make(map[int]int)
	ans := make([]string, m)
	for i := 0; i < m; i++ {
		mp[cs[i].p]++
		ans[cs[i].o] = fmt.Sprintf("%06d%06d", cs[i].p, mp[cs[i].p])
	}
	for _, v := range ans {
		fmt.Println(v)
	}
}


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

int main() {
    int N, m;
    int H[100000];
    int M[100000][2];
    int is_samll[100000];

    cin >> N >> m;

    for (int i=0; i < N; i++) cin >> H[i];

    for (int i=0; i < m; i++) {
        cin >> M[i][0] >> M[i][1];
    }

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

    for (int i=0; i < m; i++) {
        int A = M[i][0] - 1;
        int B = M[i][1] - 1;
        if (H[A] > H[B]) {
            is_samll[B] = 1;
        } else if (H[A] == H[B]) {
            is_samll[A] = 1;
            is_samll[B] = 1;
        } else {
            is_samll[A] = 1;
        }
    }

    int ans = N;
    for (int i=0; i < N; i++) {
        ans = ans - is_samll[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5188
import sys
from decimal import Decimal
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


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


def main():
    A, B = readstrs()
    A = Decimal(A)
    B = Decimal(B)
    print(int(Decimal(A * B)))


if __name__ == "__main__":
    main()


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

bool is_prime(int n){
  for(int i=2; i*i<=n; i++){
    if(n % i == 0) return false;
  }
  return true;
}

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

  vector<int> ans, prime;

  for(int i=2; i<=55555; i++){
    if(is_prime(i)) prime.push_back(i);
  }

  int cur = 0;
  while(ans.size() < N){
    if(prime[cur] % 5 == 1){
      ans.push_back(prime[cur]);
    }
    cur++;
  }

  for(int i=0; i<N; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int x,y;
cin >> x >> y;
while (!(x==0&&y==0)){
if (y < x){
cout << y << " " <<x <<endl;
}
else{
cout << x << " " << y <<endl;
}
cin >> x >> y;
}
return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}

int main()
{
	int k,cnt = 0;
	cin>>k;
  priority_queue<ll,vector<ll>,greater<ll>>pq;
  for(ll i=1;i<10;i++)pq.push(i);
  ll ans;
  while(cnt < k)
  {
	  ans = pq.top();
	  pq.pop();
	  ll d = ans%10;
	  pq.push(ans*10+d);
	  if(d > 0)pq.push(ans*10 + d-1);
	  if(d < 9)pq.push(ans*10 + d+1);
	  cnt++;
  }
 cout<<ans;
}

Measured memory_bytes: 2420
n = int(input())
s = input()
t = input()

ans = n * 2
chk = False

for i in range(n):
    j = 0
    while i+j < n:
        if s[i+j] == t[j]:
            ans -= 1
            j += 1
            chk = True
        else:
            ans = n * 2
            chk = False
            break
    if chk:
        break

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
using namespace std;
 
int main() {
  ll N, exccnt = 0;
  vector<ll> sumcnt(3, 0);
  cin >> N;
  string S;
  cin >> S;
  for(ll i = 0; i < N; i++) {
    if(S.at(i) == 'R') sumcnt.at(0)++;
    else if(S.at(i) == 'G') sumcnt.at(1)++;
    else sumcnt.at(2)++;
  }
  for(ll i = 0; i < N - 2; i++) {
    for(ll j = i + 1; j < N - 1; j++) {
      if((0 <= 2 * j - i) && (2 * j - i < N)) {
        if((S.at(i) != S.at(j)) && (S.at(i) != S.at(2 * j - i)) && (S.at(j) != S.at(2 * j - i))) exccnt++;
      }
    }
  }
  cout << sumcnt.at(0) * sumcnt.at(1) * sumcnt.at(2) - exccnt << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    if (a >= 2*b)
        cout << a-2*b;
    else cout << 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N, K;
vector<VPII> graph; //(cost, next)
VI cost;
bool ng = false;

VI dijkstra() {
    VI res(N + 1, INF);
    priority_queue<PII, VPII, greater<PII>> pq;
    pq.push({0, N});
    res[N] = 0;
    while (!pq.empty()) {
        int dist, now;
        tie(dist, now) = pq.top();pq.pop();
        if (res[now] < dist) continue;
        FORE(e, graph[now]) {
            int nd, nxt;
            tie(nd, nxt) = e;
            if (res[nxt] <= dist + nd) continue;
            res[nxt] = dist + nd;
            pq.push({res[nxt], nxt});
        }
    }
    return res;
}

int main(void) {
    scanf("%d", &N);
    graph.resize(N + 1);
    cost.resize(N);
    REP(i, N - 1) {
        int a, b;
        scanf("%d%d", &a, &b);
        a--;b--;
        graph[a].EB(MP(1, b));
        graph[b].EB(MP(1, a));
    }
    scanf("%d", &K);
    VI vv(K);
    REP(i, K) {
        int v, p;
        scanf("%d%d", &v, &p);
        v--;
        cost[v] = p;
        vv[i] = v;
        graph[N].EB(MP(p, v));
    }
    VI res = dijkstra();
    FORE(e, vv) {
        if (res[e] != cost[e]) {
            ng = true;
        }
    }
    REP(i, N) FORE(e, graph[i]) {
        if (abs(res[i] - res[e.second]) != 1) {
            //cerr << i + 1 << " " << e.second + 1 << endl;
            ng = true;
        }
    }
    if (ng) {
        cout << "No" << endl;
        return 0;
    } else {
        cout << "Yes" << endl;
    }
    REP(i, N) {
        printf("%d\n", res[i]);
    }
}


Measured memory_bytes: 9716
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int T = sc.nextInt();
    	int A = sc.nextInt();
    	double near = Double.MAX_VALUE;
    	int num = 0;
    	for (int i = 0; i < N; i++) {
    		double tmp = (T - sc.nextInt() * 0.006) - A;
    		if (Math.abs(tmp) < near) {
    			near = Math.abs(tmp);
    			num = i + 1;
    		}
    	}
    	System.out.println(num);
    }
}

Measured memory_bytes: 24404
n=int(input())
k=int(input())
ans=[]
for i in range(2**n):
    ln=["a"]*n
    tmp=1
    for j in range(n):
        if ((i>>j)&1):
            ln[n-j-1]="b"
    for m in range(n):
        if ln[m]=="a":
            tmp=tmp*2
        elif ln[m]=="b":
            tmp=tmp+k
    ans.append(tmp)
print(min(ans))


Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	int i[119] = { 0 };
	int num;

	cin >> num;

	i[num]++;

	cin >> num;

	i[num]++;

	cin >> num;

	i[num]++;

	int ret = 0;
	for (int ii = 0; ii < 110; ii++) {
		ret = max(ret, i[ii]);
	}



	cout << 4-ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
int a, b, c, d[1000];

int main(){
	while (cin >> n){
		cin >> a >> b >> c;
		int cost = a, cal = c;
		int MAX = cal / cost;
		REP(i, n)cin >> d[i];
		sort(d, d + 1000, greater<int>());
		REP(i, n){
			cost += b;
			cal += d[i];
			MAX = max(MAX, (int)(cal / cost));
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 1180
def solve_c(n, a_list):
    res_list = [0] * n
    for i in range(n):
        res_list[a_list[i] - 1] = i + 1
    return res_list


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    res_list = solve_c(n, a_list)
    print(" ".join([str(r) for r in res_list]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 61036
#include<iostream>
#include<cstdio>
using namespace std;
long long n,k;
long long gcd(long long x,long long y)
{
	if(y==0LL)return x;
	return gcd(y,x%y); 
}
int main()
{
	scanf("%lld%lld",&n,&k);
	printf("%lld",3LL*(n-gcd(n,k)));
	return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	int n = in(), a = -in();
	pair<int, int> m = {in(), a}, t;
	while (--n) {
		a = -in();
		t = {in(), a};
		m = max(m, t);
	}
	outl(-m.second, ' ', m.first);
}


Measured memory_bytes: 2632
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		int [] n = new int [N];
		for(int i = 0;i < N;i++)    n[i] = sc.nextInt();
		int max = 0;
		int sum =0;

		for (int i=0;i<n.length;i++) {
			if(n[i]>max) {
				max=n[i];
			}
			sum += n[i];
		}
		if(max<(sum-max)) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}

	}
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


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

const ll MAX_N = 1e5;
ll N;
ll height[MAX_N];
ll dp[MAX_N];

int main(){
  //input
  cin >> N;
  REP(i, N){
    cin >> height[i];
  }
  dp[0] = 0;
  dp[1] = abs(height[1] - height[0]);
  FOR(i, 2, N){
    dp[i] = min(dp[i-1] + abs(height[i] - height[i-1]), dp[i-2] + abs(height[i] - height[i-2]));
  }
  cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[200001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=200000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}

//vector< vector <lld > > v(100001);
lld p1=1000000007,p2=998244353;
lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,n1,a,b,n2,h,z,c;
queue<lld> q;
lld d,p=1000000000;

void solve()
{
    cin>>n;
    x=-1;
    if(n==1)
    {
        cout<<"0";
        return;
    }
    for(i=1;i*i<=n;i++)
    {
        if(n%i==0) x=i;
    }
    if(x==-1) cout<<n-1;
    else 
    {
        cout<<((x)+(n/x))-2;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
    //getfac(p2);
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
            solve();
        cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
mod = 10**9 + 7

import numpy as np

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
b = na()
ans = b[0] + b[-1]
bpre = b[0]
for bi in b[1:]:

        if bpre < bi:
                ans += bpre
        else:
                ans += bi
        bpre = bi
print(ans)

Measured memory_bytes: 21524
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    string s,t;
    cin >> n;
    cin >> s >> t;
    string u;
    for(int i=0;i<n;++i) {
        u[2*i]=s[i];
        u[2*i+1]=t[i];
    }
    for(int i=0;i<2*n;++i) cout << u[i];
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> p(N), a(N), b(N);
    REP(i, N) cin >> p[i];

    ll ma = 20000;
    REP(i, N){
    	a[i] = ma*i+1;
    	b[i] = ma*(N-1-i)+1;
    }
    REP(i, N) a[p[i]-1] += (i+1);
    REP(i, N) cout << a[i] << " ";
    cout << endl;
    REP(i, N) cout << b[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n){
    cin>>a[i];
  }
  int ave=0;
  rep(i,0,n){
    ave+=a[i];
  }
  ave/=n;
  int x=0;
  rep(i,0,n){
    x+=(a[i]-ave)*(a[i]-ave);
  }
  int y=0;
  rep(i,0,n){
    y+=(a[i]-ave-1)*(a[i]-ave-1);
  }
  cout<<min(x,y)<<endl;
}

Measured memory_bytes: 256
// agrawal117
//chahatagrawal117 
#include<bits/stdc++.h>
 #include <boost/multiprecision/cpp_int.hpp>
 namespace mp = boost::multiprecision;
typedef mp::cpp_int ll;
 using namespace std;
int main()
{
    ll a, b, c; cin>>a>>b>>c;
    ll val= 4*a*b;
    ll f= c-a-b;
    if(f<0) {cout<<"No"<<endl; return 0; }
    f=f*f;
    if(f>val) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;


int main()
{
	cin >> n;
	if (n < 1200)
		cout << "ABC" << endl;
	else if (n < 2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;
	
	return 0;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    REP(i, N) cin >> L[i];

    sort(all(L));

    int result = 0;

    FOR(i, 1, N) FOR(j, i + 1, N) {
        int l = abs(L[i] - L[j]);
        int u = L[i] + L[j];
        result += lower_bound(L.begin(), L.begin() + i, u) - upper_bound(L.begin(), L.begin() + i, l);
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;

signed main()
{
    FAST_IO;

    int N, W;
    cin >> N >> W;
    int t = N;
    vector<int> wt;
    vector<int> val;
    while (t--)
    {
        int a, b;
        cin >> a >> b;
        wt.push_back(a);
        val.push_back(b);
    }

    vector<vector<long int>> dp(N + 1, vector<long int>(W + 1, 0));
    // int t[N + 1][W + 1];

    for (int i = 1; i < N + 1; i++)
    {
        for (int j = 1; j < W + 1; j++)
        {
            if (wt[i - 1] <= j)
            {
                dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - wt[i - 1]]);
            }

            else
            {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[N][W];
    return 0;
}

Measured memory_bytes: 83140
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
      Scanner in = new Scanner(System.in);
      int N = in.nextInt();
      int W = in.nextInt();
      int[][] a = new int[N+1][2];
      for (int i = 1; i <= N; i++) {
        a[i][0] = in.nextInt();
        a[i][1] = in.nextInt();
      }
      long[][] dp = new long[N+1][W+1];
      for(int i = 1; i <= N ; i++){
        for(int j = 1; j <= W ; j++){
          if(j - a[i][0] < 0)
            dp[i][j] = dp[i-1][j];
          else
            dp[i][j] = Math.max(dp[i-1][j - a[i][0]] + a[i][1], dp[i-1][j]);
        }
      }
      System.out.println(dp[N][W]);
	}
}


Measured memory_bytes: 128084
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int ans[1010][1010];
int A[101010];
int H, W, N;
int main(){
    cin >> H >> W >> N;
    REP(i, N) cin >> A[i];
    int cnt = 0;
    REP(y, H){
        REP(x, W){
            ans[y][x] = cnt + 1;
            A[cnt]--;
            if(!A[cnt])
                cnt++;
        }
    }
    REP(y, H){
        REP(_x, W){
            int x;
            if(y % 2 == 0)
                x = _x;
            else
                x = W - 1 - _x;
            if(_x)
                cout << " ";
            cout << ans[y][x];
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int a[1234567];

int main() {
  int n;
  scanf("%d", &n);
  int x = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
    x ^= a[i];
  }
  int ans = 0;
  for (int j = 30; j >= 0; j--) {
    if (x & (1 << j)) {
      for (int i = 0; i < n; i++) {
        if (a[i] & (1 << j)) {
          if (!(a[i] & ((1 << j) - 1))) {
            x ^= a[i];
            x ^= a[i] - 1;
            ans++;
            break;
          }
        }
      }
    }
  }
  printf("%d\n", x == 0 ? ans : -1);
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3592
import std.algorithm, std.array, std.conv, std.stdio, std.string;
void main()
{
    auto buf = readln.chomp.split;
    immutable nProblems = buf[0].to!size_t, mSubmissions = buf[1].to!size_t;
    auto
        penalties = new int[nProblems],
        accepted = new bool[nProblems];
    int totalPenalty;
    foreach (i; 0..mSubmissions)
    {
        buf = readln.chomp.split;
        immutable
            problem = buf[0].to!size_t - 1,
            status = buf[1];
        if (status == "WA")
        {
            penalties[problem] += 1;
        }
        else
        if (status == "AC")
        {
            if (accepted[problem])
                continue;
            accepted[problem] = true;
            totalPenalty += penalties[problem];
        }
        else assert (false);
    }
    "%d %d".writefln(accepted.sum, totalPenalty);
}


Measured memory_bytes: 3708
n = int(input())
a = list(map(int, input().split()))
arr = [False] * n

for i in range(n, 0, -1):
    if sum(arr[i - 1::i]) % 2 != a[i - 1]:
        arr[i - 1] = True

if not any(arr):
    print(0)
else:
    print(sum(arr))
    ans = []
    for i, x in enumerate(arr):
        if x:
            ans.append(i + 1)
    print(*ans)

Measured memory_bytes: 14132
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<int, int> P;
struct Edge
{
	int to;
	int cost;
};
vector<Edge> V[100001];

void solve()
{
	int N;
	cin >> N;
	vector<long long int> D(N);
	for (int i = 0; i < N; ++i)
	{
		D[i] = 1LL << 62;
	}

	for (int i = 0; i < N - 1; ++i)
	{
		int a, b, c;
		cin >> a >> b >> c;
		--a;
		--b;
		Edge e;
		e.to = b;
		e.cost = c;
		V[a].push_back(e);
		e.to = a;
		V[b].push_back(e);
	}
	int Q, K;
	cin >> Q >> K;
	D[K - 1] = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, K - 1));
	while (!que.empty())
	{
		P p = que.top();
		que.pop();
		int v = p.second;
		if (D[v] < p.first)
		{
			continue;
		}
		for (int i = 0; i < V[v].size(); ++i)
		{
			Edge e = V[v][i];
			if (D[e.to] > D[v] + e.cost)
			{
				D[e.to] = D[v] + e.cost;
				que.push(P(D[e.to], e.to));
			}
		}
	}
	for (int i = 0; i < Q; ++i)
	{
		int x, y;
		cin >> x >> y;
		cout << D[x - 1] + D[y - 1] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 9332
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  ll x;
  cin >> x;
ll cnt= 0;
ll A = x/11;
ll B = x % 11;
ll tot = B;
if(B == 0){
cout << A * 2 << endl;
return 0;

}
  while(tot > 0){
    tot -= 6;
    cnt++;
    if(tot <= 0){
      cout << cnt + A * 2 << endl;
      return 0;
    }
    tot -= 5; 
    cnt++;
    if(tot <= 0){
      cout << cnt  + A * 2<< endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int N = Integer.parseInt(str);
        str = br.readLine();
        long ans = 0;
        for (String s:str.split(" ")){
            ans += Long.parseLong(s);
        }
        System.out.println(ans-N);
    }
}

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

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int W, H, x, y, r;
            bool result;

            W = cin.GetInt();
            H = cin.GetInt();
            x = cin.GetInt();
            y = cin.GetInt();
            r = cin.GetInt();

            result = x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H;

            Console.WriteLine("{0}", result ? "Yes" : "No");
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public string GetLine()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            string line;
            this._i = 0;
            do
            {
                line = Console.ReadLine();
            } while (line == "");

            this._s = line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);

            return this._s[this._i++];
        }

        public int GetInt()
        {
            return int.Parse(this.GetLine());
        }

        public long GetLong()
        {
            return long.Parse(this.GetLine());
        }

        public double GetDouble()
        {
            return double.Parse(this.GetLine());
        }
    }
}

Measured memory_bytes: 19656