akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n; cin >> n;
  map<string, int> mp;
  int maxv = 0;
  for (int i = 0; i < n; i ++) {
    string s; cin >> s;
    mp[s] ++;
    maxv = max(maxv, mp[s]);
  }

  for (auto x : mp) {
    if (x.second == maxv) cout << x.first << endl;
  }
}


Measured memory_bytes: 25216
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
using namespace std;
const double eps = 1e-8;
typedef long long LL;
const int M=1005;
int n;
int a[M];
int main()
{
    int t,b;
    scanf("%d",&n);
    scanf("%d%d",&t,&b);
    int id=1;
    double minn=1e9;
    for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		double k=abs(t-a[i]*0.006-b);
		
		if(minn>k)
		{
			minn=k;
			id=i;
		}
	}
	 cout<<id<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<set>
#include<cstring>
#define mp(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
const int maxn=1e5+50;
int main()
{
	int n,a[maxn],i,sum=0,asum=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
		asum+=abs(a[i]);
	}
	sort(a+1,a+1+n);
	int num=n;
	if(a[1]>=0)
	{
		printf("%d\n",sum-a[1]-a[1]);
		if(n==2)
		{
			printf("%d %d\n",a[2],a[1]);
			return 0;
		}
		int fir=1;
		printf("%d %d\n",a[1],a[n]);
		a[1]=a[1]-a[n];
		num=n-1;
		while(num>2)
		{
			printf("%d %d\n",a[fir],a[fir+1]);
			a[fir+1]=a[fir]-a[fir+1];
			num--;fir++;
		}
		printf("%d %d\n",a[fir+1],a[fir]);
	}
	else if(a[n]<=0)
	{
		printf("%d\n",a[n]-(sum-a[n]));
		int fir=1;
		printf("%d %d\n",a[n],a[1]);
		a[n]=a[n]-a[1];
		num=n-1;fir++;
		while(num>1)
		{
			printf("%d %d\n",a[n],a[fir]);
			a[n]-=a[fir];
			num--;fir++;
		}
	}
	else
	{
		printf("%d\n",asum);
		int fir=1,last=n;
		while(num>1)
		{
			if(a[last-1]>=0)
			{
				printf("%d %d\n",a[fir],a[last]);
				a[fir]-=a[last];
				last--;
				num--;
			}
			else
			{
				printf("%d %d\n",a[last],a[fir]);
				a[last]-=a[fir];
				fir++;
				num--;
			}
		}
	}
}

Measured memory_bytes: 2176
use itertools_num::ItertoolsNum;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use std::cmp::max;
use std::iter;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        k: usize,
        a: [usize; n],
        b: [usize; m],
    }
    let a_sum: Vec<_> = iter::once(0)
        .chain(a.into_iter().cumsum().collect::<Vec<_>>())
        .collect();
    let b_sum: Vec<_> = iter::once(0)
        .chain(b.into_iter().cumsum().collect::<Vec<_>>())
        .collect();

    let mut l = b_sum.len() - 1;
    let mut ans = 0;
    for (i, ai) in a_sum.into_iter().enumerate() {
        if ai > k {
            break;
        }
        for j in (0..=l).rev() {
            let bj = b_sum[j];
            if ai + bj <= k {
                ans = max(ans, i + j);
                l = j;
                break;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 10924
package main

import "fmt"

func isPrime(num int) bool {
	for i := 2; i < num; i++ {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	var x int
	fmt.Scan(&x)

	for i:=x;;i++{
		if isPrime(i){
			fmt.Println(i)
			break
		}
	}
}

Measured memory_bytes: 1772
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>

using namespace std;

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



int main()
{
    int N;
    cin >> N;
    string arr[N];
    set<string> ss;
    rep(i, N) {
        cin >> arr[i];
        ss.insert(arr[i]);
    }
    cout << ss.size() << endl;
}

Measured memory_bytes: 20388
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] L = new int[N];
        for (int i = 0; i < N; i++) {
            L[i] = sc.nextInt();
        }

        Arrays.sort(L);

        int sum = 0;
        for (int i = 0; i < N-1; i++) {
            sum += L[i];
        }

        if (L[N-1] < sum) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    i32 N, D;
    cin >> N >> D;
    i32 sum = 0;
    for (i32 i = 0; i < N; i += 2 * D + 1) {
        sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3608
import scala.io.StdIn._
object Main extends App {
  val Array(t1, t2), Array(a1, a2), Array(b1, b2) = readLine.split(" ").map(_.toLong)
  val la1 = a1 * t1
  val la2 = a2 * t2
  val lb1 = b1 * t1
  val lb2 = b2 * t2
  val (f1, f2, s1, s2) = if (la1 + la2 > lb1 + lb2) (la1, la2, lb1, lb2) else (lb1, lb2, la1, la2)

  println(
    if (f1 + f2 == s1 + s2) "infinity"
    else if (f1 > s1) 0
    else {
      val diff1 = s1 - f1
      val diff = f1 + f2 - s1 - s2
      if (diff1 % diff == 0) diff1 / diff * 2 else diff1 / diff * 2 + 1
    })
}

Measured memory_bytes: 27440
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long a[n],s[n+1];
  s[0]=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    s[i+1]=a[i]+s[i];
  }
  sort(s,s+n+1);
  long long b=s[0],c=0,d=1;
  for(int i=1;i<=n;i++){
    if(b==s[i])
      d++;
    else{
      c+=d*(d-1)/2;
      d=1;
      b=s[i];
    }
  }
  c+=d*(d-1)/2;
  cout<<c;
}
    


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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector <int> l(n), cnt(1001), pre(1001);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        cnt[l[i]]++;
    }
    for (int i = 0; i <= 1000; i++) {
        pre[i] = cnt[i] + (i ? pre[i - 1] : 0);
    }
    long long int ans = 0;
    for (int i = 1; i <= 1000; i++) {
        for (int j = i; j <= 1000; j++) {
            int left = j;
            int right = min(i + j - 1, 1000);
            long long int c = pre[right] - pre[max(left - 1, 0)];
            long long int part = c - cnt[j];
            if (i == j) {
                ans += part * (cnt[i] - 1) * cnt[j] / 2;
                ans += (long long int) (cnt[i] - 2) * (cnt[i] - 1) * cnt[i] / 6;
            } else {
                ans += part * cnt[i] * cnt[j];
                ans += (long long int) cnt[i] * cnt[j] * (cnt[j] - 1) / 2;
            } 
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

class weight_unionfind {
	int par[100005], Rank[100005], diff_weight[100005];
public:
	weight_unionfind(int x) {
		rep(i, x) {
			par[i] = i;
			Rank[i] = 0;
			diff_weight[i] = 0;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		int r = find(par[x]);
		diff_weight[x] += diff_weight[par[x]];
		return par[x] = r;
	}
	int weight(int x) {
		find(x);
		return diff_weight[x];
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	bool unite(int x, int y, int w) {
		if (same(x, y)) {
			if (weight(x) + w != weight(y))return false;
			return true;
		}
		w += weight(x); w -= weight(y);
		x = find(x);
		y = find(y);
		if (Rank[x] < Rank[y])swap(x, y), w *= -1;
		if (Rank[x] == Rank[y])Rank[x]++;
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}
	int diff(int x, int y) {
		if (same(x, y))return weight(y) - weight(x);
		return inf;
	}
};
signed main() {
	int n, q;
	cin >> n >> q;
	static weight_unionfind uf(n);
	rep(i, q) {
		int a, b, c;
		cin >> a >> b >> c;
		if (!uf.unite(a - 1, b - 1, c)) { cout << "No" << endl, endre; }
	}
	cout << "Yes" << endl;
	endre;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 505;
int dp[N][N];
int a[N],b[N];

int32_t main(){
  fastio;
  map<int,int> mp;
  int res=0;
  int n;
  cin>>n;
  vector<int> v(n+1);
  for(int i=1;i<=n;i++){
    cin>>v[i];
    res+=mp[v[i] - i];
    mp[-v[i] - i ]++;
  }
  cout << res << endl;


  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 27392
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;
const int MAX = 1001001;
const ll MOD = 1e9+7;
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i % MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i) % MOD;
        finv[i]=finv[i-1]*inv[i] % MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
}

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    COMinit();
    int n,k; cin >> n >>  k;
    for(int i=1;i<=k;i++){
        ll  ans=COM(n-k+1,i)*COM(k-1,i-1);
        cout << ans%MOD << endl;
    }
}


Measured memory_bytes: 27060
#include <stdio.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = long long;
using VI = vector<int>;
using VF = vector<float>;
using VL = vector<ll>;
using VVL = vector<VL>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template<class T, class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T, class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return 1; } return 0; }

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF 1000000000000
#define MOD 10000007

ll N;
VL H, dp;

void solve() {
  cin >> N;
  H = VL(N);
  dp = VL(N, INF);
  for (auto &i : H) cin >> i;
  dp[0] = 0;
  dp[1] = abs(H[0] - H[1]);
  FOR(i, 2, N) {
      dp[i] = min(abs(H[i] - H[i - 1]) + dp[i - 1], abs(H[i] - H[i - 2]) + dp[i - 2]);
  }
  print(dp[N-1]);
}

int main() {
  solve();
  return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

vector<double> dp;
int main()
{
	ll n;
	cin >> n;
	vector<double> p(n);
	rep(i,n) cin >> p[i];
	dp.assign(n+1,0);
	dp[0] = 1;

	rep(i,n){
		for(int j = n; j >= 0; j--){
			dp[j] = dp[j-1] * p[i] + dp[j] * (1-p[i]);
		}
	}
	double ans = 0;
	for(int i = n; i >= (n/2+1); i--){
		ans += dp[i];
	}
	cout << setprecision(15);
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            int N = in.nextInt();
            Set<Long> set = new HashSet<>();
            for (int i = 0; i < N; i++) {
                long A = in.nextLong();
                set.add(A);
            }
            out.println(N == set.size() ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 102904
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
void vout(vl V) {
	for (ll i = 0; i < (ll)V.size(); i++) cout << V[i] << " ";
	cout << endl;
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color,D; vll path,path2; vl A; vl dp; vl Ans;
//***********//
void warshall_floyd(int n) {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if(i!=k && k!=j) path2[i][j] = min(path2[i][j], path[i][k] + path[k][j]);
			}
		}
	}
}
int main() {
	cin >> N;
	path.resize(N);
	path2.resize(N);
	vll A(N, vl(N));
	for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			cin >> A[i][j];
			path[i].push_back(A[i][j]);
			path2[i].push_back(INF);
			if(i<j) ans += A[i][j];
		}
	}
	warshall_floyd(N);
	for (i = 0; i < N-1; i++) {
		for (j = i+1; j < N; j++) {
			//debug(i, j, k, path2[i][j], path[i][j]);
			if (path[i][j] == path2[i][j]) {
				ans -= path[i][j];
			}
			else if (path[i][j] > path2[i][j]) {
				cout << -1;
				exit(0);
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl

const ll INF = (ll)(1e18) + 1;
const int MAXN = 200005;

vector<ll> a(MAXN);

bool f(ll x, ll k) {
  ll sum = 0LL;
  int n = a.size();
  rep(i, n) {
    bool sflg = a[i] < 0;
    int ng = sflg ? -1 : n;
    int ok = sflg ? n : -1;
    while(abs(ok - ng) > 1) {
      int mid = (ng + ok) / 2;
      if(a[mid] * a[i] < x)
        ok = mid;
      else
        ng = mid;
    }
    sum += sflg ? n - ok : ok + 1;
  }
  rep(i, n) if(a[i] * a[i] < x) sum--;
  sum >>= 1;
  return sum < k;
}

int main() {
  int n;
  ll k;
  cin >> n >> k;
  a.resize(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  ll ok = -INF, ng = INF;
  while(abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if(f(mid, k))
      ok = mid;
    else
      ng = mid;
  }
  cout << ok << endl;
  return 0;
}

Measured memory_bytes: 1920
/**
  * author : thegeniushead
**/
#include <bits/stdc++.h>
 
/*.....DEFINITIONS...... */
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T() int tt; cin>>tt; while(tt--)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define lchild (2*node+1)
#define rchild (2*node+2)
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

using namespace std;
 
/*.....TYPEDEFS ....*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long double ld;
 
/*....USEFUL FUNCTIONS....*/
ll pwr(ll base, ll exp, ll mod=MOD){ll res=1; while(exp>0){if(exp%2){res=(res*base)%mod;}base=(base*base)%mod;exp/=2;}return res;}
ll gcd(ll a, ll b){ if(b==0)return a; else gcd(b, a%b);}
bool isPrime(ll n){if(n<=1)return false;if(n<=3)return true;if (n%2==0||n%3==0)return false;for(int i=5; i*i<=n; i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
 
/*....I/O Functions...*/
inline string rs(){char x[1234567];scanf("%s", x);string s = x; return s;}
inline int ri(){int x; scanf("%d", &x);return x;}
inline long long rl(){long long x; scanf("%lld", &x); return x;}
 
/*---------Solution below this line --------*/
 
const int N = 1234567;

int n, k;

int32_t main()
{
	FIO
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> n >> k;
	
	int res = 1;
	
	rep(i,0,n){
		res = min(res + k, 2 * res);
	}
	
	cout << res << '\n';
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> adjlist[100001];
int dp[100001];
int solve(int i)
{
    if(dp[i]!=-1)
        return dp[i];
    int m=0;
    if(adjlist[i].size()==0)
        return 0;
    for(int j=0;j<adjlist[i].size();j++)
    {
        m=max(m,solve(adjlist[i][j]));
    }
    return dp[i]=1+m;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        adjlist[a].push_back(b);
    }
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        if(dp[i]==-1)
        {
            solve(i);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8192
import java.awt.Point;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
 
public class Main {
	static char[][] c;
	static int H, W;
	static List<Point> p;
	static long ans = 0;
	static boolean[][] m;
	static int[][] g;
	static long cnt1 = 0;
	static long cnt2 = 0;
	static int[][] h;
	static Set<Integer> set1;
	static Set<Integer> set2;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		String[] S = new String[H];
		for(int i = 0; i < H; i++) {
			S[i] = sc.next();
		}
		sc.close();
		c = new char[H][W];
		m = new boolean[H][W];
		g = new int[H][W];
		h = new int[H][W];
		set1 = new HashSet<Integer>();
		set2 = new HashSet<Integer>();
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				m[i][j] = true;
			}
		}
		p = new ArrayList<Point>();
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				c[i][j] = S[i].charAt(j);
				if(c[i][j] == '#') {
					p.add(new Point(j, i));
				}
			}
		}
		for(int i = 0; i < p.size(); i++) {
			int x = p.get(i).x;
			int y = p.get(i).y;
			//System.out.println(y + " " + x);
			if(g[y][x] == 1) {
				continue;
			}
			g[y][x] = 1;
			h[y][x] = 1;
			m[y][x] = false;
			rec('#', x, y);
			m[y][x] = true;
			int k = (y + 1) * H + x + 1;
			set2.add(k);
			cnt1 = set1.size();
			cnt2 = set2.size();
 
			//System.out.println(cnt1 +" " + cnt2);
			ans += cnt1 * cnt2;
			set1.clear();
			set2.clear();
		}
		System.out.println(ans);
	}
	static void init() {
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				h[i][j] = 0;
			}
		}
	}
	static void rec(char color, int x, int y) {
		int[] dx = {1, -1, 0, 0};
		int[] dy = {0, 0, 1, -1};
		for(int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if(nx >= 0 && nx < W && ny >= 0 && ny < H) {
				if(color == '#' && m[ny][nx] && c[ny][nx] == '.') {
					m[ny][nx] = false;
					rec('.', nx, ny);
					//m[ny][nx] = true;
					int k = (ny + 1) * H + nx + 1;
					set1.add(k);
					//h[ny][nx] = 1;
				}else if(color == '.' && m[ny][nx] && c[ny][nx] == '#') {
					g[ny][nx] = 1;
					m[ny][nx] = false;
					rec('#', nx, ny);
					//m[ny][nx] = true;
					g[ny][nx] = 1;
					int k = (ny + 1) * H + nx + 1;
					set2.add(k);
					//h[ny][nx] = 1;
				}
			}
		}
	}
}

Measured memory_bytes: 79124
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <map>
using namespace std;


int main(){
  int x, y; cin >> x >> y;
  map<int, int> m;
  m[1] = 1;
  m[2] = 3;
  m[3] = 1;
  m[4] = 2;
  m[5] = 1;
  m[6] = 2;
  m[7] = 1;
  m[8] = 1;
  m[9] = 2;
  m[10] = 1;
  m[11] = 2;
  m[12] = 1;
  if(m[x] == m[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
#define inf 1000000000
#define mod 1000000007
#define eps 1e-10
#define N 500005
#define rep(i, l, r) for(int i=l; i<r; ++i)
const double pi=acos(-1.0);

using namespace std;
int n, q;
int c[N];
struct query{
	int num, l, r;
	bool operator < (const query &rhs) const{
		return l/700==rhs.l/700 ? r<rhs.r : l<rhs.l;
	}
}a[N];
int cnt[N];
int ans[N];
int main(){
	scanf("%d%d", &n, &q);
	rep(i, 1, n+1) scanf("%d", &c[i]);
	rep(i, 1, q+1){
		a[i].num=i;
		scanf("%d%d", &a[i].l, &a[i].r);
	}
	sort(a+1, a+q+1);
	int l=1, r=0, tmp=0;
	rep(i, 1, q+1){
		while(l>a[i].l) if(cnt[c[--l]]++==0) ++tmp;
		while(r<a[i].r) if(cnt[c[++r]]++==0) ++tmp;
		while(l<a[i].l) if(--cnt[c[l++]]==0) --tmp;
		while(r>a[i].r) if(--cnt[c[r--]]==0) --tmp;
		ans[a[i].num]=tmp;
	}
	rep(i, 1, q+1) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 15272
#include<bits/stdc++.h>
using namespace std;
 
const int MAX_N = 1<<17;
typedef pair<int,int> P;
int n;
P dat[2*MAX_N-1];
 
//?????????
void init(int n_){
  //????´???°n???2???????????????
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=P(INT_MAX,INT_MAX);
}
 
int update(int a,int b,int k,int l,int r,int x){
  if(r<=a||b<=l)return dat[k].second;
  if(a<=l&&r<=b){
    dat[k]=P(x,x);
    return x;
  }else{
    if(dat[k].first!=INT_MAX){
      dat[k*2+1].first=dat[k*2+1].second=dat[k].first;
      dat[k*2+2].first=dat[k*2+2].second=dat[k].first;
      dat[k].first=INT_MAX;
    }
    int m=(l+r)/2;
    int v1=update(a,b,k*2+1,l,m,x);
    int v2=update(a,b,k*2+2,m,r,x);
    return dat[k].second=min(v1,v2);
  }
}
 
int find(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return INT_MAX;
  if(a<=l&&r<=b)return dat[k].second;
  else{
    if(dat[k].first!=INT_MAX){
      dat[k*2+1].first=dat[k*2+1].second=dat[k].first;
      dat[k*2+2].first=dat[k*2+2].second=dat[k].first;
      dat[k].first=INT_MAX;
    }
    return min(find(a,b,k*2+1,l,(l+r)/2),find(a,b,k*2+2,(l+r)/2,r));
  }
}
 
int main(){
  int q;
  cin>>n>>q;
   
  init(n);
  int u,s,t,x;
  for(int i=0;i<q;i++){
    cin>>u;
    if(!u){
      cin>>s>>t>>x;
      update(s,t+1,0,0,n,x);
    }else{
      cin>>s>>t;
      cout<<find(s,t+1,0,0,n)<<endl;
    }
  }
   
  return 0;
}


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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
//using P = pair<double, double>;
using edge = struct {int to; ll cost;};

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

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;

struct prime
{
  vector<bool> num;
  prime(int n) : num(n+1, true)
  {
    num[0] = false;
    num[1] = false;
    for(int i = 2; i <= n; i++) {
      if(num[i]) {
        for(int j = 2; i*j <= n; j++) num[i*j] = false;
      }
    }
  }
  bool isPrime(int x)
  {
    return num[x];
  }
};
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};


void solve()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a - c) <= d || abs(a-b) <= d && abs(c-b) <= d) cout << "Yes" << "\n";
  else cout << "No" << "\n";
}

int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N + 1];
        for (int i = 1; i <= N; i++) {
            a[i] = a[i - 1] + (long) sc.nextInt();
        }

        long[][] dp = new long[N + 1][N + 1];

        long res = backtrack(a, dp, 1, N);

        System.out.println(2 * res - a[N]);

    }

    public static long backtrack(long[] a, long[][] dp, int start, int end) {
        if (start > end) {
            return 0;
        } else if (start == end) {
            return a[start] - a[start - 1];
        }
        if (dp[start][end] != 0) return dp[start][end];

        long res = 0;

        long cur1 = a[start] - a[start - 1];
        res = Math.max(res, cur1 + a[end] - a[start] - backtrack(a, dp, start + 1, end));

        long cur2 = a[end] - a[end - 1];
        res = Math.max(res, cur2 + a[end - 1] - a[start - 1] - backtrack(a, dp, start, end - 1));
        dp[start][end] = res;
        return res;
    }
}


Measured memory_bytes: 128760
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 300001
using namespace std;
inline int read()
{
   int f=1,s=0,ch=getchar();
   while(ch!='-'&&!isdigit(ch)) ch=getchar();
   ch=='-' ? f=-1:s=ch-'0',ch=getchar();
   while(isdigit(ch)) s=s*10+ch-'0',ch=getchar();
   return s*f;
}
int n,t,a;
double h[1501];
double Abs(double a)
{
	return a<0? -a:a;
}
int main()
{
	n=read();
	t=read();a=read();
	for(int i=1;i<=n;i++) 
	{
		cin>>h[i];
		double nn=h[i]*0.006;
		h[i]=(double)t-nn;
	}
	double del=1000007;int tmp;
	for(int i=1;i<=n;i++)
	{
		if(Abs(h[i]-a)<del)
		{
			tmp=i;
			del=Abs(h[i]-a);
		}
	}
	printf("%d\n",tmp);
	return 0;
}

Measured memory_bytes: 256
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn main() {
    loop {
        let nums: Vec<usize> = get_line().trim()
            .split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect();
        let (w, h): (usize, usize) = (nums[0], nums[1]);
        if w == 0 && h == 0 {
            break;
        }
        println!("{}", "#".repeat(h));
        for _ in 0..w - 2 {
            println!("#{}#", ".".repeat(h - 2));
        }
        println!("{}\n", "#".repeat(h));
    }
}



Measured memory_bytes: 5024
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

s = list(input())
n = len(s)
if n%2==0:
    l = s[0:len(s)//2]
    r = s[len(s)//2:len(s)]
else:
    l = s[0:n//2]
    r = s[n//2+1:n]

r.reverse()
ans=0
for i in range(n//2):
    if l[i]!=r[i]:
        ans+=1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

int i[1000],p[1000],q[1000],r[1000];

int main(){
    int n;
    while(cin >> n, n){
        for(int j=0;j<n;j++){
            cin >> i[j] >> p[j] >> q[j] >> r[j];
        }
        bool is_na = true;
        int P, Q, R, C;
        cin >> P >> Q >> R >> C;
        for(int j=0;j<n;j++){
            int c = 4*(p[j]+r[j])+9*q[j];
            if(p[j]<=P&&q[j]<=Q&&r[j]<=R&&c<=C){
                is_na = false;
                cout << i[j] << endl;
            }
        }
        if(is_na) cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 1180
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    count = int(N/(A + B))
    print(A * count + min(N-(A+B)*count, A))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res%=m;
		}
		a*=a;a%=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
LP extGcd(lint a,lint b) {
	if(b==0)return {1,0};
	LP s=extGcd(b,a%b);
	std::swap(s.first,s.second);
	s.second-=a/b*s.first;
	return s;
}
LP ChineseRem(const lint& b1,const lint& m1,const lint& b2,const lint& m2) {
	lint p=extGcd(m1,m2).first;
	lint tmp=(b2-b1)*p%m2;
	lint r=(b1+m1*tmp+m1*m2)%(m1*m2);
	return std::make_pair(r,m1*m2);
}
/*template<typename F>
inline constexpr decltype(auto) lambda_fix(F&& f){
	return [f=std::forward<F>(f)](auto&&... args){
		return f(f,std::forward<decltype(args)>(args)...);
	};
}*/
#line 2 "main.cpp"
int n,l[110];
int main(){
	std::cin>>n;
	rep(i,n)std::cin>>l[i];
	int ans=0;
	rep(i,n-2){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				if(l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]&&l[i]+l[j]>l[k]&&std::abs(l[i]-l[j])<l[k])ans++;
			}
		}
	}
	std::cout<<ans<<std::endl;
	return 0;
}

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

int main()
{
	int a[3];
	for (int i = 0; i < 3; ++i)
	{
		cin >> a[i];
	}
	sort(a, a+3);
	cout << (a[0]*a[1])/2 << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$N = $key->A[0];
$M = $key->A[1];
$NT = 1;
for($i=1;$i<$N;$i++) {
  $NT = ($NT * ($i+1))%1000000007;
}
$MT=1;
for($i=1;$i<$M;$i++) {
  $MT = ($MT * ($i+1))%1000000007;
}
if (abs($N - $M) > 1) {
  printf("%d\n",0);
  exit;
}
if ($N == $M) {
  printf("%d\n",(2*$NT*$MT)%1000000007);
}
else {
  printf("%d\n",($NT*$MT)%1000000007);
}


Measured memory_bytes: 3700
def abc(S, W):
    # 答えの準備
    ans = 'unsafe'
    
    # 比較
    if W < S:
        ans = 'safe'
    
    # 答え
    return(ans)


# バッチスタート
if __name__ == "__main__":
    # 標準入力処理
    # 1行目の入力を空白で分割された2つの数値として扱う
    S, W = map(int, input().split())
    
    # 関数呼び出し
    f = abc(S, W)
    
    # 答えの出力
    print(f)


Measured memory_bytes: 9136
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    int ans = 0;
    for (int i = 0; i < 2; i++)
    {
        if (a > b)
        {
            ans += a;
            a--;
        }
        else
        {
            ans += b;
            b--;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  string s;
  cin >> s;
  if (s.back() == 's') {
    s += 'e';
  }
  s += 's';
  cout << s << endl;

  return 0;
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> result(h, vector<char>(w));
    vector<int> ignore_row(h, true);
    vector<int> ignore_column(w, true);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> result[i][j];
            if (result[i][j] == '#')
            {
                ignore_row[i] = false;
                ignore_column[j] = false;
            }
        }
    }
    for (int i = 0; i < h; i++)
    {
        if (ignore_row[i]) continue;
        for (int j = 0; j < w; j++)
        {
            if (ignore_column[j]) continue;
            cout << result[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a , b;
  	cin >> a >> b;
  	long long int i=0,n = a.size(),count=0;
  	for(i=0;i<n;i++){
    	if(a[i]!=b[i]){count++;}
    }
  cout << count << endl;
}

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

using namespace std;

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

const double PI=3.14159265358979323846;

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

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

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

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


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

    s64 n, m;
    cin >> n >> m;
    vs64 x(n), y(m);
    rep (i, n)
    {
        cin >> x[i];
        if (x[i] < 0) x[i] += MOD;
    }
    rep (i, m)
    {
        cin >> y[i];
        if (y[i] < 0) y[i] += MOD;
    }

    s64 xadd, xsub, yadd, ysub;
    xadd = xsub = yadd = ysub = 0;
    rep (i, n)
    {
        xadd = (xadd + x[i] * i % MOD) % MOD;
        xsub = (xsub + x[n - i - 1] * i % MOD) % MOD;
    }
    xsub = MOD - xsub;
    rep (i, m)
    {
        yadd = (yadd + y[i] * i % MOD) % MOD;
        ysub = (ysub + y[m - i - 1] * i % MOD) % MOD;
    }
    ysub = MOD - ysub;

    cout << (((xadd + xsub) % MOD) * ((yadd + ysub) % MOD)) % MOD << "\n";
    return 0;
}



Measured memory_bytes: 1792
import numpy as np

N,M=map(int,input().split())
P=[0]*M
Y=[0]*M
ans=[0]*M
cityList=[[] for i in range(N)]

for i in range(M):
    P[i],Y[i]=map(int,input().split())

for i in range(M):
    cityList[P[i]-1].append((P[i],Y[i],i))

for i in range(N):
    cityList[i]=sorted(cityList[i])

for i in range(N):
    for j,item in enumerate(cityList[i]):
        ans[item[2]]="%06d%06d" % (item[0],j+1)

for i in range(M):
    print(ans[i])


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

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

    int A, B, C;
    cin >> A >> B >> C;
    if (A==B) cout << C << endl;
    else if (B==C) cout << A << endl;
    else cout << B << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define in inline
#define int long long
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,m,ans[100002],A,B,C,dp[100002][3][3][3],pre[100002][3][3][3];
char s[12];
long long sum;
inline void work(re int x,re int a,re int b,re int c){
	if(x==0)return;
	re int xx=pre[x][a][b][c];
	if(xx==1)++a,--b;
	if(xx==2)--a,++b;
	if(xx==3)++a,--c;
	if(xx==4)--a,++c;
	if(xx==5)++b,--c;
	if(xx==6)--b,++c;
	work(x-1,a,b,c);
	if(xx==2||xx==4)puts("A");
	if(xx==1||xx==6)puts("B");
	if(xx==3||xx==5)puts("C");
}
signed main(){
	n=read();A=read();B=read();C=read();
//	if(A+B+C==2ll)return 1;
	if(A+B+C!=2ll){
		for(re int i=1;i<=n;++i){
			scanf("%s",s+1);
			if(s[1]=='A'&&s[2]=='B'){
				if(A>B){--A;++B;ans[i]=2;
				}
				else{
					if(B==0){
						puts("No");
						return 0;
					}
					--B;++A;
					ans[i]=1;
				}
			}
			if(s[1]=='A'&&s[2]=='C'){
				if(A>C){
					--A;++C;
					ans[i]=3;
				}
				else{
					if(C==0){
						puts("No");
						return 0;
					}
					--C;++A;
					ans[i]=1;
				}
			}
			if(s[1]=='B'&&s[2]=='C'){
				if(B>C){
					--B;++C;
					ans[i]=3;
				}
				else{
					if(C==0){
						puts("No");
						return 0;
					}
					--C;++B;
					ans[i]=2;
				}
			}
		}
		puts("Yes");
		for(re int i=1;i<=n;++i){
			if(ans[i]==1)puts("A");
			if(ans[i]==2)puts("B");
			if(ans[i]==3)puts("C");
		}
	}
	else{
		dp[0][A][B][C]=1;
		for(re int ii=1;ii<=n;++ii){
			scanf("%s",s+1);
			if(s[1]=='A'&&s[2]=='B'){
				for(re int i=0;i<=1;++i){
					for(re int j=1;j<=2;++j){
						for(re int k=0;k<=2;++k){
							if(dp[ii-1][i+1][j-1][k]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=1;
							}
						}
					}
				}
				for(re int i=1;i<=2;++i){
					for(re int j=0;j<=1;++j){
						for(re int k=0;k<=2;++k){
							if(dp[ii-1][i-1][j+1][k]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=2;
							}
						}
					}
				}
			}
			if(s[1]=='A'&&s[2]=='C'){
				for(re int i=0;i<=1;++i){
					for(re int j=0;j<=2;++j){
						for(re int k=1;k<=2;++k){
							if(dp[ii-1][i+1][j][k-1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=3;
							}
						}
					}
				}
				for(re int i=1;i<=2;++i){
					for(re int j=0;j<=2;++j){
						for(re int k=0;k<=1;++k){
							if(dp[ii-1][i-1][j][k+1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=4;
							}
						}
					}
				}
			}
			if(s[1]=='B'&&s[2]=='C'){
				for(re int i=0;i<=2;++i){
					for(re int j=0;j<=1;++j){
						for(re int k=1;k<=2;++k){
							if(dp[ii-1][i][j+1][k-1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=5;
							}
						}
					}}
				for(re int i=0;i<=2;++i){
					for(re int j=1;j<=2;++j){
						for(re int k=0;k<=1;++k){
							if(dp[ii-1][i][j-1][k+1]){
								dp[ii][i][j][k]=1;
								pre[ii][i][j][k]=6;
							}
						}
					}
				}
		}
		}
		for(re int i=0;i<=2;++i){
			for(re int j=0;j<=2;++j){
				for(re int k=0;k<=2;++k){
					if(dp[n][i][j][k]){
						puts("Yes");
						work(n,i,j,k);
						return 0;
					}
				}
			}
		}
		puts("No");
	}
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n][26];
  memset(a, 0, sizeof a);
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < s.length(); j++) {
      a[i][s[j] - 'a']++;
    }
  }
  s = "";
  for (int i = 0; i < 26; i++) {
    int x = 100;
    for (int j = 0; j < n; j++) {
      x = min(x, a[j][i]);
    }
    for (int j = 0; j < x; j++) {
      s += 'a' + i;
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 256