akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(in.readLine());
    int X = Integer.parseInt(st.nextToken());
    int Y = Integer.parseInt(st.nextToken());
    int Z = Integer.parseInt(st.nextToken());
    
    int tmp = X;
    X = Y;
    Y = tmp;
    
    tmp = X;
    X = Z;
    Z = tmp;
    
    System.out.println(X + " " + Y + " " + Z);
  }
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;

void solve()
{
    ll n,m,k,x,y=0,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1;
    cin>>n;
    ll pre[n],suf[n];
    ll ar[n];
    
	rep(i,0,n)
       cin>>ar[i];
    
	pre[0]=ar[0];suf[n-1]=ar[n-1];
    
	rep(i,1,n) 
	   pre[i]=__gcd(pre[i-1],ar[i]);
    
	for(ll i=n-2;i>=0;i--) 
	   suf[i]=__gcd(ar[i],suf[i+1]);
    
	ll ans=max(suf[1],pre[n-2]); 
	// not taking the first and last element respectively
    
	rep(i,1,n)
       ans=max(ans,__gcd(pre[i-1],suf[i+1]));
    
	cout<<ans;
}

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

Measured memory_bytes: 2560
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	LL N, M;
	cin >> N >> M;
	vector<vector<LL>> v(N, vector<LL>(2, 0));
	vector<vector<LL>> vv(M, vector<LL>(2, 0));
	REP(i, N) {
		cin >> v[i][0] >> v[i][1];
	}
	REP(i, M) {
		cin >> vv[i][0] >> vv[i][1];
	}
	REP(i, N) {
		LL min = 900000000;
		LL flag = 0;
		REP(j, M) {
			LL sum = 0;
			if (v[i][0] - vv[j][0] > 0) {
				sum += (v[i][0] - vv[j][0]);
			}
			else {
				sum -= (v[i][0] - vv[j][0]);
			}
			if (v[i][1] - vv[j][1] > 0) {
				sum += (v[i][1] - vv[j][1]);
			}
			else {
				sum -= (v[i][1] - vv[j][1]);
			}
			if (min > sum) {
				min = sum;
				flag = j+ 1;
			}
		}
		cout << flag << endl;
	}
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    set<char> st;
    i32 n;
    char tmp;
    cin >> n;
    rep(i,n) {
        cin >> tmp;
        st.insert(tmp);
    }

    cout << (st.size() == 3 ? "Three" : "Four") << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 512
N = str(input())

if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
    print('hon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 61836
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
//#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
int main()
{
    Hello
    int a, b;
    cin >> a >> b;
    cout << a * b;
    return 0;
}

Measured memory_bytes: 3628
from collections import deque

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = deque(a)
b = deque(b)
t = 0
book = deque()
while len(b):
    if b[0]+t <= k:
        t += b[0]
        book.append(b.popleft())
    else:
        break
nn = len(book)
# 逆じゅん
new_book = deque()
for i in range(nn):
    new_book.append(book.pop())
book = new_book
# aも詰め込めるだけ
while len(a):
    if a[0]+t <= k:
        t += a[0]
        book.append(a.popleft())
    else:
        break
ans = len(book)
for i in range(nn):
    t -= book.popleft()
    while len(a) and t+a[0]<=k:
        ta = a.popleft()
        t += ta
        book.append(ta)
    ans = max(ans, len(book))

print(ans)

Measured memory_bytes: 114104
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int n){
  S[++top] = n;
}

int pop(){
  top--;
  return S[top + 1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else{
      push(atoi(s));
    }
  }

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

  return 0;
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c.size())
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define f first
#define s second

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e5 + 11;

void solve(){
    string s1 ,s4, s2 ,s3;
    s1  = "AC";
    s2 = "TLE";
    s3 = "WA";
    s4 = "RE";
    map<string ,ll> m;
    ll n;
    cin >> n;
    while(n--){
        string s;
        cin >> s;
        m[s]++;
    }
    cout <<s1 <<" x " << m[s1] << endl;
    cout <<s3 <<" x " << m[s3] << endl;
    cout <<s2 <<" x " << m[s2] << endl;
    cout <<s4 <<" x " << m[s4] << endl;

}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC = 1;
    // cin >> NTC;
    ll PTC = 0;
    while(PTC++ < NTC){
        // cout << "Case #" << PTC << ":" << ' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[3],b[3],c[3];
ll n,f[25000000];
int main()
{
    scanf("%lld",&n);
    scanf("%d%d%d",&a[1],&b[1],&c[1]);
    scanf("%d%d%d",&a[2],&b[2],&c[2]);
    for(int i=1;i<=n;i++)
    {
        if(i-a[1]>=0)
            f[i]=max(f[i],f[i-a[1]]+a[2]-a[1]);
        if(i-b[1]>=0)
            f[i]=max(f[i],f[i-b[1]]+b[2]-b[1]);
        if(i-c[1]>=0)
            f[i]=max(f[i],f[i-c[1]]+c[2]-c[1]);
    }
    n+=f[n];
    for(int i=1;i<=n;i++)
    {
        f[i]=0;
        if(i-a[2]>=0)
            f[i]=max(f[i],f[i-a[2]]+a[1]-a[2]);
        if(i-b[2]>=0)
            f[i]=max(f[i],f[i-b[2]]+b[1]-b[2]);
        if(i-c[2]>=0)
            f[i]=max(f[i],f[i-c[2]]+c[1]-c[2]);
    }
    n+=f[n];
    printf("%lld\n",n);
}


Measured memory_bytes: 195584
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int K = int.Parse(str);
		int[]N = new int[K];
		var pq = new PriorityQueue<int>((x,y)=>N[x].CompareTo(N[y]));
		pq.Enqueue(1);
		N[1] = 1;
		while(pq.Count > 0){
			int ni = pq.Dequeue();
			if(N[ni] > N[0] && N[0] > 0){
				break;
			}
			int nni = N[ni];
			if(nni + 1 < N[(ni+1)%K] || N[(ni+1)%K] == 0){
				N[(ni+1)%K] = nni + 1;
				pq.Enqueue((ni+1)%K);
			}
			if(nni < N[(ni*10)%K] || N[(ni*10)%K] == 0){
				N[(ni*10)%K] = nni;
				pq.Enqueue((ni*10)%K);
			}
		}
		Console.WriteLine(N[0]);
	}
	
    public class PriorityQueue<T>
    {
        readonly List<T> heap = new List<T>();
        readonly Comparison<T> cmp;
        public PriorityQueue() { cmp = Comparer<T>.Default.Compare; }
        public PriorityQueue(Comparison<T> comparison) { cmp = comparison; }
        public PriorityQueue(IComparer<T> comparer) { cmp = comparer.Compare; }
        public void Enqueue(T item)
        {
            var pos = heap.Count;
            heap.Add(item);
            while (pos > 0)
            {
                var par = (pos - 1) / 2;
                if (cmp(heap[par], item) <= 0)
                    break;
                heap[pos] = heap[par];
                pos = par;
            }
            heap[pos] = item;

        }
        public T Dequeue()
        {
            var ret = heap[0];
            var pos = 0;
            var x = heap[heap.Count - 1];

            while (pos * 2 + 1 < heap.Count - 1)
            {
                var lch = pos * 2 + 1;
                var rch = pos * 2 + 2;
                if (rch < heap.Count - 1 && cmp(heap[rch], heap[lch]) < 0) lch = rch;
                if (cmp(heap[lch], x) >= 0)
                    break;
                heap[pos] = heap[lch];
                pos = lch;
            }
            heap[pos] = x;
            heap.RemoveAt(heap.Count - 1);
            return ret;

        }
        public T Peek() { return heap[0]; }
        public int Count { get { return heap.Count; } }
        public bool Any() { return heap.Count > 0; }
        public T[] Items
        {
            get
            {
                var ret = heap.ToArray();
                Array.Sort(ret, cmp);
                return ret;
            }
        }
    }

}

Measured memory_bytes: 13308
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i) 
using namespace std;
using ll = long long;
int main() {
int a,b,c,x;
cin >> a>>b>>c>>x;
int ans=0;
rep(i,a+1){
 rep(j,b+1){
  rep(k,c+1){
    if(x==500*i+100*j +50*k)ans++;
  }}}
  cout << ans << endl;
   }


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>; using vvi = vector<vector<int>>;
using vl = vector<ll>; using vvl = vector<vector<ll>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n,k;
  cin >> n >> k;
  vi x(n);
  REP(i,n) cin >> x[i];
  int l = 0,r = k-1;
  int ans = min(abs(x[l]),abs(x[r]))+abs(x[l]-x[r]);
  REP(i,n-k){
    ++l; ++r;
    ans = min(ans,min(abs(x[l]),abs(x[r]))+abs(x[l]-x[r]));
  }
  cout << ans << endl;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n), c(m), d(m);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for(int i = 0; i < m; i++) cin >> c[i] >> d[i];

    for(int i = 0; i < n; i++){
        int mincost = 1001001001;
        int ans = -1;
        for(int j = 0; j < m; j++){
            if(abs(a[i]-c[j]) + abs(b[i]-d[j]) < mincost){
                mincost = abs(a[i]-c[j]) + abs(b[i]-d[j]);
                ans = j;
            }
        }
        cout << ans+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
import math

n,k = (int(x) for x in input().split())
An = [int(i) for i in input().split()]

left = 0
right = max(An)

def check(x):
    chk = 0
    for i in range(n):
        chk += math.ceil(An[i]/x)-1
    return chk

while right-left!=1:
    x = (left+right)//2
    if check(x)<=k:
        right = x
    else:
        left = x

print(right)

Measured memory_bytes: 31084
import collections

n = int(input())
vs = [int(i) for i in input().split()]
evens = []
odds = []
for i,num in enumerate(vs):
    if i % 2 == 0:
        evens.append(num)
    elif i % 2 == 1:
        odds.append(num)

def plana():
    if (len(set(vs)) == 2) and (len(set(evens)) == 1) and (len(set(odds)) == 1):
        return 0
    elif (len(set(vs)) == 1):
        return len(evens)
    ec = collections.Counter(evens)
    oc = collections.Counter(odds)

    # check
    if ec.most_common()[0][0] == oc.most_common()[0][0]:
        if len(set(evens))==1:
            return len(odds)-oc.most_common()[1][1]
        elif len(set(odds))==1:
            return len(evens)-ec.most_common()[1][1]
        e1 = ec.most_common()[0][1]
        e2 = ec.most_common()[1][1]
        o1 = oc.most_common()[0][1]
        o2 = oc.most_common()[1][1]
        count1 = 0
        count2 = 0
        count1 += (len(evens) - e1)
        count1 += (len(odds) - o2)
        count2 += (len(odds) - o1)
        count2 += (len(evens) - e2)
        if (count1 >= count2):
            return count2
        else:
            return count1

        # if ec.most_common()[0][1] >= oc.most_common()[0][1]:
        #     count = 0
        #     count += (len(evens) - ec.most_common()[0][1])
        #     count += (len(odds) - oc.most_common()[1][1])
        #     return count
        # elif ec.most_common()[0][1] < oc.most_common()[0][1]:
        #     count = 0
        #     count += (len(evens) - ec.most_common()[1][1])
        #     count += (len(odds) - oc.most_common()[0][1])
        #     return count

    count = 0
    count += (len(evens) - ec.most_common()[0][1])
    count += (len(odds) - oc.most_common()[0][1])
    return count

print(int(plana()))



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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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(b < a) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec) {
        is >> x;
    }
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    vi p(n);
    cin >> p;

    vi p_sorted(p);
    sort(all(p_sorted));

    bool ans = true;
    int x = -1;
    REP(i, n) {
        if(p[i] == i + 1)
            continue;
        else {
            if(x == -1) {
                x = p[i];
            } else {
                if(x != i + 1) {
                    ans = false;
                }
            }
        }
    }

    if(ans) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


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

using namespace std;

#define inf 1<<30
#define llong long long
#define usd unsigned
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef struct data{
	int now;
	int cost;
}data;
int nw[9] = {0, 1, 0, -1, -1, 1, 1, -1, 0};
int nh[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};

string in;
int mod = 1000000007;
usd llong int memo[100001][4];

usd llong int dp(int now, int use){
	if(memo[now][use] != -inf) return memo[now][use];
	if(now == (int)in.size()){
		if(use == 3) return 1;
		else return 0;
	}

	usd llong int ret = 0;
	if(in[now] == 'A'){
		if(use == 0){
			ret += dp(now+1, 1)%mod;
		}
		ret += dp(now+1, use)%mod;
	}else if(in[now] == 'B'){
		if(use == 1){
			ret += dp(now+1, 2)%mod;
		}
		ret += dp(now+1, use);
	}else if(in[now] == 'C'){
		if(use == 2){
			ret += dp(now+1, 3)%mod;
		}
		ret += dp(now+1, use)%mod;
	}else if(in[now] == '?'){
		if(use < 3){
			ret += dp(now+1, use+1)%mod;
		}
		ret += 3*dp(now+1, use)%mod;
	}

	return memo[now][use] = ret%mod;
}

int main(){
	fn(*memo, 100001*4, -inf);
	cin >> in;
	cout << dp(0,0) << endl;

	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart)/CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
bool ok(int n, int a, int b){
    int sm = 0;
    while(n){
        sm+=n%10;
        n/=10;
    }
    if(sm >= a && sm <= b)
        return(true);
    return(false);
}
int main(){
   int n, a, b;
   cin >> n >> a >> b;
   int sum = 0;
   for(int i=1;i<=n;i++){
        if(ok(i,a,b)){
            sum+=i;
        }
   }
   cout << sum;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String b = Integer.toString(a/100);
        int c = Integer.parseInt(b + b + b);
        if (a - c > 0) {
            System.out.println(c + 111);
        } else {
            System.out.println(c);
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(){
	string O;
	string E;
	cin>>O>>E;
	if(O.length()==E.length()){
		for(int i=0;i<O.length();i++){
		cout<<O[i];
		cout<<E[i];
	}
	}
	if(O.length()>E.length()){
		for(int i=0;i<O.length()-1;i++){
		cout<<O[i];
		cout<<E[i];
		}
	cout<<O[O.length()-1];
	}
cout<<endl;
return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int maxn=200000;
int n,k,fin[maxn+5];
char s[maxn+5];
signed main()
{
	scanf("%d%d",&n,&k);
	scanf("%s",s);
	fin[n+1]=n+1;
	for(int i=n;i>=0;i--)
	{
		if(s[i]=='0') fin[i]=i;
		else fin[i]=fin[i+1];
	}
	int now=n,flag=0;
	vector<int> ans;
	while(now>0)
	{
		int delta=now-k;
		if(delta<0) delta=0;
		int pos=fin[delta];
		if(pos==now) 
		{
			flag=1;
			break;
		}
		ans.push_back(now-pos);
		now=pos;
	}
	if(flag) printf("-1\n");
	else
	{
		for(int i=(int)ans.size()-1;i>=0;i--) printf("%d ",ans[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2296
Vertex = Struct.new(:id, :adj_list, :found_time, :completed_time) do
	def to_s
		"#{id} #{found_time} #{completed_time}"
	end
end

def dfs!(vertex, time)
	return time unless vertex.found_time.nil?

	vertex.found_time ||= time
	time += 1

	time = vertex.adj_list.inject(time) { |t, v| dfs!(v, t) }
	vertex.completed_time = time
	time += 1
end

n = STDIN.gets.to_i
vertex_list = Array.new(n) { |i| Vertex.new(i + 1) }
n.times do
	node_no, degree, *adj_list = STDIN.gets.split.map(&:to_i)

	vertex = vertex_list[node_no - 1]
	vertex.adj_list = adj_list[0...degree].map! { |adj| vertex_list[adj - 1] }
end

time = 1
vertex_list.each do |v|
	time = dfs!(v, time)
	puts v
end

Measured memory_bytes: 6372
#include <bits/stdc++.h>
#define ll long long
#define li long int
#define ld long double
#define pl pair<long long, long long>
#define pi pair<int, int>
#define ppl pair<pl, ll>
#define ppi pair<int, pi>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LLFOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define MOD 1000000007
#define M2 998244353
//std::cout <<setprecision(30) << av << endl;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll s;
    cin >> s;
    ll y3, x3;
    ll k = 1e9;
    if(s%k==0){
        x3=0;
        y3=s/k;
    }else{
        x3 = k-(s+k)%k;
        y3 = (s+k)/k;
    }
    cout << "0 0 " << k << " " << 1 << " " << x3 << " " << y3 << endl;
//    cout << k*y3-x3 << endl;


}


Measured memory_bytes: 256
def min_cost():
    # Translation of Errichto's solution
    len_costs = input()
    costs = input().split(' ')
    costs = list(map(int, costs))
    dp = [float('inf') for i in range(len(costs))]
    dp[0] = 0
    for i in range(len(costs)):
        for j in [i + 1, i + 2]:
            if j < len(costs):
                dp[j] = min(dp[j], dp[i] + abs(costs[i] - costs[j]))
    print(dp[-1])

min_cost()
# min_cost([10, 30, 40, 20])
# min_cost([10, 10])
# min_cost([30, 10, 60, 10, 60, 50])


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

int main()
{
	string str;
	cin >> str;
	if (str[2] == str[3] && str[4] == str[5]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;


int main(){
    string s; cin >> s;
    int N = s.length();
    int a=s[0]-'0';
    int b=s[1]-'0';
    int c=s[2]-'0';
    int d=s[3]-'0';
    for(int i=0;i<1<<(N-1);i++){
        int sum=s[0]-'0';
        cerr << endl << sum;
        for(int j=0;j<N-1;j++){
            if(i&(1<<j)){ //+する
                sum += s[j+1]-'0';
                cerr << "+" << s[j+1]-'0';
            }else{ //-する
                sum -= s[j+1]-'0';
                cerr << "-" << s[j+1]-'0';
            }
        }
        cerr << "=" << sum;
        if(sum==7){
            cout << s[0]-'0';
            for(int j=0;j<N-1;j++){
                if(i&(1<<j)){ //+する
                    cout << "+";
                }else{ //-する
                    cout << "-";
                }
                cout << s[j+1]-'0';
            }
            cout << "=7" << endl;
            break;
        }
    }
    return 0;
}


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

int main(void)
{
    int n;
    scanf("%d", &n);
    int x[n],l[n];
    for (size_t i = 0; i < n; i++)
    {
        scanf("%d", &(x[i]));
        l[i] = x[i];
    }
    sort(l, l + n);
    for (size_t i = 0; i < n; i++)
    {
        printf("%d\n", x[i] < l[n / 2] ? l[n / 2] : l[(n / 2) - 1]);
    }
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x) { int k, m = 0; *x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { *x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; *x = (*x) * 10 + k - '0'; }if (m)(*x) = -(*x); }
void reader(int *x, int *y) { reader(x); reader(y); }
void reader(int *x, int *y, int *z) { reader(x); reader(y); reader(z); }
void writer(int x, char c) { int i, sz = 0, m = 0; char buf[10]; if (x<0)m = 1, x = -x; while (x)buf[sz++] = x % 10, x /= 10; if (!sz)buf[sz++] = 0; if (m)mypc('-'); while (sz--)mypc(buf[sz] + '0'); mypc(c); }

int a[1000][1000], dp[1000][1000];
int main() {
	int h, w, n;
	while (reader(&h, &w, &n), h) {
		rep(i, h)rep(j, w)reader(&a[i][j]);
		memset(dp, 0, sizeof(dp));
		dp[0][0] = n - 1;
		rep(i, h)rep(j, w) {
			if (i) {
				if (a[i - 1][j])dp[i][j] += dp[i - 1][j] >> 1;
				else dp[i][j] += (dp[i - 1][j] + 1) >> 1;
			}
			if (j) {
				if (a[i][j - 1])dp[i][j] += (dp[i][j - 1] + 1) >> 1;
				else dp[i][j] += dp[i][j - 1] >> 1;
			}
		}
		rep(i, h)rep(j, w) {
			if (dp[i][j] & 1)a[i][j] = !a[i][j];
		}
		int x = 0, y = 0;
		while (x < h&&y < w) {
			if (a[x][y])y++;
			else x++;
		}
		writer(x + 1, ' '); writer(y + 1, '\n');
	}
}

Measured memory_bytes: 10864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll N,X,L,A;cin>>N>>X;
    A=0;
    vector<ll>v;
    while(X>=A && v.size()<N+1){
    cin>>L;
    v.push_back(L);
    A=A+L;
    }
    cout<<v.size()<<endl;

}



Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int a[100010];
int main()
{
	int i,j,k,n,m,x=0,y=inf;
	ll sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		x=x^(a[i]<0);
		y=min(y,abs(a[i]));
		sum+=abs(a[i]);
	}
	if(x)
	{
		sum-=2*y;
	}
	printf("%lld",sum);
	return 0;
}


Measured memory_bytes: 4212
using System;
using System.IO;
using System.Collections.Generic;

namespace ARC090
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var X = ss.Next(Int);
            var A = ss.Next(Int);
            var B = ss.Next(Int);
            sw.WriteLine((X - A) % B);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
        static readonly Func<string, int> Int = int.Parse;
        static readonly Func<string, long> Long = long.Parse;
        static readonly Func<string, double> Double = double.Parse;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }

 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    char s[100010];
    cin>>s;
    bool a[26];
    rep(i,26) a[i]=false;
    for(int i=0;s[i]!='\0';i++){
        a[s[i]-'a']=true;
    }
    rep(i,26){
        if(!a[i]){
            cout<<(char)(i+'a');
            return 0;
        }
    }
    cout<<"None";
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,a) REP(i,0,a)
#define rev(s) reverse(s.begin(),s.end())
#define pb push_back
#define MAX 1000005
 
int main() 
{   
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ll n,i;
	cin>>n;
	ll a[n];
	rep(i,n)
	cin>>a[i];
	sort(a,a+n);
	bool b=1;
	rep(i,n-1)
	{
		if(a[i]==a[i+1])
		{
			b=0;
			break;
		}

	}
	if(b==0)
		cout<<"NO"<<endl;
	else cout<<"YES"<<endl;

	return 0;
	}
	
	


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ll H[100005];

  cin >> N;
  rep(i, N){
    cin >> H[i];
  }

  int ans = 0;
  int count = 0;
  rep(i, N-1){
    if (H[i] >= H[i+1]){
      count += 1;
    } else {
      ans = max(ans, count);
      count = 0;
    }
  }

  cout << max(ans, count) << endl;


}

Measured memory_bytes: 1024
L, R = map(int, input().split())
mod = 2019
ans = mod + 1

if R - L >= 3000 or L == 0:
    print(0)
else:
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % mod
            if m < ans:
                ans = m
    print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  int mod = 1000000007;
  long long sum =0;
  for(int i=0;i<n;i++)
  {
    cin >> A.at(i);
    sum += A.at(i);
    sum %= mod;
  }
  
  long ans =0;
  
  for(int i =0;i<n;i++){
    sum -=A.at(i);
    if(sum < 0) sum +=mod;
    
    ans += A.at(i) * sum;
    ans %= mod;
  }
  cout << ans << endl;
}
    
  


Measured memory_bytes: 4016
N = int(input())
C,S,F = [],[],[]
for i in range(N-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

#d = {}
#d[0] = 0
#d[1] = t

for k in range(N-1):
    t = S[k] + C[k]
    for i in range(k+1,N-1):
        if t >= S[i]:
            for j in range(F[i]):
                if t % F[i] == 0:
                    t += C[i]
                    break
                t += 1
        else:
            t = S[i] + C[i]
    print(t)
print(0)

   #d[i+1] = t


Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
ll findXOR(ll n) 
{
	if(n==-1)	return 0; 
	int mod = n % 4;
	if(mod==0) 	return n;
	if(mod==1) 	return 1;
	if(mod==2) 	return n+1; 
	if(mod==3) 	return 0; 
}
ll findXOR(ll l,ll r) { return(findXOR(l-1)^findXOR(r)); }
int main() 
{
	ll l,r; 
	cin>>l>>r;
	cout<<findXOR(l,r); 
} 


Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>		
#include <stdio.h>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main()
{
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> p(N);
	for (int i = 0; i < Q; i++) {
		int A;
		cin >> A;
		p[A - 1] += 1;
	}
	for (int i = 0; i < N; i++) {
		if (K - (Q - p[i]) <= 0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}

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


int main(){
  string S; cin >> S;
  int N = S.size();
  for(int i = 1; i < N; i++){
    int n = N - i;
    string tmp = S.substr(0, n);
    if(n % 2 == 1) continue;
    if(tmp.substr(0, n / 2) == tmp.substr(n / 2, n / 2)){
      cout << n << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

bool solve(){
  int n,m;
  cin>>n>>m;
  vector<int> vec(n,0);

  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    vec[a]++;
    vec[b]++;
  }

  rep(i,n) if(vec[i]%2==1) return false;

  return true;
}

int main(){
  if(solve()) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


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

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

int main(){
int n;
cin>>n;
int d[n];
rep(i,n)
cin>>d[i];
sort(d,d+n);
int count=0; 
rep(i,n-1){
  if(d[i]==d[i+1])
  count++;
}

cout<<n-count<<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))

cnt = 0
while h != [0] * n:
    prev = -1
    for i in range(n):
        if prev == -1 and h[i] != 0:
            cnt += 1
        if h[i] == 0:
            prev = -1
        else:
            prev = 1
            h[i] -= 1

    # print(h, cnt)

print(cnt)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    ll a[55][55];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            scanf("%lld", &a[i][j]);
        }
    }
    const ll MAX=1e9;
    mcf_graph<int, ll> g(2*n+4);
    int s=2*n, t=2*n+1, S=2*n+2, T=2*n+3;
    for(int i=0; i<n; i++){
        g.add_edge(s, i, k, 0);
        g.add_edge(i+n, t, k, 0);
    }
    g.add_edge(S, s, n*k, 0);
    g.add_edge(t, T, n*k, 0);
    g.add_edge(s, t, n*k, 0);
    ll ans=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            g.add_edge(S, j+n, 1, 0);
            g.add_edge(j+n, i, 1, a[i][j]);
            g.add_edge(i, T, 1, 0);
            ans+=a[i][j];
        }
    }
    ans-=g.flow(S, T, n*k+n*n).second;
    printf("%lld\n", ans);
    auto ve=g.edges();
    string str[55];
    for(int i=0; i<n; i++) for(int j=0; j<n; j++) str[i]+='.';
    for(auto e:ve){
        if(n<=e.from && e.from<2*n && e.to<n && e.flow==0){
            str[e.to][e.from-n]='X';
        }
    }
    for(int i=0; i<n; i++) cout<<str[i]<<"\n";
    return 0;
}


Measured memory_bytes: 4416
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    _ = int(sys.stdin.readline())
    L = list(map(int, sys.stdin.readline().split()))

    ml = max(L)
    if ml < sum(L) - ml:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 5356
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
string l;
ll MOD = 1e9+7;
 
int main(){
	cin >> l;
	ll n = l.size();
 
	ll dp[n];
	ll powpow = 1;
	for(ll i = n-1; i >= 0; i--){
		if(i == n-1){
			if(l[i] == '0'){dp[i] = 1;}
			else{dp[i] = 3;}
		}
		else{
			if(l[i] == '0'){dp[i] = dp[i+1];}
			else{
				dp[i] = 2*dp[i+1];
				dp[i] %= MOD;
				dp[i] += powpow;
				dp[i] %= MOD;
			}
		}
		powpow *= 3;
		powpow %= MOD;
	}
	cout << dp[0] << endl;
	return 0;
}

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

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

    double l[n];

    for(int i=0;i<n;i++){
        cin>>l[i];
    }

    int count=0;
    
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j]){
                    if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]){
                       count++; 
                    }  
                }
            }
        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 3752
#include<iostream>

using namespace std;


int main(void)
{
	
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			cout<<i<<'x'<<j<<'='<<i*j<<endl;
		}
		
	}
	
	return 0;
 } 


Measured memory_bytes: 2932
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
#define PI 3.14159265358979
using namespace std;

typedef vector<vector<int> > vtype;
typedef long long ll;

int main()
{
	//ios::sync_with_stdio(false);
	set<string> s;
	int n = 0;
	cin >> n;
	for(int i = 0; i < n; ++i){
		string mid;
		cin >> mid;
		s.insert(mid);
	}
	cout << s.size() << endl;
    return 0;
}















Measured memory_bytes: 19256
import math
k=int(input())
l=[]
s=0
for x in range(1,k+1):
  for y in range(1,k+1):
    l.append(math.gcd(x,y))

for x in range(len(l)):
  for y in range(1,k+1):
    s+=math.gcd(l[x],y)
print(s)

Measured memory_bytes: 9304
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

bool prime(ll x){
  if(x % 2 == 0){
    return false;
  }
  for(int i = 3;i * i <= x;i += 2){
    if(d[i])continue;
    if(x % i == 0){
      return false;
    }
    rep(j,2,x)d[i*j]++;
  }
  return true;
}

void func(ll p){
  vi vec;
  //cout << p << ":";
  rep(i,2,p){
    if(p < 2){
      vec.pb(p);
      break;
    }
    if(p % i == 0){
      vec.pb(i);
      p /= i;
      i = 1;
    }
  }
  if(p > 1)vec.pb(p);
  sort(all(vec));
  rep(i,0,vec.sz){
    //cout << vec[i] << " ";
    d[vec[i]]++;
  }
  //puts("");
}

int main(){
  cin >> n;
  d[1]++;
  lep(i,2,n)func(i);
  l = 1;
  rep(i,2,1001){
    if(d[i] == 0)continue;
    l *= d[i] + 1;
    l %= INF;
  }
  print(l);
  return 0;
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

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

    int n;
    cin >> n;
    deque<int> dq1,dq2,res1,res2;
    int sum1 = 0,sum2 = 0;

    rep(i,n){
        int a;
        cin >> a;
        dq1.push_front(a);
        dq2.push_front(a);
    }

    sort(all(dq1));
    sort(all(dq2),greater<int>());

    res1.push_front(dq1.front());
    dq1.pop_front();

    rep(i,n){
        if(dq1.size() > 1){
            if(i % 2 == 0){
                res1.push_front(dq1.back());
                dq1.pop_back();
                res1.push_back(dq1.back());
                dq1.pop_back();
            }else{
                res1.push_front(dq1.front());
                dq1.pop_front();
                res1.push_back(dq1.front());
                dq1.pop_front();
            }
        }else if(!dq1.empty()){
            res1.push_front(dq1.front());
            dq1.pop_front();
        }else break;
    }

    res2.push_front(dq2.front());
    dq2.pop_front();

    rep(i,n){
        if(dq2.size() > 1){
            if(i % 2 == 0){
                res2.push_front(dq2.back());
                dq2.pop_back();
                res2.push_back(dq2.back());
                dq2.pop_back();
            }else{
                res2.push_front(dq2.front());
                dq2.pop_front();
                res2.push_back(dq2.front());
                dq2.pop_front();
            }
        }else if(!dq2.empty()){
            res2.push_front(dq2.front());
            dq2.pop_front();
        }else break;
    }

    rep(i,n-1){
        sum1 += abs(res1[i] - res1[i+1]);
        sum2 += abs(res2[i] - res2[i+1]);
    }

    cout << max(sum1,sum2) << '\n';

  	return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <math.h>
// 入力a,bの平均値の小数点以下を切上げた値を出力
int main(void) {
  int a, b, c;
  // scanfで入力を読み込み
  scanf("%d%d", &a, &b);
  // 平均値の計算 ceil:小数点を切上げる関数
  c = ceil((a+b) / 2.0);
  // 答えの出力
  printf("%d\n", c);
  return 0;
}

Measured memory_bytes: 128
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:i64 = read();
    let an = read_vec::<i64>();
    let mut diff = an.into_iter().enumerate()
        .map(|(j,v)| v- (j+1)as i64)
        .collect::<Vec<i64>>();
    diff.sort();
    let mid = diff[(n/2) as usize];
    let ans = diff.iter().fold(0,|y,x| y + (x-mid).abs());
    println!("{}",ans );    
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

ll fct[100010];

ll nCr(ll n, ll r) {
    ll ans = fct[n];
    ans = (ans*modpow(fct[r], mod-2))%mod;
    ans = (ans*modpow(fct[n-r], mod-2))%mod;

    return ans;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    fct[0] = 1;

    for(int i = 1; i < 100010; i++) {
        fct[i] = (fct[i-1]*i)%mod;
    }

    ll n,k;
    cin>>n>>k;

    vector<ll> inp(n);

    for(int i = 0; i < n; i++) {
        cin>>inp[i];
    }

    sort(inp.begin(), inp.end());

    ll ans = 0;

    for(int i = 0; i < n; i++) {
        ll grt = n - 1 - i;
        ll less = i;

        if(less >= k - 1) {
            ans = (ans + inp[i]*nCr(less, k-1))%mod;
        }
        if(grt >= k - 1) {
            ans = (ans - inp[i]*nCr(grt, k-1))%mod;
        }
    }

    if(ans < 0) ans+=mod;
    cout<<ans<<endl;


}


Measured memory_bytes: 1792