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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int L = 128;
string alpha;
int l;

string smerge(string a, string b) {
    int i = b.size();
    while (!a.empty()) {
        assert(i >= 0);
        string c = b;
        c.insert(c.begin() + i, a.back());
        cout << "? " << c << endl;
        int res;
        cin >> res;
        if (res == l - c.size()) {
            b = c;
            a.resize(a.size() - 1);
        } else --i;
    }
    return b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
//    freopen("input.txt", "rt", stdin);
#endif

    forn(i, 26) alpha += (char)('a' + i);
    forn(i, 26) alpha += (char)('A' + i);
    forn(i, 10) alpha += (char)('0' + i);

    vector<string> s;
    vi cnt(alpha.size());
    int sum = 0;
    forn(i, alpha.size()) {
        cout << "? " << string(L, alpha[i]) << endl;
        cin >> cnt[i];
        sum += cnt[i];
        cnt[i] = L - cnt[i];
    }
    l = (L * alpha.size() - sum);
    forn(i, alpha.size()) if (cnt[i]) s.pb(string(cnt[i], alpha[i]));

    while (s.size() > 1) {
        sort(all(s), [&](string a, string b){return a.size() > b.size();});
        string a = s.back(); s.pop_back();
        string b = s.back(); s.pop_back();
        s.pb(smerge(a, b));
    }
    cout << "!" << s[0] << endl;

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using namespace std;

int n,i,j,t,m;
int c[500],s[500],f[500];

int main(){
    scanf("%d", &n);
    for(i=0;i+1<n;i++){
		scanf("%d %d %d", c+i, s+i, f+i);
	}
	for(i=0;i+1<n;i++){
		t=0;
		for(j=i;j+1<n;j++){
			if(t<=s[j])
				t=s[j];
			else{
				m = t-s[j];
				m /= f[j];
				m = m*f[j] + s[j];
				while(t>m){
					m+=f[j];
				}
				t = m;
			}
			t+=c[j];
		}
		printf("%d\n", t);
	}
	puts("0");
    return 0;
}

Measured memory_bytes: 256
(defun reads (num)
  (loop as i 
        below num 
        collect (list (read) (read))))

(defun set-num (n l ht)
    (loop as point ; (rank value)
          in l ; (list (rank value))
          do (cond ;((< n (car point)) (setf (gethash 'check ht) T)); nより大きい桁に入れようとするとアウト
                   ((and (not (= n 1))
                         (= 1 (car point))
                         (= 0 (cadr point))) (setf (gethash 'check ht) T)); nに0を入れようとしたらアウト
                   ((not (gethash (car point) ht)) (setf (gethash (car point) ht) (cadr point))); まだ入っていないのでOK
                   ((not (= (gethash (car point) ht) (cadr point))) (setf (gethash 'check ht) T))))); 入っていて値が異なるのでアウト

(defun get-number (n ht)
  (loop as i
        below n
        collect (* (expt 10 (- n i 1))
                   (if (gethash (+ i 1) ht)
                       (gethash (+ i 1) ht)
                       (if (and (= i 0) (not (= n 1))) 1 0)))))


(let ((n (read))
      (c (reads (read)))
      (ht (make-hash-table)))
  (set-num n c ht)
  (if (gethash 'check ht)
      (princ (- 0 1))
      (princ (reduce (lambda (m x) (+ m x)) (get-number n ht)))))


Measured memory_bytes: 7008
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ld nums[109];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    ld sum=0;
    rep(i,N) cin>>nums[i];
    rep(i,N) sum+=nums[i];
    
    ld ave=sum/N;
    
    ld mn=INF;
    int best;
    rep(i,N){
        if(mn>abs(ave-nums[i])){
            mn=abs(ave-nums[i]);
            best=i;
        }
    }
    cout1(best);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,vis[66];
long long S,X,a[333],D,BBLL;
void go(){
	cout<<-1<<endl;
	exit(0);
}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=3;i<=n;i++) X^=a[i];
	S=a[1]+a[2];
	D=(S-X)/2LL;
	if(((S-X)&1)||D<0) go();
	for(int i=55;i>=0;i--)
		if(((D>>i)&1)) BBLL+=(1LL<<i),vis[i]=1;
	for(int i=55;i>=0;i--)
		if(((X>>i)&1)&&!vis[i])
			if((BBLL+(1LL<<i))<a[1])
				BBLL+=(1LL<<i);
	if(BBLL<=0||BBLL>a[1]) go();
	BBLL=a[1]-BBLL;
	if(((a[1]-BBLL)^(a[2]+BBLL))==X){
		cout<<BBLL<<endl;
		return 0;
	}
	go();
	return 0;
}


Measured memory_bytes: 3648
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		long E = C*D;
		long F = Math.max(C,D);
		long G = Math.min(C,D);
		for( long i=1; i*i<=G; i++ ){
			if( G%i==0 ){
				if( F%(G/i)==0 ){
					E = (C*D)/(G/i);
					break;
				}
				if( F%i==0 ){
					E = (C*D)/i;
				}
			}
		}    
		System.out.println( (B-A+1) - (B/C+B/D-B/E) + ((A-1)/C+(A-1)/D-(A-1)/E) );     
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct Combination
{
	vector<ll> fact, inv, invFact;
	int MAX_FACT;
	ll MOD;
	Combination(int n, ll mod) : fact(n + 1), inv(n + 1), invFact(n + 1)
	{
		MAX_FACT = n + 1;
		MOD = mod;
		fact[0] = 1;
		fact[1] = 1;
		invFact[0] = 1;
		invFact[1] = 1;
		inv[1] = 1;
		for (auto i = 2; i < MAX_FACT; ++i)
		{
			fact[i] = fact[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			invFact[i] = invFact[i - 1] * inv[i] % MOD;
		}
	}

	unsigned long long calcCombination(int n, int k)
	{
		if (n < k)
		{
			return 0;
		}
		if ((n < 0) || (k < 0))
		{
			return 0;
		}

		return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
	}
};


int main()
{
	int X, Y;
	cin >> X >> Y;

	auto ans = 0ll;
	auto mod = (ll)1e9 + 7;
	auto a = 2 * X - Y;
	auto b = 2 * Y - X;
	if ((X + Y) % 3 == 0
		&& a >= 0
		&& a % 3 == 0
		&& b >= 0
		&& b % 3 == 0)
	{
		a /= 3;
		b /= 3;
		Combination c(a + b, mod);
		ans = c.calcCombination(a + b, a);
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i = 0;i < n; ++i){
		cin >> a[i];
	}
	int sum = accumulate(a, a + n, 0);
	vector<int> div;
	for(int i = 1;i * i <= sum; ++i){
		if(sum % i == 0){
			div.push_back(i);
			div.push_back(sum/i);
		}
	}
	int ans = 0;
	for(int d : div){
		vector<int> mods(n);	
		for(int i = 0;i < n; ++i){
			mods[i] = (d - (a[i] % d)) % d;	
		}
		int tsum = accumulate(mods.begin(), mods.end(), 0);
		sort(mods.rbegin(),mods.rend());
		int moves = 0, ind = 0;
		while(tsum){
			moves += (d-mods[ind]) % d;
			tsum -= d;	
			++ind;
		}
		if(moves <= k){
			ans = max(ans, d); // don't make dumb assumptions
		}
	}
	cout << ans << '\n';
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vpll vector<pll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ln length()
#define M 1000000007
ll n,a,b;
bool pos(ll cen,ll a,ll b,ll mid){
    if(cen <= 0 || cen > mid) return true;
    return cen*(a+mid+1-cen) < a*b;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    rep(i,1,n){
        cin>>a>>b;
        ll k1=0,k2=0;
        ll lo=1,hi=a-1,mid;
        while(lo <= hi){
            mid=(lo+hi)/2;
            ll cen = (mid+b+1)/2;


            if(pos(cen,b,a,mid) && pos(cen+1,b,a,mid) && b+mid < a*b && mid*(b+1) < a*b){
                k1=mid;
                lo=mid+1;
            }
            else hi=mid-1;
        }
        lo=1,hi=b-1;
        while(lo <= hi){
            mid=(lo+hi)/2;
            ll cen = (mid+a+1)/2;

            if(pos(cen,a,b,mid) && pos(cen+1,a,b,mid) && a+mid < a*b && mid*(a+1) < a*b){
                k2=mid;
                lo=mid+1;
            }
            else hi=mid-1;
        }
        ll inter = min(a-1-k1,b-1-k2);
        cout<<k1+k2+inter<<'\n';
    }

}



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

int main() {
  int N, M, count, m=0;
  cin >> N;
  vector<string> b(N);
  for(int i=0;i<N;i++){
    cin >> b.at(i);
  }
  
  cin >> M;
  vector<string> r(M);
  for(int i=0;i<M;i++){
    cin >> r.at(i);
  }
  
  for(int i=0;i<N;i++){
      count=0;
    for(int s=0;s<N;s++){
      if(b.at(i)==b.at(s)){
        count++;
      }
    }
    for(int t=0;t<M;t++){
      if(b.at(i)==r.at(t)){
        count--;
      }
    }
    m=max(m,count);
  }
  cout << m << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EFriendships solver = new EFriendships();
        solver.solve(1, in, out);
        out.close();
    }

    static class EFriendships {
        List<String> answer;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();

            int e = (n - 1) * (n - 2) / 2;

            answer = new ArrayList<>();

            for (int i = 2; i <= n; i++) {
                output(1, i);
            }

            outer:
            for (int i = 2; i <= n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    if (e == k) {
                        break outer;
                    }

                    output(i, j);
                    e--;
                }
            }

            if (e == k) {
                out.println(answer.size());
                for (String s : answer)
                    out.println(s);
            } else {
                out.println(-1);
            }
        }

        private void output(int a, int b) {
            answer.add(a + " " + b);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23764
using System;
using System.Linq;

namespace Linear_Search
{
    class Program
    {
        static void Main()
        {
            Console.ReadLine();
            var a = Console.ReadLine().Split();
            Console.ReadLine();
            var b = Console.ReadLine().Split();
            Console.WriteLine("{0}", a.Intersect(b).Count());
        }
    }
}

Measured memory_bytes: 9908
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  vector<pair<ll,ll>> vec(N-1);
  vector<vector<ll>> tree(N,vector<ll>(0));
  
  for(ll i=0;i<N-1;i++) {
ll a,b;
    cin>>a>>b;
    tree[a-1].push_back(b);
    tree[b-1].push_back(a);
    vec[i]=make_pair(a,b);
  }
  queue<pair<ll,ll>> S;
  S.push(make_pair(1,0));
         map<pair<ll,ll>,ll> W;
  
  ll ans=0;
         while(!S.empty()) {
ll a,b;
           a=S.front().first;
           b=S.front().second;
           S.pop();
           ll i=1;
           for(ll x:tree[a-1]) {
if(W.count(make_pair(x,a))) {
continue;
}
             if(i==b) {
i++;
             }
             W[make_pair(a,x)]=i;
             S.push(make_pair(x,i));
             i++;
           }
           ans=max(ans,i-1);
         }
         
       cout<<ans<<endl;
         for(ll i=0;i<N-1;i++) {
cout<<W[vec[i]]<<endl;
         }
}
  
  
  
  
  
  
  
  
  
  
  
  
  
  

Measured memory_bytes: 17176
/*ॐ नमो भगवते वासुदेवाय नमः*/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).rend()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a, n) sort(a, a + n)
#define sortvec(V) sort(all(V))

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

typedef unordered_map<int, int, custom_hash> u_map;
typedef unordered_set<int, int, custom_hash> u_set;
typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef priority_queue<int> p_queue;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b, int m) {
    a %= m;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve()
{
    int n;
    cin >> n;
    V a(n);
    for(auto & i : a)   cin >> i;
    int ans = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]){
            ans += (a[i] - a[i + 1]);
            a[i + 1] += (a[i] - a[i + 1]);
        }
    }
    cout << ans << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n ";
}

Measured memory_bytes: 4780
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;

typedef vector<pair<int,int>> vpii;

int main(){
    int n,i,tmp,res,pi;
    vi a,b,c;
    cin >> n;
    pb(int,a,n);
    pb(int,b,n);
    pb(int,c,n-1);
    res = 0;
    pi = -1;
    forN(i,n){
        if(a[i] - pi == 1) res += c[pi-1];
        res += b[i];
        pi = a[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 256
S = list(input())
S.reverse()
S = ''.join(S)
idx = 0
len_S = len(S)
flag = True
while idx != len_S:
    if (len_S - idx > 6) and (S[idx:idx+7] == 'remaerd'):
        idx += 7
    elif (len_S - idx > 5) and (S[idx:idx+6] == 'resare'): 
        idx += 6
    elif (len_S - idx > 4) and (S[idx:idx+5] == 'maerd'): 
        idx += 5
    elif (len_S - idx > 4) and (S[idx:idx+5] == 'esare'): 
        idx += 5
    else:
        flag = False
        break

if flag:
    print('YES')
else:
    print('NO')


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__NA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
ll X[MAX_N];
ll Y[MAX_N];

signed main()
{
    ll x_max = 0, y_max = 0;
    ll cnt_odd = 0, cnt_even = 0;
    cin >> N;
    REP(i, N) {
        cin >> X[i] >> Y[i];
        x_max = max(x_max, abs(X[i]));
        y_max = max(y_max, abs(Y[i]));
        if((abs(X[i]) + abs(Y[i])) % 2 == 0) { cnt_even++; }
        else { cnt_odd++; }
    }

    // 最短マンハッタン距離の偶奇が違うなら不可能
    if(cnt_odd > 0 && cnt_even > 0) {
        printf("-1\n");
        return 0;
    }

    const int MaxBit = 32;
    vector<ll> D;

    // D の作成
    D.push_back(1);
    if(cnt_even > 0) { D.push_back(1); }
    {
        ll tmp = 2;
        for(ll i = 1; i <= MaxBit; ++i) {
            D.push_back(tmp);
            tmp *= 2;
        }
    }

    sort(D.begin(), D.end(), greater<ll>());

    // とりあえず m と D を出力
    printf("%zu\n", D.size());
    REP(j, D.size()) {
        printf("%lld", D[j]);
        if(j != D.size() - 1) { printf(" "); }
        else { printf("\n"); }
    }

    REP(i, N) {
        // X, Y 経路の作成
        string path = "";
        // 絶対値が大きい方に対して D の大きい値を加え差をなくしていく
        // X と Y の符号を反転してそこから 0 に戻ることを考える
        X[i] = -X[i];
        Y[i] = -Y[i];
        REP(j, D.size()) {
            if(abs(X[i]) > abs(Y[i])) {
                if(X[i] < 0) {
                    X[i] += D[j];
                    path += 'R';
                }
                else {
                    X[i] -= D[j];
                    path += 'L';
                }
            } else {
                if(Y[i] < 0) {
                    Y[i] += D[j];
                    path += 'U';
                }
                else {
                    Y[i] -= D[j];
                    path += 'D';
                }
            }
        }
        assert(X[i] == 0 && Y[i] == 0);
        printf("%s\n", path.c_str());
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,v,j,now,cnt;
  cin >> N;
  vector<int>d(N);
  for (int i=0;i<N;i++){
    cin >> d.at(i);
  }
  for (int i=1;i<N;i++){
    v = d.at(i);
    j = i - 1;
    while (j>=0 && d.at(j)>v){
      d.at(j+1) = d.at(j);
      j--;
    }
    d.at(j+1) = v;
  }
  while (d.size()>0){
    if (d.at(d.size()-1) == now){
      d.pop_back();
      continue;
    }
    now = d.at(d.size()-1);
    d.pop_back();
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <set>
#include <map>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()

using namespace std;

int main()
{
	int n = 0, m = 0, a = 0;
	while (cin >> n >> m >> a && n != 0)
	{
		vector<vector<int>> dat(1010, vector<int>(10000, 0));
		rep(i, m)
		{
			int tmp[3] = { 0 };
			cin >> tmp[0] >> tmp[1] >> tmp[2];
			dat[tmp[1]][tmp[0]] = tmp[2];
			dat[tmp[2]][tmp[0]] = tmp[1];
		}
		rep(i, 1001)
		{

			if (dat[a][1001 - i] == 0) { continue; }
			else if (dat[a][1001 - i] > 0) { a = dat[a][1001 - i]; }
		}
		printf("%d\n", a);
	}

	return 0;
}

Measured memory_bytes: 42396
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=sort(parseMap(split(readline())))
    println(a+b)
end
main()

Measured memory_bytes: 114880
#include<bits/stdc++.h>
//#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;
using mii=map<int, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<typename T>
vector<vector<T>> fill_vector(int h, int w, T val) {
	vector<vector<T>> ret;
	vector<T> v(w, val);
	rep(h)ret.push_back(v);
	return ret;
}

signed main() {
	makei(n);
	makev(h, n);
	vi ans(n);
	ans[0] = 0;
	ans[1] = abs(h[0] - h[1]);
	Rep(2, n) {
		ans[i] = min(ans[i - 1] + abs(h[i - 1] - h[i]), ans[i - 2] + abs(h[i - 2] - h[i]));
	}
	say(ans.back());
}

Measured memory_bytes: 1024
h,w=map(int,input().split())
b=[list(input())for _ in range(h)]
ans=[w*[10**9]for _ in range(h)]
ans[0][0]=(b[0][0]=="#")+0
for i in range(h):
  for j in range(w):
    if i==j==0:continue
    if i==0:
      if b[0][j-1]=="." and b[0][j]=="#":ans[0][j]=ans[0][j-1]+1
      else:ans[0][j]=ans[0][j-1]
    elif j==0:
      if b[i-1][0]=="." and b[i][0]=="#":ans[i][0]=ans[i-1][0]+1
      else:ans[i][0]=ans[i-1][0]
    else:
      ii=ans[i-1][j]
      if b[i-1][j]=="." and b[i][j]=="#":ii+=1
      jj=ans[i][j-1]
      if b[i][j-1]=="." and b[i][j]=="#":jj+=1
      ans[i][j]=min(ii,jj)
print(ans[-1][-1])

Measured memory_bytes: 3188
a,b,c = map(int, input().split())
z = [int(_) for _ in input().split()]
if a == 1:
  sco = abs(z[0]-c)
else:
  if abs(z[-1] - c) > abs(z[-2] - z[-1]):
    sco = abs(z[-1] - c)
  else:
    sco = abs(z[-2] - z[-1])
    
print(sco)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long ll;
typedef long double ld;
typedef unsigned long long int ull;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
ll n, m, k, y, x, d, w = -1, num=0, sum1,sum2, ans = 0; string s;
ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}
int main(void) {
	cin >> n >> s; vector<int> a(n),b(n);
	rep(i, n) {
		if (s[i] == '1') num++;
	}
	if (num == 1) { // 1の時は処理が面倒なので別々に処理
		if (s[n - 1] == '1') {
			rep(i, n - 1) cout << 2 << endl;
			cout << 0 << endl;
		}
		else {
			rep(i, n - 1) {
				if (s[i] == '1') cout << 0 << endl;
				else cout << 1 << endl;
			}cout << 2 << endl;
		}
		return 0;
	}
	rep(i, n) {
		a[i] = mod_pow(2, n - i - 1, num - 1);
		b[i] = mod_pow(2, n - i - 1, num + 1);
		if(s[i] == '1') sum1 += a[i],sum2 += b[i]; // bitが立っているときにタス。
	}int ss, tt,cnt;
	rep(i, n) {
		ans = 1;
		if (s[i] == '1') ss = (sum1 - a[i] + num - 1) % (num - 1);
		else ss = (sum2 + b[i]) % (num + 1);
		while (ss != 0) {
			cnt = 0;
			tt = ss;
			while (tt > 0) {// __built_count()でもOK
				if (tt % 2) cnt++;
				tt /= 2;
			}
			ans++;
			ss %= cnt;
		}
		cout << ans << endl;
	}
}

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

using namespace std;

vector<int> a;

void f1()
{
    int p;
    cin>>p;

    a.push_back(p);
}

void f2()
{
    int p;
    cin>>p;

    cout<<a[p]<<endl;
}

void f3()
{
    a.pop_back();
}

int main()
{
    int n;

    cin>>n;

    while(n--)
    {
        int op;

        cin>>op;

        switch(op)
        {
            case 0:f1();break;
            case 1:f2();break;
            case 2:f3();break;
        }
    }


    return 0;
}



Measured memory_bytes: 3932
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

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

const int INF = 1 << 24;
 
int main(void){
    for(int n; cin >> n, n;){
        vector<vi> res(n + 1);
        rep(y, n + 1) res[y].resize(n + 1);
        rep(y, n) rep(x, n) cin >> res[y][x];

        rep(y, n) rep(x, n) res[y][n] += res[y][x], res[n][x] += res[y][x];
        rep(y, n) res[n][n] += res[y][n];

        rep(y, n + 1){ rep(x, n + 1) printf("%5d", res[y][x]); cout << endl; }
    }
 
    return 0;
}

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll A,B,N;
    cin >> N >> A >> B;
    ll ans = 0;
    if ((B-A)%2==0) {
        ans = (B-A)/2;
    }
    else {
        ans = A + ((B-A)-1)/2;
        ans = min(ans,(N-B+1)+(N-(A+N-B+1))/2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

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

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    var(int, N);
    vector<int> a(N);
    read(a);

    int cnt = 0;
    rep(i, 1, N - 1) {
        if (a[i - 1] < a[i] && a[i] < a[i + 1])
            ++cnt;
        else if (a[i + 1] < a[i] && a[i] < a[i - 1])
            ++cnt;
    }
    print(cnt);

    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
Xs, Ys = [], []
readlines.each{|l| x, y = l.split.map(&:to_i); Xs << x; Ys << y}

@p = Array.new(N + 1, -1)

def root(x)
  @p[x] < 0 ? x : @p[x] = root(@p[x])
end

def unite(x, y)
  x, y = root(x), root(y)
  if x != y
    x, y =  y, x if @p[y] < @p[x]
    @p[x] += @p[y]
    @p[y] = x
  end
end

xs = (0 ... N).sort_by{|n| Xs[n]}.each_cons(2).to_a
ys = (0 ... N).sort_by{|n| Ys[n]}.each_cons(2).to_a
es = (xs + ys).map{|i, j| [[(Xs[i] - Xs[j]).abs, (Ys[i] - Ys[j]).abs].min, i, j]}.sort
puts es.inject(0){|s, (c, i, j)| root(i) == root(j) ? s : (unite(i, j); s + c)}

Measured memory_bytes: 37124
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli n,p;

bool comp(const pair<lli,lli> &a,const pair<lli,lli> &b){
	return (a.first*(100-p) + a.second*p) < (b.first*(100-p) + b.second*p);
}

signed main(){

	cin>>n>>p;

	vector<pair<lli,lli>> v;

	lli sumW = 0;
	lli sumB = 0;
	REP(i,0,n){
		lli w,b;
		cin>>w>>b;
		sumB += b;
		v.push_back(make_pair(w,b));
	}
	sort(v.rbegin(),v.rend(),comp);

	if(DEBUG){
		REP(i,0,n)cout<<v[i].first<<" "<<v[i].second<<endl;
	}

	for(lli i=0;i<n;i++){
		sumB -= v[i].second;
		sumW += v[i].first;

		if(sumW*100 /(double)(sumW+sumB) >= p){
			cout<<i+1<<endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 2420
a = int(input())
b = int(input())
c = int(input())
x = int(input())

counter = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      if 500 * i + 100 * j + 50 * k == x:
        counter += 1

print(counter)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int K;
  cin >> K;
  for(int i=0; i<S.size(); i++){
    int x = 26 + ('a' - S.at(i));
    if(K >= x && S.at(i) != 'a'){
      S.at(i) = 'a';
      K -= x;
    }
  }
  if(K > 0){
    K %= 26;
    S.at(S.size()-1) = S.at(S.size()-1) + K;
  }
  cout << S << endl;
}

Measured memory_bytes: 764
use std::io::stdin;

fn main() {
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let s:Vec<char> = st.trim().chars().collect();
    let mut g = 0;
    let mut p = 0;
    let mut result = 0;
    for i in 0..(s.len() as usize) {
        if &s[i].to_string() == "g" {
            if p<g {
                result += 1;
                p += 1;
            } else {
                g += 1;
            };
        } else {
            if p<g {
                p += 1;
            } else {
                result -= 1;
                g += 1;
            };
        };
    };
    println!("{}", result);
}

Measured memory_bytes: 4352
import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

X, Y, A, B, C = map(int, readline().split())
p = list(map(int, readline().split()))
q = list(map(int, readline().split()))
r = list(map(int, readline().split()))

p = sorted(p, reverse=True)[:X]
q = sorted(q, reverse=True)[:Y]

bag = p + q + r
bag = sorted(bag, reverse=True)
print(sum(bag[:(X + Y)]))


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

 int main() {
 int N;
 cin >> N;
 vector<int> a(N);
 int sum = 0;

 for (int i = 0; i < N; ++i) {
 cin >> a[i];
 sum += a[i];
 }

 int mini = sum;
 int prefix_sum = 0;
 for (int i = 0; i < N; ++i) {
 cin >> a[i];
 prefix_sum += a[i];
 mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
 }

 cout << mini << endl;
 return 0;
 }

Measured memory_bytes: 256
S=list(input())

count=0
re=0
for i in range(len(S)):
  if i==0:
    count+=1
    pre=S[i]
  else:
    if re==0:
      if S[i]!=pre:
        count+=1
        pre=S[i]
      else:
        re=1
    elif re==1:
      pre="".join([S[i-1],S[i]])
      count+=1
      re=0

print(count)

Measured memory_bytes: 4840
#include <iostream>
using namespace std;
int main(){
	int i,o,s,t,r,e=1,a=1,m,q;
	cin>>i>>o>>s>>t>>r;
	m=o;
	q=t;
	while(i>m){
		e++;
		m=m+o;
	}
	while(i>q){
		a++;
		q=q+t;
	}
	s=s*e;
	r=r*a;
	if(s<=r){
		cout<<s<<endl;
	}else{
		cout<<r<<endl;
	}
return 0;
}


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

using ll = long long int;

int main(){
    int n;
    cin >> n;
    vector<ll> L(n+1);
    L[0] = 2;
    L[1] = 1;
    for(int i=2;i<=n;i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

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

const int INF = 1 << 24;
const int H = 4;

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

    while(n --){
        int out = 0;
        vi t(5);
        while(out != 3){
            t[0] = 1;
            string in; cin >> in;
            
            if(in == "OUT")
                out ++;
            else
                rep(i, 4){
                    int next = in == "HIT" ? 4 - i:H;
                    if(t[3 - i]) t[next] ++, t[3 - i] = 0;
                }
        }
        cout << t[H] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1212
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

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

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

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

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

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

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

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

VI a;
LL temp,N;

int main(void){
    cin>>N;
    temp=1;
    a.PB(temp);
    while(-1){
        temp*=6;
        if(temp > NMAX)break;
        a.PB(temp);
    }
    temp=1;
    while(-1){
        temp*=9;
        if(temp > NMAX)break;
        a.PB(temp);
    }
    LL n=a.size();
    int dp[n+1][NMAX+1];
    REP(i,n+1)REP(j,NMAX+1)dp[i][j]=1<<29;
    REP(i,n+1)dp[i][0]=0;
    REP(i,n)REP(j,NMAX+1){ 
        dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
        if(j>=a[i]){
            dp[i+1][j]=min(dp[i+1][j],dp[i+1][j-a[i]]+1);
        }
    }
    cout<<dp[n][N]<<endl;
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int arr[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
	}
	int m,swap,k=0;
	scanf("%d",&m);
	int p[m][2],arr1[m]={0};
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&p[i][1],&p[i][2]);
		swap=arr[p[i][1]-1];
		arr[p[i][1]-1]=p[i][2];
		for(int j=0;j<n;j++)
		{
			arr1[k]+=arr[j];
		}
		k++;
		arr[p[i][1]-1]=swap;
	}
	for(int k=0;k<m;k++)
	{
		printf("%d\n",arr1[k]);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] d=new int[n];
		for(int i=0; i<n; i++){
			d[i]=sc.nextInt();
		}
		long sum=0;
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				sum+=d[i]*d[j];
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<queue>
#include<memory.h>
using namespace std;
class P{
public :
	int c, x, y;
	bool flag;
	P(int a,int b,int d){
		x = a;
		y = b;
		c = d;
	}
};
int main()
{
	int dx[] = { -2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2 };
	int dy[] = { -1, 0, 1, -2, 2, -2, 2, -2, 2, -1, 0, 1 };
	bool map[10][10][10];
	int px,py,n,x,y;
	while (true){
		memset(map, 0, sizeof(map));
		cin >> px >> py;
		if (!px&&!py)break;
		cin >> n;
		for (int i = 0; i < n; i++){
			cin >> x >> y;
			for (int i2 = -1; i2 < 2; i2++){
				for (int i3 = -1; i3 < 2; i3++){
					int xx = x + i2;
					int yy = y + i3;
					if (xx >= 0 && xx <= 10 && yy >= 0 && yy <= 10){
						map[xx][yy][i] = true;
					}
				}
			}
		}
		queue<P>p;
		p.push(P(px, py, -1));
		bool flag = false;
		while (!p.empty()){
			P q = p.front();
			p.pop();
			if (q.c == n - 1){
				flag = true;
				break;
			}
			for (int i = 0; i < 12; i++){
				int xx = q.x + dx[i];
				int yy = q.y + dy[i];
				if (xx >= 0 && xx < 10 && yy >= 0 && yy < 10 && map[xx][yy][q.c + 1]){
					p.push(P(xx, yy, q.c + 1));
					map[xx][yy][q.c + 1] = false;
				}
			}
		}
		if (flag){
			cout << "OK" << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}
	
}

Measured memory_bytes: 1192
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	int sum = 0;
	int t[110];
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	int m; cin >> m;
	for (int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		a--;
		cout << sum - t[a] + b << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n, b, f, r, v;
    int kousya[5][4][11] = {};
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> b >> f >> r >> v;
        kousya[b][f][r] += v;
    }
    for(int a = 1; a <= 4; a++ ){
        for(int c = 1; c <= 3; c++){
            for (int d = 1; d <= 10; d++){
                cout << " " << kousya[a][c][d];
                
                
            }
            cout << endl;
        }
        if(a != 4){
            cout << "####################" << endl;
        }
        
    }
    return 0;
}
    


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

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n;
int main() {
	scanf("%d", &n);
	if(n&1) {
		printf("%d\n",(n-1+(n-1)*(n-2))/2);
		for(int i=1;i<n;++i) {
			for(int j=i+1;j<=n;++j) {
				if(j+i==n) continue;
				printf("%d %d\n",i,j);
			}
		}
	}
	else {
		printf("%d\n",n*(n-2)/2);
		for(int i=1;i<=n;++i)
			for(int j=i+1;j<=n;++j) {
				if(i+j==n+1) continue;
				printf("%d %d\n",i,j);
			}
	}
	return 0;
}

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

int hand[5];
//iツ氾板姪堋づ個偲ィツつェツ堕シツづづづアツづ按甘鳴係ツつゥ
int sarch(int n)
{
	int g=0,t=0,p=0;//1,2,3
	for(int i=0;i<5;i++){
		switch(hand[i]){
			case 1:
				g++;
				break;
			case 2:
				t++;
				break;
			case 3:
				p++;
				break;
			default:
				break;
		}
	}
	switch(hand[n]){
		case 1:
			if(p==0 && t!=0)
				return 1;
			else if(t==0 && p!=0)
				return 2;
			else
				return 3;
			break;
		case 2:
			if(g==0 && p!=0)
				return 1;
			else if(g!=0 && p==0)
				return 2;
			else
				return 3;
			break;
		case 3:
			if(t==0 && g!=0)
				return 1;
			else if(t!=0 && g==0)
				return 2;
			else
				return 3;
			break;
	}
	return 0;
}

int main()
{
	while(cin >> hand[0]){
		if(hand[0]==0)
			break;
		for(int i=1;i<5;i++){
			cin >> hand[i];
		}
		for(int i=0;i<5;i++){
			cout << sarch(i) <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;
int main(void)
{
	long long X, Y, Z, K;
	long long A[1009], B[1009], C[1009];
	vector<long long> vec;
	cin >> X >> Y >> Z >> K;
	FOR(i, 0, X) {		cin >> A[i];	}
	sort(A, A + X, greater<long long>());
	FOR(i, 0, Y) {		cin >> B[i];	}
	sort(B, B + Y, greater<long long>());
	FOR(i, 0, Z) {		cin >> C[i];	}
	sort(C, C + Z, greater<long long>());
	FOR(i, 0, X) {
		FOR(j, 0, Y) {
			FOR(k, 0, Z) {
				if ((i + 1) * (j + 1) * (k + 1) > K) continue;
				vec.push_back(A[i] + B[j] + C[k]);
			}
		}
	}
	sort(vec.begin(), vec.end(), greater<long long>());
	FOR(i, 0, K) {		cout << vec[i] << endl; 	}
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <math.h>

int main(){
    double x1,x2,y1,y2,r;
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    
    r=hypot((x2-x1),(y2-y1));
    printf("%f",r);
    
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;
#define MOD 1000000007

int main() {
  long long n, k;
  cin >> n >> k;
  long long total = 0;
  for (long long i = k; i <= n + 1; i++) {
    total += (n - i + 1 + n) * i / 2 - (0 + i - 1) * i / 2 + 1;
    total %= MOD;
  }
  cout << total << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template <typename X>
struct BIT
{
  vector<X> dat;
  int n;

  BIT(){
  }

  void init(int _n){
    n = _n+1;
    dat.assign(n,0);    
  }
  
  X sum(int i)
  {
    X s = 0;
    while(i > 0){
      s += dat[i];
      i -= i&(-i);
    }
    return s;
  }

  void add(int i,X x)
  {
    while(i<=n){
      dat[i] += x;
      i += i&(-i);
    }
  }
};

int main()
{
  int n;cin >> n;
  vector<BIT<int>> bt(26);
  rep(i,26) bt[i].init(n+1);
  string s;cin >> s;
  rep(i,n){
    int cc = s[i]-'a';
    bt[cc].add(i+1,1);
  }
  int q;cin >> q;
  vector<int> res;
  rep(i,q){
    int a;cin >> a;
    if(a==1){
      int b;char c;cin >> b >> c;
      int cc = s[b-1]-'a';
      int ccc = c-'a';
      s[b-1]=c;
      bt[cc].add(b,-1);
      bt[ccc].add(b,1);
    }
    else if(a==2){
      int b,c;cin >> b >> c;
      int cnt=0;
      rep(j,26){
	if(bt[j].sum(c)-bt[j].sum(b-1)>=1){
	  cnt++;
	}
      }
      res.push_back(cnt);
    }
  }
  rep(i,res.size()) cout << res[i] << "\n";
 
  
  return 0;
}


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

int main()
{
	int n,k,a[100003],b=0x7ffffff,c=0,d;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<b) b=a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==b) c=c+1;
	}
	d=(n-c)/(k-1);
	if((n-c)%(k-1)!=0)
	d+=1;
	cout<<d;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{
    public static void main(String[] args)throws IOException{
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(isr);
        String string;
        int h, w, n, c, v;
         
        while(!(string = reader.readLine()).equals("0 0")){
            h = Integer.parseInt(string.split(" ")[0]);
            w = Integer.parseInt(string.split(" ")[1]);
             
            int[][] array = new int[h + 1][w + 1];
            boolean[][] imp = new boolean[h + 1][w + 1];
             
            n = Integer.parseInt(reader.readLine());
            for(int i = 0; i < n; i++){
                string = reader.readLine();
                c = Integer.parseInt(string.split(" ")[0]);
                v = Integer.parseInt(string.split(" ")[1]);
                imp[c][v] = true;
            }
             
            array[1][1] = 1;
            for(int i = 1; i <= h; i++){
                for(int j = 1; j <= w; j++){
                    if(!imp[i][j]){
                        array[i][j] = array[i][j - 1] + array[i - 1][j];
                        if(i == 1 && j == 1) array[i][j] = 1;
                    }else{
                        array[i][j] = 0;
                    }
                }
            }
            System.out.println(array[h][w]);
        }
        reader.close();
    }
}

Measured memory_bytes: 24028