akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define iP pair<int,P>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

const int N_max=100000;

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	string S;
	map<char,int> mp;

	cin>>S;
	FOR(i,1,S.length()-1){
		if(S[i]==S[i-1]||S[i-1]==S[i+1]){
			print(i,i+2);
			return 0;
		}
	}
	int N=S.length();
	if(S[N-2]==S[N-1]) print(N-1,N);
	else print(-1,-1);
	return 0;
}






Measured memory_bytes: 512
from sys import stdin

s = list(stdin.readline().rstrip())

ans = True

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i, t in enumerate(s):
    if (i+1)%2 == 1:
        if not t in odd:
            ans = False
    else:
        if not t in even:
            ans = False

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9120
def run(N, M, K, S, P):
    ret = 0
    for i in range(2 ** N):
        bit = bin(i)[2:].zfill(N)
        chk = True
        for j in range(M):
            cnt = 0
            for s in S[j]:
                cnt += int(bit[s-1])
            if cnt % 2 == P[j]:
                pass
            else:
                chk = False
                break
        if chk:
            ret += 1
    return ret


def main():
    N, M = map(int, input().split())
    K = []
    S = []
    for _ in range(M):
        tmp = list(map(int, input().split()))
        K.append(tmp[0])
        S.append(tmp[1:])
    P = list(map(int, input().split()))
    print(run(N, M, K, S, P))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(input())
T,A = map(int,input().split())
H = input().split()

for i in range(N):
  tmp = T - int(H[i])*0.006
  if(i == 0):
    min = abs(A-tmp)
    ans_num = i+1
  else:
    if(min > abs(A-tmp)):
      min = abs(A-tmp)
      ans_num = i+1
      
print(ans_num)
    

Measured memory_bytes: 3060
#include <iostream>

int main(int argc, char *argv[])
{
    int a, b;
    int ans;

    std::cin >> a >> b;

    if (a < 10 && b < 10) {
        ans = a * b;
    } else {
        ans = -1;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
# Nまでの素数を列挙
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int type.")
    if n < 2:
        raise ValueError("n is more than 2")
    prime = [2]
    limit = int(n ** 0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


# if __name__ == '__main__':
# data = get_sieve_of_eratosthenes(100)
# print(' '.join(map(str, data)))
# print("2～{0}までで以上が素数です\n".format(100))


N = int(input())
P = get_sieve_of_eratosthenes(55555)
cnt = 0
for p in P:
    if p % 5 == 1:
        print(p)
        cnt += 1
    if cnt == N:
        break


Measured memory_bytes: 74060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
 
  if (A >= 500) {
    cout << "Yes" << endl;
  }
  else {
    if (N % 500 <= A) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
h,w=map(int,input().split())
s=[input() for i in range(h)]
a=[[0]*w for i in range(h)]

if h==1 and w==1:
  if s[0]=="#":
    print("#")
  else:
    print(0)
elif h==1 and w>1:
  for i in range(w):
    t=0
    if i==0:
      if s[0][i+1]=="#":t+=1
    elif 0<i<w-1:
      if s[0][i+1]=="#":t+=1
      if s[0][i-1]=="#":t+=1
    elif i==w-1:
      if s[0][i-1]=="#":t+=1
    if s[0][i]=="#":
      a[0][i]="#"
    else:
      a[0][i]=t
  tt=""
  for aa in a:
    for aaa in aa:
      tt+=str(aaa)
  print(str(tt))

elif w==1 and h>1:
  for i in range(h):
    t=0
    if i==0:
      if s[i+1]=="#":t+=1
    elif 0<i<h-1:
      if s[i+1]=="#":t+=1
      if s[i-1]=="#":t+=1
    elif i==h-1:
      if s[i-1]=="#":t+=1
    if s[i]=="#":
      a[i][0]="#"
    else:
      a[i][0]=t
  for aa in a:
    print(*aa)
elif w>1 and h>1:
  for i in range(h):
    for j in range(w):
      t=0
      if i==0:
        if j==0:
          if s[i][j+1]=="#":t+=1
          if s[i+1][j+1]=="#":t+=1
          if s[i+1][j]=="#":t+=1
        elif 0<j<w-1:
          if s[i][j+1]=="#":t+=1
          if s[i+1][j+1]=="#":t+=1
          if s[i+1][j]=="#":t+=1
          if s[i+1][j-1]=="#":t+=1
          if s[i][j-1]=="#":t+=1        
        elif j==w-1:
          if s[i+1][j]=="#":t+=1
          if s[i+1][j-1]=="#":t+=1
          if s[i][j-1]=="#":t+=1 
      elif 0<i<h-1:
        if j==0:
          if s[i-1][j]=="#":t+=1
          if s[i-1][j+1]=="#":t+=1
          if s[i][j+1]=="#":t+=1
          if s[i+1][j+1]=="#":t+=1
          if s[i+1][j]=="#":t+=1
        elif 0<j<w-1:
          if s[i][j+1]=="#":t+=1
          if s[i+1][j+1]=="#":t+=1
          if s[i+1][j]=="#":t+=1
          if s[i+1][j-1]=="#":t+=1
          if s[i][j-1]=="#":t+=1
          if s[i-1][j-1]=="#":t+=1
          if s[i-1][j]=="#":t+=1
          if s[i-1][j+1]=="#":t+=1
        elif j==w-1:
          if s[i+1][j]=="#":t+=1
          if s[i+1][j-1]=="#":t+=1
          if s[i][j-1]=="#":t+=1
          if s[i-1][j-1]=="#":t+=1
          if s[i-1][j]=="#":t+=1      
      elif i==h-1:
        if j==0:
          if s[i][j+1]=="#":t+=1
          if s[i-1][j+1]=="#":t+=1
          if s[i-1][j]=="#":t+=1
        elif 0<j<w-1:
          if s[i][j+1]=="#":t+=1
          if s[i-1][j+1]=="#":t+=1
          if s[i-1][j]=="#":t+=1
          if s[i-1][j-1]=="#":t+=1
          if s[i][j-1]=="#":t+=1        
        elif j==w-1:
          if s[i-1][j]=="#":t+=1
          if s[i-1][j-1]=="#":t+=1
          if s[i][j-1]=="#":t+=1
      if s[i][j]=="#":
        a[i][j]="#"
      else:
        a[i][j]=t
  for aa in a:
    tt=""
    for aaa in aa:
      tt+=str(aaa)
    print(tt)

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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 64
#define MOD 999979999
#define STEP 313
#define MOD2 994979499
#define STEP2 511

int n;
char s[MAXN], t[MAXN];
map <int, int> d[MAXN][MAXN];
map <int, int> d2[MAXN][MAXN];

inline int gethash() {
	int hash = 0;
	for (int i = 0; i < n; ++i) {
		hash = (1LL * hash * STEP + t[i] - 'a' + 1) % MOD;
	}
	return hash;
}

inline int gethash2() {
	int hash = 0;
	for (int i = 0; i < n; ++i) {
		hash = (1LL * hash * STEP2 + t[i] - 'a' + 1) % MOD2;
	}
	return hash;
}

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

	scanf("%d", &n);
	scanf("%s", s);
	for (int mask = 0; mask < (1 << n); ++mask) {
		int k1 = 0, k2 = 0;
		for (int i = 0, l = 0, r = n - 1; i < n; ++i) {
			if ((mask >> i) & 1) {
				++k1;
				t[l++] = s[i];
			} else {
				++k2;
				t[r--] = s[i];
			}
		}
		d[k1][k2][gethash()]++;
		d2[k1][k2][gethash2()]++;
	}
	ll ans = 0;
	for (int mask = 0; mask < (1 << n); ++mask) {
		int k1 = 0, k2 = 0;
		for (int i = 0, l = 0, r = n - 1; i < n; ++i) {
			if ((mask >> i) & 1) {
				++k1;
				t[l++] = s[n + n - 1 - i];
			} else {
				++k2;
				t[r--] = s[n + n - 1 - i];
			}
		}
		ans += min(d[k1][k2][gethash()], d2[k1][k2][gethash2()]);
	}
	printf(I64"\n", ans);

	return 0;
}


Measured memory_bytes: 49792
#include<bits/stdc++.h>
using namespace std;
int n,x,tmp;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);tmp^=x;
	}
	if(tmp==0)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
s=list(map(int,input().split()))
t=list(map(int,input().split()))
u=list(map(int,input().split()))
a=s[0]+s[1]+s[2]+t[0]+t[1]+t[2]+u[0]+u[1]+u[2]
b=s[1]+s[2]+t[0]+t[2]+u[0]+u[1]-2*s[0]-2*t[1]-2*u[2]
if a%3==0 and b==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int getDigit(int num) {
    if (num == 0) return 1;
    int ret = 0;
    while (num != 0) {
        num /= 10;
        ret++;
    }
    return ret;
}

string next(string str) {
    int num = atoi(str.c_str());

    bool all9 = true;
    for (int i = 0; i < str.size(); i++) {
        if (str[i] != '9') {
            all9 = false;
            break;
        }
    }

    if (all9) {
        string ret;
        for (int i = 0; i < str.size() + 1; i++) ret += "0";
        return ret;
    } else {
        string ret = to_string(num+1);
        string tmp;
        for (int i = 0; i < str.size() - ret.size(); i++) tmp += "0";
        return tmp + ret;
    }
}

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

    if (N <= 9) {
        cout << N << endl;
        return 0;
    }

    map<P, int> m;
    for (int left = 1; left <= 9; left++) {
        for (int right = 1; right <= 9; right++) {
            int cnt = 0;
            if (10 * left + right <= N) {
                cnt++;
            }

            if (left == right) {
                cnt++;
            }

            string mid = "0";
            while (1) {
                string str = to_string(left) + mid + to_string(right);
                int num = atoi(str.c_str());
                if (num <= N) cnt++;
                else break;
                mid = next(mid);
            }

            m[P(left, right)] = cnt;
        }
    }

    int ret = 0;
    for (int l = 1; l <= 9; l++) {
        for (int r = 1; r <= 9; r++) {
            ret += m[P(l, r)] * m[P(r, l)];
        }
    }

    cout << ret << endl;
    return 0;
}

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

#define N 100
#define INFTY INT_MAX

int min(int,int);

int main(){

  int n,p[N+1],m[N+1][N+1];
  int i,l,j,k;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  
  for(i=1;i<=n;i++) m[i][i] = 0;
  
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      
      m[i][j]=INFTY;
      
      for(k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
      //printf("%d %d %d\n", i, j, m[i][j]);
    }
  }
  
  printf("%d\n",m[1][n]);//1からnまでの最小コスト合計
  
  return 0;
  
}

int min(int m,int mp){
  if(m<=mp) return m;
  else return mp;
}



Measured memory_bytes: 2108
/**********************************************
 *Author*        :XzzF
 *Created Time*  : 2018/11/4 20:24:06
 *Ended  Time*  : 2018/11/4 20:36:01
*********************************************/

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100000;

int n, m;

struct City {
	int p, year, pos;
	City () {}
	City (int _p, int _year) {
		p = _p; year = _year;
	}
	friend bool operator < (const City A, const City B) {
		return A.year < B.year;
	}
}C[MaxN + 5];

vector <int> ID[MaxN + 5];
int id[MaxN + 5], Y[MaxN + 5], ans[MaxN + 5];

bool cmpp(City A, City B) {
	return A.pos < B.pos;
}

int main()
{
    while(scanf("%d %d", &n, &m) != EOF)
	{
		for(int i = 1; i <= n; i++) ID[i].clear();
		for(int i = 1; i <= m; i++) {
			scanf("%d %d", &C[i].p, &C[i].year);
			C[i].pos = i;
		}
		sort(C + 1, C + m + 1);
		for(int i = 1; i <= m; i++) ID[C[i].p].push_back(C[i].pos);
		for(int i = 1; i <= n; i++) {
			for(int j = 0; j < ID[i].size(); j++)
				ans[ID[i][j]] = j + 1;
		}
		sort(C + 1, C + m + 1, cmpp);
		for(int i = 1; i <= m; i++) printf("%06d%06d\n", C[i].p, ans[i]);
	}
    return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
using namespace std;
 
 
int main() {
  int w[10], k[10];
   
  for(int i = 0; i < 10; i++) {
    cin >> w[i];
  }
   
  for(int i = 0; i < 10; i++) {
    cin >> k[i];
  }
 
  sort(w, w+10);
  sort(k, k+10);
 
  cout << w[9]+w[8]+w[7] << " ";
  cout << k[9]+k[8]+k[7] << endl;
   
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int K;
  cin >> K;
  int A, B;
  cin >> A >> B;

  repp(i, A, B) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  10005
ll d;
ll a[N];
ll n;
ll dp[N][2][105];

ll calc(ll pos, bool f, ll mod){
	if(dp[pos][f][mod]!=-1)return dp[pos][f][mod];
	ll ret=0;
	ll mx=9;
	if(!f)mx=a[pos];
	if(pos==n){
		if(mod==0)return 1;
        return 0;
	// cerr<<"pos:"<<pos<<" f:"<<f<<" mod:"<<mod<<" ret:"<<ret<<endl;
		//return dp[pos][f][mod]=ret%hell;
	}
	rep(i,0,mx+1){
		bool nf=f;
		if(!f && i<a[pos])nf=1-f;
		ll modreq = (mod-i+d)%d;
		ret=(ret+calc(pos+1,nf,modreq))%hell;
	}
	return dp[pos][f][mod]=ret;
}


void solve()
{
	string s;
	cin>>s;
	cin>>d;
	n=sz(s);
	rep(i,0,n)a[i]=s[i]-'0';
	rep(i,0,N)rep(j,0,2)rep(k,0,105)dp[i][j][k]=-1;
	cout<<(calc(0,0,0)-1+hell)%hell<<endl;

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 21044
#include <iostream>
#include <string>
using namespace std;
using i64 = long long;

int main(){
  i64 n;
  cin >> n;
  string s = "";
  if(n == 0) s = "0";
  while(n != 0){
    s = to_string(!!(n % 2)) + s;
    if(n % -2 == -1 && n > 0) n++;
    if(n % -2 == -1 && n < 0) n--;
    n /= -2;
  }
  cout << s << endl;
}

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

using namespace std;

int main() {
  string s;
  int n,p;
  while(cin >> s && s!="-"){
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> p;
      string temp = s.substr(0,p);
      s = (s.substr(p,s.length()-p)+temp);
    }
    cout << s << endl;
  }
  return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
template<typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) {
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
};
bool operator == (Edge<int> e1, Edge<int> e2) {
    return e1.from == e2.from &&
            e1.to == e2.to &&
            e1.cost == e2.cost;
}
template<typename T>
using Edges = std::vector<Edge<T>>;
template<typename T>
using Graph = std::vector<Edges<T>>;
template <typename T>
std::vector<T> dijkstra(const Graph<T> &g, int s) {
    int sz = (int)(g.size());
    std::vector<T> dist(sz, std::numeric_limits<T>::max());
    std::priority_queue<std::pair<T, int>, std::vector<std::pair<T, int>>, std::greater<std::pair<T, int>>> pq;
    dist[s] = 0;
    pq.push({0, s});
    while(!pq.empty()) {
        int d = pq.top().first, now = pq.top().second;
        pq.pop();
        if(d > dist[now]) continue;
        for(int i=0;i<(int)(g[now].size());++i) {
            int next = g[now][i].to, cost = g[now][i].cost;
            if(dist[next] > dist[now] + cost) {
                dist[next] = dist[now] + cost;
                pq.push({cost, next});
            }
        }
    }
    return dist;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m, s, t; cin >> n >> m >> s >> t;
  s--; t--;
  Graph<ll> ge(n), gs(n);
  for(int i=0;i<m;++i) {
    int u, v; ll a, b; cin >> u >> v >> a >> b;
    u--; v--;
    ge[u].push_back(Edge<ll>(u, v, a));
    ge[v].push_back(Edge<ll>(v, u, a));
    gs[u].push_back(Edge<ll>(u, v, b));
    gs[v].push_back(Edge<ll>(v, u, b));
  }
  vll de = dijkstra(ge, s);
  vll ds = dijkstra(gs, t);
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
  for(int i=0;i<n;++i) {
    pq.push({de[i] + ds[i], i+1});
  }
  ll init = 1;
  for(int i=0;i<15;++i) {
    init *= 10;
  }
  for(int i=0;i<n;++i) {
    while(pq.top().second <= i) {
      pq.pop();
    }
    cout << init - pq.top().first << endl;
  }
}


Measured memory_bytes: 22096
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

//A 65
//a 97
//pairの比較関数(昇順)
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  ll n,m;cin>>n>>m;
  VL a(n);
  vector<pair<ll,ll>> data;
  REP(i,n){
    cin>>a[i];
  }
  REP(i,m){
    ll s,t;cin>>s>>t;
    data.push_back({s,t});
  }
  sort(a.begin(),a.end());
  sort(data.begin(),data.end(),compare_by_b_high);
  ll start=0;
  ll count=0;
  for(int i=0;i<n;i++){
    if(a[i]<data[start].second){
      a[i]=data[start].second;
      count++;
      if(count==data[start].first){
        count=0;
        start++;
      }
    }
  }
  ll sum=0;
  REP(i,n){
    sum+=a[i];
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define chmin(x,y) x = min(x, y)
#define chmax(x,y) x = max(x, y)
#define V vector
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    ll x, k, d; cin >> x >> k >> d;
    if (x == 0) {
        if (k%2 == 0) cout << 0 << endl;
        else cout << d << endl;
        return 0;
    }
    ll m = x%d;
    if (m < 0) m += d;
    //小さくてもmin(m, d-m)
    ll cnt = (abs(x) + d - 1) / d;
    if (k < cnt) {
        ll ans = abs(abs(x) - k*d);
        cout << ans << endl;
        return 0;
    }
    k -= cnt;
    if (m == 0) {
        if (k%2 == 0) cout << 0 << endl;
        else cout << d << endl;
        return 0;
    }
    if (k%2 == 0) {
        if (x > 0) cout << d-m << endl;
        else cout << m << endl;
    }
    else {
        if (x > 0) cout << m << endl;
        else cout << d-m << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    int k,a[33]={0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    cin>>k;
    cout<<a[k];
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<=m;i++)
#define read(n) cin>>n;
#define write(n) cout<<n;
using namespace std;
const int N = 2e5+5;
int n,cnt[N],x[N];
ll sum=0;
int main()
{
	cin>>n;
	rep(i,n)cin>>x[i],cnt[x[i]]++;
	rep(i,n+1)sum+=1ll*cnt[i]*(cnt[i]-1)/2;
//	cout<<sum<<"\n";
	rep(j,n)
	{
		ll ans=sum;
		int i=x[j];
		if(cnt[i]!=0)
		{
			ans=ans-1ll*cnt[i]*(cnt[i]-1)/2+1ll*(cnt[i]-1)*(cnt[i]-2)/2;
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3712
from sys import stdin
input = stdin.readline
from time import time
from random import randint
from copy import deepcopy

start_time = time()

def calcScore(t, s, c):
    scores = [0]*26
    lasts = [0]*26
    for i in range(1, len(t)):
        scores[t[i]] += s[i][t[i]]
        dif = i - lasts[t[i]]
        scores[t[i]] -= c[t[i]] * dif * (dif-1) // 2
        lasts[t[i]] = i
    for i in range(26):
        dif = len(t) - lasts[i]
        scores[i] -= c[i] * dif * (dif-1) // 2
    return scores

def greedy(c, s):
    day_lim = len(s)
    socres = [0]*26
    t = [0]*day_lim
    lasts = [0]*26
    for i in range(1, day_lim):
        pls = [v for v in socres]
        mns = [v for v in socres]
        for j in range(26):
            pls[j] += s[i][j]
            mns[j] -= c[j] * (i - lasts[j])
        sum_mns = sum(mns)
        pt = sum_mns - mns[0] + pls[0]
        idx = 0
        for j in range(1, 26):
            tmp = sum_mns - mns[j] + pls[j]
            if pt < tmp:
                pt = tmp
                idx = j
        t[i] = idx
        lasts[idx] = i
        for j in range(26):
            if j == idx:
                socres[j] = pls[j]
            else:
                socres[j] = mns[j]
    return socres, t

D = int(input())
c = list(map(int, input().split()))
s = [[0]*26 for _ in range(D+1)]
for i in range(1, D+1):
    s[i] = list(map(int, input().split()))

scores, t = greedy(c, s)
sum_score = sum(scores)

while time() - start_time < 1.8:
    tmp_t = deepcopy(t)
    typ = randint(0, 1)
    if typ == 0:
        for _ in range(3):
            tmp_t[randint(1, D)] = randint(0, 25)
        tmp_scores = calcScore(tmp_t, s, c)
        sum_tmp_score = sum(tmp_scores)
        if sum_score < sum_tmp_score:
            sum_score = sum_tmp_score
            t = tmp_t
            scores = tmp_scores
    elif typ == 1:
        dist = randint(1, 30)
        p = randint(1, D-dist)
        q = p + dist
        tmp_t[p], tmp_t[q] = tmp_t[q], tmp_t[p]
        tmp_scores = calcScore(tmp_t, s, c)
        sum_tmp_score = sum(tmp_scores)
        if sum_score < sum_tmp_score:
            sum_score = sum_tmp_score
            t = tmp_t
            scores = tmp_scores

for v in t[1:]:
    print(v+1)


Measured memory_bytes: 96880
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
vector<int> v[100000];
int z[100000],d[100000];
int f(int x){
    if(d[x]>-1)return d[x];
    int y=v[x].size();
    for(int i=0;i<y;i++){
        z[i]=f(v[x][i]);
    }
    sort(z, z+y, greater<int>());
    int r=0;
    for(int i=0;i<y;i++){
        r=max(r, z[i]+i+1);
    }
    return r;
}
int main(void){
    cin>>n;
    for(int i=1;i<n;i++){
        int a;
        cin>>a;
        a--;
        v[a].push_back(i);
    }
    fill(d, d+n, -1);
    for(int i=n-1;i>=0;i--){
        d[i]=f(i);
    }
    cout<<d[0]<<endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
using namespace std;
int z[100002],f[100002];
int main(){
    int n,max1=100001,max2=100001;
    cin>>n;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(i%2==0) z[a]++;
        else f[a]++;
    }
    for(int i=0;i<=100000;i++){
        if(z[i]>z[max1])max1=i;
        if(f[i]>f[max2])max2=i;
    }
    sort(z,z+100001);
    sort(f,f+100001);
    if(max1==max2) cout<<n-max(z[100000]+f[99999],z[99999]+f[100000])<<endl;
    else cout<<n-(z[100000]+f[100000])<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int n;
vector<vector<int>> to;
bool d[100000];
int route[100000];
int dfs2(int i,int count){
	if(i==0) return route[i]=count;
	int ret=0;
	d[i]=true;
	rep(j,to[i].size()){
		int v=to[i][j];
		if(d[v]) continue;
		int tmp=dfs2(v,count+1);
		ret=max(ret,tmp);
		if(tmp>0) route[i]=count;
	}
	d[i]=false;
	return ret;
}
signed main(){
	
	cin>>n;
	to.resize(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	int dim=dfs2(n-1,0)-2;
	vector<int> s(n,0);
	rep(i,n){
		if(route[i]==0&&i!=n-1) continue;
		int par=(route[i]<=(dim+1)/2)?1:2;
		queue<int> que;
		que.push(i);
		s[i]=par;
		while(!que.empty()){
			int u=que.front();que.pop();
			rep(j,to[u].size()){
				int v=to[u][j];
				if(s[v]>0||route[v]>0||v==n-1) continue;
				que.push(v);s[v]=par;
			}
		}
	}
	int fen=0,snu=0;
	rep(i,n){
		//cout<<1+i<<" "<<route[i]<<" "<<s[i]<<endl;
		if(s[i]==2) fen++;
		else if(s[i]==1) snu++;
	}
	if(fen>snu) cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
}

Measured memory_bytes: 13568
// atcoder/abc141/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    set<char> odd, even;
    odd.insert('R');
    odd.insert('U');
    odd.insert('D');
    even.insert('L');
    even.insert('U');
    even.insert('D');

    bool f = true;
    for (int i = 0; i < s.size(); ++i) {
      unless (i % 2) f = f && odd.count(s[i]);
      else       f = f && even.count(s[i]);
    }
    cout << (f ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/*===== gets, printf などの入出力に必要 =====*/
#include <stdio.h>
/*===== strtok などの文字列操作に必要 =====*/
#include <string.h>
/*===== その他必要なヘッダファイルがあれば include する =====*/
#include <ctype.h> ////////
#include <stdlib.h> ////////

/*===== 定数の定義 =====*/
#define LEN 80  // 文字列の長さの最大値
#define MAX 100 // スタックサイズの最大値

/*===== 関数のプロトタイプ宣言 =====*/
void STK_init(void);
void STK_push(double a);
double STK_pop(void);

int main(void)
{
    /*===== 変数の宣言 =====*/
    char str[LEN+1];
    char* p;
    double ret;

    /*===== 他にも変数が必要であれば宣言する =====*/
    double a, b; ////////////

    for(;;){
        /*===== 入力がなければ終了 =====*/
        if(gets(str) == NULL){
            return 0;
        }

        /*===== スタックの初期化 =====*/
        STK_init();

        /*===== strtok により、文字列を空白区切りでトークンに分割する =====*/
        for(p = strtok(str, " "); p != NULL; p = strtok(NULL, " ")){
            /*----- ここからを自分で記述 -----*/

            if(isdigit(p[0]) || isdigit(p[1])){
                a = atof(p);
                STK_push(a);
            }else{
                b = STK_pop();
                a = STK_pop();
                switch(p[0]){
                    case '+':
                        STK_push(a + b);
                        break;
                    case '-':
                        STK_push(a - b);
                        break;
                    case '*':
                        STK_push(a * b);
                        break;
                    case '/':
                        STK_push(a / b);
                        break;
                    default:
                        break;
                }
            }
            
            /*----- ここまでを自分で記述 -----*/
        }

        /*===== 答えを ret に代入する =====*/
        /* ret = ???; */

        ret = STK_pop(); ////////////

        /*===== 答えを出力する =====*/
        printf("%.10f\n", ret);
    }
}

/*===== スタックで使用する変数 =====*/
static int pos;
static double buf[MAX];

/*===== 以下3つの関数を自分で記述 =====*/
/*-----
    (本当はファイルを分割して書くべきだが、
     多くのプログラミングコンテストでは
     1つのファイルで提出することになっているため、
     それに従うこととする。)
 -----*/

/*----- スタックの初期化 -----*/
void STK_init(void)
{
    pos = 0;
}

/*----- スタックにプッシュ -----*/
void STK_push(double a)
{
    buf[pos] = a;
    ++ pos;
}

/*----- スタックからポップ -----*/
double STK_pop(void)
{
    -- pos;
    return buf[pos];
}

Measured memory_bytes: 580
#include <stdio.h>

int main(void)
{
	int num[100];
	int i;
	int max;
	int val;
	
	for (i = 0; i < 100; i++){
		num[i] = 0;
	}
	
	while (scanf("%d", &val) != EOF){
		num[val - 1] ++;
	}
	
	max = 0;
	for (i = 0; i < 100; i++){
		if (max < num[i]){
			max = num[i];
		}
	}
	
	for (i = 0; i < 100; i++){
		if (max == num[i]){
			printf("%d\n", i + 1);
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if ( (A == B && A == C) || ( (A != B && B != C) && A != C ) ){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 35752
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

int prim(){
  int u,minv,i,v,sum;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
  sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1){
      sum+=M[i][p[i]];
    }
  }
  return sum;
}

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

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&e);
      M[i][j]=(e==-1)?INFTY:e;
    }
  }

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

  return 0;
}
	  



Measured memory_bytes: 2100
#include <bits/stdc++.h>
typedef long long ll;
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define test(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;

const int M=1e9+7;
ll mod(ll x){
      return ((x%M + M)%M);
}
ll add(ll a, ll b){
      return mod(mod(a)+mod(b));
}
ll mul(ll a, ll b){
      return mod(mod(a)*mod(b));
}

vector<int> adj[200005];
vector<bool> vis(200005,false);

void dfs(int src, int& count){
	vis[src] = true;
	count++;
	for(int child:adj[src]){
		if(!vis[child]){
			dfs(child,count);
		}
	}
}

int main(){
	fast();
	//test(t){}
	
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	int ma = 0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			int c=0;
			dfs(i,c);
			ma = max(ma,c);
		}
		
	}
	cout<<ma<<endl;
	return 0;
}


Measured memory_bytes: 23932
#!/usr/bin/env python3

N = int(input().split()[0])
r_list = []
b_list = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    r_list.append((a, b))

blue_dict = {}

for _ in range(N):
    c, d = list(map(int, input().split()))
    b_list.append((c, d))
    blue_dict[(c, d)] = []
    for ab in r_list:
        a, b = ab
        if a < c and b < d:
            blue_dict[(c, d)] += [(a, b)]

    if blue_dict[(c, d)]:
        # y座標が大きい順に並び替え
        blue_dict[(c, d)] = sorted(blue_dict[(c, d)], key=lambda x: x[0], reverse=True)

# x座標が小さい順に並び替え
b_list = sorted(b_list, key=lambda x: x[1])
pair_list = []

for b in b_list:
    kouho_r_list = blue_dict[b]
    if kouho_r_list:
        r = kouho_r_list[0]
        pair_list.append((r, a))

        for k, v in blue_dict.items():
            if r in v:
                v.remove(r)

ans = len(pair_list)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  char s[5];
  cin>>s;
  bool flag=false;
  for(int i=1;i<4;i++){
    if(s[i-1]==s[i])flag=true;
  }
  if(!flag)cout<<"Good"<<endl;
  else cout<<"Bad"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll f(ll a, ll b);

int main()
{
    ll n;
    ll ans = 1000;

    cin >> n;

    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ans = min(ans, f(i, n / i));
        }
    }

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

ll f(ll a, ll b)
{
    ll aa = 0;
    ll bb = 0;

    while (a) {
        a /= 10;
        aa++;
    }

    while (b) {
        b /= 10;
        bb++;
    }

    return max(aa, bb);
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
#define LL long long
int n,a,b;
int main()
{
    LL x, y,ans = 1;
    scanf("%lld%lld",&x,&y);
    x = x + x;
    while(x<=y){
        ans++;
        x = x + x;
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

typedef long long ll;

ll A, B, N;

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

	if (B == 1) {
		cout << 0 << endl;
		return 0;
	}

	ll x = 0;
	if (N % B == B - 1) {
		x = N;
	}
	else {
		x = N / B * B - 1;
		if (x < 0)x = N;
	}

	cout << (A * x) / B - A * (x / B) << endl;

	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	FIO();
	int n; cin >> n;
	vi a(n);

	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}

	int cnt = 0;

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

	for (int i = 0; i < n - 2; ++i)
	{
		for (int j = i + 1; j < n - 1; ++j)
		{
			if (a[i] != a[j])
			{
				for (int k = j + 1; k < n ; ++k)
				{
					if ((a[i] + a[j] > a[k]) && a[j] != a[k] && a[i] != a[k])
						cnt++;
				}
			}
		}
	}

	cout << cnt << '\n';

	return 0;
}

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

int n,y;

int main(){
  int i,j;
  bool ch =0;

  cin >> n >> y;

  for(i=0;i<=n;i++){
    for(j=0;j<=n-i;j++){
      if(ch==0){
	if(y == 9000*i + 4000*j + 1000*n){
	  cout << i << ' ' <<  j << ' ' << n-i-j << endl;
	  ch++;
	}
      }
    }
  }
  if(ch==0)cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N, 0));
    REP (i, 0, 2) REP (j, 0, N) cin >> A[i][j];
    REP (i, 0, 2) REP (j, 0, N) {
        int tmp = 0;
        if (i != 0) {
            tmp = max(tmp, A[i - 1][j]);
        } 
        if (j != 0) {
            tmp = max(tmp, A[i][j - 1]);
        }
        A[i][j] += tmp;
    }
    cout << A[1][N - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

cnt = 0
def dfs(n):
    global cnt
    if len(n) >= 11:
        return 0
    for s in '357':
        dfs(n+s)
    if int(n) <= N and '3' in n and '5' in n and '7' in n:
        cnt += 1
    return cnt

print(dfs('0'))

Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int len, n, m;
    cin >> len;

    while (len != 0)
    {
        cin >> n >> m;

        vs32 d(n + 1);
        d[0] = 0; d[n] = len;
        rep (i, n - 1) cin >> d[i + 1];
        sort(d.begin(), d.end());

        s64 ans = 0;
        rep (i, m)
        {
            int k;
            cin >> k;
            vs32::iterator it = lower_bound(d.begin(), d.end(), k);
            ans += min(abs(k - *it), abs(k - *(it - 1)));
        }

        cout << ans << "\n";

        cin >> len; // next
    }

    return 0;
}



Measured memory_bytes: 3404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
const int INF=2e9;
const int maxv= 10000+10;
int V;
struct Edge{int to,cost;};
vector<Edge> g[maxv];

typedef pair<int,int> P;

vector<int> dijkstra(int s)
{
    vector<int> d(V);
    fill(d.begin(),d.end(),INF);
    priority_queue<P,vector<P>,greater<P> > que;
    que.push(P(0,s));
    d[s]=0;
    while(!que.empty())
    {
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<g[v].size();i++)
        {
            Edge &e=g[v][i];
            if(d[v]!=INF&&d[e.to]>d[v]+e.cost)
            {
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }

    }
    return d;

}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&V);
    int u,v,cost;
    while(~scanf("%d%d%d",&u,&v,&cost))
    {
        g[u].push_back((Edge){v,cost});
         g[v].push_back((Edge){u,cost});
    }
    vector<int> d=dijkstra(0);
    int target=max_element(d.begin(),d.end())-d.begin();
    d=dijkstra(target);
    target=max_element(d.begin(),d.end())-d.begin();
    vector<int> d1=dijkstra(target);
    for(int i=0;i<V;i++)
        printf("%d\n",max(d[i],d1[i]));

    return 0;

}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int a, p;
	cin >> a >> p;
	cout << (p + 3 * a) / 2 << endl;

}

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

using namespace std;

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

    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
            cin >> c[i][j];
    }
    int ans = 0;
    for(int mask1 = 0; mask1 < (1 << h) - 1; mask1++)
    {
        for(int mask2 = 0; mask2 < (1 << w) - 1; mask2++)
        {
            int black = 0;
            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    if(c[i][j] == '#' && ((mask1 >> i) & 1) == 0 && ((mask2 >> j) & 1) == 0)
                        black++;
                }
            }
            if(black == k)
                ans++;
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3668
_ = int(input())

S = list(map(int, input().split()))
# S = list(map(int, '0 0 0 0 0 0 0 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 11 11 11 11 11 12 12 12 12 13 13 13 14 14 14 14 14 15 15 16 16 16 16 16 16 16 16 17 17 17 17 17 17 17 17 18 18 18 18 19 19 19 19 19 19 19 19 20 20 20 20 20 21 22 23 23 23 23 24 24 24 24 24 24 25 25 25 25 26 26 26 26 27 27 27 27 27 28 28 28 28 28 29 29 29 29 29 29 29 30 30 30 30 30 30 30 30 30 30 30 30 31 31 31 31 31 31 32 32 32 32 32 32 32 32 33 33 33 34 34 34 34 35 35 35 36 36 36 37 37 37 37 37 38 38 38 40 40 40 40 41 41 41 42 42 42 42 42 43 43 43 43 43 43 43 43 44 44 44 45 45 45 45 46 46 47 47 47 47 47 47 47 47 48 48 48 48 49 49 49 49 49 49 49 49 50 50 50 51 51 51 51 51 52 52 52 52 52 53 53 53 53 53 53 53 54 54 54 54 54 54 54 55 55 55 55 55 55 55 55 56 56 56 56 56 56 56 56 57 57 57 58 58 58 58 58 58 59 59 59 59 60 60 60 60 60 61 61 61 62 62 62 63 63 63 63 63 63 63 64 64 64 65 65 65 65 65 66 66 66 67 67 67 67 68 68 68 68 68 69 69 70 70 70 71 71 71 71 71 71 71 72 72 72 72 73 73 73 73 73 73 74 74 74 74 74 74 75 75 75 76 76 76 76 77 77 77 77 77 78 78 78 79 79 79 79 79 79 79 80 80 80 80 80 80 81 81 81 82 82 82 83 83 83 83 83 83 84 84 84 85 85 85 86 86 86 87 87 87 87 87 87 88 88 88 88 88 88 89 89 89 90 90 90 90 90 91 91 91 91 92 92 92 92 92 93 93 93 93 93 93 93 93 94 94 94 94 95 95 95 95 95 95 95 95 96 96 96 96 96 96 97 97 97 97 97 97 97 98 98 98 98 99'.split()))
_ = int(input())
T = list(map(int, input().split()))
# T = list(map(int, '76 31 21 17 28 60 6 62 7 35 78 39 12 90 14 3 46 0 41 10 96 59 22 92 24 99 58 47 51 38 77 79 36 33 34 45 55 37 88 18 52 57 73 32 44 54 91 8 48 11 61 67 9 16 84 85 97 70 75 2 15 95 50 94 89 66 19 40 68 65 5 56 72 49 74 64 4 25 43 42 69 27 82 13 80 23 53 26 29 63 81 86 83 98 71 1 30 20 93 87'.split()))


def binary_search(num_list, num, left, right):
    mid = (left + right) // 2
    # print(left, mid, right)
    if num_list[mid] == num:
        # print(f"{num}がある")
        return True
    if left >= right:
        return False
    elif num_list[mid] > num:
        return binary_search(num_list, num, left, mid - 1)
    else:
        return binary_search(num_list, num, mid + 1, right)


count = 0
for num in T:
    if binary_search(S, num, 0, len(S) - 1):
        count += 1

print(count)



Measured memory_bytes: 16708
def cmb(n,r,mod):
  if r<0 or r>n:
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
 
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
l2=[]
for i in range(n):
  l.append([a[i],i])
l.sort()
for i in range(n):
  l2.append([l[i][1],i])
l2.sort()
mod=10**9+7

g1=[1,1]
g2=[1,1]
inverse=[0,1]
 
for i in range(2,n+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)

ans=0
for i in range(n):
  ans+=a[i]*cmb(l2[i][1],k-1,mod)
  ans%=mod
for i in range(n):
  ans-=a[i]*cmb(n-l2[i][1]-1,k-1,mod)
  ans+=mod
  ans%=mod
print(ans)

Measured memory_bytes: 98088
gross = int(input())
numbers = input().split()
numbers = list(map(int,numbers))
numbers = sorted(numbers)
count = 0

for n in range(gross-2):
    for m in range(gross-1):
        for l in range(gross):
            if (n < m) and (m < l):
                if (int(numbers[n]) != (int(numbers[m]))) and (int(numbers[n]) != (int(numbers[l]))) and (int(numbers[m]) != (int(numbers[l]))):
                    if (int(numbers[n]) + int(numbers[m])) > int(numbers[l]):
                        count += 1
print(count)

Measured memory_bytes: 9124