akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
	
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d.at(i);
	}

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

	int ans=0;

	if (N % 2 == 0) {
		if (d.at(N / 2) != d.at(N / 2 - 1)) {
			ans += d.at(N / 2) - d.at(N / 2 - 1);
		}
	}
	else {
		if (!(d.at((N - 1) / 2) == d.at((N - 1) / 2 + 1) && d.at((N - 1) / 2) == d.at((N - 1) / 2 - 1))) {
			ans += 1;
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;


public class Main{

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		ArrayList<Integer> intervalList = new ArrayList<Integer>();
		intervalList.add(1);
		int tmp = 1;
		for(;;){
			tmp = tmp*3+1;
			if(intervalList.size() > 100 || tmp >= num)
				break;
			intervalList.add(tmp);
		}
		Collections.reverse(intervalList);
		ArrayList<String> list = new ArrayList<String>();
		for(int i=0; i<num;i++)
			list.add(scan.next());
		scan.close();
		InsertionSort insSort = new InsertionSort(num);
		insSort.loadSequence((String[])list.toArray(new String[0]));
		for(int i=0; i<intervalList.size();i++)
			insSort.sort(intervalList.get(i));
			
		//output
		//line#1
		System.out.println(intervalList.size());
		//line#2
		String str="";
		for(int i=0; i<intervalList.size();i++)
			str = str + " " + intervalList.get(i);
		System.out.println(str.trim());
		//line#3
		System.out.println(insSort.count);
		//line#4~
		for(int i=0; i<insSort.sortList.size();i++)
			System.out.println(insSort.sortList.get(i));
		
		
	}

}

class InsertionSort extends SortingNumbers{
	int interval = 1;
	int count = 0;
	public InsertionSort(int n){
		super(n);
	}
	
	public void sort(int g){
		interval = g;
		sort();
	}
	@Override
	public void sort(){
		for(int i=interval; i<this.length;i++){
			comparable key = sortList.get(i);
			int j=i-interval;
			for(; j>=0 ;){
				if(sortList.get(j).compValue()<=key.compValue())
					break;
				sortList.set(j+interval,sortList.get(j));
				j-=interval;
				count++;
			}
			sortList.set(j+interval, key);
		}
	}
}


interface comparable{
	int compValue();
}
class numbers implements comparable{
	Integer num;
	public numbers(String str){
		num = Integer.parseInt(str);
	}
	@Override
	public int compValue(){
		return num;
	}
	@Override
	public String toString(){
		return num.toString();
	}
}
class SortingNumbers extends Sorting{
		public SortingNumbers(int n){
		super(n);
	}
	@Override
	public void loadSequence(String[] str){
		for(int i=0; i<this.length;i++)
			sortList.add(new numbers(str[i]));
	}
	@Override
	public void sort(){};
}

abstract class Sorting{
	int swapTimes;
	int length;
	ArrayList<comparable> sortList;
	public Sorting(int n){
		swapTimes=0;
		length=n;
		sortList = new ArrayList<comparable>();
	}
	
	@Override
	public String toString(){
		String tmp = "";
		for(int i=0; i<length; i++)
			tmp = tmp + " " + sortList.get(i);
		return tmp.trim();
	}
	void swap(int i, int j){
		swapTimes++;
		comparable tmp = sortList.set(i,sortList.get(j));
		sortList.set(j,tmp);
	}
	abstract public void loadSequence(String[] str);
	abstract public void sort();
}

Measured memory_bytes: 285116
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n,m;
int nei[55][55];
int hv[55];
ll dp[1<<20];

bool dfs(int now,int lst,int to,int id){
	if(now==to)return 1;
	cont(i,n)if(i!=lst&&nei[now][i]&&dfs(i,now,to,id))return hv[nei[now][i]]|=(1<<id),1;
	return 0;
}
 
int main(){
	scanf("%d",&n);
	cont(i,n-1){
		int a,b;scanf("%d%d",&a,&b);
		nei[a][b]=nei[b][a]=i;
	}
	scanf("%d",&m);
	loop(i,m){
		int a,b;scanf("%d%d",&a,&b);
		dfs(a,0,b,i);
	}
	dp[0]=1;
	cont(i,n-1)range(j,(1<<m)-1,0,-1)dp[j|hv[i]]+=dp[j];
	printf("%lld\n",dp[(1<<m)-1]);
	return 0;
}

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

int main() {
	int a;
	cin >> a;
	if (a <= 111) {
		cout << "111" << endl;
	}
	else if (a <= 222) {
		cout << "222" << endl;
	}
	else if (a <=333)  {
		cout << "333" << endl;
	}
	else if (a <= 444) {
		cout << "444" << endl;
	}
	else if (a <= 555) {
		cout << "555" << endl;
	}
	else if (a <= 666) {
		cout << "666" << endl;
	}
	else if (a <= 777) {
		cout << "777" << endl;
	}
	else if (a <= 888) {
		cout << "888" << endl;
	}
	else if (a <= 999) {
		cout << "999" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

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

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

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, D, ans;
  cin >> N >> D >> ans;

  REP(i, N){
    int a;
    cin >> a;
    ans += (D-1+a)/a;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> s;
    int sum = 0;
    s.push_back(0);
    for(int i = 0; i < n; i++){
        int t;
        cin >> t;
        s.push_back(t);
        sum += t;
    }
    sort(s.begin(), s.end());
    int ans = sum;
    for(int i = 0; i < s.size(); i++){
        if((ans - s[i]) % 10 != 0){
            ans -= s[i];
            break;
        }
    }
    if(ans % 10 == 0){
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
N, M = map(int, input().split())
S = input()
T = input()
lcm = N * M // gcd(N, M)
tmp = {}
for s, i in zip(S, range(0, lcm, lcm//N)):
    tmp[i] = s
is_ans = True
for t, i in zip(T, range(0, lcm, lcm//M)):
    if i in tmp:
        if tmp[i] == t:
            continue
        is_ans = False
        break
if is_ans:
    print(lcm)
else:
    print(-1)


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	int d = 0;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		d += min(x, k-x);
	}
	cout << d*2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
const double EPS=1E-8;
////////////////////////////////////////



int main() {
   // ios::sync_with_stdio(false);cin.tie(0);
    
    ll n;scanf("%lld",&n);
    ll a[n],b[n];rep(i,0,n-1)scanf("%lld",&a[i]);
    rep(i,0,n-1)scanf("%lld",&b[i]);
    ll ans=0;
    rep(k,1,29){
        ll p=(ll)1<<k;
        ll c[n],d[n];
        rep(i,0,n-1){
            d[i]=b[i]%p;
            c[i]=a[i]%p;
        }
        sort(d,d+n);
        ll sum=0;
        rep(i,0,n-1){
            sum+=lower_bound(d,d+n,p-c[i])-lower_bound(d,d+n,p/2-c[i]);
            sum+=lower_bound(d,d+n,2*p-c[i])-lower_bound(d,d+n,3*p/2-c[i]);
        }
        if(sum%2)ans+=1<<(k-1);
    }
    //cout<<ans<<endl;
    printf("%lld",ans);
    return 0;
}
//ios::sync_with_stdio(false);cin.tie(0);


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

int main() {
  int N, sum;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N, K;
    cin >> N >> K;
    vector<pair<int, int>> ans;
    if(K > (N - 1) * (N - 2) / 2) {
        cout << -1 << endl;
        return 0;
    }
    for(int i = 1; i < N; i++) ans.push_back({0, i});
    int c = (N - 1) * (N - 2) / 2 - K;
    for(int i = 1; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            if (c > 0) {
                ans.push_back({i, j});
                c--;
            }
        }
    }
    cout << ans.size() << endl;
    for(auto &x : ans) cout << x.first + 1 << " " << x.second + 1 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<typename T>
struct BinaryIndexedTree{
    vector<T> data;
    int sz;

    BinaryIndexedTree(int n){
        sz = n + 1;
        data.assign(sz, 0);
    }

    void add(int i, T x){
        ++i;
        while(i < sz){
            data[i] += x;
            i += i & -i;
        }
    }

    // [0, i] の区間和
    T sum(int i){
        T res = 0;
        ++i;
        while(i > 0){
            res += data[i];
            i -= i & -i;
        }
        return res;
    }

    T sum(int l, int r){
        return sum(r - 1) - sum(l - 1);
    }

    // val 以上を満たす 0-indexed の位置を返す
    int lower_bound(T val){
        // if(val <= 0)    return -1;
        int res = 0;
        int n = 1;
        while(n < sz)   n <<= 1;
        for(int k = n >> 1; k > 0; k >>= 1){
            if(res + k < sz && data[res + k] < val){
                val -= data[res + k];
                res += k;
            }
        }
        return res;     // 1-indexed であれば、res + 1 を返す
    }
};

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

    int n, m, q;
    cin >> n >> m >> q;
    vector<tuple<int, int, int>> table;
    for(int i = 0; i < m; ++i){
        int l, r;
        cin >> l >> r;
        table.emplace_back(l, q, r);
    }
    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        table.emplace_back(l, i, r);
    }
    sort(table.begin(), table.end());
    // for(auto tup : table){
    //     cout << get<0>(tup) << ' ' << get<1>(tup) << ' ' << get<2>(tup) << endl;
    // }
    BinaryIndexedTree<int> bit(n + 1);
    for(auto tup : table){
        if(get<1>(tup) < q) continue;
        bit.add(get<2>(tup), 1);
    }
    vector<int> ans(q);
    for(auto tup : table){
        int i = get<1>(tup);
        if(i == q)  bit.add(get<2>(tup), -1);
        else{
            int l = get<0>(tup), r = get<2>(tup);
            ans[i] = bit.sum(r) - bit.sum(l - 1);
        }
    }
    for(int x : ans)    cout << x << '\n';
}

Measured memory_bytes: 9436
#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 RFOR(i, k, j) for (int i = k - 1; i >= j; i--)
#define RREP(i, j) RFOR(i, j, 0)
#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;
typedef vector<pii> vpii;

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() {

    const int mod = 1000000007;

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

    int n;
    cin >> n;
    
    string s;
    cin >> s;

    if (s[0] == 'W' or s.back() == 'W') {
        cout << 0 << endl;
        return 0;
    }

    vi v1, v2;
    v1.push_back(0);
    bool is_left = true;
    FOR(i, 1, s.size()) {
        if (s[i] != s[i - 1]) {
            if (is_left) v1.push_back(i);
            else v2.push_back(i);
        } else {
            is_left = !is_left;
            if (is_left) v1.push_back(i);
            else v2.push_back(i);
        }
    }

    if (v1.size() != v2.size()) {
        cout << 0 << endl;
        return 0;
    }

    // REP(i, n) cout << v1[i] << " "; cout << endl;
    // REP(i, n) cout << v2[i] << " "; cout << endl;
    
    sort(rall(v1)); sort(all(v2));
    int cnt = 0;
    ll ans = 1;
    for (auto e : v1) {
        ll rem = (v2.end() - upper_bound(all(v2), e)) - cnt;
        //  cout << "rem " << rem << endl;
        ans = ans * rem % mod;
        cnt++;
    }

    FOR (i, 1, n + 1) {
        ans = ans * i % mod;
    }

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


Measured memory_bytes: 1936
import java.io.*;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner();
        int h = in.nextInt();
        int w = in.nextInt();
        int[][] costs = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                costs[i][j] = in.nextInt();
            }
        }
        
        int[][] dp = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                dp[i][j] = Integer.MAX_VALUE;
            }
            dp[i][i] = 0;
            Queue<Integer> q = new LinkedList<>();
            q.add(i);
            while (!q.isEmpty()) {
                int cur = q.poll();
                for (int j = 0; j < 10; j++) {
                    if (costs[cur][j] + dp[i][cur] < dp[i][j]) {
                        q.add(j);
                        dp[i][j] = costs[cur][j] + dp[i][cur];
                    }
                }
            }
        }
        
        int count = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int x = in.nextInt();
                if (x != -1) {
                    count += dp[x][1];
                }
            }
        }
        System.out.println(count);
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}


Measured memory_bytes: 27220
#include<cstdio>
///#include<iostream>
using namespace std;

int main ()
{
while  (true)
  {
  int loop,vna,vnb;
  scanf("%d",&loop);
  if (loop == 0)
    {
	break;
	  };
  vna=0;
  vnb=0;
  for (int i=0;i<loop;i++)
    {
      int vn2,vn3;
      scanf("%d",&vn2);
      scanf("%d",&vn3);
      if (vn2 > vn3)
	{
	  vna = vna + vn2 + vn3;
	    };
      if (vn2 < vn3)
	{
	  vnb = vnb + vn2 + vn3;
	    };
      if(vn2 == vn3)
	{
	  vna = vna + vn2;
	  vnb = vnb + vn3;
	};
    };
  printf ("%d %d\n",vna,vnb);


 };

}

Measured memory_bytes: 1028
#include <stdio.h>

int main()
{
    int N, T, c[100], t[100], i, minc;
    scanf("%d%d", &N, &T);
    minc = 1001;
    for (i=0; i<N; i++)
    {
        scanf("%d %d", &c[i], &t[i]);
    }
    for (i=0; i<N; i++)
    {
        if (t[i]<=T) {
            if (c[i]<minc) {
                minc = c[i];
            }
        }
    }
    if (minc == 1001) {
        printf("TLE\n");
    } else {
        printf("%d\n", minc);
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main {
    static StringBuilder sb;

    public static void solve(String n) {
        long sum = 0;
        for (int i = 0; i < n.length(); i++) {
            sum += n.charAt(i) - '0';
        }
        if (sum % 9 == 0) sb.append("Yes");
        else sb.append("No");
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        sb = new StringBuilder();

        String n = sc.next();

        solve(n);

        pw.print(sb);
        pw.flush();
        sc.close();
    }
}

Measured memory_bytes: 40268
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000001;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	ll N;
	cin>>N;
	N--;
	if(N==0){
		cout<<'a'<<endl;
		return 0;
	}

	vi digit(11);
	int max=0;
	rep(i,0,12){
		ll div=(ll)pow(26,i);
		if(N/div==0){
			max=i;
			break;
		}
	}
	string ans;
	rep(i,0,max){
		digit[i]=N%26;
		ans.pb((char)('a'+digit[i]));
		N/=26;
		N--;
		if(N<0) break;
		DBG(i,N,ans,"");
	}
	reverse(all(ans));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3980
s = int(input())
s1 = s//100
s2 = s%100//10
s3 = s%100%10

count = 0

if s1 == 1:
  count = count +1
  
if s2 == 1:
  count = count +1

if s3 == 1:
  count = count +1

print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i=1;i<=ty-sy;i++)
    {
        cout<<"U";
    }
    for(int i=1;i<=tx-sx;i++)
    {
        cout<<"R";
    }
    for(int i=1;i<=ty-sy;i++)
    {
        cout<<"D";
    }
    for(int i=1;i<=tx-sx;i++)
    {
        cout<<"L";
    }
    cout<<"L";
    for(int i=0;i<=ty-sy;i++)
    {
        cout<<"U";
    }
    cout<<"R";
    for(int i=1;i<=tx-sx;i++)
    {
        cout<<"R";
    }
    cout<<"D";
    cout<<"R";
    for(int i=0;i<=ty-sy;i++)
    {
        cout<<"D";
    }
    cout<<"L";
    for(int i=1;i<=tx-sx;i++)
    {
        cout<<"L";
    }
    cout<<"U";
    return 0;
}

Measured memory_bytes: 256
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int main()
{
	_fast_
	ll t = 1;
	//cin>>t;
	while(t--){
	ll n,m;
	cin>>n>>m;
	ll arr[n];
	f(n)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	ll sum = 0;
	for(ll i = 0;i<n-m;i++)
	{
		sum += arr[i];
	}
	cout<<sum<<"\n";
	}
	return 0;
}

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

int main(){
  int n,p;
  while(cin>>n>>p,n){
    int man[n];
    for(int i=0;i<n;i++){
      man[i]=0;
    }
    int cnt=0;
    int stone=p;
    while(man[cnt]!=p){
      if(stone!=0){
	man[cnt]++;
	stone--;
      }else{
	stone=man[cnt];
	man[cnt]=0;
      }
      if(cnt==n-1)cnt=0;
      else cnt++;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    vector<vector<int>> c2i(26, vector<int>());
    string S, T;
    cin >> S;
    cin >> T;

    for (int i = 0; i < S.size(); i++)
        c2i[S[i] - 'a'].push_back(i);

    //for (auto is : c2i)
    //{
    //    for (auto i : is)
    //        cout << i << " ";
    //    cout << endl;
    //}

    int cur = 0, count = 0;
    int ci;
    int insertedIdx;
    for (int i = 0; i < T.size(); i++)
    {
        ci = T[i] - 'a';
        insertedIdx = lower_bound(c2i[ci].begin(), c2i[ci].end(), cur) - c2i[ci].begin();

        if (c2i[ci].size() == 0)
        {
            cout << -1 << endl;
            return 0;
        }

        if (insertedIdx == c2i[ci].size() || c2i[ci][insertedIdx] < cur)
        {
            count++;
            cur = c2i[ci][0] + 1;
        }
        else
            cur = c2i[ci][insertedIdx] + 1;
    }

    cout << count * S.size() + cur << endl;
}

Measured memory_bytes: 1216
import random
import sys
input = sys.stdin.readline
#import copy
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[tuple(map(int,input().split())) for _ in range(D)]   #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
#types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
#last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0
s=tuple(s)
#print(s)
types=[(i%26)+1 for i in range(D)]
#print(l)
sc = [0] * D
last=[0]*26
#print(c,s)
for i in range(D):
    typ = types[i] - 1
    score = s[i][typ]
    dwn = 0
    last[typ] = (i + 1)
    for j in range(26):
        dwn = dwn + c[j] * ((i + 1) - last[j])
    ans = score - dwn
    # print(score,last)
    sc[i] = max(ans+10**6,0)
all = sum(sc)
for _ in range(30000):
    types2 = [0]*D
    mi=float("inf")
    ind=0
    for i in range(D):
        if mi>sc[i]:
            mi=sc[i]
            ind=i
    l=list(range(1,D+1))
    #print(l)
    #print(ind,types[ind]-1)
    l.pop(ind-1)
    ind2=random.choice(l)
    spans=ind//26
    for i in range(D):
        types2[i]=types[i]
    buf=types[ind]
    types[ind]=types[ind2-1]
    types[ind2-1]=buf
    sc2=[0]*D
    last=[0]*26
    for i in range(D):
        typ = types[i] - 1
        score = s[i][typ]
        dwn = 0
        last[typ] = (i + 1)
        for j in range(26):
            dwn = dwn + c[j] * ((i + 1) - last[j])
        ans = score - dwn
                # print(score,last)
        sc2[i] = max(ans+10**6,0)
    all2 = sum(sc2)
    if all2<=all:
        types=types2
    else:
        sc=sc2
        all=all2
        sc2=[]
        #print(114514)
    #print(all)
    #input()
for i in range(D):
    print(types[i])






Measured memory_bytes: 85936
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <climits>
#include <numeric>
int main() {
	int n; std::cin >> n;
	std::vector<int> node_values(n);
	for (auto& node : node_values) std::cin >> node;
	std::vector<std::vector<int>> nodes(n);
	for (auto i = 0; i < n - 1; ++i) {
		int u, v; std::cin >> u >> v;
		nodes[--u].push_back(--v);
		nodes[v].push_back(u);
	}
	std::vector<int> result(n, -1), longest(n, INT_MAX);
	std::vector<std::pair<int, int>> revert(n, std::make_pair(-1, -1));
	std::stack<int> stack; stack.push(0);
	while (!stack.empty()) {
		const auto top = stack.top();
		if (result[top] == -1) {
			const auto pos = std::distance(longest.begin(), std::lower_bound(longest.begin(), longest.end(), node_values[top]));
			revert[top] = std::make_pair(pos, longest[pos]);
			longest[pos] = node_values[top];
			result[top] = std::distance(longest.begin(), std::lower_bound(longest.begin(), longest.end(), INT_MAX));
			for (const auto next : nodes[top]) if (result[next] == -1) stack.push(next);
		}
		else {
			stack.pop();
			longest[revert[top].first] = revert[top].second;
		}
	}
	for (const auto r : result) std::cout << r << '\n';
}

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

int main(void)
{
    int n, x ;
    
    cin >> n >> x ;
    std::vector<int> l(100,0) ;
    for (int i = 0; i < n; i++)
        cin >> l[i] ;
    
    int total = 0, j;
    for (j = 0; j < n; j++) {
        total += l[j] ;
        if (total > x) {
            break ;
        }
    }
    cout << j+1 << endl ;

    return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
const int MAXN=100000+20;
int n; 
int h[MAXN];
int dp[MAXN];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>h[i];
	}
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;++i)
	{
		dp[i]=min((dp[i-1]+abs(h[i]-h[i-1])),(dp[i-2]+abs(h[i]-h[i-2])));
	}
	cout<<dp[n]<<endl;
	
	return 0;
}


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

using namespace std;

int main(void)
{
	int a[9];
	for(int i = 0; i < 9; i++){
		cin>>a[i];
	}
	int n;
	cin>>n;
	int b[n];
	for(int i = 0; i < n; i++) cin>> b[i];
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 9; j++){
			if(b[i] == a[j]) a[j] = 200;
		}
	}
	if(a[0] == a[3] &&a[0] == a[6] &&a[0] == 200) cout<<"Yes"<<endl;
	else if(a[1] == a[4]&&a[1] == a[7]&&a[1] == 200) cout<<"Yes"<<endl;
	else if(a[2] == a[5]&&a[2] == a[8]&&a[2] == 200) cout<<"Yes"<<endl;
	else if(a[0] == a[1]&&a[0] == a[2]&&a[0] == 200) cout<<"Yes"<<endl;
	else if(a[3] == a[4]&&a[3] == a[5]&&a[3] == 200) cout<<"Yes"<<endl;
	else if(a[6] == a[7]&&a[6] == a[8]&&a[6] == 200) cout<<"Yes"<<endl;
	else if(a[0] == a[4]&&a[0] == a[8]&&a[0] == 200) cout<<"Yes"<<endl;
	else if(a[2] == a[4]&&a[2] == a[6]&&a[2] == 200) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
using namespace std;
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	 long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//string s[1001];
	//long long n, A[1000000000];
	//string s;
	 long n;
	cin >> n;
	 long A[200002];

	for (a = 1; a <= n; a++)
	{
		cin >> A[a];
		A[a] -= a + 1;
	}
	sort(A+1, A + n+1);
	/*for (a = 1; a <= n; a++)
	{
		cout << A[a] << endl;
	}*/
	if (n%2==1)
	{
		b = ((double)n  / 2) + 0.5000001;
		//cout << b << endl;
		//cout << 1111111111111111111 << endl;
		b=A[b];
	}
	else
	{
		b = A[n/2]+ A[(n / 2)+1];
		b =((double)b/2)+0.5;
	}
	//cout << A[n/2] << endl;

	for (a = 1; a <= n; a++)
	{
		d += abs(A[a] - b);
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 1792
s = input()
op = ["+","-"]
for i in range(2**(len(s)-1)):
    t = s[0]
    for j in range(len(s)-1):
        t += op[(i>>j)&1] + s[j+1]
    if eval(t) == 7:
        ans = t+"=7"
print(ans)

Measured memory_bytes: 3060
import math


def main():

    a, b, h, m = map(int, input().split())
    kakub = 6.0 * m
    kakua = 30.0 * h + (30.0 * (m / 60.0))
    maxx = max(kakua, kakub)
    minn = min(kakua, kakub)

    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn
    else:
        aug = 180.0

    if aug == 180.0:
        ans = a + b
        print(ans)

    else:
        ans = (a ** 2.0) + (b ** 2.0) - ((2.0 * a * b) * math.cos(math.radians(aug)))
        print(math.sqrt(ans))


if __name__ == '__main__':
    main()


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

int main(){
  int x,y,m,n;
  while(1){
    cin>>x>>y;
    m=max(x,y);
    n=min(x,y);

    if (x==0 && y==0) break;
    else cout<<n<<" "<<m<<endl;
  }
}


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

using namespace std;

int main() {
    int h , n;
    cin>>h>>n;
    int s = 0;
    for(int i = 0 ; i < n; ++i){
        int x; cin>>x;
        s += x;
    }
    //cerr<<s<<"\n";
    cout<<((s>=h)?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef array<ll,2> pll;
const ll NMAX=100005;
ll dp[NMAX],deg[NMAX];
vector<ll> edg[NMAX];

int main()
{
    ll n,m,ans=0;
    cin>>n>>m;
    for(ll i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        deg[b]++;
        edg[a].push_back(b);
    }
    queue<ll> q;
    for(ll i=1;i<=n;i++){
        if(!deg[i]){
            q.push(i);
        }
    }
    while(!q.empty()){
        for(auto it : edg[q.front()]){
            dp[it]=max(dp[it],dp[q.front()]+1);
            deg[it]--;
            if(!deg[it])
                q.push(it);
        }
        ans=max(ans,dp[q.front()]);
        q.pop();
    }
    cout<<ans;
    return 0;
}


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

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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n, k; cin >> n >> k;
	
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

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

	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += a[i];
	}

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

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<" "<<x<<endl;

using namespace std;

		  #define dsz 300000
          ll dsu[dsz];
          ll si[dsz];

          void sdsu(ll n){for(ll i=0;i<n;i++){dsu[i]=i;si[i]=1;}}

          ll root(ll a){
          	if(dsu[a]==a)return a;
          	else return dsu[a]=root(dsu[a]);
          }
          
          void join(ll x,ll y){
          	ll x1=root(x);
          	ll x2=root(y);
          	if(x1==x2)return;
          	if(si[x1]<si[x2])swap(x1,x2);
          	si[x1]+=si[x2];
          	dsu[x2]=x1;
          }





		
void run(){
	ll n,m;
	cin>>n>>m;
	sdsu(n+4);
	for(ll i=0;i<m;i++){ll x,y;cin>>x>>y;join(x,y);}
	ll maxi=0;
	for(ll i=1;i<=n;i++){
		ll f=root(i);
		ll se=si[f];
		maxi=max(maxi,se);
	}
	cout<<maxi;	
}

int main() {
	int t=1;
	//cin>>t;
	for(ll i=0;i<t;i++){
	run();
	}
	// your code goes here
	return 0;
}

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

typedef long long ll;

const ll M=1000000007;

ll dp[1000006][2][2];

ll f(int k,int x,int y)
{
    if(k==0) return (x && y);
    if(dp[k][x][y]!=-1) return dp[k][x][y];
    dp[k][x][y]=0;
    for(int i=0;i<=9;i++){
        int a=(i==0 || x);
        int b=(i==9 || y);
        dp[k][x][y]+=f(k-1,a,b);
        if(dp[k][x][y]>=M) dp[k][x][y]-=M;
    }
    return dp[k][x][y];
}

int main()
{
    ll n;
    cin>> n;
    //memset(dp,-1,sizeof(dp));
    for(int k=0;k<=n;k++){
        for(int x=1;x>=0;x--){
            for(int y=1;y>=0;y--){
                if(k==0) dp[k][x][y]=(x && y);
                else{
                    for(int i=0;i<=9;i++){
                        int a=(i==0 || x);
                        int b=(i==9 || y);
                        dp[k][x][y]+=dp[k-1][a][b];
                        if(dp[k][x][y]>=M) dp[k][x][y]-=M;
                    }
                }
                //cout<< k << "," << x << "," << y << " --> " << dp[k][x][y] <<endl;
            }
        }
    }
    //cout<< f(n,0,0) <<endl;
    cout<< dp[n][0][0] <<endl;
    return 0;
}

Measured memory_bytes: 34864
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a, b, n;
	cin >> n >> a >> b;
	int ans = min(n*a, b);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a==b && b==c)
        printf("No\n");
    else if(a==b || b==c || c==a)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int a[214514];
double b[214514];
signed main(){
	ic(n)
	double sum=0;
	rep(0,i,n){
		cin>>b[i];
		sum+=1/b[i];
	}
	double ans=1/sum;
	printf("%.100f\n",ans);
}		


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,k;
ll a,b,c;
int main()
{
	cin>>s>>k;
	if(s=="H") 
	{
		if(k=="H") cout<<"H"<<endl;
		else cout<<"D"<<endl;
	}
	if(s=="D") 
	{
		if(k=="H") cout<<"D"<<endl;
		else cout<<"H"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a,b,c,i;
    cin>>i;
    for(int n=0;n<i;n++){
        cin>>a>>b>>c;
        if(a*a == b * b + c * c){
            cout<<"YES"<<endl;
        }else if(b*b == a * a + c * c){
            cout<<"YES"<<endl;
        }else if(c*c == b * b + a * a){
            cout<<"YES"<<endl;
        }else{cout<<"NO"<<endl;}
    }
    return 0;
}

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

using namespace std;

int main()
{
    long long int n,a,b;
    while(~scanf("%lld%lld%lld",&n,&a,&b))
    {
      	long long int ans = n/(a+b)*a;
      	long long int rem = n%(a+b);
      	printf("%lld\n",ans+min(rem,a));
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;

int N, M, A, B, C, T;

mat mul(const mat &A, const mat &B) {
	mat C(A.size(), vec(B[0].size()));
	for (int i = 0; i < A.size(); i++)
		for (int k = 0; k < B.size(); k++)
			for (int j = 0; j < B[0].size(); j++)
				C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
	return C;
}

mat powMat(mat A, int n) {
	mat B(A.size(), vec(A.size()));
	for (int i = 0; i < A.size(); i++)
		B[i][i] = 1;
	while (n >> 0) {
		if (n & 1) B = mul(B, A);
		A = mul(A, A);
		n >>= 1;
	}
	return B;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> N >> M >> A >> B >> C >> T, N || M || A || B || C || T) {
		vec s(N);
		for (int i = 0; i < N; i++)
			cin >> s[i];

		mat a(N, vec(N));
		a[0][0] = B;	a[0][1] = C;
		a[N - 1][N - 2] = A; a[N - 1][N - 1] = B;
		for (int i = 1; i < N - 1; i++)
			a[i][i - 1] = A, a[i][i] = B, a[i][i + 1] = C;
		a = powMat(a, T);
		vec ans(N);
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				ans[i] += a[i][j] * s[j];
		for (int i = 0; i < N - 1; i++)
			cout << ans[i] % M << " ";
		cout << ans[N - 1] % M << endl;
	}
}

Measured memory_bytes: 1292
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

/**
 * Sieve of Eratosthenes
 */
template <size_t N>
struct Sieve {
  using Integer = int;
  bool is_prime[N + 1];
  constexpr Sieve() : is_prime() {
    Integer sqrt_N = sqrt(N);

    for (Integer i = 0; i <= N; i++) is_prime[i] = true;

    is_prime[1] = false;
    is_prime[2] = true;

    for (Integer p = 2; p <= sqrt_N; p++) {
      if (is_prime[p] == false) continue;

      is_prime[p] = true;

      for (Integer i = p + 1; i <= N; i++) {
        if (i % p == 0) is_prime[i] = false;
      }
    }
  }
};

Sieve<200> sieve;

int count_factors (int n, int p) {
  int x = n;
  int count = 0;
  while (x % p == 0) {
    x /= p;
    count++;
  }
  return count;
}

int factorize_and_count (int m) {
  int divisors = 1;
  for (int i = 1; i <= m; i++) {
    if (m % i == 0 && sieve.is_prime[i]) {
      divisors *= (count_factors(m, i) + 1);
    }
  }
  return divisors;
}

/**
 * main
 */
int main () {
  int N, count = 0;
  cin >> N;

  for (int m = 1; m <= N; m++) {
    if (m % 2 != 1) continue;
    if (factorize_and_count(m) == 8) count++;
  }

  cout << count << '\n';
}


Measured memory_bytes: 256
import heapq


def main():
    n, m = [int(e) for e in input().split()]
    AB = [[int(e) for e in input().split()] for i in range(n)]

    AB.sort(key=lambda x: x[0])
    H = []
    ans = 0
    mi = 1
    for a, b in AB:
        while a > mi:
            if len(H) > 0:
                ans += -heapq.heappop(H)

            mi += 1
            if mi > m:
                break

        if a > m:
            break

        heapq.heappush(H, -b)

    while mi <= m and len(H) > 0:
        ans += -heapq.heappop(H)
        mi += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 97488
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
i = 1
j = 0
ans = 1
while i < n and j < 2:
    if a[i-1] == a[i]:
        ans *= a[i]
        j += 1
        i += 2
    else:
        i += 1
if j == 2:
    print(ans)
else:
    print(0)

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

int colorsize;
const int MAXN = 1e5;
vector<vector<int>> to(MAXN);

map<P,int> mp;

void dfs(int v, int col){
   // cout << v << " " << col << "---" << endl;
	col++;
	for(auto next : to[v]){
		if(mp.find(P(v,next)) == mp.end()){
			mp[P(v,next)] = col%colorsize + 1;
			mp[P(next,v)] = col%colorsize + 1;
			dfs(next,col);
			col++;
		}
	}
	return;
}

int main(){
	int n;
	cin >> n;
	
	vector<int> a(n-1),b(n-1);
	rep(i,n-1){
		int x,y;
		cin >> x >> y;
		--x; --y;
		a[i] = x;
		b[i] = y;
		to[x].push_back(y);
		to[y].push_back(x);
		
	}
	
	
	
	
	rep(i,n) colorsize = max(colorsize, (int)to[i].size());
	
	dfs(0,-1);
	
	cout << colorsize << endl;
	rep(i,n-1) cout << mp[P(a[i],b[i])] << endl;
	
	return 0;
}


Measured memory_bytes: 19328
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define P pair<int,int>
#define enld endl

int main() {
	lint N, M;
	cin >> N >> M;
	priority_queue<lint>A;
	lint tmp;
	rep(i, N) {
		cin >> tmp;
		A.push(tmp);
	}
	rep(i, M) {
		A.push(A.top() / 2);
		A.pop();
	}
	lint sum = 0;
	while (!A.empty()) {
		sum += A.top();
		A.pop();
	}
	cout << sum << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tr1/unordered_map>
using namespace std;

#define LL long long
#define RG register int
template<typename elemType>
inline void Read(elemType &T){
    elemType X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    T=(w?-X:X);
}

int Data[200010];
tr1::unordered_map<int,int> Hash;
int N,Ans=0;

inline int GetNum(int x){
    int Res=1;
    while(Res<=x) Res<<=1;
    return Res-x;
}

int main(){
    Read(N);
    for(RG i=1;i<=N;++i){Read(Data[i]);++Hash[Data[i]];}
    sort(Data+1,Data+N+1,greater<int>());
    for(RG i=1;i<=N;++i){
        int x=GetNum(Data[i]);
        if(x==Data[i]){if(Hash[x]>=2){++Ans;Hash[x]-=2;}}
        else if(Hash[x] && Hash[Data[i]]) {++Ans;--Hash[x];--Hash[Data[i]];}
    }
    printf("%d\n",Ans);
    return 0;
}

Measured memory_bytes: 17524