akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(){
  int S;
  cin >> S;
  string result;
  int up = S/100;
  int down = S % 100;
  if((up >= 13) && (down >= 13)) result = "NA";
  else if((up >= 13) && (1 <= down && down <=12)) result = "YYMM";
  else if((up >= 13) && (down == 0)) result = "NA";
  else if((1 <= up && up <= 12) && (13 <= down)) result = "MMYY";
  else if((1 <= up && up <= 12) && (1 <= down && down <=12)) result = "AMBIGUOUS";
  else if((1 <= up && up <= 12) && (down == 0)) result = "MMYY";
  else if((up == 0) && (down >= 13)) result = "NA";
  else if((up == 0) && (1 <= down && down <=12)) result ="YYMM";
  else if((up == 0) && (down == 0)) result = "NA";
  cout << result << endl;
  return 0;
}



Measured memory_bytes: 256
import math
a,b,c = map(int, input().split())
sin_c = math.sin(math.radians(c))
S = a*b*sin_c/2
#print(S)
cos_c = math.cos(math.radians(c))
L = a + b + (a**2+b**2-2*a*b*cos_c)**0.5

h = b*sin_c

print(S,L,h)


Measured memory_bytes: 5720
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif
const long long mod = 1e9+7; // CHECK
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
#define ll long long
const int INT_INF = 1e9+9;
const ll LL_INF = 2e18;
const int N = 3e5+9; // check N, mod

signed main() {  
    ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    vector<int> a(n);
    vector<int> pos(n+1);
    pos[n] = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
        pos[a[i]] = i;
    }
    int ans = 1;
    int prv = 0;
    for (int i = 0; i < n; i++) {
        if (pos[i] > pos[i+1]) {
            ans = max(ans, i - prv + 1);
            prv = i+1;
        }
    }
    cout << n - ans << '\n';


    

    

    return 0;
}



Measured memory_bytes: 4748
import re

n = int(raw_input())

ab = 0
a = 0
b = 0

ans = 0
for i in range(0, n):
    s = raw_input()
    find_list = re.findall("AB", s)
    ans += len(find_list)

    if re.search("^B.*A$", s) is not None:
        ab += 1
        continue

    if re.search(".*A$", s) is not None:
        a += 1

    if re.search("^B.*", s) is not None:
        b += 1

if ab > 0:
    ans += ab - 1
    if a > 0:
        ans += 1
        a -= 1
    if b > 0:
        ans += 1
        b -= 1
    ans += min(a, b)

else:
    ans += min(a, b)

print(ans)


Measured memory_bytes: 2948
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // llの1次元の型に vi という別名をつける
using vvi = vector<vi>; // llの2次元の型に vvi という別名をつける
 
ll n;
ll M=1e5+1;
 
//bit全探索
vi bt;
void setbit(ll i){
  bt.clear();
  for(ll tmp=0;i>0;i/=2){
    if (i%2==1) bt.push_back(tmp);
    tmp++;
  }
}
 
 
 
 
int main(){
  ll ans=0,q;
  cin >>n;
  n++;
  ll nlg=ceil(log2(n));
  vi V(n),W(n);
  REP(i,n-1) cin>>V[i+1]>>W[i+1];
 
  cin >>q;
  vi u(q),L(q);
  REP(i,q) cin>>u[i]>>L[i];
 
  //上半分
  ll nhi=nlg-(nlg/2);
  if (nhi==9)nhi=10;
  vvi data(1LL<<nhi, vi(M));  // N * M の2次元配列
 
  for(ll i=1;i<(1LL<<nhi);i++){
    for(ll j=0;j<M;j++){
      if ((j-W[i])>=0)
      {
        data[i][j]=max(data[i/2][j-W[i]]+V[i],data[i/2][j]);
      }
      else
      {
        data[i][j]=data[i/2][j];
      }
    }
  }
 
 
ll uiv[10];
ll wuiv=0;
 
 
//下半分
for(ll loop=0;loop<q;loop++){
  ll uidx=u[loop];
  if (uidx<(1LL<<nhi)){
    cout<<data[uidx][L[loop]]<<endl;
  }else{//上＋下
    ll maxval=0;
    //vi uiv;
    ll nn=0;
    wuiv=0;
    for(;;uidx/=2){
      if (uidx<(1LL<<nhi))break;
      uiv[wuiv]=uidx;
      wuiv++;
      nn++;
    }
 
    ll bn=1<<nn;
    for(ll i=0;i<bn;i++){
      setbit(i);
      ll tmpw=0;
      ll tmpv=0;
      /*
      for(ll j=0;j<nn;j++){
        if (i&(1<<j)){
          tmpv+=V[uiv[j]];
          tmpw+=W[uiv[j]];
        }
      }
      */
      for (auto j : bt) {
        tmpv+=V[uiv[j]];
        tmpw+=W[uiv[j]];
      }
      if (tmpw<=L[loop]){
        maxval=max(data[uidx][L[loop]-tmpw]+tmpv,maxval);
      }
    }
 
    cout<<maxval<<endl;
  }
 
 
 
 
 
 
 
 
 
 
 
 
}
 
 
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

int solution(vector<int>& A, vector<int>& B)
{
    int N = A.size();
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if(N%2 == 1) return B[N/2]-A[N/2]+1;
    else{
        // /2 ではなく足し上げたものが中央値だと思う
        int l = A[N/2-1]+A[N/2];
        int r = B[N/2-1]+B[N/2];
        return r-l+1;
    }
}

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

    cout << solution(A, B) << endl;

    return 0;
}

Measured memory_bytes: 4840
require 'set'

def s()
  gets().chomp
end
def i()
  gets.to_i
end
def ls()
  gets.split
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
def inli()
  n = gets.to_i
  as = []
  n.times {
    as << gets.split.map(&:to_i)
  }
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end

def eratosthenes(size)
  prime_list = []
  is_prime = Array.new(size, true)
  is_prime[0] = false
  is_prime[1] = false

  2.upto(size-1){|i|
    if is_prime[i]
      prime_list << i
      (2).upto((size.to_f/i).ceil-1){|j|
        is_prime[j*i] = false
      }
    end
  }
  [prime_list, is_prime]
end

def dijkstra(s, e, cost)
  size = cost.length
  if s==e
    return 0
  end
  dp = {}
  dp[s] = 0
  undefined_node = {}
  size.times{|i|
    if i != s
      undefined_node[i] = cost[s][i]
    end
  }
  while undefined_node.length != 0
    min = undefined_node.min_by{|_, v| v}
    stock = {}
    temp = undefined_node.clone
    temp.each{|k, v|
      if min[1] == v
        undefined_node.delete(k)
        if k == e
          return v
        end
        dp[k] = v
        stock[k] = v
      end
    }

    stock.each{|k, v|
      undefined_node.each{|k2, v2|
        undefined_node[k2] = v + cost[k][k2] < v2 ?  v + cost[k][k2] : v2
      }
    }
  end
end

def get_bits(len)
  res =  []
  (2**len).times{|i|
    res << i.to_s(2).rjust(len, '0')
  }
  res
end

def get_GCD(m, n)
  tmp = [n, m].max
  n = [n, m].min
  m = tmp
  while n != 0
    tmp = m % n
    m = n
    n = tmp
  end
  m
end
def fact(n, m=0)
  (m+1..n).inject(1,:*)
end
def perm(n, r)
  fact(n, n-r)
end
def comb(n, m)
  fact(n, n-m)/fact(m)
end

def matrix(n, m=n, init=0)
  Array.new(n).map{Array.new(m,init)}
end
class UnionFind
  def initialize(size)
    @par = (0..size).to_a
    @size = Array.new(size+1, 1)
  end
  def root(x)
    while @par[x] != x
      @par[x] = @par[@par[x]]
      x = @par[x]
    end
    x
  end
  def merge(a, b)
    a = root(a)
    b = root(b)
    if a == b
      return false
    end
    if @size[a] < @size[b]
      tmp = a
      a = b
      b = tmp
    end
    @size[a] += @size[b]
    @par[b] = a
    true
  end

  def is_same(a, b)
    root(a) == root(b)
  end

  def size(a)
    @size[root(a)]
  end
end


n, m, k = li()
fs = []
m.times do
  fs << li()
end
bs = []
k.times do
  bs << li()
end

uf = UnionFind.new(n)
map = {}
fs.each do |a,b|
  if map.has_key?(a)
    map[a] << b
  else
    map[a] = Set.new([b])
  end
  if map.has_key?(b)
    map[b] << a
  else
    map[b] = Set.new([a])
  end
  uf.merge(a, b)
end

bs.each do |a,b|
  if map.has_key?(a)
    map[a] << b
  else
    map[a] = Set.new([b])
  end
  if map.has_key?(b)
    map[b] << a
  else
    map[b] = Set.new([a])
  end
end
res = []
1.upto(n) do |i|
  tmp = uf.size(i) - map.fetch(i, Set.new()).count{|j| uf.is_same(i, j)} - 1
  res << tmp
end
puts res.join(" ")


Measured memory_bytes: 105596
#include<bits/stdc++.h>
#define MX 105
#define ll long long int
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
using namespace std;
ll n,m,k,s[10005],g[105][105];
int main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    for(ll i=1;i<=k;i++)
    {
        scanf("%lld",&s[i]);
    }
    for(ll i=0,cur=1,f=0;i<n;i++)
    {
        if(f)
        {
            for(ll j=0;j<m;j++)
            {
                g[i][j]=cur;
                s[cur]--;
                if(s[cur]==0)
                    cur++;
            }
        }
        else
        {
            for(ll j=m-1;j>=0;j--)
            {
                g[i][j]=cur;
                s[cur]--;
                if(s[cur]==0)
                    cur++;
            }
        }
        f=1-f;
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            if(j>0)printf(" ");
            printf("%lld",g[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	int N;
	cin>>N;
	ll ans = 1;
	rep(i,N) ans *= 3;

	ll od = 1;
	rep(i,N){
		int x;
		cin>>x;
		if(x%2==0) od*=2;
	}
	cout<<ans-od<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n, t;
    cin >> n >> t;
    vector<pii> P(n);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        P[i] = pii(a, b);
    }
    sort(all(P));

    vi dp(t+1, 0);
    rep(i,n){
        int a = P[i].fi;
        int b = P[i].se;
        dp[t] = max(dp[t], dp[t-1] + b);
        RREP(j,a,t){
            dp[j] = max(dp[j], dp[j-a] + b);
        }
    }
    cout << dp[t] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 212345
char s[N];
vi v[2];

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

	REP(ii, 2){
		for(int i = 0;;){
			while(i < n && s[i] == 'x') i++;
			if(i >= n) break;
			v[ii].EB(i);
			i += c+1;
		}
		if((int)v[ii].size() > k) return 0;
		reverse(s, s+n);
	}
	
	reverse(ALL(v[1]));
	for(auto &i : v[1]) i = n-1-i;
	REP(i, k) if(v[0][i] == v[1][i]) printf("%d\n", v[0][i]+1);

	REP(i, 2){
		for(auto &j : v[i]) DEBUG("%d ", j);
		DEBUG("\n");
	}
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = (int)(1e9 + 123);
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e;

    map<int, int> cnt;
    cnt[a[0]] = 1;
    set<int> s = {-a[0], 1};

    int res = 1;
    rep(i, 1, n){
        int x = a[i];
        int v = -(*s.upper_bound(-x));
        if(v == -1){
            res++;
        }
        else {
            if(--cnt[v] == 0){
                s.erase(-v);
            }
        }
        s.insert(-x);
        cnt[x]++;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9856
import heapq
N, M = map(int, input().split())
*A, = map(int, input().split())
BC = [list(map(int, input().split())) for _ in range(M)]
BC = list(reversed(sorted(BC, key=lambda x:x[1])))
#print(BC)
hq = []
for i in range(N):
    heapq.heappush(hq, A[i])

flag = False
for bc in BC:
    for i in range(bc[0]):
        tmp = heapq.heappop(hq)
        if tmp < bc[1]:
            heapq.heappush(hq, bc[1])
        else:
            heapq.heappush(hq, tmp)
            flag = True
            break
    if flag:
        break

print(sum(hq))

Measured memory_bytes: 33740
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
X = LI()

ans = mod
for i in range(1, 101):
    tmp = 0
    for x in X:
        tmp += (x - i) ** 2
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 66540
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n;
long long ans;
int x,y;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		ans+=y-x+1;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int w[n];
    for(int i=0;i<n;i++){
        cin >> w[i];
    }
    int result = 100000;
    for(int i=0;i<n;i++){
        int sum1 = 0;
        for(int k=0;k<=i;k++){
            sum1 += w[k];
        }
        int sum2 = 0;
        for(int j=i+1;j<n;j++){
            sum2 += w[j];
        }
        result = min(result, abs(sum1 - sum2));
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



string s, t;
ll k;

signed main() {
	cin >> s >> k;
	if (k<=s.size()) t = s.substr(0,k);
	if (k<=s.size() && count(all(t),'1')==k)
		return cout << 1 << ln, 0;
	each(i,s) if (i!='1') return cout << i << ln, 0;
}

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

#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))

typedef long long ll;

int main(){
    ll a; double b;  cin >> a >> b;
    ll bb = floor(100*b + 0.01);
    ll ans = (a * bb) / 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[MAXn];
map<int,int> cnt;
int main(){
  IOS();
  int n,m;
  ll ans=0;
  cin>>n>>m;
  int tmp=0;
  cnt[0]++;
  REP(i,n){
    cin>>d[i];
    d[i]%=m;
    tmp=(tmp+d[i])%m;
    ans+=cnt[tmp];
    cnt[tmp]++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cmath>
#define INF 

typedef long long ll;

int main() {
	char a;
	std::cin >> a;
	if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o') {
		std::cout << "vowel" << std::endl;
	}
	else {	
		std::cout << "consonant" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
    int x,a,b;
    cin>>x;
    for (int i=0;i<=x;i++)
        for (int j=-i;j<=i;j++)
        {
            if (i*i*i*i*i-j*j*j*j*j==x){

                cout<<i<<" "<<j;
            exit(0);}
        }

    return 0;
}


Measured memory_bytes: 3624
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

#define PI 3.14159265358979323846
int main()
{
  int r;
  scanf("%d", &r);
  printf("%lf\n", 2 * PI * r);
}

Measured memory_bytes: 1704
R, C = map(int, input().split())
sheet = []
for r in range(R):
    row = list(map(int,input().split()))
    s = sum(row)
    row.append(s)
    sheet.append(row)

last_row = [0 for c in range(C + 1)] 

for r in range(R):
  for c in range(C + 1):
    last_row[c] += sheet[r][c]
sheet.append(last_row)

for row in sheet:
  print(*row, sep = ' ')


Measured memory_bytes: 6232
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String t = sc.next();
    int n =s.length(), res = 0;
    
    for(int i = 0; i < n; i++) {
      if(s.charAt(i) != t.charAt(i))
        res++;
    }
    
    System.out.println(res);
  }
}


Measured memory_bytes: 41348
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
    string s, tmp, tmp2;
    long long i=0, ans=0, n;
    map<string, int> mp;
    cin >> s;
    n=s.size();
    for(i=0;i<n;i++){
        tmp=tmp+s[i];
        if(tmp!=tmp2){
            ans++;
            tmp2=tmp;
            tmp.clear();
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Union Find tree
//-------------------------------------------------
class UnionFind
{
private:
    ::std::vector<int> par;
    ::std::vector<int> rank;
public:
    UnionFind(int n):par(n), rank(n){
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int root(int x){
        if (par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x)==root(y);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx==ry) return;
        if (rank[rx]>rank[ry]){
            par[ry] = rx;
        }else{
            par[rx] = ry;
            if (rx==ry) rank[ry]++;
        }
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    UnionFind uf(15);
    uf.unite(1,3);
    uf.unite(1,5);
    uf.unite(1,7);
    uf.unite(1,8);
    uf.unite(1,10);
    uf.unite(1,12);
    uf.unite(4,6);
    uf.unite(4,9);
    uf.unite(4,11);
    int x,y; cin>>x>>y;
    if (uf.same(x,y)){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,m,k,a[maxn],b[maxn],amn=1e9,bmn=1e9,ans=1e9;
int main(){
	n=read();m=read();k=read();
	FOR(i,1,n) amn=min(amn,a[i]=read());
	FOR(i,1,m) bmn=min(bmn,b[i]=read());
	while(k--){
		int x=read(),y=read(),c=read();
		ans=min(ans,a[x]+b[y]-c);
	}
	ans=min(ans,amn+bmn);
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
/**
 *   created: 22 May 2019  23:46:41
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n,w;
		cin>>n>>w;
		vector< pair<long long, long long> > v(n);
		rep(i,0,n){
			int wt,val;
			cin>>wt>>val;
			v[i] = {wt,val};
		}
		vector< vl > mem(n, vl(w+1,0));
		if(w-v[0].first>=0)
			mem[0][w-v[0].first] = v[0].second;
		rep(i,1,n){
			rep(j,0,w+1){
				if(j-v[i].first>=0)
					mem[i][j-v[i].first] = max(v[i].second + mem[i-1][j],mem[i-1][j-v[i].first]);
			}
			rep(j,0,w+1)
				if(mem[i][j]==0)
					mem[i][j] = mem[i-1][j];
		}
		ll maxi=0;
		rep(i,0,w+1)
			maxi = max(mem[n-1][i],maxi);
		// rep(i,0,w+1){
		// 	rep(j,0,n)
		// 		cout<<mem[j][i]<<" ";
		// 	cout<<endl;
		// }
		cout<<maxi;
	}
	return 0;
}


Measured memory_bytes: 79488
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        int num = GetInput.getInt();
        while (num>0){
            if (num%10 == 7){
                System.out.println("Yes");
                return;
            }
            num = num/10;
        }
        System.out.println("No");
    }
}


class GetInput {
    static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

    static char[] getCharArray() {
        char[] charArray;
        try {
            StringBuilder string = getInputString();
            charArray = new char[string.length()];
            for (int i = 0; i < string.length(); i++) {
                charArray[i] = string.charAt(i);
            }
            return charArray;
        } catch (Exception e) {
            e.printStackTrace();
        }
        charArray = new char[0];
        return charArray;
    }

    static int[] getArrayInt() {
        String[] string;
        int[] array;
        try {
            string = bufferedReader.readLine().split("\\s+");
            array = new int[string.length];
            for (int i = 0; i < string.length; i++) {
                array[i] = Integer.parseInt(string[i]);
            }
            return array;
        } catch (IOException e) {
            e.printStackTrace();
        }

        int[] arra = new int[2];
        return arra;
    }

    static int getInt() {
        try {
            String string = bufferedReader.readLine();
            return Integer.parseInt(string);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return 0;
    }

    static StringBuilder getInputString() {
        try {
            StringBuilder string = new StringBuilder();
            string.append(bufferedReader.readLine());
            return string;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new StringBuilder();
    }

    static long getLongInput() {
        try {
            String string = bufferedReader.readLine();
            return Long.parseLong(string);
        } catch (IOException e) {
            e.printStackTrace();
        }

        return 0;
    }

    static long[] getLongArrayInput() {
        String[] string;
        long[] array;
        try {
            string = bufferedReader.readLine().split("\\s+");
            array = new long[string.length];
            for (int i = 0; i < string.length; i++) {
                array[i] = Long.parseLong(string[i]);
            }
            return array;
        } catch (IOException e) {
            e.printStackTrace();
        }

        long[] arra = new long[2];
        return arra;
    }
}


Measured memory_bytes: 32548
#include <stdio.h>

/*
show that gcd(a,b)=gcd(b,a%b)
let c=gcd(a,b), a=bd+r>b
then r=a-bd has factor c

assume c!=gcd(b,r)
then there exists e>c, s.t. e is a factor of b and r
since a=bd+r, e is also a factor of a
e is a factor of a and b, which contradict to c=gcd(a,b)
therefore c=gcd(b,r)

what if a<b?
gcd(2, 6)
=gcd(6, 2%6)=gcd(6, 2)
 */
int gcd(int a, int b) {
    return b==0?a:gcd(b, a%b);
}

int main() {
    int a,b;
    scanf("%d %d", &a, &b);
    printf("%d\n", gcd(a,b));
    return 0;
}



Measured memory_bytes: 2728
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    int p = 1;
    int ans;


    foreach (ai ; a) {
        if (ai == p) {
            p++;
        }
        else {
            ans++;
        }
    }

    writeln(ans == n ? -1 : ans);
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 11408
package main

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

func main() {
	n := nextInt()
	S := make([]string, n)
	for i := 0; i < n; i++ {
		S[i] = nextString()
	}

	var ans []rune
	for r := 'a'; r <= 'z'; r++ {
		min := 50
		for _, s := range S {
			var cnt int
			for _, sr := range s {
				if sr == r {
					cnt++
				}
			}

			if cnt < min {
				min = cnt
			}
		}

		for i := 0; i < min; i++ {
			ans = append(ans, r)
		}
	}

	fmt.Println(string(ans))
}

type runeSlice []rune

func (p runeSlice) Len() int           { return len(p) }
func (p runeSlice) Less(i, j int) bool { return p[i] < p[j] }
func (p runeSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

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

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// ---------- Util.


Measured memory_bytes: 640
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N] ;



int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code

        cin>>n;
        sl st;
        for(i=0;i<n;i++)
        {
            cin>>arr[i];
           // st.insert(arr[i]);
        }
        cnt=0;
        for(i=0;i<n;i++)
        {
               for(j=i+1;j<n;j++)
               {
                      for(k=j+1;k<n;k++)
                      {
                             if(arr[i]+arr[j]>arr[k]&&arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[i]!=arr[k])
                                    if(arr[j]+arr[k]>arr[i])
                                     if(arr[k]+arr[i]>arr[j])
                                    cnt++;
                      }
               }
        }
        cout<<cnt<<endl;

    //code
    return 0;
}




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

if n == 0:
    print(0)
    quit()
base = []
while n != 1:
    if n % -2 == 0:
        base.append('0')
        n //= -2
    else:
        base.append('1')
        n -= 1
        n //= -2
base.append('1')
base.reverse()
ans = ''.join(base)
print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func alphabetNum(c string)int{
	alphabet := map[string]int {
		"a":1,
		"b":2,
		"c":3,
		"d":4,
		"e":5,
		"f":6,
		"g":7,
		"h":8,
		"i":9,
		"j":10,
		"k":11,
		"l":12,
		"m":13,
		"n":14,
		"o":15,
		"p":16,
		"q":17,
		"r":18,
		"s":19,
		"t":20,
		"u":21,
		"v":22,
		"w":23,
		"x":24,
		"y":25,
		"z":26,
	}
	return alphabet[c]
}

func alphabetIdx(n int)string{
	alphabet := map[int]string {
		1:"a",
		2:"b",
		3:"c",
		4:"d",
		5:"e",
		6:"f",
		7:"g",
		8:"h",
		9:"i",
		10:"j",
		11:"k",
		12:"l",
		13:"m",
		14:"n",
		15:"o",
		16:"p",
		17:"q",
		18:"r",
		19:"s",
		20:"t",
		21:"u",
		22:"v",
		23:"w",
		24:"x",
		25:"y",
		26:"z",
	}
	return alphabet[n]
}

func main() {
	var c string
	fmt.Scan(&c)

	nextAlphabet := alphabetNum(c) + 1
	
	fmt.Println(alphabetIdx(nextAlphabet))
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>
#include <type_traits>
#include <map>
#include <cstdio>
#include <string>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

// 最大公約数算出
int calc_gcd(const vector<int> vec){
	int gcd = *min_element(vec.begin(), vec.end());
	for (const int ele: vec){
		gcd = gcd_euclid(gcd,ele);
	}
	return gcd;
}

// 最小公倍数
int calc_lcm(const vector<int> vec) {
	int tmp = 1;
	for (const int ele: vec){
		tmp *= ele;
	}
	int gcd = calc_gcd(vec);
	return tmp/gcd;
}

std::string join(const std::vector<std::string>& v, const char* delim = 0) {
  std::string s;
  if (!v.empty()) {
    s += v[0];
    for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += v[i];
    }
  }
  return s;
}

// nが奇数、偶数の場合の場合分け
// n & 1 ? odd : even

// distinctはsortしてunique + erase
// https://qiita.com/ysk24ok/items/30ae72f4f1060b088588
//sort(vec.begin(), vec.end());
//vec.erase(unique(vec.begin(), vec.end()), vec.end());


void run() {

	int a,b,c; get a;get b; get c;
	if (a < b) {
		if ((a < c && c < b)) {
			put "Yes";
		}else {
			put "No";
		}
	} else {
		if ((b < c && c < a)) {
			put "Yes";
		}else {
			put "No";
		}
	}


}

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


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,m; cin >> h >> w >> m;
  static vector<P<int,int>> b(m);
  int cntr[300001] = {};
  int cntc[300001] = {};
  int maxr=0,maxc=0;
  for(auto&e:b){
    cin >> e.first >> e.second;
    ChangeMax(maxr,++cntr[e.first]);
    ChangeMax(maxc,++cntc[e.second]);    
  }
  static uset<int>r,c;
  for(int i = 1; i <= h; ++i)if(maxr == cntr[i])r.insert(i);
  for(int i = 1; i <= w; ++i)if(maxc == cntc[i])c.insert(i);
  int cntd = 0;
  for(const auto&e:b)
    cntd += r.count(e.first)&&c.count(e.second);
  cout << maxr + maxc - (cntd == (ll)r.size()*(int)c.size()) << endl;
}


Measured memory_bytes: 35368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int m=min({a,b,c});
  int M=max({a,b,c});
  int n=a+b+c-m-M;
  cout << M-m << endl;
}

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

int main(){
	int n,rui[4],out;
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < 4;j++) rui[j] = 0;
		out = 0;
		while(out < 3){
			string s;
			cin >> s;
			if(s == "HIT"){
				rui[3] += rui[2];
				rui[2] = rui[1];
				rui[1] = rui[0];
				rui[0] = 1;
			}
			else if(s == "OUT") out++;
			else if(s == "HOMERUN"){
				rui[3] += rui[2] + rui[1] + rui[0] + 1;
				rui[2] = 0;
				rui[1] = 0;
				rui[0] = 0;
			}
		}
		cout << rui[3] << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;
    string s[3] =  {"Sunny", "Cloudy", "Rainy"};
    if(S == s[0]){
        cout << s[1] << endl;
    }else if(S == s[1]){
        cout << s[2] << endl;
    }else{
        cout << s[0] << endl;
    }
}

Measured memory_bytes: 888
#include<stdio.h>
int main()
{
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	
	int ax=a-x;
	int bx=b-x;
	
	if(ax<0){ax=ax*-1;}
	if(bx<0){bx=bx*-1;}
	
	if(ax<bx){printf("A");}
	if(ax>bx){printf("B");}

	return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
    static Scanner sc = new Scanner(System.in);
    static StringBuffer sb = new StringBuffer();
    public static void main(String args[]){
        int N=sc.nextInt(),M=sc.nextInt(),i=0,c;
        long a;
        TreeMap<Integer,Long> cost=new TreeMap<>();
        for(i=0;i<N;i++){
            c=sc.nextInt();
            a=sc.nextInt();
            if(!cost.containsKey(c)){
                cost.put(c,a);
            }else{
                cost.put(c,cost.get(c)+a);
            }
        }
        a=0;
        for(int k:cost.keySet()){
            long m=Math.min(M,cost.get(k));
            a+=k*m;
            M-=m;
            if(M==0)break;
        }
        System.out.println(a);
    }
}


Measured memory_bytes: 67236