akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib> 
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

int main() {
	int n;
	cin >> n;
	
	int x = n / 100;
	int  y = (n - 100*x) / 10;
	int z = n - 100*x - 10*y;
	
	if (x == z) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    long long ArrayN[N];
    bool isEven = true;
    for(int i = 0; i < N; i++){
        long long x;
        cin >> x;
        ArrayN[i] = x;
        if(x % 2 == 1) isEven = false;
    }
    long long cn = 0;
    if(isEven == true){
        while(isEven == true){
            for(int i = 0; i < N; i++){
                if(ArrayN[i] % 2 == 0){
                    ArrayN[i] = ArrayN[i] / 2;
                }else {isEven = false; break;}
            }
            if(isEven == true) cn++;
        }
        cout << cn << "\n";
    }else cout << "0" << "\n";
    return 0;
}


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

P f(int x){
    int a=x%10;
    int b=0;
    while(x>0){
        b=x;
        x/=10;
    }
    return P(a, b);
}

int main(){
    int n;
    cin>>n;
    map<P, int> mp;
    for(int i=1;i<=n;i++){
        P p=f(i);
        mp[p]++;
    }

    ll ans=0;
    for(int i=1;i<=n;i++){
        P p=f(i);
        P q(p.second, p.first);
        ans+=mp[q];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,heapq
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    a = inlt()
    a.sort()
    q = (sum(a[n // 2:]) * 2) - max(a)
    if n % 2 != 0:
        q = q - a[n // 2]
    print(q)
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    b = [[0] * len(a) for i in range(len(a))]
    for i in range(len(a)): 
        for j in range(len(a)): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()

Measured memory_bytes: 103728
S = input()
lens = len(S)
A = []
x = 0
if lens == 3:
    ans = 753 - int(S)
    if ans >= 0:
        print(ans)
    else:
        print(-1 * ans)
        x = 1
else:
    for i in range(lens - 2):
        r = int(S[i] + S[i+1] + S[i+2])
        ans = r - 753
        if ans < 0:
            ans = ans * -1
        A.append(ans)

if x == 0:
    print(min(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;
 
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 
	int n; cin >> n;

	int a = n/500, b = (n%500)/5;
	cout << a*1000+b*5 << '\n';
 
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m;
    cin >> n >> m;
    cout << n * m << "\n";
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int x, y, z;
int main() {
    DAU
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' << y;
    PLEC
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    ull sum = 0;
    for(ll a : A){
        while(a % 2 == 0){
            a /= 2;
            sum++;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3712
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    n = int(input())
    res = ''
    for i in range(0, len(s), n):
        res += s[i]
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main() {
	int x1 = 0, x2 = 0, x3 = 0, x4 = 0, y1 = 0, y2 = 0, y3 = 0, y4 = 0, sub1, sub2;
	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	//x2基準でx1から-90°回転でx3(どの場合も)
	//x1基準でx2から90°回転でx4(どの場合も)
	x3 = y1 - y2 + x2;
	y3 = x2 - x1 + y2;
	x4 = y1 - y2 + x1;
	y4 = x2 - x1 + y1;
	printf("%d %d %d %d", x3, y3, x4, y4);
	return 0;
}

Measured memory_bytes: 128
#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;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> t[i];
    w[1] = A(t[1],t[0]);
    for(int i = 2; i < n; i++) w[i] = min(w[i-1]+A(t[i],t[i-1]) , w[i-2] + A(t[i],t[i-2]));
    cout << w[n-1];
    return 0;
}


Measured memory_bytes: 1024
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1, 0), b(m + 1, 0);
    rep(i, n) cin >> a[i + 1];
    rep(i, m) cin >> b[i + 1];
    ll sum = 0;
    ll idx = 0;
    for(ll i = 0; i < n + 1; i++){
        if(sum + a[i] > k){
            idx = i - 1;
            break;
        }
        sum += a[i];
        idx = i;
    }
    ll ans = idx;
    ll bi = 0;
    for(ll i = idx; i >= 0; i--){
        while(bi + 1 < m + 1 && sum + b[bi + 1] <= k){
            bi++;
            sum += b[bi];
        }
        ans = max(ans, i + bi);
        sum -= a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 6332
#include "bits/stdc++.h"

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if(A == B or A + 1 == B or A == B + 1 or abs(A - B) % 2 == 1) puts("IMPOSSIBLE");
    else cout << (A + B) / 2 << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    printf("%d\n", min(min(a, b) + c, a + b));
    return 0;
}

Measured memory_bytes: 256
n,k = STDIN.gets.split(' ').map{|s| s.to_i}
a   = STDIN.gets.split(' ').map{|s| s.to_i}

e   = a.map{|v| (v+1)/2.0}

$memo = []
r = []
n.times do |i|
  r[i] = e[i] + (i == 0 ? 0 : $memo[i-1])
  $memo[i] = r[i]
end
# p e
# p r
# p $memo

s_list = []
n.times do |i|
#  puts "i:#{i} r[(i-1)+k]:#{r[(i-1)+k]} r[i-1]:#{r[i-1]}"
  break if i + k > n
  s_list << r[(i-1)+k] - (i == 0 ? 0 : r[i-1])
end

puts s_list.max

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


void solve(long long N, std::string S){
    vector<set<int>> places(3);
    for(int i=0;i<N;i++){
        if(S[i] == 'R'){
            places[0].insert(i);
        }else if(S[i] == 'G'){
            places[1].insert(i);
        }else if(S[i] == 'B'){
            places[2].insert(i);
        }

    }
    ll  ans =0;
    vector<int> array = {0,1,2};
    do{
        vector<int> dp(N,0);
        for(auto mitr = places[array[1]].begin();mitr != places[array[1]].end(); ++mitr){
                auto eStart = places[array[2]].lower_bound(*mitr);
                for(auto eitr = eStart;eitr != places[array[2]].end(); ++eitr){
                    dp[*mitr]++;
                }
        }
        for(auto fitr = places[array[0]].begin();fitr != places[array[0]].end(); ++fitr){
            auto mStart = places[array[1]].lower_bound(*fitr);
            for(auto mitr = mStart;mitr != places[array[1]].end(); ++mitr){
                ans += dp[*mitr];
                if(places[array[2]].find(*mitr*2 -*fitr) != places[array[2]].end()){
                    ans--;
                }        
            }             
        }
    }while(next_permutation(array.begin(),array.end()));
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b / gcd(a,b);}

int main() {
    int x,t;
    cin >> x >> t;
    cout << max(0,x-t) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    // 0: R, 1: S, 2: P
    int t[N];
    int v[3] = {R, S, P};
    for (int i = 0; i < N; i++) {
        if (T[i] == 'r') t[i] = 2;
        if (T[i] == 's') t[i] = 0;
        if (T[i] == 'p') t[i] = 1;
    }
    int d[N][3]{};
    for (int i = 0; i < K; i++) {
        d[i][t[i]] = v[t[i]];
        for (int j = i + K; j < N; j += K) {
            for (int k = 0; k < 3; k++) {
                if (t[j] == k) {
                    d[j][k] = max(d[j - K][(k + 1) % 3], d[j - K][(k + 2) % 3]) + v[k];
                } else {
                    d[j][k] = max(d[j - K][(k + 1) % 3], d[j - K][(k + 2) % 3]);
                }
            }
        }
    }
 
    int ans = 0;
    for (int i = 1; i <= K; i++) {
        ans += max(d[N - i][0], max(d[N - i][1], d[N - i][2]));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2048
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	vector<int>a;
	int n, x;
	int ans;
	ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &x);
		a.push_back(x);
	}
	sort(a.begin(), a.end(), greater<int>());

	for (int i = 0; i < n; i++){
		if (i % 2 == 0)ans += a[i];
		else ans -= a[i];
	}

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


	return 0;
}

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

int main(){
	int a[200],b[200],i=0,sum,count;
	while(cin>>a[i]){
		cin>>b[i];
		i++;
	}
	for(int j=0;j<i;j++){
		sum = a[j]+b[j];
		count = 0;
		while(sum != 0){
			sum/=10;
			count++;
		}
		cout<<count<<endl;
	}
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll inf = 1LL << 55;
ll mod = 1000000007;

using namespace std;

int main(){
    FAST;
    //freopen("in.in", "r", stdin);

    int ab, bc, ac; cin >> ab >> bc >> ac;
    
    cout << (ab*bc)/2 << endl;

    return 0;
}


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

int sumf(vector<int> v,int x){
    int re = 0;
    for(int i=0;i<=x;i++){
        re += v[i];
    }
    return re;
}

int sumb(vector<int> v,int x){
    int re = 0;
    for(int i=x;i<v.size();i++){
        re += v[i];
    }
    return re;
}

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(2,vector<int>(n));
    for(int i=0;i<n;i++){
        cin >> a[0][i];
    }
    for(int i=0;i<n;i++){
        cin >> a[1][i];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        int tmp = sumf(a[0],i) + sumb(a[1],i);
        ans = max(ans,tmp);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long i,j,k,n,l,ans=0,b[3][10010]={};
  char s[10010],c[]={"RGB"};
  scanf("%lld %s",&n,s);
  for(i=0;i<n;i++){
    for(j=0;j<3;j++)b[j][i+1]=b[j][i];
    for(j=0;s[i]-c[j];j++);
    b[j][i+1]++;
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(s[i]==s[j])continue;//printf("%d %d %d\n",i,j,i-(j-i));
      k=(int)'R'+'G'+'B'-s[i]-s[j];
      for(l=0;c[l]-k;l++);
      ans+=b[l][i];
      if(i-(j-i)>=0&&s[i-(j-i)]==c[l])ans--;
    }
  }
  printf("%lld\n",ans);
  return 0;
}
	


Measured memory_bytes: 1972
N = int(input())
 
h = [1]
 
t = []
i = 1
while True:
  t.append(6**i)
  i += 1
  if t[-1]>10000:
    break
h.extend(t)
 
t = []
i = 1
while True:
  t.append(9**i)
  i += 1
  if t[-1]>10000:
    break
h.extend(t)
 
h.sort()
 
DP = []
DP.append(0)
 
hlen = len(h)
for i in range(1,N+1):
  m = 999999
  for j in range(hlen):
    if i-h[j]<0:
      break
    else:
      if m>DP[i-h[j]] + 1:
        m = DP[i-h[j]] + 1
  DP.append(m)  
print(DP[N])

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

int d[111][111];
int main() {
    int h, w;
    cin >> h >> w;
    string s[111];
    for(int i = 0; i < h; i++)
        cin >> s[i];
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(!i && !j) {
                d[i][j] = s[i][j] == '#';
                continue;
            }
            if(!i) {
                d[i][j] = d[i][j - 1] + (s[i][j] == '#' && s[i][j - 1] != '#');
                continue;
            }
            if(!j) {
                d[i][j] = d[i - 1][j] + (s[i][j] == '#' && s[i - 1][j] != '#');
                continue;
            }
            if(s[i][j] == '#')
                d[i][j] = min(d[i - 1][j] + (s[i - 1][j] != '#'),
                              d[i][j - 1] + (s[i][j - 1] != '#'));
            else
                d[i][j] = min(d[i - 1][j], d[i][j - 1]);
        }
    }
    cout << d[h - 1][w - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main(){
    int n;
    cin>>n;
    long long a[100100];
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
        long long count1=0;
        long long su1=0;
            for(int j=0;j<n;++j){
                su1+=a[j];
                        if(j%2==0&&su1<=0){
                            count1+=-su1+1;
                            su1=1;
                        }
                        else if(j%2==1&&su1>=0){
                            count1+=su1+1;
                            su1=-1;
                        }
    }
        long long count2=0;
        long long su2=0;
            for(int j=0;j<n;++j){
                su2+=a[j];
                        if(j%2==0&&su2>=0){
                            count2+=su2+1;
                            su2=-1;
                        }
                        else if(j%2==1&&su2<=0){
                            count2+=-su2+1;
                            su2=1;
                        }
    }
    cout<<min(count1,count2)<<endl;
}


Measured memory_bytes: 1024
def solve(string):
    n, s = string.split()
    n = int(n)
    es = {i for i, _s in enumerate(s) if _s == "E"}
    num_e = len(es)
    count_e = 0
    count_w = 0

    ans = n
    for i, _s in enumerate(s):
        tmp = count_w
        if i in es:
            count_e += 1
        else:
            count_w += 1
        tmp += num_e - count_e
        ans = min(ans, tmp)
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> L){
    sort(all(L));
    int answer = 0;
    rep(i,0,N) rep(j,i+1,N) rep(k,j+1,N) {
        if (L[i] + L[j] > L[k] && L[i] != L[j] && L[j] != L[k]) answer++;
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> L(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&L[i]);
    }
    solve(N, std::move(L));
    return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

const int64_t INF = 1e+18;

struct edge {
    int to;
    int64_t weight;
};

void Dijkstra(int s, vector<vector<edge>> &G, vector<int64_t> &d) {
    fill(d.begin(), d.end(), INF);
    d[s] = 0;
    priority_queue<pair<int64_t, int>, vector<pair<int64_t, int>>, greater<pair<int64_t, int>>> q;
    q.push(make_pair(0, s));
    
    while (!q.empty()) {
        pair<int, int> p = q.top(); q.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[e.to] > d[v] + e.weight) {
                d[e.to] = d[v] + e.weight;
                q.push(make_pair(d[e.to], e.to));
            }
        }
    }
    
    return;
}

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m; cin >> n >> m;
    
    vector<vector<edge>> G(3 * n, vector<edge>());
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v; u--; v--;
        G[u].push_back({v + n, 1});
        G[u + n].push_back({v + 2 * n, 1});
        G[u + 2 * n].push_back({v, 1});
    }
    
    int s, t; cin >> s >> t; s--; t--;
    
    vector<int64_t> d(3 * n);
    Dijkstra(s, G, d);
    
    cout << (d[t] == INF ? -1 : d[t] / 3) << endl;
    
    return 0;
}


Measured memory_bytes: 19072
/*
 _____ _             _              _           _ 
|_   _| |__   ___   / \   _ __  ___| |__  _   _| |
  | | | '_ \ / _ \ / _ \ | '_ \/ __| '_ \| | | | |
  | | | | | |  __// ___ \| | | \__ \ | | | |_| | |
  |_| |_| |_|\___/_/   \_\_| |_|___/_| |_|\__,_|_|                                                

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll,ll>
#define msi         map<string,ll>
#define mis         map<ll, string>
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) 	for(auto& a : x)
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pair<ll, ll>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define max(a,b)	(a>b?a:b)
#define min(a,b)	(a<b?a:b)

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define DECIMAL(n)  cout << fixed ; cout << setprecision(n);
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace __gnu_pbds;
using namespace std;
#define PI 3.141592653589793
#define N  100005
ll dp[4005][3];
void solve()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	s='#'+s;
	rep(i,1,n+1)
	{
		if(s[i]=='R')
			dp[i][0]=1;
		else if(s[i]=='G')
			dp[i][1]=1;
		else
			dp[i][2]=1;
	}
	rep(i,1,n+1)
	{
		rep(j,0,3)
		dp[i][j]+=dp[i-1][j];
	}
	ll ans=0,ps;
	rep(i,1,n+1)
	{
		rep(j,1,i)
		{
			if(s[i]==s[j])
				continue;
			ps=j-(i-j);
			if((s[i]=='R' && s[j]=='G') || (s[j]=='R' && s[i]=='G'))
			{
				ans+=dp[j-1][2]-(ps>0 && s[ps]=='B');
			}
			else if((s[i]=='B' && s[j]=='G') || (s[j]=='B' && s[i]=='G'))
			{
				ans+=dp[j-1][0]-(ps>0 && s[ps]=='R');
			}
			else
			{
				ans+=dp[j-1][1]-(ps>0 && s[ps]=='G');
			}
		}
	}
	cout<<ans<<endl;
	return;
}
int main()
{
	FAST
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	TIME
	return 0;
}

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

signed main(){
  string s; cin >> s;
  int N = s.size() - 1;
  int ans = 0;
  string h;
  for(int bit = 0; bit < (1 << N); bit++){
    h = s[0];
    for(int i = 0; i < N; i++){
      if(bit & (1 << i)){
        h += s[i+ 1];
      }
      else{
        ans += stoll(h);
        h = s[i + 1];
      }
    }
    ans += stoll(h);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
var all=[""];
for(var i=1;i<=9;i++){
   all.push([]);
   var loop=function(start,sum,cnt){
      if(cnt==i)all[i].push(sum);
      else{
         for(var j=start;j<=9;j++)loop(j+1,sum+j,cnt+1);
      }
   };
   loop(0,0,0);
 } 
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
arr.some(function(v){
   if(v=="0 0")return true;
   var ns=v.split(" ").map(Number);
   var n=ns[0];
   var s=ns[1];
   var cnt=0;
   all[n].forEach(function(v){
      if(v==s)cnt++;
   });
   console.log(cnt);
});

Measured memory_bytes: 15680
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int BScnt=0,AEcnt=0;//Bで始まる文字列を数える,Aで終わる文字列を数える
		int BSAEcnt=0;//BS,AEどちらも当てはまる文字列の個数を数える
		String[] S = new String[N];
		for(int i=0;i<N;i++)S[i]=sc.next();

		long sum = 0;
		for(int l=0;l<N;l++) {
			int f = 0;
			int Slen=S[l].length();

			if(S[l].substring(0,1).equals("B")) {BScnt++;f++;}
			if(S[l].substring(Slen-1,Slen).equals("A")) {AEcnt++;f++;}
			if(f==2) {BSAEcnt++;}


			int Slen2=S[l].replaceAll("AB", "-").length();//部分文字列ABを-へと置き換える。
			sum += (Slen - Slen2);//差分が部分文字列の個数。
		}

		int addAB = min(BScnt,AEcnt);
		if(addAB==N)addAB--;
		else if(BSAEcnt>0&&BSAEcnt==BScnt&&BSAEcnt==AEcnt)addAB--;

		sum += addAB;
		//out.println(sum + " B:" + BScnt + " A:"+AEcnt);
		//out.println(BSAEcnt);
		out.println(sum);

	}
	@SuppressWarnings("unused")
	private int min(int a, int b) {
		return Math.min(a, b);
	}
	@SuppressWarnings("unused")
	private int nextInt() {
		return Integer.parseInt(next());
	}
	@SuppressWarnings("unused")
	private long nextLong() {
		return Long.parseLong(next());
	}
	private String next() {
		return sc.next();
	}
}

Measured memory_bytes: 36768
#include<bits/stdc++.h>
#define N 1000005
using namespace std;
int a[N],sum[N];
int n;
char s[N];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='W')a[i]=1;
		else a[i]=0;
		sum[i]=sum[i-1]+a[i];
	}
	int ans=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
	{
		ans=min(ans,sum[i-1]+(n-i)-(sum[n]-sum[i]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5760
a, b, k = map(int, input().split())
ans = []
for i in range(a, min(a+k, b)):
    ans.append(i)
for i in range(max(b-k+1, a), b+1):
    ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
    print(i)


Measured memory_bytes: 38384
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n;cin>>n;
    cout << divceil(n, 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k;
  cin>>k;
  string s="ACL";
  while(k>0){
    cout<<s;
    k-=1;
  }
  return 0;
}

Measured memory_bytes: 3624
while True:
    n = int(input())
    if n == 0:
        break
    a = [int(input()) for i in range(n)]
    nums = [0 for i in range(10)]
    for j in range(len(a)):
        k = int(a[j])
        nums[int(a[j])] += 1
    for t in range(10):
        s = nums[t]
        if s == 0:
            print('-')
        else:
            print('*'*s)


Measured memory_bytes: 5716
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  char op;
  int B;
  cin >>A>>op>>B;
  if(op=='+') {
cout << A+B<< endl;
  }
else {
cout <<A-B<< endl;
}
}


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

signed main() {
	string s;
	cin >> s;
	
	if (s <= "2019/04/30") {
		cout << "Heisei" << endl;
	}
	else {
		cout << "TBD" << endl;
	}
}


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

data = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, N + 1):
    s_i = str(i)
    a = int(s_i[0])
    b = int(s_i[-1])
    data[a][b] += 1

ans = 0

for i in range(1, 10):
    for j in range(1, 10):
        ans += data[i][j] * data[j][i]

print(ans)


Measured memory_bytes: 3060
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

const ll mod = 1000000009;

inline ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

inline ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

inline ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

string s;

bool okay1() {
	int x = (s[2] - '0') * 10 + s[3] - '0';
	return (0 < x && x < 13);
}

bool okay2() {
	int x = (s[0] - '0') * 10 + s[1] - '0';
	return (0 < x && x < 13);
}

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

	cin >> s;
	bool f1 = okay1();
	bool f2 = okay2();
	if(f1 && f2) cout << "AMBIGUOUS" << endl;
	else if(f1) cout << "YYMM" << endl;
	else if(f2) cout << "MMYY" << endl;
	else cout << "NA" << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = []
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if N % 2 == 0 and i+j == N+1: continue
        if N % 2 == 1 and i+j == N: continue
        ans.append([i,j])
print(len(ans))
for a in ans:
    print(a[0],a[1])

Measured memory_bytes: 74568
#入力
h,w=map(int,input().split())
s=[]
for i in range(h):
  s_=list(input())
  s.append(s_)
#幅優先探索
from collections import deque
q=deque([(0,0)])
X=((-1,0),(1,0),(0,1),(0,-1))
used=[[-1]*w for i in range(h)]
used[0][0]=0
while len(q)>0:
  y,x=q.popleft()
  if y==h-1 and x==w-1:
    break
  for dy,dx in X:
    nx=x+dx
    ny=y+dy
    if nx>=0 and nx<w and ny>=0 and ny<h and s[ny][nx]=="." and used[ny][nx]==-1:
      used[ny][nx]=used[y][x]+1
      q.append((ny,nx))
      
      
cnt=0
for i in range(h):
  for j in range(w):
    if s[i][j]=="#":
      cnt+=1

if used[h-1][w-1]==-1:
  print(-1)
else:
  print(w*h-cnt-(used[h-1][w-1]+1))
  
  

Measured memory_bytes: 74096
n=int(input())
s=input()
a=list(s.split())
ans=1
flag=0
for i in range(0,n):
    ans=ans*int(a[i])
    if(ans>1000000000000000000):
        ans=-1
        j=i
        flag=1
        break
f=0
if(flag==1):
    for i in range(j+1,n):
        if(int(a[i])==0):
            f=1
            ans=0
            break
if(ans<-1 and f==0):
    print("-1")
else:
    print(ans)


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

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

    int ans = 0;
    ans = min(a + b + 1, c) + b;
    cout << ans << endl;

    return 0;
}


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

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int, int> mp;

const int MOD = 1e9 + 7;


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

    int n;
    cin >> n;
    vi a(n);
    vi all;
    mp cnt;

    rep(i, n){
        cin >> a[i];
        cnt[a[i]]++;
    }

    if(cnt[0] == n){
        cout << "Yes" << endl;
        return 0;
    }
    if(n % 3 != 0){
        cout << "No" << endl;
        return 0;
    }

    for(auto& p : cnt){
//        cout << p.first << " " << p.second << endl;
        rep(i, p.second * 3 / n){
            all.push_back(p.first);
        }
    }

//    for(auto& p : all) cout << p << " ";
//    cout << endl;

    if (all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    } 
 
    return 0;
}



Measured memory_bytes: 4224
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long N, cnt = 0, tmp, ans = 0;
	cin >> N;

	if (N < 1200) {
		cout << "ABC" << endl;
	}
	else if (N < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}

	char qq;
	cin >> qq;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()

ll mod = 1000000007;

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

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  int n;
  cin >> n;
  string s;
  cin >> s;
  vi white(n+1);
  rep(i,n){
    white[i+1] = white[i];
    if(s[i] == 'W')  white[i+1]++;
  }

  int ret = 0;
  for(int i = n-1;i >= 0;i--){
    if(s[i] == 'R' && white[i+1] - ret > 0){
      ret++;
    }
  }

  cout << ret << endl;
}

Measured memory_bytes: 4376
n = int(input())
list_a = list(map(int, input().split()))
list_a.sort(reverse=True)
list_alice = [a for i, a in enumerate(list_a) if i % 2 == 0]
list_bob = [a for i, a in enumerate(list_a) if i % 2 != 0]
print(sum(list_alice) - sum(list_bob))

Measured memory_bytes: 3316
# https://atcoder.jp/contests/abc110/tasks/abc110_d


def get_prime_dic(n):
    dic = {}

    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            if i in dic:
                dic[i] += 1
            else:
                dic[i] = 1
        i += 1

    if n > 1:
        dic[n] = 1
    return dic


# Calculate count of combination
def combination(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i)
        b *= (i + 1)
    return a // b


def main():
    N, M = map(int, input().split())
    d = get_prime_dic(M)
    # print(d)

    ans = 1
    for k, v in d.items():
        ans *= combination(v + N - 1, v)
        ans %= 1000000007

    print(ans)


main()


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
    int a, b, c;
    int t;
    int count = 0;
    
    scanf("%d %d %d", &a, &b, &c);
    
    for(int x = a; x <= b;x++){
        t = c%x;
        if(t == 0)
        count++;
    }

    
    printf("%d\n", count);
    
    return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>

int main(void)
{
    int n[1000];
    int x[1000];
    int flag[1000];
    int i, l, k, j, o, p;
    for( i = 1; ; i++){
        scanf("%d %d", &n[i], &x[i]);
        if( n[i] == 0 && x[i] == 0)  break;
    }
    for( o = 1; o <= i - 1; o++){
        for( l = 1; l <= n[o]; l++ ){
            for( k = 1; k <= n[o]; k++ ){
                for( j = 1; j <= n[o]; j++ ){
                    if( l != k && k != j && l != j){
                        if( x[o] == l + k + j){
                            flag[o]++;
                        }
                    }
                }
            }
        }
    }
    for( p = 1; p <= i - 1; p++){
        printf("%d\n", flag[p] / 6);
    }
    return 0;
}
     


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

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

int main(){
	int l,a,b,c,d;
	
	scanf("%d%d%d%d%d",&l,&a,&b,&c,&d);
	printf("%d\n",l-MAX((a+c-1)/c,(b+d-1)/d));
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define MAX 1e9 + 7
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    int t;
//    cin>>t;
//    int x=1;
//    while(t--) {
//
//    }

    int n;
    cin>>n;
    string s;
    unordered_map<string,int> ss;
    while(n--){
        cin>>s;
        ss[s]+=1;
    }
    cout<<ss.size()<<endl;
    return 0;
}

Measured memory_bytes: 17716
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	//gfedcba1101101
	int n;
	bool  table[10][7]={{0,1,1,1,1,1,1},{0,0,0,0,1,1,0},{1,0,1,1,0,1,1},{1,0,0,1,1,1,1},{1,1,0,0,1,1,0},{1,1,0,1,1,0,1},{1,1,1,1,1,0,1},{0,1,0,0,1,1,1},{1,1,1,1,1,1,1},{1,1,0,1,1,1,1}};
	while(cin>>n,n!=-1){
		bool now[7]={0,0,0,0,0,0,};
		for(int i=0;i<n;i++){
			int tmp;
			cin>>tmp;
			for(int i=0;i<7;i++){
				if(now[i]==table[tmp][i])cout<<0;
				else cout<<1;
				if(i==6)cout<<endl;
			}
			for(int i=0;i<7;i++)now[i]=table[tmp][i];
		}
	}
	return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

    if(n%2==1){
      ANS(n / 2 + 1);
    }
    else{
      ANS(n / 2);
    }
    return 0;
}


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

using namespace std;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	if(s == "Sunny") cout << "Cloudy" << endl;
	if(s == "Cloudy") cout << "Rainy" << endl;
	if(s == "Rainy") cout << "Sunny" << endl;
	
	return 0;
}

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

int main()
{
  int A, B, X;
  bool res=false;
  cin >> A >> B >> X;

  if(A+B>X && A<=X) res = true;

  if(res) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i,N)
  {
    cin >> L[i];
  }
  int count = 0;
  sort(RALL(L));
  for(int i=0;i<N-2;i++)
  {
    for(int j=i+1;j<N-1;j++)
    {
      for(int k=j+1;k<N;k++)
      {
        if(L[i]<L[j]+L[k])
        {
          if(L[j]<L[k]+L[i])
          {
            if(L[k]<L[i]+L[j])
            {
              count ++;
            }
          }
        }
        else
        {
          break;
        }
        
      }

    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
l=[input() for i in range(h)]
m=[]
for i in range(h):
  if l[i]=='.'*w:
    m.append(i)
for x in m[::-1]:
  del l[x]
m=[]
for i in range(w):
  now=0
  for j in range(len(l)):
    if l[j][i]=='.':
      now+=1
  if now==len(l):
    m.append(i)
for x in m[::-1]:
  for i in range(len(l)):
    l[i]=l[i][:x]+l[i][x+1:]
[print(x) for x in l]

Measured memory_bytes: 3064
#!python3

LI = lambda: list(map(int, input().split()))

# input
K = int(input())
S = input()

MOD = 10 ** 9 + 7
MAX = 2 * (10 ** 6) + 1
p25, p26 = [None] * MAX, [None] * MAX
fac, finv, inv = [None] * MAX, [None] * MAX, [None] * MAX


def comb_init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = -inv[MOD%i] * int(MOD / i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


def power_init():
    p25[0] = 1
    p26[0] = 1
    for i in range(1, MAX):
        p25[i] = p25[i - 1] * 25 % MOD
        p26[i] = p26[i - 1] * 26 % MOD


def main():
    comb_init()
    power_init()
    n = len(S)
    ans = 0
    for i in range(K + 1):
        x = p25[i] * comb(i + n - 1, n - 1) % MOD * p26[K - i] % MOD
        ans = (ans + x) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 326992
#include<bits/stdc++.h>
using namespace std;
int n,k;
string s;
int dp[200009][2];
int main()
{
    cin>>n>>s;
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='.')
        {
            dp[i][0]=min(dp[i+1][0],dp[i+1][1]);
            dp[i][1]=1+dp[i+1][1];
        }
        else if(s[i]=='#')
        {
            dp[i][0]=1+min(dp[i+1][0],dp[i+1][1]);
            dp[i][1]=dp[i+1][1];
        }
    }
    cout<<min(dp[0][0],dp[0][1]);
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n,m=0,a[200000],b[200000],c[200000];
vector<int>ans;
vector<P>p;
queue<int>que;
vector<int>vec[200000];
vector<bool>used(200000);
void bfs(){
    que.push(0);
    while(!que.empty()){
        int t=que.front();
        que.pop();
        used[t]=true;
        int l=vec[t].size();
        rep(i,l){
            if(!used[vec[t][i]])que.push(vec[t][i]);
        }
        ans.push_back(t);
    }
}
signed main(){
    cin>>n;
    rep(i,n-1){
        cin>>a[i]>>b[i];
        vec[a[i]-1].push_back(b[i]-1);
        vec[b[i]-1].push_back(a[i]-1);
    }
    rep(i,n)cin>>c[i];
    sort(c,c+n);
    rep(i,n-1)m+=c[i];
    reverse(c,c+n);
    cout<<m<<endl;
    bfs();
    rep(i,n){
        p.push_back(make_pair(ans[i],c[i]));
    }
    sort(p.begin(),p.end());
    rep(i,n){
        cout<<p[i].S;
        if(i!=n-1)cout<<" ";
        else cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 9408