akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int N;
    cin >> N;
    int ans = 0;
    int maxa = 0;
    rep(i,0,N){
        int a,b;
        cin >> a >> b;
        if(a > maxa){
            maxa = a;
            ans = a + b;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

dic1 = dict()

n = int(readline())
for i in range(n):
    a = int(readline())
    if a in dic1:
        dic1[a] += 1
    else:
        dic1[a] = 1

ans = 0
for i in dic1.values():
    if not even(i):
        ans += 1
print(ans)

Measured memory_bytes: 15068
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++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(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int x,y;
    int answer = 0;
    cin >> x >> y;

    answer += max((4-x)*100000,0);
    answer += max((4-y)*100000,0);
    if(x == 1 && y == 1)answer += 400000;

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> graph(N, vector<bool>(N, false));
  rep(i, M)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a][b] = true;
    graph[b][a] = true;
  }

  vector<int> root(N - 1);
  rep(i, N - 1)
  {
    root[i] = i + 1;
  }

  int ans = 0;
  do
  {
    if (!graph[0][root[0]])
      continue;

    bool is_ok = true;
    rep(i, root.size() - 1)
    {
      if (!graph[root[i]][root[i + 1]])
        is_ok = false;
    }
    if (is_ok)
      ans++;
  } while (next_permutation(root.begin(), root.end()));

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
const int MAX = 100005;
int n = MAX;
vector<vector<pp>> tree(n);
vector<int> color(n,0);

void dfs(int i,int before,int cost){
  if( cost == 1) color[i] = 1;
  for(auto j : tree[i]){
    if(j.first == before) continue;
    dfs(j.first,i,(cost+j.second)%2);
  }
}

int main() {
  cin >> n;
  rep(i,n-1){
    int a,b,c;
    cin >> a >> b >> c;
    --a; --b;
    tree[a].push_back(make_pair(b,c));
    tree[b].push_back(make_pair(a,c));
  }
  
  dfs(0,-1,0);
  
  rep(i,n) cout << color[i] << endl;
}

  


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

int main() {
  char b;
  cin >> b;

  char ans;
  if (b =='A') ans = 'T';
  if (b =='T') ans = 'A';
  if (b =='C') ans = 'G';
  if (b =='G') ans = 'C';

  cout << ans << endl;

  return 0;
}


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

a = list(map(int, input().split()))

q = int(input())

b = [0] * q
c = [0] * q
cnt = [0] * 100001

for i in range(len(a)):
    cnt[a[i]] += 1
s = sum(a)
for i in range(q):
    b[i], c[i] = map(int, input().split())

for i in range(q):
    s = s + ((c[i]-b[i])*cnt[b[i]])
    cnt[c[i]] += cnt[b[i]]
    cnt[b[i]] = 0
    print(s)

Measured memory_bytes: 22176
#coding:UTF-8
s = input().split()
w=int(s[0])
h=int(s[1])
x=int(s[2])
y=int(s[3])
r=int(s[4])

if((x-r)>=0 and (x+r)<=w and (y-r)>=0 and (y+r)<=h):
    print("Yes")
else:
    print ("No")

Measured memory_bytes: 7640
#include<bits/stdc++.h>
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
ll const MOD = 1000000007;
ll const N = 1000005;
ll const LN = 20;
ll const inf = 8e18;
using namespace std;

ll n, m, a[N];



ll id[N];
ll sz[N];
void ini()
{
	for (ll i = 0; i < N; i++) { id[i] = i, sz[i] = 1; }
}
ll root (ll i)
{
	while (i != id[i]) { id[i] = id[id[i]], i = id[i]; }
	return i;
}
void uni (ll a, ll b)
{
	ll ra = root (a);
	ll rb = root (b);
	if (ra == rb) { return; }
	if (sz[ra] > sz[rb]) { id[rb] = ra, sz[ra] += sz[rb]; }
	else { id[ra] = rb, sz[rb] += sz[ra]; }
}
set<ll>st;
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	ini();
	ll n, k;
	cin >> n >> k;
	for (ll i = 1; i <= n; i++)
	{ cin >> a[i]; }
	for (ll i = 1; i <= k; i++)
	{
		st.insert (a[i]);
	}
	for (ll i = 1; i <= n - k; i++)
	{
		st.insert (a[i + k]);
		if (a[i] == *st.begin() && a[i + k] == * (--st.end()))
		{
			uni (i, i + 1);
		}
		st.erase (a[i]);
	}
	vector<ll>v;
	vector<ll>temp;
	v.pb (a[n]);
	for (ll i = n - 1; i > 0; i--)
	{
		if (a[i] > v.back())
		{
			v.clear();
			v.pb (a[i]);
		}
		else
		{
			v.pb (a[i]);
			if (v.size() >= k)
			{
				temp.pb (i);
			}
		}
	}
	for (ll i = 1; i < temp.size(); i++)
	{ uni (temp[i], temp[i - 1]); }
	ll ans = 0;
	for (ll i = 1; i <= n - k + 1; i++)
	{
		if (root (i) == i) { ans++; }
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 30200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n, t;
    cin >> n >> t;
    vector<vector<ll>> dp(n+1,vector<ll>(6000));
    vector<pair<ll,ll>> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i].first >> z[i].second;
    }
    sort(z.begin(), z.end());
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j < t; j++) {
            dp[i][j] = max(dp[i - 1][j],dp[i][j-1]);
            if(j - z[i - 1].first>=0)dp[i][j] = max(dp[i-1][j - z[i-1].first]+z[i-1].second, dp[i][j]);
        }
        ans = max(ans, z[i].second + dp[i][t-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 141056
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;


int dp[60][60];
int dx[4] = {1,-1, 0, 0};
int dy[4] = {0, 0, 1,-1};

int main() {
  int h, w;
  cin >> h >> w;
  char tab[60][60];
  int m = 0;//'.'の数
  rep(i,h) {
    rep(j,w) {
      cin >> tab[i][j];
      if(tab[i][j]=='.') m++;
    }
  }
  rep(i,h) {
    rep(j,w) dp[i][j] = INF;
  }
  dp[0][0] = 1;
  queue<P> que;
  que.push({0,0});
  while(!que.empty()) {
    P a = que.front();
    que.pop();
    rep(i,4) {
      int y = a.first+dy[i];
      int x = a.second+dx[i];
      if(y<0||y>=h||x<0||x>=w) continue;
      if(tab[y][x]=='#') continue;
      if(dp[y][x]!=INF) continue;
      dp[y][x] = dp[a.first][a.second]+1;
      que.push({y,x});
    }
  }
  int ans = m - dp[h-1][w-1];
  if(ans<0) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
using namespace std;

int main () {

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

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

    int order[N];
    for (int i = 0; i < N; i++) {
        order[A[i]-1] = i+1;
    }
    for (int i = 0; i < N; i++) {
        printf("%d", order[i]);
        printf((i == N-1)? "\n" : " ");
    }

    return 0;
}


Measured memory_bytes: 1536
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[1000000];
int main()
{
    int n;
    while (~scanf("%d",&n))
    {
        for(int i=0; i<n; i++)
        {
            int te;
            scanf("%d",&a[i]);
        }
        if(n<4)
        {
            printf("0\n");
            continue;
        }
        sort(a,a+n);
        int c=0;
        int flag=0;
        int k[3];
        for(int i=n-2; i>=0; i--)
        {
            if(a[i+1]==a[i])
            {
                k[c]=a[i];
                i--;
                c++;
            }
            if(c==2)
            {
                break;
            }
            if(i==0)
            {
                printf("0\n");
                flag=1;
                break;
            }
        }
        if(!flag)
        {
            long long r;
            r=k[0]*k[1];
            printf("%lld\n",r);
//            printf("%d×%d rectangle can be formed.\n",k[1],k[0]);
        }
    }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	double x,ans=0;
	string u;
	while(cin>>x>>u)
		if(u=="JPY")
			ans+=x;
		else
			ans+=x*380000;
	cout<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 256
// Atcoder
    // Practice Problems
    // A. Apple Pie
    #include <bits/stdc++.h>
    #include <iostream>
    #include <map>
    #include <queue>
    #include <set>
    #include <string>   
    #include <vector>
    #include <numeric>
    using namespace std;
    typedef long long int ll;
    typedef pair<ll, int> PLI;
    typedef pair<int, int> PII;
    const ll mxsize = 5e3 + 15;
    const ll linf = 1e16;
    #define fastIO                                                                 \
      ios_base::sync_with_stdio(false);                                            \
      cin.tie(NULL);                                                               \
      cout.tie(NULL);
    
    /******************************************* IMPORTANT CODE SNIPPETS ************************************************/ 
    
    ll pow(ll x, ll n) {
      if (n == 0)
        return 1ll;
      ll temp;
      temp = pow(x, n / 2);
      if (n % 2 == 0)
        return temp * temp;
      else
        return x * temp * temp;
    }

    ll gcd(ll a, ll b) {
      if (b == 0)
        return a;
      return gcd(b, a % b);
    }

    int sum_digit(int val) {
      if (val < 0)
        return -1;
      if (val == 0)
        return 0;
      int ans = 0;
      while (val > 0) {
        ans = ans + val % 10;
        val = val / 10;
      }
      return ans;
    }

    ll count_div(ll l, ll r, ll val) {
      if (l % val == 0)
        return (((r / val) - (l / val)) + 1);
      else
        return ((r / val) - (l / val));
    }

    int powmod(int x, int y, int m) {
      int res = 1;
      // x = x % mod;
      while (y > 0) {
        if (y & 1)
          res = (res * x) % m;
        cout << res << endl;
        y = y / 2;
        cout << x << endl;
        x = (x * x) % m;
      }
      // cout << res << endl;
      return res;
    }
    /******************************************** CODE STARTS FROM HERE *************************************************/ 
  
  int main()
  {
    int A , P;
    cin >> A >> P;
    cout << ((3 * A + P % 2) / 2) + (P / 2) << endl; 
  }

Measured memory_bytes: 256
As = sorted(list(map(int, input().split())))
"""
2つ選んで両方を1増やす
1つ選んで2増やす

2 5 4
2 6 3
偶奇が一致しているものを選ぶ
・全部一致している -> 差の総数を2で割る
・1つだけ異なる -> 一回、1つ選んで2増やす

"""
amari = [a%2 for a in As]
# すべての偶機が一致
if sum(amari) == 0 or sum(amari) == 3:
    print(((As[2]-As[1])+(As[2]-As[0]))//2)
# 一箇所だけ奇数
elif sum(amari) == 1:
    Bs = [a+1 if a%2==0 else a for a in As]
    print(((Bs[2]-Bs[1])+(Bs[2]-Bs[0]))//2 + 1)
# 一箇所だけ偶数
elif sum(amari) == 2:
    Bs = [a+1 if a%2==1 else a for a in As]
    print(((Bs[2]-Bs[1])+(Bs[2]-Bs[0]))//2 + 1)

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

int main (void){
    string S,T;
    cin >> S;
    cin >> T;
    T.erase(T.length()-1);
    if(S == T) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define R(a,b) (a.r + b.r) * (a.r + b.r)
#define TP(a,b) (b.pos.x - a.pos.x) * (b.pos.x - a.pos.x) + (b.pos.y - a.pos.y) * (b.pos.y - a.pos.y)

using namespace std;

struct POINT{
	double x;
	double y;
};

struct CIRCLE{
	POINT pos;
	double r;
};

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

	CIRCLE a,b;
	while(n--){
		cin >> a.pos.x >> a.pos.y >> a.r >> b.pos.x >> b.pos.y >> b.r;

		if(R(a,b) >= TP(a,b)){
			POINT pa,pb,ma,mb;
			pa.x = a.pos.x + a.r;
			ma.x = a.pos.x - a.r;
			pa.y = a.pos.y + a.r;
			ma.y = a.pos.y - a.r;
			pb.x = b.pos.x + b.r;
			mb.x = b.pos.x - b.r;
			pb.y = b.pos.y + b.r;
			mb.y = b.pos.y - b.r;

			if(ma.x < mb.x && pa.x > pb.x){
				if(ma.y < mb.y && pa.y > pb.y) cout << "2" << endl;
			}
			else if(ma.x > mb.x && pa.x < pb.x){
				if(ma.y > mb.y && pa.y < pb.y) cout << "-2" << endl;
			}
			else{
				cout << "1" << endl;
			}
		}
		else if(R(a,b) < TP(a,b)){
			cout << "0" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1228
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner in = new Scanner(System.in);

		while (true) {
			int cnt = in.nextInt();
			if(cnt==0)break;
			int i = 0;
			int[] str = new int[cnt * 2];
			while (i < cnt * 2) {
				str[i] = in.nextInt();
				i++;				
			}
			
			int p1=0,p2=0;
			for(int j=0;j<cnt*2;j+=2){
				if(str[j]>str[j+1])p1+=(str[j]+str[j+1]);
				else if(str[j]<str[j+1])p2+=(str[j]+str[j+1]);
				else{
					p1+=str[j];
					p2+=str[j+1];
				}
			}
			System.out.println(p1+" "+p2);
		}
	}
}

Measured memory_bytes: 13000
//
// Created by myabu on 2020/02/02.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int X;
    cin>>X;

    int ans = 1;
    for (int i = 1; i < 1000; ++i) {
        for (int k = 2; k < 1000; ++k) {
            int temp = pow(i,k);
            if(temp > X){
                break;
            }
            ans = max(ans, temp);
        }
    }
    cout<<ans<<endl;


    return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    string s="123";
    if(a<b){
    s.erase(s.begin()+(a-1));
    s.erase(s.begin()+(b-2));
    cout << s << endl;
    }
    if(a>b){
    s.erase(s.begin()+(a-1));
    s.erase(s.begin()+(b-1));
    cout << s << endl;
    }
}

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

int main(){

  string s;
  cin>>s;
  

  if(s=="SUN")cout<<7;
  else if(s=="SAT")cout<<1;
  else if(s=="FRI")cout<<2;
  else if(s=="THU")cout<<3;
  else if(s=="WED")cout<<4;
  else if(s=="TUE")cout<<5;
  else if(s=="MON")cout<<6;
  

  
}


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

constexpr int64_t mod = 998244353;
vector<int64_t> fact, inv;

int64_t power(int64_t n, int64_t k) {
  if (k == 0) return 1;
  int64_t res = power(n * n % mod, k / 2);
  if (k % 2) {
    res = res * n % mod;
  }
  return res;
}

void init(int n) {
  fact.push_back(1);
  inv.push_back(1);
  for (int i = 0; i < n; i++) {
    fact.push_back(fact.at(i) * (i + 1) % mod);
    inv.push_back(power(fact.at(i + 1), mod - 2));
  }
}

int64_t ncr(int64_t n, int64_t r) {
  return fact.at(n) * inv.at(r) % mod * inv.at(n - r) % mod;
}

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  init(n);
  int64_t ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += m * power(m - 1, n - 1 - i) % mod * ncr(n - 1, i) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6556
import java.io.*;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
//        InputStreamReader isr = new InputStreamReader(System.in);
//        BufferedReader br = new BufferedReader(isr);
//        String buf = br.readLine();
//        int x = Integer.parseInt(buf);
        int x = Integer.parseInt(input[0]);
        int y = Integer.parseInt(input[1]);
        System.out.println(gcd(x,y));
    }
    
    static int gcd(int x, int y){
        int a = Math.max(x, y);
        int b = Math.min(x, y);
        
        while(b > 0){
            int c = a % b;
            a = b;
            b = c;
        }
        return a;
    }

}

Measured memory_bytes: 24452
#include<iostream>
using namespace std;
const int e = 100000+10;

int w[e];
int t[e];

int A(int a, int b)
{
    int c = a-b;
    if(c < 0)return -c;
    return c;
}

int main()
{
    int n,k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> t[i];
        w[i] = 1e9;
    }
    w[0] = 0;
    for(int i = 1; i < n; i++) for(int j = 1; j <= min(k,i); j++) w[i] = min(w[i-j]+A(t[i],t[i-j]) , w[i]);
    cout << w[n-1];
    return 0;
}


Measured memory_bytes: 1024
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

char A[110][110];

int main(){
  int h,w;
  cin>>h>>w;
  
  vector<char> H(h),W(w);
  char c;
  rep(i,h){
    rep(j,w){
      cin>>c;
      if(c=='#') H[i]=1,W[j]=1;
      A[i][j]=c;
    }
  }
  rep(i,h){
    if(H[i]==0) continue;
    rep(j,w){
      if(W[j]==0) continue;
      cout<<A[i][j];
    }
    cout<<endl;
  }

  return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

//x:1,z:2,y:3,w:4,a:0,b:5

int main(){
  int dt[1000][1000];
  rep(i,1000)rep(j,1000)dt[i][j]=10000;
  dt[0][1]=dt[3][1]=dt[5][3]=dt[2][4]=dt[4][5]=0;
  dt[0][3]=dt[1][2]=dt[4][3]=dt[5][1]=dt[2][5]=1;
  int x=0;
  string s;
  while(1){
    cin>>s;
    if(s=="#")break;
    queue<int> que;
    que.push(0);
    rep(i,s.size()){
      if(que.size()==0)break;
      int now=que.front();
      que.pop();
      
      rep(j,6){
	if(dt[now][j]==(int)(s[i]-'0')){
	  que.push(j);
	}
      }
    }
    //cout<<que.size()<<endl;
    bool check=false;
    while(!que.empty()){
      if(que.front()==5){
	check=true;
	break;
      }
      que.pop();
    }
    if(check)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 5088
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

std::uint64_t full(std::uint64_t n)
{
    if (n == 0ul) return 1ul;
    auto x = full(n - 1ul);
    return 1ul + 2ul * x;
}

std::uint64_t f(std::uint64_t n, std::uint64_t x)
{
    if (n == 0ul) return 1ul;
    std::uint64_t s2 = (1ul << (n + 1)) - 3;
    if (x == 1) return 0;
    if (x <= s2 + 1) {
        return f(n - 1, x - 1);
    }
    if (x == 1 + s2 + 1) {
        return full(n - 1) + 1;
    }
    if (x <= 1 + s2 + 1 + s2) {
        return full(n - 1) + 1 + f(n - 1, x - 2 - s2);
    }
    return 1 + full(n - 1) * 2;
}

void prog()
{
    std::uint64_t n, x;
    std::cin >> n >> x;
    out(f(n, x));
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int M;
	cin >> M;
	cout << 48 - M << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ans = 0
    m = n - 1
    num = 1
    while num * num <= m:
        if m % num == 0:
            if num > 1:
                ans += 1
            if m // num != num:
                ans += 1
        num += 1
    num = 1
    while num * num <= n:
        if n % num == 0:
            tmp = n
            while num > 1 and tmp % num == 0:
                tmp = tmp // num
            if tmp == 1 or tmp % num == 1:
                ans += 1
            rest = n // num
            if rest != num:
                tmp = n
                while tmp % rest == 0:
                    tmp = tmp // rest
                if tmp == 1 or tmp % num == 1:
                    ans += 1
        num += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

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

    int cnt = 0;

    for (int i = A; i <= B; ++i) {
        string s=to_string(i);

        if (s[0]==s[4]&&s[1]==s[3]){
            cnt++;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cassert>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    /*ll N;
    scanf("%lld", &N);

    ll d = 10;
    ll sum = 0;
    while (N > 0)
    {
        sum += N % d;
        N -= N % d;
        d *= 10;
    }*/

    char c;
    scanf("%c", &c);
    ll sum = 0;
    while (c != '\n')
    {
        sum += c - '0';
        scanf("%c", &c);
    }
    if (sum % 9 == 0)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 3752
// https://atcoder.jp/contests/aising2020/tasks/aising2020_b
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    lli n,i,a[105],c=0;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
        if((a[i]&1) && (i&1))
            c++;
    cout<<c<<"\n";
    return 0;
}

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

int main(){
  ll x;
  cin>>x;
  ll y =0;
  ll num =100;
  while(num<x){
    ll r= num/100;
    num  += r;
    y++;
    
  }
  cout << y;
}
  

Measured memory_bytes: 3632
// 6/14 リアルタイム参加
// 終了後に再挑戦
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

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

    vector<bool> divide(1000001, false);

    int ans = 0;

    rep(i, N) {
        if (divide[A[i]]) continue;

        int a = A[i];
        for (int j = a; j <= 1000001; j += a) {
            divide[j] = true;
        }

        if (i == N - 1) ans++;
        else {
            if (A[i] != A[i + 1]) ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4044
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define printyn(a) printf(a ? "Yes\n" : "No\n");
#define printYN(a) printf(a ? "YES\n" : "NO\n");
#define all(x) (x).begin(), (x).end()

using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
//#include <vector>

using namespace std;

int main() {

	char tmp[10];
	string s = "";
	scanf("%s", tmp);
	rep(i, strlen(tmp)) {
		if (tmp[i] == 'B') {
			if (!s.length())continue;
			else s.pop_back();
		}
		else if (tmp[i] == '0') {
			s.push_back('0');
		}
		else {
			s.push_back('1');
		}
	}
	printf("%s", s.c_str());
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)



int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans=0;
    ans+=a*(n/(a+b));
    if((n%(a+b))<a)  ans+=(n%(a+b));
    else ans+=a;
    cout << ans << endl;
}





Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
string s[55];
int f[55];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s[i] >> f[i];
    }
    string p;
    cin >> p;
    for (int i = 1; i <= n; i++) {
        if (p == s[i]) {
            int tot = 0;
            for (int j = i + 1; j <= n; j++) tot += f[j];
            cout << tot << '\n';
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

s = input()
prefix = int(s[:2])
suffix = int(s[2:])

def isMonth(n):
    if n <= 12 and n >= 1:
        return True

if isMonth(prefix) and isMonth(suffix):
    ans = 'AMBIGUOUS'
elif not isMonth(prefix) and isMonth(suffix):
    ans = 'YYMM'
elif isMonth(prefix) and not isMonth(suffix):
    ans = 'MMYY'
else:
    ans = 'NA'

print(ans)


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

const ll nmax = 1e5;
vector<vector<pair<ll, ll>>> g(nmax);
vector<bool> black(nmax, false);

void dfs(ll now = 0, ll parent = 0) {
  for (auto next : g[now]) {
    if (next.first == parent) continue;
    if (next.second % 2 == 1) {
      black[next.first] = !black[now];
    } else {
      black[next.first] = black[now];
    }
    dfs(next.first, now);
  }
}

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

  ll u, v, w;
  for (ll i = 0; i < n - 1; i++) {
    cin >> u >> v >> w;
    u--; v--;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
  }

  dfs();

  for (ll i = 0; i < n; i++) {
    cout << black[i] << endl;
  }
}


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

int main(void) {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	
	int n;
	int ans = 0;
	cin >> n;
	
	int a[2][n];
	
	for (int i=0;i <= n-1;i++) {
		cin >> a[0][i];
	}
	
	for (int j=0;j <= n-1;j++) {
		cin >> a[1][j];
	}
	
	for (int k=0;k<=n-1;k++){
		int s = 0;
		for (int l=0;l<=k;l++){
			s = s + a[0][l];
		}
		
		for (int m=k;m<=n-1;m++){
			s = s + a[1][m];
		}
		ans = max(s,ans);
	}
	
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool used[2000001];
int n,h,w,x;
int main(){
  cin>>n>>h>>w;
  for(int i=0;i<n;i++){
    cin>>x;
    if(i%2==0)for(int j=(w)*(i)+x;j<(w)*(i)+x+w;j++){
	if(j>=0&&j<=w*n)used[j]=1;
    }
    else for(int j=w*(i)-x;j<w*(i)-x+w;j++){
      if(j>=0&&j<=w*n)used[j]=1;
    }
  }
  int sum=0;
  for(int i=0;i<w*n;i++){
    if(!used[i])sum+=h;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3112
k = int(input())

l = [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]

print(l[k-1])

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]+a[1]==a[2])
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
  	return 0;
}







Measured memory_bytes: 3652
N, K = [int(hk) for hk in input().split()]
H = []
for n in range(N):
  H.append(int(input()))
H.sort()
dh_mn = 10**9
for i in range(N-K+1):
  dh = H[K+i-1]-H[i]
  if dh < dh_mn:
    dh_mn = dh
print(dh_mn)

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

int main(){
    int N;
    cin >> N;
    int p[10],ans = 0;

    for(int i = 0 ; i < N; i++){
        cin >> p[i];
    }
    sort(p,p + N,greater<int>());
    ans += p[0]/2;
    for(int i = 1 ; i < N; i++){
       ans += p[i]; 
    }

    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <bits/stdc++.h>

using namespace std;
int main() {
    int r,d,n;
    cin >>r>>d>>n;
    for (int i = 0; i < 10; i++)
    {
        n=n*r-d;
        cout<<n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200005],t[200005],b[200005],sum;
signed main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)scanf("%d",&a[i]),t[a[i]]++;//桶存储每个数出现次数
	for(int i=1; i<=n; i++)//枚举的是数字1~n，不是下标的1~n
		if(t[i]>1)//t[i]<=1时，对答案是没有影响的
		{
			sum+=(t[i]-1)*t[i]/2;//计算次数累加
            b[i]=t[i]-1;//去掉这个数字后答案的减少量
		}
	for(int i=1; i<=n; i++)cout<<sum-b[a[i]]<<endl; 
}

Measured memory_bytes: 6272
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main()
{
	LL n,k;
	cin>>n>>k;
	LL a[n];
	for(LL i=0; i<n; i++)
	cin>>a[i];
	sort(a,a+n);
	LL sum=0;
	for(LL i=0; i<n && k>0; i++,k--)
	{
		sum+=a[i];
	}
	cout<<sum<<"\n";
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 1e6 +9;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9+7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>

const int MAX_N = 105, MAX_K = 1e5 + 5, MOD = 1e9 + 7;
ll dp[10005],a[10005],b[10005];
ll n;

ll rec(ll v){
     if(v<=0){
          return 0;
     }
     if(dp[v]!=-1){
          return dp[v];
     }
     ll ans = inf;
     for(int i = 0;i<n;i++){
          ans = min(ans,rec(v-a[i])+b[i]);
     }
     return dp[v] = ans;
}

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

     ll t = 1;
     // cin>>q;
     while(t--){
          ll n,d,a;cin>>n>>d>>a;
          pii v[n];
          for(int i = 0;i<n;i++){
               cin>>v[i].x>>v[i].y;
          }
          sort(v,v+n);
          queue<pii> q;
          q.push(v[0]);
          ll i = 1;
          ll no_of_moves = 0;
          while(!q.empty() || i<n){
               if(q.empty()){
                    pii ins = v[i];
                    ins.y += no_of_moves*a;
                    q.push(ins);
                    i++;
               };
               pii curr = q.front();

               if(i<n){
                    while(v[i].x<=(curr.x+2*d )){
                         pii ins = v[i];
                         ins.y += no_of_moves*a;
                         q.push(ins);
                         i++;
                    }
               }
               ll health_left = (curr.y- (no_of_moves*a));
               ll req_move = max(health_left,0ll)/a;
               if(req_move*a<health_left){
                    req_move++;
               }

               no_of_moves+=req_move;
               q.pop();

          }
          cout<<no_of_moves<<'\n';

     }
}         

Measured memory_bytes: 6656
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(int[]);
    int c;
    foreach (a; AS) {
        while (a && a%2 == 0) {
            ++c;
            a /= 2;
        }
    }
    writeln(c);
}

Measured memory_bytes: 2684
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
//ゲート１　１から３　ゲート２　２から４　１がゲート２が×　４はゲート１が×
void _main() {
	int N,M;
	cin >> N >> M;
	int L,R;
	int MINmax = 1;
	int MAXmin = N;
	rep(i, 0, M) {
		cin >> L >> R;
		MINmax = max(MINmax, L);//L(最小値)の内最大のもの
		MAXmin = min(MAXmin, R);//R(最大値)の内最小のもの
	}

	//ansはMINmax以上でMAXmin以下の区間
	//ゲートは１からＭまでの並んだ数字なので差で充分。
	//+1する必要あり
	int ans = MAXmin - MINmax + 1;
	//MAXminの最大値よりMINmaxの最大値方が大きいなら0なので０にする。
	ans = max(ans, 0);

	cout << ans << endl;

}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = (x - 9) % 7;
		if(y < 0) {
			y += 7;
		}
		
		switch(y) {
		case 0:
			System.out.println("sat");
			break;
		case 1:
			System.out.println("sun");
			break;
		case 2:
			System.out.println("mon");
			break;
		case 3:
			System.out.println("tue");
			break;
		case 4:
			System.out.println("wed");
			break;
		case 5:
			System.out.println("thu");
			break;
		case 6:
			System.out.println("fri");
		}
	}
}


Measured memory_bytes: 26332
#include <bits/stdc++.h> 
using namespace std; 
typedef   long long int ll;
int main() 
{   
     ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    ll n;cin>>n;
    ll a[n],k=0;
    for (ll i=0;i<n;i++) cin>>a[i];
    for (ll i=0;i<n;i++) {
        if (a[i]%2==0) {
        if (a[i]%3==0||a[i]%5==0) continue;
        k=1;
        }
    }
    if (k==1) cout<<"DENIED"<<endl;
    else cout<<"APPROVED"<<endl;
   }


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

void solve() 
{
    int n;cin>>n;int ans=0;
    ll l[n];REP(i,n)cin>>l[i];
    sort(l,l+n);
    REP(i,n-2)rep(j,i+1,n-1)rep(k,j+1,n){
        if(l[i]!=l[j]&&l[j]!=l[k]&&l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[k]+l[j]>l[i])ans++;
    }
    cout<<ans<<endl;
}

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

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var N = IO.RInt;
            var dic = new Dictionary<string, int>();
            for (int i = 0; i < N; i++)
            {
                var nyu = ReadLine().Split();
                dic[nyu[0]] = int.Parse(nyu[1]);
            }
            var x = ReadLine();
            bool f = false;
            var ans = 0;
            foreach (var item in dic)
            {
                if (item.Key == x)
                {
                    f = true;
                    continue;
                }
                if (f) ans += item.Value;
            }
            WriteLine(ans);
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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



int main() {
  int n;
  int ans = 0;
  cin >> n;
  vector<int> button(n + 1, 0);
  vector<int> check(n + 1, -1);
  

  rep(i, n) cin >> button[i + 1]; 
  
  
  int next = 1;
  while(check[next] == -1 && next != 2)
  {
    check[next] = 0;
    next = button[next];
    ans ++;
  
  }
  if(next == 2) cout << ans << endl;
  else cout << -1 << endl;
  
    } 
   
  





Measured memory_bytes: 4048
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[]) {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a==b && b==c && a%2==0) cout << -1 << endl;
  else {
    ll ans = 0;
    while((a%2==0)&&(b%2==0)&&(c%2==0)){
      ll tempa = (b+c)/2, tempb = (c+a)/2, tempc = (a+b)/2;
      a = tempa;
      b = tempb;
      c = tempc;
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll n, a;
    cin >> n;

    ll mn = 1LL << 60;
    for (int i = 0; i < 5; i++) {
        cin >> a;
        mn = min(mn, a);
    }

    cout << 5 + (n - 1) / mn << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
const ll mod = 1e9 + 7;
const int intmax = 0x7fffffff, intmin = ~intmax;
const ll llmax = 0x7fffffffffffffffll, llmin = ~llmax;

int main() {
  int n, d;
  cin >> n >> d;
  cout << ((n + 2 * d + 1 - 1) / (2 * d + 1)) << endl;
}


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

int main(){
    vector<int> v(3);
    for(int i=0;i<3;i++) cin >> v[i];
    sort(v.begin(),v.end());
    if(v[0]==5 && v[1]==5 && v[2]==7)
        cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;

int main() {
	ll n,a,b;
	cin >> n >> a >>b;
	if((b-a)%2==0)cout << (b-a)/2 << endl;
	else cout << min(a-1,n-b)+(b-a-1)/2+1 << endl;
	
	return 0;
}	

Measured memory_bytes: 256
var
    a:array[-1..200,-1..200] of longint;
    i,j,n,m:longint;
    ch:char;
function slei(x,y:longint):longint;
var
    s:longint;
begin
    s:=a[x-1,y-1]+a[x-1,y]+a[x-1,y+1]+a[x,y-1];
    s:=s+a[x,y+1]+a[x+1,y-1]+a[x+1,y]+a[x+1,y+1];
    exit(s);
end;
begin
    readln(n,m);
    for i:=1 to n do
    begin
        for j:=1 to m do 
        begin 
            read(ch);
            if ch='.' then a[i,j]:=0 else a[i,j]:=1;
        end;
        readln;
    end;
    for i:=1 to n do
    begin
        for j:=1 to m do
            if a[i,j]=1 then write('#')
                else write(slei(i,j));
        writeln;
    end;
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    int a[5]={0};
    for(int i=0;i<5;i++)
        cin>>a[i];
    for(int i=0;i<5;i++)
        if(!a[i])
        cout<<i+1;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a,b;
  int pri,i=-1;
  cin>>a>>b;
  for(pri=ceil(a*100/8);pri<ceil((a+1)*100/8);pri++){
    if(pri/10==b){
      i=pri;
      break;
    }
  }
    cout<<i<<endl;
}

Measured memory_bytes: 256
from pprint import pprint
N, M = map(int, input().split())
shop = []
for i in range(N):
    AB = list(map(int, input().split()))
    shop.append(AB)
shop.sort()
money = 0
for j in shop:
    A = int(j[0])
    B = int(j[1])
    if B < M:
        money += A*B
        M -= B
    elif B >= M:
        money += A*M
        break
print(money)

Measured memory_bytes: 28388