akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int A, B; cin >> A >> B;
    reps(i, 1010) if ((int)(i * 0.08) == A && (int)(i * 0.1) == B) {cout << i << endl; return 0;}
    cout << -1 << endl; return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[10005];
long long ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(int i=1;i<n;i++)
    {
        for(int w=i+1;w<n;w++)
        {
            if(a[i]+a[w]<=a[w+1])continue;
            else
            {
                int l=w+1,r=n,mid;
                while(l<r-1)
                {
                    mid=l+r>>1;
                    if(a[i]+a[w]<=a[mid])r=mid;
                    else
                        l=mid;
                }
                if(a[i]+a[w]>a[r])
                ans=ans+r-w;
                else ans=ans+l-w;
            }

        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 256
s = str(input())
n = len(s)
ans = 0
j = n-1
for i in range(n):
    if i>=j:
        break

    if s[i]=='x' and s[j]=='x':
        j-=1
        continue
    elif s[i]=='x' and s[j]!='x':
        ans +=1
        continue
    while i<j:
        if s[j]=='x':
            j-=1
            ans +=1
        elif s[i]==s[j]:
            j-=1
            break
        else:
            print(-1)
            exit()


print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<array>
#include<vector>
#include<string>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<deque>
#include<algorithm>
#include<cmath>

using namespace std;
#define ll long long
#define ff first
#define ss second
#define e endl

void solve() {
	ll n; cin >> n;
	ll a[100001];
	unordered_map<ll, ll> m;
	ll sum = 0;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		m[a[i]]++;
		sum += a[i];
	}
	ll q; cin >> q;
	while (q--) {
		ll b, c; cin >> b >> c;
		ll temp = m[b];
		m[b] = 0;
		m[c] += temp;
		sum += temp * (c - b);
		cout << sum << e;
	}

}

int main()
{
	//ll t; cin >> t; while (t--)
	solve();
	
}

Measured memory_bytes: 7900
N, M = [int(_) for _ in input().split()]
XYZ = [[int(_) for _ in input().split()] for _ in range(N)]


def sum_pm(xyz, pm):
    return sum([xyz[j] * (-1)**(1 & pm >> j) for j in range(3)])


ans = -float('inf')
for pm in range(8):
    XYZsort = sorted(XYZ, key=lambda xyz: -sum_pm(xyz, pm))
    ans = max(ans, sum([sum_pm(xyz, pm) for xyz in XYZsort[:M]]))
print(ans)
# https://img.atcoder.jp/abc100/editorial.pdf


Measured memory_bytes: 3304
M,D = map(int, input().split())

matched = []
for i in range(22, D+1):
    d10 = int(i / 10)
    d1 = int(i % 10)
    if d10 < 2 or d1 < 2:
        continue
    if d10 * d1  <= M:
        matched.append((d10*d1, i))
print(len(matched))


Measured memory_bytes: 3060
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
  a, b = na()
  if a > 9 or b > 9:
    print(-1)
    return
  print(a * b)

main()

Measured memory_bytes: 3316
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int L, R, D; cin >> L >> R >> D;
	int cnt = 0;
	for (int i = L; i <= R; i++) {
		if (i % D == 0) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3640
main = do
  li <- getLine
  let n = read li
  li <- getLine
  let as = map read $ words li
  let ans = compute n as
  putStrLn $ unwords $ map show ans

{-
A1 = x1 + x2
A2 =      x2 + x3
A3 =           x3 + x4
:
AN =                   xN + x1
交互に+-していくとNは奇数だから最後はプラスで
A1 - A2 + A3 - ... + AN = xN + xN = 2x1
-}

compute :: Int -> [Int] -> [Int]
compute n as = map (2 *) $ init $ scanl (flip (-)) x1 as
  where
    x1 = (flip div 2) $ sum $ zipWith ($) (cycle [id,negate]) as


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool f(string t) {
	for (auto v : t) {
		if (v == 'A') {
			continue;
		}
		if (v == 'C') {
			continue;
		}
		if (v == 'G') {
			continue;
		}
		if (v == 'T') {
			continue;
		}

		return false;
	}

	return true;
}


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

	string s;
	cin >> s;

	int n = s.size(), ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			string t = s.substr(i, j);
			if (f(t)) {
				ans = max(ans, (int)t.size());
			}
		}
	}

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


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


int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin>>n;
    map<int,int> freq;
    vector<ll> a(n);
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        freq[a[i]]++;
    }
    vector<ll> ans(n+1);
    vector<ll> diff(n+1);
    ll sum = 0;
    for(auto l : freq)
    {
        ll one = (1ll*(l.second - 1) * (l.second - 2 ))/2;
        ans[l.first] = (1ll*(l.second) * (l.second-1))/2;
        diff[l.first] = abs(one-ans[l.first]);
        sum+=ans[l.first];
    }
    for(int i=0;i<n;++i)
    {
        //ll curr = ((freq[a[i]]-1) * (freq[a[i]]-2))/2;
        cout<<sum-diff[a[i]]<<'\n';
    }
}



Measured memory_bytes: 12288
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++){
			a[i]= sc.nextInt();
		}
		
		int l = 0, r= 0, mask = 0;
		long ans = 0;
		while(l < n){
			if(r<n && (a[r] & mask) == 0){
				mask |= a[r++];
			}
			else{
				ans += r-l;
				mask ^= a[l++];
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 83124
#include<stdio.h>
int main(){
	int n,i,k;
	char c;
	int S[13] = {0};
	int H[13] = {0};
	int C[13] = {0};
	int D[13] = {0};

	scanf("%d\n",&n);
	
	for(i = 0;i <= n;i++){
		scanf("%c %d\n",&c,&k);
		
		if(c == 'S')
			S[k-1] = 1;
		else if(c == 'H')
			H[k-1] = 1;
		else if(c == 'C')
			C[k-1] = 1;
		else if(c == 'D')
			D[k-1] = 1;
	}
	for(i = 0;i < 13;i++){
		if(S[i] == 0)
			printf("S %d\n",i+1);
	}
	for(i = 0;i < 13;i++){
		if(H[i] == 0)
			printf("H %d\n",i+1);
	}
	for(i = 0;i < 13;i++){
		if(C[i] == 0)
			printf("C %d\n",i+1);
	}
	for(i = 0;i < 13;i++){
		if(D[i] == 0)
			printf("D %d\n",i+1);
	}
	return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>
#include<math.h>
int main()
{
	char str[200];
	int n,a[200]={0},i,j,max=0,x,y,ok,t;
	scanf("%d",&n);
	scanf("%s",str);
	for(i=0;i<n;i++)
	{
		ok=1;
		if(str[i]=='0')
			continue;
		for(j=n-1;j>i;j--)
		{
			if(str[j]==str[i] && ok==1)
			{
				for(x=i;x<=j;x++) a[x]++;
				ok=0;
			}
			else if(ok==0 && str[j]==str[i])
				str[j]='0';
		}
		if(i==j && ok==1)
			str[i]='0';
	}
	for(i=0;i<n;i++)
		max=max>a[i]?max:a[i];
	printf("%d\n",max);
	return 0;
}

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



int main()
{
	ld a,b;
	cin>>a>>b;
	cout << fixed;
    cout << setprecision(0);
	cout<<floor(a*b)<<endl;
}

Measured memory_bytes: 3792
#include <cstdio>

int n;
long long int k;
int A[50][50];
int dp[50][50];

constexpr int mod = 1000000007;

void prod(int a[][50], const int l[][50], const int r[][50], int n){
  int ll[50][50];
  int rr[50][50];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      ll[i][j] = l[i][j];
      rr[i][j] = r[i][j];
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      a[i][j] = 0;
      for(int k = 0; k < n; k++){
        a[i][j] = (a[i][j] + (long long) ll[i][k] * rr[k][j]) % mod;
      }
    }
  }
}

int powsum(const int a[][50], int n, long long int m){
  int r[50][50];
  int b[50][50];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      r[i][j] = i == j;
      b[i][j] = a[i][j];
    }
  }
  for(; m; m >>= 1){
    if(m&1) prod(r, r, b, n);
    prod(b, b, b, n);
  }
  long long int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      ans += r[i][j];
    }
  }
  return ans % mod;
}

int main(){
  scanf("%d%lld", &n, &k);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      scanf("%d", &A[i][j]);
    }
  }

  printf("%d\n", powsum(A, n, k));

  return 0;
}



Measured memory_bytes: 256
n = int(input())
dp = [[[[0 for i in range(4)] for i in range(4)] for i in range(4)] for i in range(n+1)]

#A=0, C=1, G=2, T=3
for i in range(4):
    for j in range(4):
        for k in range(4):
            dp[3][i][j][k] = 1

dp[3][0][2][1] = 0
dp[3][0][1][2] = 0
dp[3][2][0][1] = 0

for i in range(4, n+1):
    for a in range(4):
        for b in range(4):
            for c in range(4):
                for d in range(4):
                    if [b,c,d] not in ([0,2,1],[2,0,1],[0,1,2]):
                        if [a,c,d] != [0,2,1] and [a,b,d] != [0,2,1]:
                                dp[i][b][c][d] += dp[i-1][a][b][c]
                                
count = 0
for i in range(4):
    for j in range(4):
            count = (count + sum(dp[n][i][j])) % (10**9+7)
print(count)

Measured memory_bytes: 3444
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	A := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	mA, mgcd, ok := 0, 0, false
	for i := range A {
		A[i] = nextInt(sc)
		if A[i] == K {
			ok = true
		}
		mA = max(mA, A[i])
		if mgcd == 0 {
			mgcd = A[0]
		} else {
			mgcd = gcd(mgcd, A[i])
		}
	}
	// fmt.Println("N", N, "K", K, "A", A)
	if K < mA && (mgcd == 1 || K%mgcd == 0) {
		ok = true
	}
	if ok {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 3072
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define swap(a,b) tmp=ver[b], ver[b]=ver[a], ver[a]=tmp;
int main(){
	double x1, y1, x2, y2, x3, y3, xp, yp;
	double p, q, r;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
		p=(x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
		q=(x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
		r=(x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
		if(p*q>0 && q*r>0 && r*p>0){
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1216
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll A, B; cin >> A >> B;
    ll H, M; cin >> H >> M;

    const double pi = acos(-1);
    ll m1 = M, m2 = H * 60 + M;
    double t1 = pi / 30 * m1;
    double t2 = pi / 360 * m2;

    double x1 = B * cos(t1), y1 = B * sin(t1);
    double x2 = A * cos(t2), y2 = A * sin(t2);

    double ex = (x1 - x2);
    double ey = (y1 - y2);
    double dist = sqrt(ex*ex + ey*ey);
    printf("%.12f\n", dist);
    return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int main() {
	fastio;
	string S;
	cin >> S;

	cout << (S.find('7') == string::npos ? "No" : "Yes");

	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	class UnionFind {
		int[] parent, rank;

		public UnionFind(int n) {
			parent = new int[n];
			rank = new int[n];
			for (int i = 0; i < n; i++) {
				parent[i] = i;
			}
		}

		public void unite(int x, int y) {
			x = find(x);
			y = find(y);
			if (x == y) {
				return;
			}

			if (rank[x] < rank[y]) {
				parent[x] = y;
			} else {
				parent[y] = x;
				if (rank[x] == rank[y]) {
					rank[x]++;
				}
			}
		}

		public int find(int x) {
			if (parent[x] == x) {
				return x;
			}

			return parent[x] = find(parent[x]);
		}

		public boolean same(int x, int y) {
			return find(x) == find(y);
		}
	}

	int n, m;
	int[] p;
	UnionFind uf;

	void run() {
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			m = sc.nextInt();
			p = new int[n];
			for (int i = 0; i < n; i++) {
				p[i] = sc.nextInt() - 1;
			}

			uf = new UnionFind(n);
			for (int i = 0; i < m; i++) {
				uf.unite(sc.nextInt() - 1, sc.nextInt() - 1);
			}
			System.out.println(fnc());
		}
	}

	String fnc() {
		int cnt = 0;

		for (int i = 0; i < n; i++) {
			if (uf.same(p[i], i)) {
				cnt++;
			}
		}

		return "" + cnt;
	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 93192
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n, x = 7;
  set<int> s;
  cin >> n;
  for (int i = 1; i <= 1000000; i++) {
    if (x % n == 0) {
      cout << i << endl;
      return 0;
    }
    x *= 10;
    x += 7;
    x %= n;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>

inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while(ch>'9' || ch<'0'){
		if(ch=='-')
		f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-48;
		ch=getchar();
	}
	return x*f;
}

int n,k,cnt;
int h[100005];
bool vis[100005];

int main(){
	memset(vis,true,sizeof(vis));
	n=read();k=read();
	for(int i=1;i<=n;++i)
	h[i]=read();
	for(int i=1;i<=k;++i){
		int x=read(),y=read();
		if(h[x]>=h[y])vis[y]=false;
		if(h[y]>=h[x])vis[x]=false;
	}
	for(int i=1;i<=n;++i)
	if(vis[i])++cnt;
	printf("%d\n",cnt);
}

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



int main()
{
 
    ll n;
    n=5;
    ll ar[n],ans;
    for(int i=0;i<n;i++)
    {
    	cin>>ar[i];
        if(ar[i]==0)
        {
            ans = i+1;
        }

    }

   cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 3620
import copy
N, M = [int(_) for _ in input().split()]
AB = [[int(_) - 1 for _ in input().split()] for _ in range(M)]

G = [set() for _ in range(N)]
a = set()
for ab in AB:
    G[ab[0]].add(ab[1])


def find(a, x):
    stack = []
    while a[x] != x:
        x = a[x]
        stack += [x]
    while stack:
        a[stack.pop()] = x
    return x


def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    a[x] = a[y] = min(x, y)


ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if j in G[i]:
            Gn = copy.deepcopy(G)
            Gn[i].discard(j)
            a = [i for i in range(N)]
            for k in range(N - 1):
                for l in Gn[k]:
                    unite(a, k, l)
            par = set()
            for k in range(N):
                par.add(find(a, k))
            if len(par) > 1:
                ans += 1
print(ans)


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

N = int(input())
A = [list(map(int, input().split(' '))) for _ in range(2)]
sum_A = [[0 for _ in range(N)] for _ in range(2)]
for i in range(N):
    if i == 0:
        sum_A[0][0] = A[0][0]
        continue
    sum_A[0][i] = sum_A[0][i-1] + A[0][i]
for i in range(N):
    if i == 0:
        sum_A[1][0] = sum_A[0][0] + A[1][0]
        continue
    sum_A[1][i] = sum_A[1][i-1] + A[1][i]
ans = sum_A[1][N-1]
for i in range(1, N):
    com_sum = sum_A[0][i] + A[1][i]
    diff = com_sum - sum_A[1][i]
    if diff > 0:
        ans = max(ans, sum_A[1][N-1] + diff)
print(ans)

Measured memory_bytes: 3064
/*

                                  In the name of Allah, Most Gracious, Most Merciful


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

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
   ll ans = max(max(a*c, a*d),max(b*c, b*d) );

  cout<<ans<<endl;

}

int main()
{
    IOS;
    ll tc = 1;
    while(tc--)
    {
        solve();
    }


return 0;
}



Measured memory_bytes: 3612
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
long long int a[200005],b[200005];
long long int k;
int na,nb;
int main()
{


    scanf("%d %d %lld",&na,&nb,&k);
    int cnt=0;
    for(int i=1;i<=na;i++)
    {
        scanf("%lld",&a[i]);
        a[i]+=a[i-1];
        if(a[i]<=k)cnt=i;
    }
    for(int i=1;i<=nb;i++)
    {
        scanf("%lld",&b[i]);
        b[i]+=b[i-1];
    }
    int mx=cnt;
    for(int i=1;i<=nb&&b[i]<=k;i++)
    {
        while(cnt>0&&a[cnt]+b[i]>k)cnt--;
        mx=max(i+cnt,mx);
    }
    printf("%d",mx);
    return 0;
}



Measured memory_bytes: 6800
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N,M;
vector<int> G[SIZE];
int s,g;
bool used[SIZE];
bool K;

void dfs(int v){
  used[v] = true;
  int nxt = -1;
  for(auto to : G[v]){
    if(to == g){
      nxt = 0; //gに到達
      break;
    }
    if(to == s || used[to]){
      continue;
    }else{
      nxt = to;
      break;
    }
  }
  if(nxt == -1){ //行き先なし
    //sに戻っている
    K = true;
  }else if(nxt == 0){ //ゴール
    //
  }else{
    dfs(nxt);
  }
}



int main(){
  cin >> N >> M;
  rep(i,0,M) {
    int a,b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  bool ans = true;
  bool e6 = false;
  vector<int> V;

  //オイラー閉路かどうか
  //6辺以上を持つvがあるか
  //4辺を持つvが3つ以上あるか
  rep(i,1,N+1){
    if(G[i].size()%2 != 0){
      ans = false;
      break;
    }
    if(G[i].size() >= 6) e6 = true;
    if(G[i].size() == 4) V.push_back(i);
  }
  if(!ans){
    cout << "No" << endl;
    return 0;
  }
  if(e6 || V.size() >= 3){
    cout << "Yes" << endl;
    return 0;
  }
  if(V.size() <= 1){
    cout << "No" << endl;
    return 0;
  }

  //4辺のvが2つあるとき
  s = V[0];
  g = V[1];
  for(auto v : G[s]){
    dfs(v);
  }

  cout << (K?"Yes":"No") << endl;

  return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
vector<pair<int,int>> v;
int main(){
	int i,j,n,k;
	cin >> n >> k;
	for(i=0;i<10;i++){
		if((1<<i)>n) break;
		for(j=1;j<=n;j++){
			if((1<<i)==j) continue;
			if((1<<i) & j){
				v.push_back({(1<<i),j});
			}
		}
	}
	cout << v.size() << endl;
	for(i=0;i<v.size();i++){
		cout << v[i].first << " " << v[i].second << endl;
	}
	while(k){
		k--;
		string s;
		int res = 0;
		for(i=0;i<10;i++){
			if((1<<i)>n) break;
			cout << (1<<i) << endl;
			cin >> s;
			if(s[0]=='Y'){
				res = -1;
				break;
			}else if(s[1]=='e'){
				res += (1<<i);
			}
		}
		if(res>0){
			cout << res << endl;
			cin >> s;
		}
	}
}


Measured memory_bytes: 3300
$known = {}
def maxval(n, rest)
  arr = rest[-n, n]
  sum = 0
  n.times{|i|
    sum += (i+1)*arr[i]
  }
  return sum
end

def count(s, n, rest)
  return 1 if s == 0 && n == 0
  return 0 if n == 0
  return 0 if s > maxval(n, rest)
  unless $known[[s,n,rest]]
    ans = 0
    rest.each{|i|
      ans += count(s - n * i, n - 1, rest - [i]) if s - n * i >= 0
    }
    $known[[s,n,rest]] = ans
  end
  return $known[[s,n,rest]]
end

init = [0,1,2,3,4,5,6,7,8,9]
readlines.each{|line|
  n, s = line.split.map(&:to_i)
  p count(s, n, init)
}

Measured memory_bytes: 24800
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

int a[105];
int ans,aa,ab,n;

bool cmp(int a,int b){
	return a > b;
}

int main()
{
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i];
	}
	sort(a,a+n,cmp);
	for(int i = 0 ; i < n ; i++){
		if(i % 2 == 0) aa += a[i];
		else ab += a[i];
	}
	ans = aa - ab;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::{Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        n: usize,
        s: [Chars; n],
    }
    let mut c: [usize; 4] = [0; 4];
    for iter in s {
        if iter.iter().collect::<String>() == "AC" {
            c[0] += 1;
        }
        else if iter.iter().collect::<String>() == "WA" {
            c[1] += 1;
        }
        else if iter.iter().collect::<String>() == "TLE" {
            c[2] += 1;
        }
        else if iter.iter().collect::<String>() == "RE" {
            c[3] += 1;
        }
    }
    println!("AC x {}", c[0]);
    println!("WA x {}", c[1]);
    println!("TLE x {}", c[2]);
    println!("RE x {}", c[3]);
}


Measured memory_bytes: 7852
import bisect
n= int(input())
a = list(map(int,input().split()))
a.sort()
b = list(map(int,input().split()))
b.sort()
c = list(map(int,input().split()))
c.sort()

ans = 0
for y in b:
    x = bisect.bisect_left(a, y)#挿入点はどの同じ値よりも左
    z = bisect.bisect_right(c, y) #挿入点はどの同じ値より右
    ans += x * (len(c) - z)#b<a * b > cの組み合わせ
print(ans)


Measured memory_bytes: 29492
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	hh := n / (60 * 60)
	mm := n % (60 * 60) / 60
	ss := n % (60 * 60) % 60
	fmt.Printf("%d:%d:%d\n",hh, mm, ss)
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, int> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

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

    int point = 0;
    rep(i, s.size()) {
        char c = s[i];
        if (c == 'g') {
            if (i % 2 == 0) continue;
            else point++;
        } else {
            if (i % 2 == 0) point--;
            else continue;
        }
    }

    cout << point << endl;
}

Measured memory_bytes: 512
a,b = gets.split(" ").map(&:to_i)
s =gets.chomp.split("").map(&:to_s)
result = 0
for i in 0...s.length do
	if s[i].to_i.to_s != s[i].to_s then
		if i == a then
			result += 1
		else
			result -= a + b
		end
	end
end
if result == 1 then
	puts "Yes"
else
	puts "No"
end

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

using namespace std;

int main()
{
    int n,q;
    vector<int>s;
    vector<int>t;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    sort(s.begin(),s.end());
    s.erase( unique(s.begin(), s.end()), s.end() );
    n = s.size();
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        int tmp;
        cin >> tmp;
        t.push_back(tmp);
    }
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < q; j++)
        {
            if(s[i] == t[j])
            {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3216
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
priority_queue<int>p;
priority_queue<int,vector<int>,greater<int> >q;
long long t1,t2;
inline void insert(int x)
{
    int d=-1;
    if(!p.empty())d=p.top();
    if(x>d)
    {
        q.push(x);t2+=x;
        while(q.size()>p.size())
        {
            int d=q.top();q.pop(),t2-=d;
            p.push(d),t1+=d;
        }
    }
    else 
    {
        p.push(x);t1+=x;
        while(p.size()>q.size()+1)
        {
            int d=p.top();p.pop(),t1-=d;
            q.push(d),t2+=d;
        }
    }
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int m=read();long long sum=0;
    int he=0;
    while(m--)
    {
    	int id=read();
    	if(id==2)
		{
			long long ul=t2-t1,wy=p.top();if(he&1)ul+=wy;
			pr1(wy),printf("%lld\n",ul+sum);
		}
    	else {int a=read(),b=read();sum+=b,insert(a);he++;}
    }
   	return 0;
}

Measured memory_bytes: 3452
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

/*int f1(int n) {
	return n % 10;
}
int f10(int n) {
	int a = n % 100;
	return a / 10;
}
int f100(int n) {
	int a = n % 1000;
	return a / 100;
}
int f1000(int n) {
	int a = n % 10000;
	return a / 1000;
}
int f10000(int n) {
	int a = n % 100000;
	return a / 10000;
}*/
int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b)) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))

t = [[] for _ in range(3)]

for i in p:
    if i <= a:
        t[0].append(i)
    elif i <= b:
        t[1].append(i)
    else:
        t[2].append(i)

print(min(len(t[0]), len(t[1]), len(t[2])))



Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
typedef long long ll;
int n;
ll a[100005],ans1=2,ans2=2;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=n;i;i--){
		if(ans1%a[i])ans1/=a[i],ans1=ans1*a[i]+a[i];
		ans2=(ans2/a[i]+1)*a[i]-1;
	}
	if(ans1>ans2)puts("-1");
	else printf("%lld %lld\n",ans1,ans2);
	return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
string S;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> S;
  if (N % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  bool ans = true;
  int h = N / 2;
  for (int i = 0; i < h; i++) {
    if (S[i] != S[h + i]) {
      ans = false;
      break;
    }
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>  
#include<set>
#include<iterator>
#include<list>
#include<utility>
#include<cstdlib>
#include<queue>
#include<stack>
#include<bitset>
//#include<bits/stdc++.h>

#define PI  2*acos(0.0)
#define pb push_back


using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;


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

string s;
ll n;
cin>>n;
ll wa_cnt=0,re_cnt=0,tle_cnt=0,ac_cnt=0;
while(n--)
{
	cin>>s;
	if(s=="AC")
	{
		ac_cnt++;
	}
	
	else if(s=="TLE")
	{
		tle_cnt++;
	}
	
	else if(s=="RE")
	{
		re_cnt++;
	}
	
	else
	{
		wa_cnt++;
	}
	
}

cout<<"AC x "<<ac_cnt<<"\n";
cout<<"WA x "<<wa_cnt<<"\n";
cout<<"TLE x "<<tle_cnt<<"\n";
cout<<"RE x "<<re_cnt<<"\n";

	
	
	return 0;
	
	
}

Measured memory_bytes: 3664
fun main(args: Array<String>) {
    val hon = arrayOf(2,4,5,7,9)
    val pon = arrayOf(1,6,8,0)
    val bon = arrayOf(3)
    val n = readLine()!!.toInt() % 10
    if (hon.contains(n)) {
        println("hon")
    } else if (pon.contains(n)) {
        println("pon")
    } else println("bon")
}

Measured memory_bytes: 38484
import numpy as np
input1 = input()

door_num = int(input1.split()[1])
lefts = []
rights = []
for i in range(door_num):
    a = input()
    new_inputs = [int(i) for i in a.split()]
    lefts.append(new_inputs[0])
    rights.append(new_inputs[1])
    #max_left = np.max([new_inputs[0], max_left])
    #min_right = np.min([new_inputs[1], min_right])
    #if not min_right >= max_left:
    #    break
min_right = np.min(rights)
max_left = np.max(lefts)

if min_right >= max_left:
    print(min_right - max_left + 1)
else:
    print(0)

Measured memory_bytes: 20756
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define toInt(x) (x - '0')
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int N, T, A;
  cin >> N >> T >> A;

  int min = INF;
  int ans = 0;
  rep(i, N) {
    int H;
    cin >> H;
    int diff = abs(A * 1000 - (T * 1000 - H * 6));
    if (diff < min) {
      min = diff;
      ans = i + 1;
    }
  }
  cout << ans << endl;

  return 0;
}


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

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

    int n;
    cin>>n;
    int remainder;
    bool vqrno=false;
    while(n!=0){
        remainder=n%10;
        if(remainder==7){
            vqrno=true;
            break;
        }
        else
            n/=10;
    }
    if(vqrno==true)
        puts("Yes");
    else
        puts("No");
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    std::string S;
    std::cin >> S;
    ll cnt=0;
    ll maxcnt=0;
    for (long long i = 0; i < S.length(); i++) {
        if(S[i]=='R') cnt++;
        if(S[i]=='S') cnt=0;
        chmax(maxcnt,cnt);
    }
    cout << maxcnt << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

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

bool cmp(pint a, pint b) {return a.second < b.second;}
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n;
    cin >> n;
    vi a(n), b(n);
    rep(i, n-1) cin >> b[i];

    a[0] = b[0];
    for(int i = 1; i < n-1; i++) {
        a[i] = min(b[i], b[i-1]);
    }
    a[n-1] = b[n-2]; 

    ll sum = 0;
    rep(i, n) {
        sum += a[i];
    }

    cout << sum << endl;
    
    return 0;
}

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


int main(){
    int n;
    cin >> n;
    vector<int> a;
    for(int i=0;i<n;++i){
        int q;
        cin >> q;
        if(q==0){
            int x;
            cin >> x;
            a.push_back(x);
        }else if(q==1){
            int x;
            cin >> x;
            cout << a[x] << endl;
        }else{
            a.pop_back();
        }
    }
    return 0;
}


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

int main(){

  int A,B,C,K;
  cin >> A >> B >> C >> K ;
  
  int total;
  
  if(A > K){
    total = K;
    
  }
  else{
    total = A;
    
    if(B > (K - A)){
      total += 0;
    }
    else{
      total = total + 0;
      total = total - (K - A -B);
    }
  }
  
  cout << total << endl;
  
}
   


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	int a[100];
	int N;
	int result = 0;
	int i, j, k;

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

	sort(a, a+N);

	for (i = 0 ; i < N - 2 ; i++)
	{
		for (j = i + 1 ; j < N - 1 ; j++)
		{
			if (a[j] == a[i])continue;

			for (k = j + 1 ; k < N ; k++)
			{
				if (a[k] == a[j])continue;

				if (a[k] >= a[i] + a[j])break;
				result ++;
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 3820
#include <iostream>
#include <vector>

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

//////////////////////////////////////////////////
//
// パスカルの三角形による実装
// （n = 10^4 程度までしか対応できないが、mod は無しでも素数でなくてもよい）
//
//   - コンストラクタの第二引数 M を省略すれば mod 計算を行わない
//

#include <iostream>
#include <vector>
template<typename T_mcp_data>

class ModCombP
{
private:
    int max_n;
    T_mcp_data mod; // M
    std::vector<std::vector<T_mcp_data>> table;

public:

    // 引数: n の最大値、M は mod の値
    ModCombP(int n, T_mcp_data M = 0) : table(n + 1, std::vector<T_mcp_data>(n + 1))
    {
        max_n = n;
        mod = M;
        for(int i = 0; i <= n; i++) {
            table[i][0] = 1;
            table[i][i] = 1;
            for(int j = 1; j < i; j++) {
                table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]);
                if(mod != 0) {
                    table[i][j] %= mod;
                }
            }
        }
        // デバッグ出力
        //debugOutput();
    }

    void debugOutput()
    {
        for(int i = 0; i <= max_n; i++) {
            for(int j = 0; j <= i; j++) {
                std::cout << table[i][j] << " ";
            }
            std::cout << std::endl;
        }
    }

    // aCb を求める
    T_mcp_data calc(T_mcp_data a, T_mcp_data b)
    {
        if(a > max_n || a < b || a < 0) return 0; // error
        if(a == 0 && b == 0) return 1;
        return table[a][b];
    }
};


int main()
{
    int N, K;
    cin >> N >> K;
    ll mod = 1000000007;
    ModCombP<ll> mc(N, mod);

    rep(i, K) {
        ll ans = 0;
        // (N-K+1)C(i+1) 赤い石の間に青い石を入れる総数
        IFD cout << "i: " << i << endl << N - K + 1 << " " << i + 1 << " " << K - 1 << endl;
        ans = mc.calc(N - K + 1, i + 1);
        if(i != 0) {
            // (K-1)C(i) 青い石の塊ごとに何個ずつにするかの総数
            ans = ans * mc.calc(K - 1, i) % mod;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 31616
mod = 10**9 + 7
N, M = map(int, input().split())
S = [None] + list(map(int, input().split()))
T = [None] + list(map(int, input().split()))
dp = [[0 for _ in range(M+1)] for _ in range(N+1)]
for i in range(1, N+1):
    for j in range(1, M+1):
        if S[i] == T[j]:
            dp[i][j] = (dp[i][j-1] + dp[i-1][j] + 1)%mod
        else:
            dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1])%mod
print((dp[N][M]+1)%mod)

Measured memory_bytes: 74588
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n;
	while (cin >> n) {
		rep (i, 1 << 10) {
			int sum = 0;
			rep (j, 10) {
				if (i >> j & 1) {
					sum += pow(2, j);
				}
			}
			if (sum == n) {
				bool First = true;
				rep (j, 10) {
					if (i >> j & 1) {
						if (!First)
							cout << " ";
						else
							First = false;
						cout << pow(2, j);
					}
				}
				cout << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3244
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long int ll;
using namespace std;

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

    int n;
    cin >> n;
    vector<int> l(n);
    int max = 0;
    int sum = 0;
    REP(i, n) {
        int a;
        cin >> a;
        if (max < a) {
            max = a;
        }
        sum += a;
    }
    if (max < sum - max) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define MAXN 100000

int v[MAXN+1];

bool cmp(const int &a, const int &b){
    return a>b;
}

int main(){
    int n;
    scanf("%d", &n);

    for(int i=1; i<=n; i++)
        scanf("%d", &v[i]);

    std::sort(v+1, v+n+1, cmp);

    int p=1;
    for(int i=2; i<=n; i++)
        if(v[i]>=i)
            p=i;

    p--;

    int q=p+1;
    for(int i=p+2; i<=n; i++)
        if(v[i]>p)
            q=i;

    if((q-p)%2+(v[p+1]-p)%2==2) printf("Second\n");
    else printf("First\n");

    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  int result = 0;

  for (int i = 0; i <= (a); ++i) {
    for (int j = 0; j <= (b); ++j) {
      for (int k = 0; k <= (c); ++k) {
        if ((i * 500 + j * 100 + k * 50) == x) {
          result++;
        }
      }
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <stack>
#define sz size()
#define pb push_back
using namespace std;
typedef long long int ll;
ll mod=1e9+7;
ll exp(ll t,ll x){if(x==0) return 1;if(x==1) return t;if(x%2==1) return (t*exp((t*t)%mod,x/2))%mod;if(x%2==0) return exp((t*t)%mod,x/2);} 
ll gcd(ll x,ll y){return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){return u<b?u:bsum(u/b,b)+u%b;}
bool isprime(ll x){for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
void YAY(void){cout<<"YES"<<endl;}
void NAY(void){cout<<"NO"<<endl;}
int n;
string s;

bool isok(int x)
{
	if(x==0)
	{
		return true;
	}
	bool ret=false;
	if(x>=5 && s[x-1]=='m' && s[x-2]=='a' && s[x-3]=='e' && s[x-4]=='r' && s[x-5]=='d')
	{
		ret|=isok(x-5);
	}
	if(x>=7 && s[x-1]=='r' && s[x-2]=='e' && s[x-3]=='m' && s[x-4]=='a' && s[x-5]=='e' && s[x-6]=='r' && s[x-7]=='d')
	{
		ret|=isok(x-7);
	}
	if(x>=5 && s[x-1]=='e' && s[x-2]=='s' && s[x-3]=='a' && s[x-4]=='r' && s[x-5]=='e')
	{
		ret|=isok(x-5);
	}
	if(x>=6 && s[x-1]=='r' && s[x-2]=='e' && s[x-3]=='s' && s[x-4]=='a' && s[x-5]=='r' && s[x-6]=='e')
	{
		ret|=isok(x-6);
	}
	return ret;	
}

int main(void)
{
	cin>>s;
	n=s.size();
	bool pos=isok(n);
	if(pos)
	{
		YAY();
	}
	else
	{
		NAY();
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

const int MAX_N = 100010;

int par[MAX_N];
int ranks[MAX_N];
int ufSize;

void init(int n){
    ufSize = n;
    for(int i=0; i<n; i++){
        par[i] = i;
        ranks[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

bool same(int x, int y){
    return find(x) == find(y);
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    ufSize--;

    if(ranks[x] < ranks[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
    }
    
    if(ranks[x] == ranks[y]){
        ranks[x]++;
    }
}

int main(){
    int n, m; cin>>n>>m;
    init(n);
    vector<int> x(m), y(m), z(m);
    for(int i=0; i<m; i++){
        cin>>x[i]>>y[i]>>z[i];
        x[i]--, y[i]--;
        unite(x[i], y[i]);
    }

    cout << ufSize << endl;
}

Measured memory_bytes: 2176