akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int arr[124];
int main()
{
    int i ,len;
    char a[120];
    scanf ("%s",a);
    for (i = 0 ; i <strlen (a); i++)
    {
        arr[a[i]]++;
    }
    int temp = 1;
    for (i = 97; i <=122; i++)
    {
        if (arr[i] & 1)
        {
            temp = 0;
            break;
        }
    }
    if (temp == 0)
        printf ("No\n");
    else printf ("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
const LL INF = 1e18;
const int MXN = 100005;
const int MXV = 0;
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define Fi first
#define Se second
#define Be begin()
#define En end()
#define FOR(i, L, R) for (int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for (int i = L; i != (int)R; --i)
#define IOS                                                                    \
    cin.tie(nullptr);                                                          \
    cout.tie(nullptr);                                                         \
    ios_base::sync_with_stdio(false);

bitset<MXN> vis;
vector<int> ans, x;
vector<PII> G[MXN + 1];

int dfs(int u)
{
    vis[u] = true;
    int res = x[u];
    for (auto it : G[u])
    {
        if (!vis[it.Fi])
        {
            int tmp = dfs(it.Fi);
            if (tmp != 0)
            {
                ans.PB(it.Se);
            }
            res ^= tmp;
        }
    }
    return res;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<PII> bombs(n);
    x.resize(n + 1);
    FOR(i, 0, n) { cin >> bombs[i].Fi >> bombs[i].Se; }
    sort(bombs.Be, bombs.En);
    x[0] = bombs[0].Se;
    FOR(i, 0, n - 1) { x[i + 1] = bombs[i].Se ^ bombs[i + 1].Se; }
    x[n] = bombs[n - 1].Se;

    FOR(i, 0, m)
    {
        int L, R;
        cin >> L >> R;
        L = lower_bound(bombs.Be, bombs.En, PII{L, 0}) - bombs.Be;
        R = upper_bound(bombs.Be, bombs.En, PII{R, 1}) - bombs.Be;
        G[L].EB(R, i + 1);
        G[R].EB(L, i + 1);
    }
    vis.reset();
    FOR(i, 0, n + 1)
    {
        if (vis[i])
        {
            continue;
        }
        if (dfs(i))
        {
            cout << "-1\n";
            return 0;
        }
    }
    cout << ans.size() << '\n';
    sort(ans.Be, ans.En);
    FOR(i, 0, ans.size()) { cout << ans[i] << " \n"[i == (int)ans.size() - 1]; }
}


Measured memory_bytes: 16252
#include<iostream>
#include<algorithm>
#include<vector>
#include<iterator>
#include<cmath>
using namespace std;

int main()
{
    int K, i, len;
    char S[250];
    cin>>K>>S;
    len=0;
    for(i=0;S[i]!='\0';i+=1)
    {
        len+=1;
    }
    if(len<=K)
    {
        cout<<S<<endl;
    }
    else
    {
        for(i=0;i<K;i+=1)
        {
            cout<<S[i];
        }
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(b-a==c-b) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.strip.split(//).collect{|d| d == 'W'}

c_w = [0]
c_e = []
c_e[N] = 0

(1..N).each{|i|
	c_w[i] = c_w[i - 1] + (S[i - 1] ? 1 : 0)
	c_e[N - i] = c_e[N - i + 1] + (S[N - i] ? 0 : 1)
}

#p c_w
#p c_e

puts (1..N).collect{|i|
#p [c_w[i], c_e[i - 1]]
	c_w[i] + c_e[i - 1] - 1
}.min



Measured memory_bytes: 37004
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

/////////////         modの計算

#define MOD_IS_PRIME
const ll mod = 1000000007LL;

class modlong {
public:
	modlong() { x = 0; }
	modlong(ll num) { x = adjust(num); }
	inline operator ll() const { return x; }
	inline bool operator ==(ll num) { return this->x == num; }
	inline bool operator !=(ll num) { return !(*this == num); }
	inline void operator = (ll num) { x = adjust(num); }
	inline void operator += (ll num) { x = adjust(x + num); }
	inline void operator ++() { this->operator+=(1); }
	inline modlong operator + (ll num) const { modlong m(this->x); m += num; return m; }
	inline void operator -= (ll num) { x = adjust(x - num); }
	inline void operator --() { this->operator-=(1); }
	inline modlong operator - (ll num) { modlong m(this->x); m -= num; return m; }
	inline void operator *= (ll num) { x = adjust(x * num); }
	inline modlong operator * (ll num) { modlong m(this->x); m *= num; return m; }
private:
	inline ll adjust(ll a) {
		if (a >= mod) { return a % mod; }
		if (a < 0) { return mod - 1 + ((a + 1) % mod); }
		return a;
	}
	ll x;
};

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

	constexpr int K = 16;

	vector<modlong> v_e = { 0, 765144583, 346175634, 347662323, 5655049, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };
	vector<modlong> v_o = { 539588932, 729548371, 700407153, 404391958, 962779130, 184117322, 927321758, 444014759, 542573865, 237315285, 417297686, 471090892, 183023413, 660103155, 727008098, 869418286 };

	int T; cin >> T;
	modlong ans, x;
	for (int _t = 0; _t < T; _t++) {
		ll N; cin >> N;
		if (N % 2 == 0) {// even
			ans = 0;
			x = 1;
			for (int i = 0; i < K; i++) {
				ans += x * v_e[i];
				x *= N;
			}
			cout << (ll)ans << endl;
		}
		else {// odd
			ans = 0;
			x = 1;
			for (int i = 0; i < K; i++) {
				ans += x * v_o[i];
				x *= N;
			}
			cout << (ll)ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3152
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    String li[] = S.split("");
    boolean judge = true;
    if(N%2==1){
      judge = false;
    }else{
      for(int i=0;i<N/2;i++){
        if(!li[i].equals(li[N/2+i])){
          judge = false;
        }
      }
    }
    if(judge){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}               

Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[1001];
bool ok;
int main()
{
	scanf("%s",a+1);
	int len=strlen(a+1);
	for(int i=1;i<=len;i++)
	{
		if(a[i]=='A'){
			if(a[i+1]=='C'){
				ok=1;cout<<"Yes";break;
			}
		}
	}
	if(ok==0)cout<<"No";
	return 0;
 } 

Measured memory_bytes: 256
from bisect import bisect_left

n = int(input())
lst = sorted([int(i) for i in input().split()])

ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        ans += bisect_left(lst, lst[i] + lst[j]) - j - 1

print(ans)


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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}


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

    loop {
        int s = next<int>();
        unless(s) break;
        cout << s - sum(next<vector<int>>(9)) ln;
    }

    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

int main(void){
    int N,X;
    cin >> N >> X;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    int ans=0;
    for(int i=0;i<N;i++){
        if(i==N-1){
            if(A[i]==X){
                ans++;
            }
            X-=X;
        }
        if(A[i]<=X){
            X -= A[i];
            ans++;
        }else{
            cout << ans << endl;
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
 
public class Main {
	
	private static Scanner sc;
	
	public static void main (String args[]) {
		sc = new Scanner(System.in);
		int lNum = Integer.parseInt(sc.next());
		int rNum = Integer.parseInt(sc.next());
		int dNum = Integer.parseInt(sc.next());
		int resultNum = 0;
		for(int i = lNum; i<=rNum; i++) {
			int def = i%dNum;
			if(def==0) {
				resultNum++;
			}
		}
		System.out.println(resultNum);		
	}	
}

Measured memory_bytes: 35444
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let a: u8 = read();
    let s: String = read();
    let ch: Vec<char> = s.chars().collect();
    for i in 0..ch.len(){
	let mut f:u8 = ch[i as usize] as u8 + a;
	if f > 90 {
	    f -= 26;
	}
	print!("{}",f as char);
    }
    println!("");
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val s = readLine()!!
    val w = readInteger()

    var ans = ""
    for (i in 0 until s.length step w) {
        ans += s[i]
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 33784
#include<bits/stdc++.h>
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
 unsigned int a,b;
 cin>>a>>b;
 if(a>=1&&a<=100&&b>=1&&b<=100)
 {
  if(a<=b)
 cout<<"unsafe"<<"\n";
 else
 cout<<"safe"<<"\n";
 }
 
 
 
 
 return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <unistd.h>

typedef unsigned long ulong;

static inline ulong diff(ulong a, ulong b){
    return __builtin_ctzl(a^b);
}
/*
static inline void pl(long n){
#define L 8
    char c[L];
    long i=L-1;
    do{
        c[i]=n%10+'0';
        n/=10;
        i--;
    }while(n>0);
    for(i++;i<L;i++){
        putchar_unlocked(c[i]);
    }
}

static inline void puts_unlocked(const char *s){
    for(size_t i=0; s[i]!='\0'; i++){
        putchar_unlocked(s[i]);
    }
    putchar_unlocked('\n');
}
*/
#define N 17
long data[1<<N];
char buf[819200];
size_t point=0;

static inline void pc(char c){
    buf[point] = c;
    point++;
}
static inline void pl(long n){
#define L 8
    char c[L];
    long i=L-1;
    do{
        c[i]=n%10+'0';
        n/=10;
        i--;
    }while(n>0);
    for(i++;i<L;i++){
        pc(c[i]);
    }
}

static inline void puts_unlocked(const char *s){
    for(size_t i=0; s[i]!='\0'; i++){
        pc(s[i]);
    }
    pc('\n');
}


static void solve(long a, long b, const size_t sp, const size_t ep, long mask){
    if(ep-sp<=2){
        data[sp+0] = a;
        data[sp+1] = b;
        return;
    }
    const ulong d = diff(a, b);
    mask ^= (1<<d);
    const ulong ad = a&(1<<d);
    const ulong bd = b&(1<<d);
    a &= mask;
    b &= mask;
    const ulong ab = a ^ (mask&(-mask));
    const size_t mp = (sp+ep)/2;
    //printf("%ld %ld %ld\n", aa, ab, bb);
    solve(a, ab, sp, mp, mask);
    solve(ab, b, mp, ep, mask);
    for(size_t i=sp; i<mp; i++){ data[i] |= ad; }
    for(size_t i=mp; i<ep; i++){ data[i] |= bd; }
}

int main(void){
    long n, a, b;
    scanf("%ld %ld %ld", &n, &a, &b);
    if(__builtin_popcountl(a)%2 == __builtin_popcountl(b)%2){
        puts("NO");
        return 0;
    }
    solve(a, b, 0, 1<<n, 0xFFFFFFFFFFFFFFFF);
    const size_t m = 1<<n;

    puts_unlocked("YES");
    for(size_t i=0; i<m-1; i++){
        pl(data[i]);
        pc(' ');
    }
    pl(data[m-1]);
    pc('\n');
    write(1, buf, point);
    return 0;
}


Measured memory_bytes: 2688
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        if(S.equals("AAA") || S.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }

    }
}

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

int main(){
  int n;
  cin >> n;
  int ans[n];
  for(int i=0; i<n; i++){
    ans[i] = 0;
  }
  int a;
  for(int i=1; i<n; i++){
    cin >> a;
    ans[a-1] = ans[a-1] + 1;
    }
  for(int i=0; i<n; i++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 4372
N=int(input())
if N<=111:
	print('111')
elif N<=222:
	print('222')
elif N<=333:
	print('333')
elif N<=444:
	print('444')
elif N<=555:
	print('555')
elif N<=666:
	print('666')
elif N<=777:
	print('777')
elif N<=888:
	print('888')
else:
	print('999')

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(){
    double N;
    cin >> N;
    double s = 0;
    REP(i , N){
        double a;
        cin >> a;
        s += 1 / a;
        
    }
    
    cout << fixed;
    
    cout << setprecision(5) <<  1 / s << endl;
}


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

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define FILE "parade"

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const ull ULLINF = numeric_limits<ull>::max();
const double PI = acos(-1.0);

long long f[500010], inv[500010], mod = 1e9 + 7;

long long sqr(long long n)
{
    return n * n % mod;
}

long long binpow(long long a, long long n)
{
    if(!n)
        return 1;
    if(n & 1)
        return binpow(a, n - 1) * a % mod;
    else
        return sqr(binpow(a, n >> 1));
}

long long c(int n, int k)
{
    if(k > n)
        return 0;
    if(k == 0)
        return 1;
    if(n == k)
        return 1;
    return f[n] * inv[k] % mod * inv[n - k] % mod;
}

int main()
{
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    f[0] = f[1] = inv[0] = inv[1] = 1;
    for(ll i = 2; i <= 500000; i++)
    {
        f[i] = f[i - 1] * i % mod;
        inv[i] = binpow(f[i], mod - 2);
    }
    int N, M, A, B;
    cin >> N >> M >> A >> B;
    long long ans = 0;
    for(int i = 1; i <= (N - A); i++)
        ans = (ans + c(i + B - 2, i - 1) * c(N - i + M - B - 1, M - B - 1) % mod) % mod;
    cout << ans;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, m, t;
vector< ll > dp(100, 0), adj[100005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
const ll mod = 1e9 + 7;

void self_sum(ll& a, ll b){
	a += b;
	if( a >= mod )
		a -= mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    ll D, len, extreme = 0;
    cin >> s;
    cin >> D;
    len = s.size();
    dp[0] = 1;
    for(int cur = 0 ; cur < len ; cur++){
    	vector< ll > new_dp(100, 0);
    	if( cur > 0 )
	    	for(int sum = 0 ; sum < D ; sum++)
    			for(int digit = 0 ; digit < 10 ; digit++)
					self_sum(new_dp[(sum + digit) % D], dp[sum]);

    	dp = new_dp;
    	for(int digit = 0 ; digit < 10 ; digit++)
    		if( digit < s[cur] - '0' )
    			self_sum(dp[(extreme + digit) % D], 1);
    	self_sum(extreme, (ll)(s[cur] - '0'));
    	extreme %= D;
    }
    self_sum(dp[extreme], 1);
    dp[0]--;
    if( dp[0] == -1 )
    	dp[0] = mod - 1;
    cout << dp[0] << endl;
   	return(0);
}

Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 20;
int n, m;
bool vis[N];
string str[N];
bool check() {
	bool use = !(m % 2);
	memset(vis, 0, sizeof(vis));
	rep(i, 0, m) {
		if(vis[i]) continue;
		bool ok = 0;
		int j;
		for(j = 0; j < m; j++) {
			if(vis[j] || j == i) continue;
			int a, b;
			for(a = 0, b = n - 1; a < n && str[a][i] == str[b][j]; a++, b--);
			if(a == n) {
				ok = 1;
				break;
			}
		}
		if(ok) vis[i] = vis[j] = 1;
		else if(!use) {
			int a, b;
			for(a = 0, b = n - 1; a <= b && str[a][i] == str[b][i]; a++, b--);
			if(a < b) return 0;
			vis[i] = use = 1;
		}
		else return 0;
	}
	rep(i, 0, m) assert(vis[i]);
	return 1;
}
void gao(int st, int ed) {
	if(st + 1 >= ed) {
		//rep(i, 0, n) de(str[i]);
	//	puts("---");
		if(check())
			throw 1;
		return ;
	}
	rep(i, st, ed + 1) {
		rep(j, i + 1, ed + 1) {
			swap(str[i], str[st]);
			swap(str[j], str[ed]);
			gao(st + 1, ed - 1);
			swap(str[i], str[st]);
			swap(str[j], str[ed]);
		}
	}
}
int main(){
	bool ans = 0;
	cin >> n >> m;
	rep(i, 0, n) cin >> str[i];
	try{
		gao(0, n - 1);
	} catch(int e) {
		assert(e == 1);
//		rep(i, 0, n) de(str[i]);
		ans = e;
	}
	puts(ans ? "YES" : "NO");
	return 0;
}


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

int main () {
  int n, x;
  int a[100];
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    x -= a[i];
    if (i == n-1) {
      if (x != 0) break;
    }
    if (x < 0) break;
    else if (x == 0) {
      ans++;
      break;
    }
    else {
      ans++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int n;
  cin >> n;
  ++n;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];

  vector<ull> B(n);
  B[n-1] = A[n-1];
  drep(i,n-1) {
    B[i] = B[i+1] + A[i];
  }

  vector<ull> D(n, 0);
  ull c {1};
  int index {-1};
  rep(i,n) {
    D[i] = c;
    if (B[i] <= D[i]) {
      index = i;
      break;
    }
    if (c < A[i]) {
      index = -1;
      break;
    }
    c -= A[i];
    c <<= 1;
  }
//  rep(i, n) {
//    cout << B[i] << ' ' << D[i] << '\n';
//  }

  if (index == -1) {
    cout << "-1\n";
    return 0;
  }

  ull ans {0};
  rep(i, index) {
    ans += D[i];
//    cout << ans << '\n';
  }
  ans += min(B[index], D[index]);
  srep(i, index+1, n) {
    ans += B[i];
//    cout << ans << '\n';
  }

  cout << ans << '\n';
}


Measured memory_bytes: 5576
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, c;
  cin >> a >> b >> c;
  if (a == b) cout << c;
  if (c == b) cout << a;
  if (a == c) cout << b;

  return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<string>data(h);
  rep(i,0,h) cin >> data[i];
  rep(i,0,h) rep(j,0,w){
    if(data[i][j] == '.') continue;
    bool f = 0;
    if(i > 0) if(data[i-1][j] == '#') f = 1;
    if(i < h-1) if(data[i+1][j] == '#') f = 1;
    if(j > 0) if(data[i][j-1] == '#') f = 1;
    if(j < w-1) if(data[i][j+1] == '#') f = 1;
    if(!f){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int h, w, m;
    cin >> h >> w >> m;
    V<int> cnt_h(h), cnt_w(w);
    set<P> points;
    rep(i,m) {
        int y, x;
        cin >> y >> x;
        y--; x--;
        cnt_h[y]++;
        cnt_w[x]++;
        points.emplace(y,x);
    }
    int mx_h = 0, mx_w = 0;
    rep(i,h) chmax(mx_h, cnt_h[i]);
    rep(i,w) chmax(mx_w, cnt_w[i]);

    V<int> hs, ws;
    rep(i,h) if(cnt_h[i] == mx_h) hs.push_back(i);
    rep(i,w) if(cnt_w[i] == mx_w) ws.push_back(i);
    int ans = mx_w + mx_h;

    for(int i : hs) for(int j : ws) {
        if(points.count(make_pair(i,j))) continue;
        cout << ans << endl;
        return 0;
    }
    ans--;
    cout << ans << endl;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, K; cin >> N >> K;
	vector<int>h(N); rep(i, 0, N) { cin >> h[i]; }
	int ans = 0;
	for (auto x : h) {
		if (x >= K)ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	ll N,K;
	cin>>N>>K;
  	ll ANS=K;
  	for(int i=0;i<N-1;i++){
      ANS=ANS*(K-1);
    }
  	cout << ANS << endl;
}


Measured memory_bytes: 256
from itertools import accumulate
N, K = map(int, input().split())
P = [0] + list(map(int, input().split()))
P_acc = list(accumulate(P))


M = 0
Mi = -1
for i in range(1, N - K + 2):
    if P_acc[i + K - 1] - P_acc[i - 1] > M:
        M = P_acc[i + K - 1] - P_acc[i - 1]
        Mi = i


ans = 0
for i in range(Mi, Mi + K):
    ans += ((1 + P[i]) * 0.5 * P[i]) / P[i]

print(ans)


Measured memory_bytes: 25152
#include<stdio.h>
int main(void){
   int a, b, c;
   scanf("%d %d %d", &a, &b, &c);
   if ( a == 1 && b == 0 && c == 0 ) printf("Close\n");
   else if ( a == 0 && b == 1 && c == 0 ) printf("Close\n");
   else if ( a == 1 && b == 1 && c == 0 ) printf("Open\n");
   else if ( a == 0 && b == 0 && c == 1 ) printf("Open\n");
   else if ( a == 0 && b == 0 && c == 0 ) printf("Close\n");
   return 0;
}

Measured memory_bytes: 1828
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<queue>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n,a[200001],b[200001];
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i]>>b[i];
	}
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	if(n&1)
	{
		cout<<b[(n+1)>>1]-a[(n+1)>>1]+1<<endl;
	}
	else
	{
		int l=a[n>>1]+a[(n>>1)+1],r=b[n>>1]+b[(n>>1)+1];
		cout<<r-l+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 6740
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	ll mx = 0;
	ll ans = 0;
	rep(i,0,n){
		ll a;
		cin>>a;
		if(a>=mx)ans++;
		mx = max(mx,a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int area = a * b;
		int length = (a * 2) + (b * 2);
		System.out.println(area + " " + length);
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;
  string board[H];
  for(int i=0; i<H; i++) cin >> board[i];

  //8方向の座標を定義
  int dx[8]={1,1,1,0,-1,-1,-1,0};
  int dy[8]={-1,0,1,1,1,0,-1,-1};

  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){

      if(board[i][j]=='.'){
        int count =0;

        for(int k=0; k<8; k++){
          int x = i+dx[k];
          int y = j+dy[k];
          if(x>=0 && x<H && y>=0 && y<W && board[x][y]=='#'){
            count++;
          }
        }

        board[i][j] = '0' + count;
      }

    }
  }
  for(int i=0; i<H; i++) cout << board[i] << endl;
}


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

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

    if((a == 2 && b == 3) || (a == 3 && b == 2))
        cout << 1 << endl;

    else if((a == 1 && b == 3) || (a == 3 && b == 1))
        cout << 2 << endl;

    else if((a == 1 && b == 2) || (a == 2 && b == 1))
        cout << 3 << endl;

    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter

N, M = map(int, input().split())
AB = sorted([list(map(int, input().split()))for i in range(N)], key=itemgetter(0))
ans = 0
cm = 0
for i in range(N):
    if cm + AB[i][1] >= M:
        print(ans + AB[i][0] * (M - cm))
        exit()
    else:
        ans += AB[i][0] * AB[i][1]
        cm += AB[i][1]


Measured memory_bytes: 29736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static private long gcdInner(long a, long b) => (a % b == 0) ? b : gcdInner(b, a % b);
    static public long GCD(long a, long b) => (a > b) ? gcdInner(a, b) : gcdInner(b, a);
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();
    
    static void Main()
    {
        var nm = Console.ReadLine().ToIntArray();
        int N = nm[0];
        int M = nm[1];
        
        var infoList = Enumerable.Range(0, M).Select(n => Console.ReadLine().ToIntArray())
            .Select(arr => new { X = arr[0] - 1, Y = arr[1] - 1, Z = arr[2] })
            .OrderBy(itm => Math.Min(itm.X, itm.Y))
            .ToList();
        
        //地点iから行ける箇所を取れるようにしておく。
        var ways = Enumerable.Range(0, N).Select(n => new List<int>()).ToArray();
        foreach(var info in infoList)
        {
            ways[info.X].Add(info.Y);
            ways[info.Y].Add(info.X);
        }

        int ans = 0;
        HashSet<int> already = new HashSet<int>();
        for(int i = 0; i < N; i++)
        {
            if (already.Contains(i)) continue;

            Queue<int> q = new Queue<int>();
            q.Enqueue(i);

            while(q.Any())
            {
                var val = q.Dequeue();
                already.Add(val);
                foreach(var next in ways[val])
                {
                    if (already.Contains(next)) continue;

                    q.Enqueue(next);
                }
            }

            ans += 1;
        }

        Console.WriteLine(ans);
        
    }
}

Measured memory_bytes: 37872
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i:a)cout << i << " "; puts("");

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

int main() {
	int h, w, x, y; cin >> h >> w >> x >> y;
	cout << h * w - x * w - y * h + x * y << endl;
}

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

const int N = 110;

typedef long long LL;

vector<int> G[N];

int dep[N], mx, pos, tmp[N], fuck[N], n;

void dfs(int u, int f) {
    dep[u] = dep[f] + 1, tmp[u] = u, fuck[u] = dep[u];
    if (dep[u] > mx) mx = dep[u], pos = u;
    for (auto v : G[u]) if (v != f) {
        dfs(v, u);
        if (fuck[v] > fuck[tmp[u]]) tmp[u] = v;
        fuck[u] = max(fuck[u], fuck[v]);
    }
}

int ans1;

inline LL work1(int pos) {
    mx = 0, dfs(pos, 0);
    if (mx != ans1) return 1e18;
    vector<int> A, B; A.push_back(pos);
    for (auto v : G[pos]) B.push_back(v);
    LL nw = B.size();
    while (233) {
        swap(A, B), B.clear(); int t = 0;
        for (auto u : A) {
            t = max((int)G[u].size() - 1, t);
            for (auto v : G[u]) if (dep[v] > dep[u]) 
                B.push_back(v);
        }
        if (!t) return nw;
        if (1e18 / t < nw) return 1e18;
        nw *= t;
    }
}

inline LL work2(int A, int B) {
    int nw = n + 1;
    for (auto &v : G[A]) if (v == B) { v = nw; break; }
    for (auto &v : G[B]) if (v == A) { v = nw; break; }
    G[nw].push_back(A), G[nw].push_back(B);
    ans1++; LL ans = work1(nw); ans1--;
    for (auto &v : G[A]) if (v == nw) { v = B; break; }
    for (auto &v : G[B]) if (v == nw) { v = A; break; }
    G[nw].clear();
    return ans;
}

int main() {
    scanf("%d", &n);
    for (int i = 1, a, b; i < n; i++) 
        scanf("%d%d", &a, &b), G[a].push_back(b), G[b].push_back(a);
    dfs(1, 0); int A = pos; mx = 0;
    dfs(A, 0); int B = pos;
    vector<int> hh;
    while (233) {
        hh.push_back(A);
        if (A == B) break;
        A = tmp[A];
    } 
    printf("%d ", ans1 = (hh.size() + 1) / 2); 
    LL ans2 = 1e18;
    for (int i = 1; i <= n; i++)
        for (auto j : G[i]) if (i < j) ans2 = min(ans2, work2(i, j));
    if (hh.size() & 1) {
        int mid = hh[hh.size() / 2];
        printf("%lld\n", min(work1(mid), ans2));
    } else {
        printf("%lld\n", ans2);
    }
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, m, k; cin >> n >> m >> k; 
	for (int i = 0; i <= n; ++i) for (int j = 0; j <= m; ++j) 
		if (i * j + (n - i) * (m - j) == k) return cout << "Yes\n", 0;
	cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n,ans = 0;
  scanf("%d",&n);
  long l[n];
  for(int i=0; i<n; i++)
    scanf("%ld",&l[i]);
  
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      for(int k=j+1; k<n; k++){
        if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
          if(l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j]){
            ans++;
          }
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1732
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

class CmbMod:
    def __init__(self, n, p):
        """
        二項係数nCr(n個の区別できるものからr個のものを選ぶ組み合わせの数)をpで割った余りを求める
        """
        self.n = n
        self.p = p
        self.fact = [1, 1]
        self.factinv = [1, 1]
        self.inv = [0, 1]

    def cmb_mod(self, n, r):
        """
        二項係数nCr(mod p)をO(r)にて計算。nが大きいがrは小さい時に使用。
        """
        numer, denom = 1, 1
        for i in range(r):
            numer = (numer * (n - i)) % self.p
            denom = (denom * (i + 1)) % self.p
        return (numer * pow(denom, self.p - 2, self.p)) % self.p

    def prep(self):
        """
        二項係数nCr(mod p)をO(1)で求める為の前処理をO(N)にて実行。
        """
        for i in range(2, self.n + 1):
            self.fact.append((self.fact[-1] * i) % self.p)
            self.inv.append((-self.inv[self.p % i] * (self.p // i)) % self.p)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % self.p)

    def cmb_mod_with_prep(self, n, r):
        """
        二項係数nCr(mod p)をO(1)で求める。事前にprepを実行する事。
        """
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] * self.factinv[n - r] % self.p


def resolve():
    H, W, A, B = map(int, input().split())
    H -= 1
    W -= 1
    cmb = CmbMod(H + W, mod)
    cmb.prep()
    total = cmb.cmb_mod_with_prep(H + W, H)
    for w in range(B):
        tmp = (cmb.cmb_mod_with_prep(H - A + w, w) * cmb.cmb_mod_with_prep(A - 1 + W - w, A - 1)) % mod
        total -= tmp
        total %= mod
    print(total)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 32760
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define inf 1e9
#define mod 1e9 + 7
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}
ll power(ll x, ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

int main(){
    int n, p;
    cin>>n>>p;
    string s;
    cin>>s;
    ll ans=0;
    if(p==2){
        lpi(0,n){
            if((s[i]-'0')%2 == 0){
                ans += i+1;
            }
        }
    }
    else if(p==5){
        lpi(0,n){
            if((s[i]-'0')%5==0) ans+=i+1;
        }
    }
    else{
        map<int , int> mp;
        int t=0, p1=1;
        mp[0]++;
        for(int i=n-1; i>=0; i--){
            t = (t+(s[i]-'0')*p1)%p;
            p1 = (p1*10)%p;
            ans += mp[t];
            mp[t]++;
        }
    }
    cout<<ans;
}

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

int main(void){
    
  int N,T,ans=10000,c,t;
  cin >> N >> T;
  
  for(int i=0;i<N;i++){
      cin >> c >> t;
      if(t <= T && c < ans){
          ans = c;
      }
  }
  
  if(ans == 10000) cout << "TLE" << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int get_digit(ll num){
    int cnt=0;
    while(1){
        num /= 10;
        cnt++;
        if(num==0) break;
    }
    return cnt-1;
}

int first_num(ll num){
    int pre;
    while(1){
        num /= 10;
        if(num==0) break;
        pre = num;
    }
    return pre;
}

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

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

    ll maxn = 1e+18;

    
    bool ok = 0;

    int total_digit = 0;
    int total_pre = 1;
    rep(i,N){
        int n = get_digit(A[i]);
        int pre = first_num(A[i]);
        //cout<< n << endl;
        total_digit += n;
        total_pre *= pre;
        if(total_digit >= 18 && total_pre>1) ok = 1;
    }

    ll total = 1;
    if(ok==0){
        rep(i,N){
            total *= A[i];
            if(total>maxn) ok = 1;
        }
    }

    rep(i,N) if(A[i]==0) {
        ok = 0, total = 0;
        break;
    }

    if(ok){
        cout << -1 << endl;
    }else{
        cout << total << endl;
    }

}

Measured memory_bytes: 3996
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(isize,isize);n],
        cm: [(isize,isize);m]
    }
    let mut res = Vec::new();
    for i in ab.iter() {
        let mut min_dis = std::isize::MAX;
        let mut min_pos = 0;
        for (k, j) in cm.iter().enumerate() {
            let dis = (i.0 - j.0).abs() + (i.1 - j.1).abs();
            if dis < min_dis {
                min_dis = dis;
                min_pos = k + 1;
            }
        }
        res.push(min_pos);
    }
    for i in res.iter() {
        println!("{}", i);
    }
}


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

int main(){
    int K;
    string S;
    cin >> K;
    cin >> S;
    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.erase(K) << "..." << endl;
    }
    return 0;
}

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

#define _BIGNUM_ 100000000

using namespace std;
typedef long long ll;

const ll mod = 1e9+7;

int main() {
  ll D;
  cin >> D;
  D -= 25;
  D = abs(D);
  cout << "Christmas";
  for (ll j=0; j < D; ++j) {
    cout << " Eve";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long
#define fi first
#define se second
#define ii  pair<int, int>
#define vi  vector <int>
#define vii vector <pair <int, int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 610
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")

int n, m;
vector <int > graph[range];
vector <bool> cached;
double dp[range];
int rm;


double dfs(int node) {
    if(cached[node]) return dp[node];
    else cached[node] = true;

    if(node == n) {
        cached[node] = true;
        return 0.0;
    }

    double to = 0, max1 = 0;
    for(auto x: graph[node]) {
        double temp = dfs(x);
        to += temp;
        max1 = max(max1, temp);
    }
    int cnt = graph[node].size();
    if(node == rm && cnt > 1) {
        dp[node] = 1 + (to - max1) / (cnt - 1);
    }
    else {
        dp[node] = 1 + to / cnt;
    }
    return dp[node];
}


void remove(int node) {
    cached.assign(n + 1, false);
    rm = node;
    dfs(1);  
}


int main(){

//    freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();

    cin >> n >> m;
    forn(i, m) {
        int a, b; cin >> a>> b;
        graph[a].pb(b);
    }
    double ans = 1e16;
    forn1(i, n - 1) {
        remove(i);  
        ans = min(ans, dp[1]);
    }


    cout << setprecision(10) << ans << endl;



    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 1408