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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 131072;

int d[MN];
pii ch[2][MN];
int N;
vector<pll> vec[MN];

void dfs(int v, ll x)
{
	if (d[v] == 0) {
		vec[v].eb(0LL, 0LL);
		return ;
	}
	int a = ch[0][v].fi, c1 = ch[0][v].se;
	int b = ch[1][v].fi, c2 = ch[1][v].se;
	dfs(a, x);
	dfs(b, x);

	if ((int)vec[a].size() == 0 || (int)vec[b].size() == 0) return ;

	if (vec[a].size() > vec[b].size()) {
		swap(a, b);
		swap(c1, c2);
	}

	int i = 0, i2 = 0;

	vector<pll> v1, v2;

	for (pll &p : vec[a]) { //a,b
		ll c = x - c1 - c2 - p.se;

		while (i+1 < vec[b].size() && vec[b][i+1].fi <= c) {
			++i;
		}

		if (vec[b][i].fi <= c) {
			v1.eb(p.fi + c1, vec[b][i].se + c2);
		}
	}

	for (pll &p : vec[a]) { //b,a
		ll c = x - c1 - c2 - p.fi;

		while (i2 < vec[b].size() && vec[b][i2].se > c) {
			++i2;
		}

		if (i2 < vec[b].size()) {
			v2.eb(vec[b][i2].fi + c2, p.se + c1);
		}
	}

	vector<pll> res;
	int num = v1.size() + v2.size();
	v1.eb(LLONG_MAX, -1LL); v2.eb(LLONG_MAX, -1LL);
	i = i2 = 0;

	rep(tt, num) {
		if (v1[i] < v2[i2]) res.eb(v1[i++]);
		else res.eb(v2[i2++]);
	}

	for (pll &p : res) {
		if (vec[v].size() == 0 || vec[v].back().se > p.se) {
			vec[v].eb(p);
		}
	}
}

bool f(ll x)
{
	rep(i, MN) vec[i].clear();
	dfs(0, x);
	return (int)vec[0].size() > 0;
}

int main() {
	cin >> N;

	rep(i, N-1) {
		int a, v;
		cin >> a >> v;
		--a;
		ch[d[a]++][a] = mp(i + 1, v);
	}

	ll ng = -1, ok = 1e11;

	while (ok - ng > 1) {
		ll m = (ok + ng) / 2;
		if (f(m)) {
			ok = m;
		} else {
			ng = m;
		}
	}

	cout << ok << endl;

	return 0;
}

Measured memory_bytes: 32132
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
import sys
import math
from collections import Counter
import itertools
import fractions
import datetime
from decimal import Decimal
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
L = LI()

L.sort()

if sum(L) - L[-1] > L[-1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5312
import itertools


def main():
    s = list(input())
    op = list(itertools.product(['+', '-'], repeat=3))
    for i in op:
        formula = s[0]
        for index, j in enumerate(i):
            formula += j
            formula += s[index + 1]
        if eval(formula) == 7:
            print(formula + "=7")
            return
    return


if __name__ == '__main__':
    main()


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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int n, k;	cin >> n >> k;
	int d;
	int num;
	bool list[n];
	int ans = 0;

	for( int i = 0; i < n; i++ )	list[i] = false;

	for( int i = 0; i < k; i++ ){
		cin >> d;
		for( int j = 0; j < d; j++ ){
			cin >> num;
			list[num-1] = true;
		}
	}

	for( int i = 0; i < n; i++ ){
		if( !list[i] )	ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  long N;
  cin >> N;

  vector<long> nums(N+1, 0);
  for (size_t n = 1; n <= N; ++n) cin >> nums[n];
  vector<uint8_t> check(N, 0);
  vector<long> res;
  res.reserve(N);
  for (size_t n = N; n > 0; --n) {
    long sum = 0;
    for (size_t i = 2 * n; i <= N; i += n) {
      if (check[i]) ++sum;
    }
    if ((sum & 1) ^ nums[n] == 1) {
      check[n] = 1;
      res.push_back(n);
    }
  }
  cout << res.size() << endl;
  if (res.size() != 0) {
    auto it = res.crbegin();
    cout << *it++;
    for (auto end = res.crend(); it != end; ++it) {
      cout << " " << *it;
    }
    cout << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str;
	str.reserve(1001);
	while(true) {
		getline(cin, str);
		if(str=="0") break;
		int sum=0;
		for(int i=0; i<str.length(); ++i) {
			sum+=str[i]-'0';
		}
		cout<<sum<<'\n';
	}

	return 0;
}



Measured memory_bytes: 3216
N,K = map(int,input().split())
H = [int(x) for x in input().split()]

def main(N,K,H):
    dp = [0]*N
    for i in range(1,N):
        L = [dp[j]+abs(H[i]-H[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)
    print(dp[-1])
main(N,K,H)


Measured memory_bytes: 13980
//解説
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const int MAX = 1000005;

int n;
vector<int> v;

int main(void) {
  cin >> n;
  rep(i,0,n) {
    int d;
    cin >> d;
    v.pb(min(d, 24-d));
  }
  sort(v.bg, v.en);
  rep(i,0,n) {
    if (i%2==1) v[i] = 24 - v[i];
  }
  v.pb(0); v.pb(24);
  
  sort(v.bg, v.en);
  int mn = 100;
  rep(i,0,n+1) mn = min(v[i+1]-v[i], mn);
  
  cout << mn << endl;
  
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define all(m) m.begin(), m.end()
#define uid uniform_int_distribution
#define init(m, x) memset(m, x, sizeof(m));
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a; cin>>a;
    ll mod = 1e9+7;
    ll e1 = 0, e2 = 0;
    for(; a--;){
        ll x; cin>>x;
        e1 += x;
        e2 += x*x;
        e1 %= mod;
        e2 %= mod;
    }
    ll o = (e1*e1-e2+mod)%mod;
    o = (o*500000004)%mod;
    cout<<o;
}

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

int main() {
  int N, next = 1, check = 0;
  cin >> N;
  vector<int> A(N);
  
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  
  for (int i = 0; i < N; i++) {
    next = A.at(next - 1);
    if (next == 2) {
      cout << i + 1;
      check = 1;
      break;
    }
  }
  
  if (check == 0)
    cout << -1;
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
if(s=="MON")
cout<<6;
if(s=="TUE")
cout<<5;
if(s=="WED")
cout<<4;
if(s=="THU")
cout<<3;
if(s=="FRI")
cout<<2;
if(s=="SAT")
cout<<1;
if(s=="SUN")
cout<<7;
return 0;
}

Measured memory_bytes: 256
Cost0 = 0
CostN = 0
length = 0

listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
X = listA[0][2]

for x in listA:
   length += len(x)

for i in range(length - 3):
    if (listA[1][i] < X):
        Cost0 = Cost0 +1
    else:
        CostN = CostN +1

if (Cost0 < CostN):
    print(Cost0)
else:
    print(CostN)


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

int main(){
    int n,s=0;
    string ans;
    cin >> n;
    vector<int> l(n);
    for(int i = 0;i < n;i ++){
        cin >> l[i];
        s += l[i];
    }
    sort(l.begin(),l.end());
    if(l[l.size()-1]<s-l[l.size()-1]) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/



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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;


void mymain(){
    int h,w,n;
    cin >> h >> w >> n;
    if(h<w)
        swap(h,w);
    cout << ceil((double)n/h) << endl;

}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t;
t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}



Measured memory_bytes: 256
N = int(input())
l = list(input())
w = [0]*N
if l[0] == "W":
    w[0] = 1
for i in range(1,N):
    if l[i] == "W":
        w[i] = w[i-1] + 1
    else:
        w[i] = w[i-1]
kosuu = N - w[N-1]
if kosuu == 0:
    print(0)
    exit()
print(w[kosuu-1])

Measured memory_bytes: 18212
import sys
inp=[i.strip() for i in sys.stdin.readlines()]
if len(inp)==1:
    if len(inp[0].split())==2:
        A,B=map(int,inp[0].split())
        print(max(2*A-1,2*B-1,A+B))
    else:
        S=inp[0]
        N=len(S)
        X=""
        Y=""
        for i in range(N):
            if i%2==0:
                X=X+"0"
                Y=Y+"1"
            else:
                X=X+"1"
                Y=Y+"0"
        A=0
        B=0
        for i in range(N):
            if X[i]!=S[i]:
                A+=1
            if Y[i]!=S[i]:
                B+=1
        print(min(A,B))
else:
    if len(inp[0].split())==1:
        N=int(inp[0])
        H=[int(i) for i in inp[1].split()]
        ans=1
        for i in range(1,N):
            flag=1
            for j in range(i):
                if H[j]>H[i]:
                    flag=0
                    break
            if flag==1:
                ans+=1
        print(ans)
    else:
        N,K=map(int,inp[0].split())
        S=inp[1]
        L=[0]
        tmp="1"
        for i in range(N):
            if tmp!=S[i]:
                L.append(1)
            else:
                L[-1]+=1
            tmp=S[i]
        if tmp=="0":
            L.append(0)
        M=len(L)
        if M<=2*K+1:
            print(N)
            exit()
        X=[0 for i in range(M+1)]
        for i in range(M):
            X[i+1]=L[i]+X[i]
        ans=0
        for i in range(0,M-2*K,2):
            ans=max(ans,X[i+2*K+1]-X[i])
        print(ans)


Measured memory_bytes: 3192
#include <stdio.h>
 
 int main(){

 int A[100];
 int val;
 int i,j,tmp,cmp;
 int count = 0;

 scanf("%d",&val);

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

 for(i = 0;i < val;i++){
     cmp = i;
	 for(j = i + 1;j < val;j++){
		 if(A[j]<A[cmp]){
			 cmp = j;
           }
	 }

	 if(A[i] > A[cmp]){
  tmp = A[cmp];
  A[cmp] = A[i];
  A[i] = tmp;
  count++;
	 }
 }

 for(i = 0;i < val - 1;i++)
   printf("%d ",A[i]);
 printf("%d\n",A[i]);
 printf("%d\n",count);

	 return 0;
    }

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if( a >= b && a >= c ){
    cout << a * 10 + b + c << endl;
  }else if( b >= a && b >= c ){
    cout << b * 10 + a + c;
  }else if( c >= a && c >= b ){
    cout << c * 10 + a + b;
  }
  
  
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
h_list = list(map(int, input().split()))
d_list = [ abs(T-0.006*x-A) for x in h_list ]
ans_d = max(d_list)
for i,x in enumerate(d_list):
    if ans_d >= x:
        ans_d = x
        ans = i
print(ans+1)

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

int main() {
  int N;
  cin >> N;
  long long ans=1;
  rep(i,N){
    ans *= (i+1);
    ans %= 1000000007;
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)

constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;



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

	ll n, a, b; cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i, 0, n) cin >> x[i];

	ll ans = 0;
	rep(i, 0, n - 1) {
		ll d = x[i + 1] - x[i];
		if (d * a > b) ans += b;
		else ans += d * a;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n,x;

    while((cin >> n >> x) && (n!=0 || x!=0)) {
        int sum = 0;
        for(int i=1;i<n;i++)
        {
            for(int j=i+1;j<x-i;j++)
            {
                int k = x-i-j;
                if(j<k && k<=n) {
                    sum += 1;
                }
            }
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 3092
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

class UnionFind {
public:
  const static int MAX_N = 100010;
  int par[MAX_N];
  int rank[MAX_N];
  int s[MAX_N];
  bool used[MAX_N];
  UnionFind() { init(); }
  UnionFind(int n) { init(n); }
  void init() { for(int i=0; i<MAX_N; ++i) par[i] = i, rank[i] = 0, s[i] = 1; }
  void init(int n) { for(int i=0; i<n; ++i) par[i] = i, rank[i] = 0, s[i] = 1; }
  int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y; s[y] = s[x] + s[y];
    } else {
      par[y] = x; s[x] = s[x] + s[y];
      if( rank[x] == rank[y] ) rank[x]++;
    }
  }
  int size(int x) { return s[find(x)];}
  bool same(int x, int y) { return find(x) == find(y);}
  int group(int n) {
    REP(i, n) used[find(i)] = true;
    int ret = 0;
    REP(i, n) if(used[i]) ret++;
    return ret;
  }
};
UnionFind uf;

VI a[10010];
signed main(void)
{
  while(true) {
    int n, m;
    cin >> n >> m;
    if(!n) break;
    REP(i, m) {
      int x, y, z;
      cin >> x >> y >> z;
      x--, y--;
      a[i] = {z, x, y};
    }
    sort(a, a+m);
    if(n == 2) {
      cout << a[0][0] << endl;
      continue;
    }

    uf.init(n);
    VI v;
    REP(i, m) {
      if(!uf.same(a[i][1], a[i][2])) {
        v.PB(a[i][0]);
        uf.unite(a[i][1], a[i][2]);
      }
    }
    sort(ALL(v));
    cout << v[n/2-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 5960
#!/usr/bin/env python3

import sys
from collections import namedtuple

Query = namedtuple("Query", ("s", "c"))

DEBUG = False


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

def read_int():
    return int(sys.stdin.readline())

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def checkq(n, num, queries):
    digits = []
    if num == 0:
        digits = [0]
    while num > 0:
        digits.append(num % 10)
        num //= 10
    if len(digits) != n:
        return False
    for q in queries:
        if digits[-q.s] != q.c:
            return False
    return True


def main():
    n, m = read_int_list()
    queries = []
    for _ in range(0, m):
        queries.append(Query(*read_int_list()))
    for i in range(0, 1000):
        if checkq(n, i, queries):
            print(i)
            return
    print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3436
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))


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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int i,j,k,n;
	cin>>n;
	ll a[n];
	REP(i,0,n-1) cin>>a[i];
	sort(a,a+n);
	int ans=0;
	REP(i,0,n-1){
		REP(j,i+1,n-1){
			REP(k,j+1,n-1){
				if(a[i]<a[j]&&a[j]<a[k]&&a[i]+a[j]>a[k]) ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3652
import fractions

def Lcm(a,b):
    return a*b//fractions.gcd(a,b)
def Kosu(min,max,k):
    if(min%k==0):
        tyousei=1
    return max//k-(min-1)//k

min,max,a,b=map(int,input().split())
c=Lcm(a,b)
print(max+1-min-Kosu(min,max,a)-Kosu(min,max,b)+Kosu(min,max,c))

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

using namespace std;

#define ll long long

int main()
{
	int N;
	cin >> N;
	vector < ll > H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	int ans = 0;

	for (int i = 0; i < N; i++) {
		ll currentHeight = H[i];
		int step = 0;
		for (int j = i + 1; H[j] <= currentHeight && j < N; j++) {
			step++;
			currentHeight = H[j];
		}
		i += step;
		ans = max(ans, step);
	}

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


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                if (input.Any(a => a < 0)) break;

                DateTime date1 = new DateTime(input[0], input[1], input[2]);
                DateTime date2 = new DateTime(input[3], input[4], input[5]);

                TimeSpan ts = date2 - date1;

                sb.AppendLine(ts.Days.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9516
from collections import defaultdict
import sys

def read_int():
    l = sys.stdin.readline().rstrip('\n').split(' ')
    return int(l[0])

def read_int_list():
    l = sys.stdin.readline().rstrip('\n').split(' ')                                                  
    return [int(i) for i in l]

N = read_int()
A = read_int_list()
Q = read_int()                                                                                        
BC = []
for _ in range(Q):                                                                                    
    BC.append(read_int_list())                                                                        

_sum = sum(A)                                                                                         

n2c = defaultdict(int)                                                                                

for a in A:                                                                                           
    n2c[a] += 1                                                                                       

for bc in BC:                                                                                         
    b = bc[0]                                                                                         
    c = bc[1]                                                                                         
    b_cnt = n2c[b]                                                                                    
    n2c[b] = 0                                                                                        
    n2c[c] += b_cnt                                                                                   
    _sum += b_cnt * (c - b)                                                                           
    print(_sum)                                                                                       




Measured memory_bytes: 38820
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)


def main():
    k = int(input())
    s = input()
    if len(s) > k:
        print(s[:k] + "...")
    else:
        print(s)

main()


Measured memory_bytes: 9448
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

template <class T>
struct BIT {
    vector<T> a;
    BIT(int size) : a(size, 0) {}
    T sum(int r) const {
        T sm = 0;
        for (--r; r >= 0; r = (r & r + 1) - 1)
            sm += a[r];
        return sm;
    }
    T sum(int l, int r) const {
        return sum(r) - sum(l);
    }
    T at(int i) const {
        return sum(i, i + 1);
    }
    void add(int i, T v) {
        for (; i < (int)a.size(); i |= i + 1)
            a[i] += v;
    }
    void set(int i, T v) {
        add(i, v - at(i));
    }
};

template <class T>
struct BIT2 {
    BIT<T> a, b;
    BIT2(int size) : a(size), b(size) {}
    T sum(int r) const {
        return a.sum(r) + b.sum(r) * r;
    }
    T sum(int l, int r) const {
        return sum(r) - sum(l);
    }
    T at(int i) const {
        return sum(i, i + 1);
    }
    void _add(int r, T v) {
        a.add(r, v * r);
        b.add(r, -v);
    }
    void add(int l, int r, T v) {
        _add(l, -v);
        _add(r, v);
    }
    void add(int i, T v) {
        add(i, i + 1, v);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    BIT2<long long> bit(n);
    while (q--) {
        int com, s, t, x;
        cin >> com >> s >> t;
        --s;
        if (com) {
            cout << bit.sum(s, t) << endl;
        } else {
            cin >> x;
            bit.add(s, t, x);
        }
    }
    return 0;
}

Measured memory_bytes: 4344
#include <stdio.h>
#define swap(type, x, y) do{ type t = x; x = y; y = t; }while(0)

void quick(int mai[], int left, int right, int sub[]){
  int pl = left, pr = right, x = mai[(left + right) / 2];
  do{
    while(mai[pl] < x)  pl++;
    while(mai[pr] > x)  pr--;
    if(pl <= pr){
      swap(int, mai[pl], mai[pr]);
      swap(int, sub[pl], sub[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(mai, pl, right, sub);
  if(left < pr)   quick(mai, left, pr, sub);
}

int main(){
  int n;  scanf("%d", &n);
  int a[200005], b[200005];
  for(int i=1; i<=n; i++)
    scanf("%d %d", a+i, b+i);

  quick(b, 1, n, a);

  int ans = 1, now = 0;
  for(int i=1; i<=n; i++)
    if(now + a[i] > b[i]){
      ans = 0;
      break;
    }else{
      now += a[i];
    }

  printf("%s\n", ans ? "Yes" : "No");

  return 0;
}
  


Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
const int maxN = 2e5 + 10;
using namespace std;

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

    int cnt = 0;

    for(auto itr = mp.begin(); itr != mp.end(); ++itr)
            ++cnt;

    cout << cnt << endl;
}


Measured memory_bytes: 18784
def main():
    inf =1000000000
    N,M = map(int,input().split())
    a,b,c = [],[],[]
    dist = [[0 if i ==j else inf for j in range(N)] for i in range(N)]
    for _ in range(M):
        x,y,z = map(int,input().split())
        a.append(x-1)
        b.append(y-1)
        c.append(z)

    for i in range(M):
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i])
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i])

    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])

    ans = M
    for i in range(M):
        if dist[a[i]][b[i]] == c[i]:
            ans -=1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, Q; 
  cin >> N >> Q;

  string s;
  cin >> s;
  s.insert(N, "0");
  s.insert(0, "0");

  vector<char> t(Q), d(Q);
  REP(i, Q) cin >> t[i] >> d[i];

  int ok = N+1;
  int ng = 0;
  while(ok-ng > 1){
    int mid = (ok+ng)/2;

    int now = mid;
    REP(i, Q){
      if(s[now] == t[i]){
        if(d[i] == 'L') now--;
        else now++;
      }
    }
    if(now == 0) ng = mid;
    else ok = mid;
  }
  int left = ng;

  ok = 0;
  ng = N+1;
  while(ng-ok > 1){
    int mid = (ok+ng)/2;

    int now = mid;
    REP(i, Q){
      if(s[now] == t[i]){
        if(d[i] == 'L') now--;
        else now++;
      }
    }
    if(now == N+1) ng = mid;
    else ok = mid;
  }
  int right = ng;

  cout << max(0ll, right-left-1) << endl;

  return 0;
}

Measured memory_bytes: 900
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


Total = 15
S = _s()
if S.count('o') + Total - len(S) >= 8:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int ans = 0;
    for (int a = 1; a < n; a++) {
        ans += (n - 1) / a;
    }

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

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

sort(a,a+n,[](int x,int y){
return x<y;
});


*/





void solve(){


int n;

cin>>n;


unordered_map<int,int>mp;



for(int i=1;i<=sqrt(n);i++){
    for(int j=1;j<=sqrt(n);j++){
        for(int k=1;k<=sqrt(n);k++){
            
            
             int r = i*i+j*j+k*k+i*j+j*k+k*i;
            
            mp[r]++;
            
            
        }
        
        
        
    }
    
    
    
    
    
    
    
    
    
}







for(int i=1;i<=n;i++){
    
    cout<<mp[i]<<endl;
    
}











}


int main() {

int t;
t=1;


while(t-->0){



solve();
}



return 0;
}

Measured memory_bytes: 4908
# 入力
A,B=map(int,input().split())
S=input()

# A+1番目が'-'出ない場合は'No'
if S[A]!='-':
  print('No')
  exit()
else:
  for x in S[:A]:
    if x not in '0123456789':
      print('No')
      exit()
  for x in S[A+2:]:
    if x not in '0123456789':
      print('No')
      exit()

# チェックに引っかからなければ形式を満たす文字列
print('Yes')

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int i,n,m;
    char s[105],t[105];
    scanf("%s%s",s,t);
    n=strlen(s);
    m=strlen(t);
    sort(s,s+n);
    sort(t,t+m);
    int minn=m>n?n:m;
    for(i=0;i<=minn;i++)
    {
        if(s[i]<t[m-1-i]){printf("Yes\n");return 0;}else if(s[i]>t[m-1-i]){printf("No\n");return 0;}
    }
    if(n<m)printf("Yes\n");else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int cnt = 0;
    
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(x - (i*500 + j*100 + k*50) == 0){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  int n, m;
  string s;
  vector<char> a(26);

  cin >> s;

  REP(i, ('z' - 'a') + 1)
  {
    a[i] = 'a' + i;
  }
  REP(i, s.size())
  {
    a[s[i] - 'a'] = '0';
  }
  REP(i, a.size())
  {
    if (a[i] != '0')
    {
      cout << a[i] << endl;
      break;
    }
    else if (i == a.size() - 1)
    {
      cout << "None" << endl;
    }
  }
}

Measured memory_bytes: 3684
/**
 * Copyright (c) 2017, xehoth
 * All rights reserved.
 * 「ARC 080E」Young Maids 26-08-2017
 * 线段树 + 堆
 * @author xehoth
 */
#include <bits/stdc++.h>

namespace Task {

const int MAXN = 200000;

int M;

inline void init(const int n) {
    for (M = 1; M < n + 2; M <<= 1)
        ;
}

struct SegmentTree {
    int d[MAXN * 4];

    inline void maintain(int k) { d[k] = std::min(d[k << 1], d[k << 1 | 1]); }

    inline void build() {
        for (register int i = M - 1; i; i--) maintain(i);
    }

    inline int query(int s, int t) const {
        register int ret = INT_MAX;
        for (s = s + M - 1, t = t + M + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
            (~s & 1) ? ret = std::min(ret, d[s ^ 1]) : 0;
            (t & 1) ? ret = std::min(ret, d[t ^ 1]) : 0;
        }
        return ret;
    }
};

SegmentTree even, odd;

int a[MAXN + 1], pos[MAXN + 1];

struct Node {
    int l, r, x;

    Node(int l, int r, int x) : l(l), r(r), x(x) {}

    inline bool operator<(const Node &b) const { return x > b.x; }
};

template <typename T>
class PriorityQueue : public std::priority_queue<T> {
   private:
#define super std::priority_queue<T>
   public:
    inline void reserve(const int n) { super::c.reserve(n); }
#undef super
};

inline void initRmq(const int n, const int *a) {
    init(n);
    for (register int i = 1; i <= n; i++) {
        if (i & 1) {
            odd.d[M + i] = a[i], even.d[M + i] = INT_MAX;
        } else {
            even.d[M + i] = a[i], odd.d[M + i] = INT_MAX;
        }
    }
    even.build(), odd.build();
}

inline void solve() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    register int n;
    std::cin >> n;
    for (register int i = 1; i <= n; i++) std::cin >> a[i], pos[a[i]] = i;
    initRmq(n, a);
    static PriorityQueue<Node> q;
    q.reserve(n * 2);
    q.push(Node(1, n, odd.query(1, n)));
    const SegmentTree *t[2] = {&even, &odd};
    while (!q.empty()) {
        Node d = q.top();
        q.pop();
        register int l = d.l, r = d.r;
        register int p1 = pos[d.x], p2 = pos[t[~p1 & 1]->query(p1 + 1, r)];
        std::cout << a[p1] << ' ' << a[p2] << ' ';
        if (l < p1) q.push(Node(l, p1 - 1, t[l & 1]->query(l, p1 - 1)));
        if (p1 < p2 - 1)
            q.push(Node(p1 + 1, p2 - 1, t[~p1 & 1]->query(p1 + 1, p2 - 1)));
        if (p2 < r) q.push(Node(p2 + 1, r, t[~p2 & 1]->query(p2 + 1, r)));
    }
}
}

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

Measured memory_bytes: 10368
s = int(input())

l = [s]
count = 1

while True:
    if l[-1] % 2 == 0:
        l.append(l[-1] // 2)
    else:
        l.append(3 * l[-1] + 1)

    count += 1

    if l[-1] in l[:-1]:
        print(count)
        break


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
main(){
  int w,now=1150;
  while(1){
    now=1150;
    cin>>w;
    if(w==-1){
      break;
    }
    if(w<=10){
    }
    else if(w>10&&w<=20){
      now+=(w-10)*125;
    }
    else if(w>20&&w<=30){
      now+=1250+(w-20)*140;
    }
    else{
      now+=1250+1400+(w-30)*160;
    }
    cout<<4280-now<<endl;
  }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>

int flag_check_shiritori(char* A, char*B)
{
  if(A[strlen(A)-1] == B[0]){
    return 1;
  }else{
    return 0;
  }
}

int main()
{
  char A[101], B[101], C[101];
  scanf("%s %s %s", A, B, C);
  if (flag_check_shiritori(A,B) && flag_check_shiritori(B,C)){
    printf("YES\n");
  }
  else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		
			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var SS = inputArray[0];
			var T = retreiveStringArray()[0];
			var length = SS.Length;
			var len = T.Length;

			var candicates = new List<string>();

			for (int i = 0; i <= length - len; i++) {
				var comp = SS.Substring(i, len);
				var isfit = true;
				for (int j = 0; j < len; j++) {

					if (comp[j] == '?') {
						continue;
					}
					if (comp[j] != T[j]) {
						isfit = false;
						break;
					}

				}

				if (isfit) {
					var str = SS.Substring(0, i) + T + SS.Substring(i + len, length - len - i);
					candicates.Add(str.Replace('?', 'a'));
				}
			}

			if (candicates.Count()==0) {
				Console.WriteLine("UNRESTORABLE");
				return;
			}

			var ans = candicates.OrderBy(x => x).First();
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n, m;
    cin >> n >> m;
    
    priority_queue<ll> a;
    ll in;
    FOR(i, 0, n) {
        cin >> in;
        a.push(in);
    }

    ll s;
    for (int i = 0; i < m && !a.empty(); i++) {
        s = a.top(); a.pop();
        s /= 2;
        if (s)a.push(s);
    }

    ll ans = 0;
    while (!a.empty()) {
        ans += a.top();
        a.pop();
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-9;
const double PI = acos(-1);
#define EQ(n,m) (abs((n)-(m)) < EPS)

double dot(Point a, Point b) {
    return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
    return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
    b -= a;  c -= a;
    if (cross(b,c) >  EPS) return +1;  // counter clockwise
    if (cross(b,c) < -EPS) return -1;  // clockwise
    if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
    if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
    return 0;                          // a--c--b on line or a==c or b==c
}

Point crosspointLL(Point a1, Point a2, Point b1, Point b2) {
  double d1 = cross(b2-b1, b1-a1);
  double d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  assert(!EQ(d2, 0)); // ???????????????
  return a1 + d1/d2 * (a2-a1);
}

bool isecSS(Point a1, Point a2, Point b1, Point b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
  ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

Point sym(Point base,Point p){
    return base*2.0 - p;
}

Point face(string XY, int deg, double len){
    double theta = deg*PI/180.0;
    VP a(3),pivot(3),g(3);
    rep(i,3) a[i] = polar(2/sqrt(3),2*PI*i/3);
    rep(i,3) pivot[i] = polar(1/sqrt(3),2*PI*i/3 + PI);
    rep(i,3) g[i] = polar(1/sqrt(3),2*PI*i/3);
    Point s,t;
    if(XY == "BC"){
        s = a[2];
        t = s + polar(len,arg(a[1]-a[2])-theta);
    }
    if(XY == "CD"){
        s = a[0];
        t = s + polar(len,arg(a[2]-a[0])-theta);
    }
    if(XY == "DB"){
        s = a[1];
        t = s + polar(len,arg(a[0]-a[1])-theta);
    }

    bool finish = false;
    while(!finish){
        finish = true;
        rep(i,3){
            if(!isecSS(s,t,a[i],a[(i+1)%3])) continue;
            Point cp = crosspointLL(s,t,a[i],a[(i+1)%3]);
            if(!EQ(cp,s)){
                Point base = pivot[(i+2)%3];
                s = sym(base,cp);
                t = sym(base,t);
                finish = false;
                break;
            }
        }
    }
    Point closest(0,0);
    rep(i,3) if(abs(closest-t) > abs(g[i]-t)){
        closest = g[i];
    }
    return closest;
}

int main(void){
    string XY1,XY2;
    int d1,d2,l1,l2;
    cin>>XY1>>d1>>l1;
    cin>>XY2>>d2>>l2;
    if(EQ(face(XY1,d1,l1),face(XY2,d2,l2))){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗する

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) の絶対値

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//配列の受け取り

main(){
  int n=in(),h=in(),w=in(),a,b,ans=0;
  for (int i=0;i<n;i++) {
    cin >> a >> b;
    if (h<=a && w<=b) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void)
{
  int A[3][3];
  
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      scanf("%d", &A[i][j]);
    }
  }
    
  int N = 0;
   
  scanf("%d", &N);
 
  int b[N];
  
  for(int i = 0; i < N; i++){
    scanf("%d", &b[i]);
  }
  
  int ans1[3] = {0, 0, 0};
  int ans2[3] = {0, 0, 0};
  
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < N; k ++){
        if(A[i][j] == b[k]){
          ans1[i] ++;
        }
      }
    }
  }
  
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < N; k ++){
        if(A[j][i] == b[k]){
          ans2[i] ++;
        }
      }
    }
  }
  
  int ans3 = 0;
  
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < N; j++){
      if(A[i][i] == b[j]){
          ans3 ++;
      }
    }
  }
  
  int ans4= 0;
    
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < N; j++){
      if(A[i][2-i] == b[j]){
          ans4 ++;
      }
    }
  }  
   
  if(ans1[0] == 3 || ans1[1] == 3 ||ans1[2] == 3 ||ans2[0] == 3 ||ans2[1] == 3 ||ans2[2] == 3 ||ans3 == 3 ||ans4 == 3){
    printf("Yes");
  }else{
    printf("No");
  }
   
   
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int n,m;
int a[200000],b[200000];
vector<int>possible_island;
int binary_search(int key) {
    int left = 0, right = (int)possible_island.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (possible_island[mid] == key) return mid;
        else if (possible_island[mid] > key) right = mid - 1;
        else if (possible_island[mid] < key) left = mid + 1;
    }
    return -1;
}
int main(void){
    cin>>n>>m;
    for(int i(0);i<m;i++){
        cin>>a[i]>>b[i];
    }
    for(int i(0);i<m;i++){
        if(b[i] == n)possible_island.push_back(a[i]);
    }
    sort(possible_island.begin(),possible_island.end());
    bool ok(false);
    for(int i(0);i<m;i++){
        if(a[i] == 1 && binary_search(b[i])>=0)ok = true;
    }
    if(ok)cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 2428
#include <iostream>

using namespace std;

int main()
{
	int  dataNum, inValue,
		 min = 1000000, max = -1000000;
	long sum = 0;
	
	cin >> dataNum;
	
	for(int i = 0; i < dataNum; i++)
	{
		cin >> inValue;
		
		if(inValue < min)
		{
			min = inValue;
		}
		if(inValue > max)
		{
			max = inValue;
		}
		sum += inValue;
	}
	
	cout << min << " " << max << " " << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3108
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   vector<int> v;
   for(int i = 0; i < 3; i++){
	   int x;
	   cin >> x;
	   v.push_back(x);  
	 }
	sort(all(v));
    cout << v[0] << " " << v[1] << " " << v[2] << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3128
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG /GCC環境下で[]による配列要素参照のエラーを出す
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc
int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  if((a+b)<=(2*c)){
    cout<<x*a+y*b<<endl;
     return 0;}
  if((x>y)&&(a<2*c)){
    cout<<y*2*c+(x-y)*a<<endl;
    return 0;
  }
  if((y>x)&&(b<2*c)){
    cout<<x*2*c+(y-x)*b<<endl;
    return 0;
  }
  cout<<max(x,y)*2*c<<endl;
  


}
    
   

  

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }


        int sum = 0;
        for (int l = 0; l < n; l++) {
            sum = sum + p[l];
        }

        int max = p[0];
        for (int j = 0; j < p.length; j++) {
            if (max < p[j]) {
                max = p[j];
            }
        }

        System.out.println(sum - (max / 2));

    }
}










Measured memory_bytes: 23764