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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"
#define ff first
#define ss second

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define take(arr,n) REP(i,0,n)cin>>arr[i];
#define print(arr, n) REP(i,0,n)cout<<arr[i]<<" ";
#define printv(v) REP(i,0,v.size())cout<<v[i]<<" ";

ll gcd(ll a, ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}

ll lcm(ll a, ll b){
  return a*b/gcd(a,b);
}

void merge(ll *arr, ll st, ll mid, ll ed, ll maxele){
  ll i=st,j=mid+1,k=st;
  while(i<=mid && j<=ed){
    if(arr[i]%maxele <= arr[j]%maxele){
      arr[k]=arr[k]+(arr[i]%maxele)*maxele;
      k++;
      i++;
    }
    else{
      arr[k]=arr[k]+(arr[j]%maxele)*maxele;
      k++;
      j++;
    }
  }
  while(i<=mid){
    arr[k]=arr[k]+(arr[i]%maxele)*maxele;
    k++;
    i++;
  }
  while(j<=ed){
    arr[k]=arr[k]+(arr[j]%maxele)*maxele;
    k++;
    j++;
  }
  REP(i,st,ed+1)arr[i]=arr[i]/maxele;
}

void mergeSortRec(ll *arr, ll st, ll ed, ll maxele){
  if(st>=ed)return;
  ll mid=(st+ed)/2;
  mergeSortRec(arr,st,mid,maxele);
  mergeSortRec(arr,mid+1,ed,maxele);
  merge(arr,st,mid,ed,maxele);
}

void mergeSort(ll *arr, ll n){
  ll maxele=*max_element(arr,arr+n)+1;
  mergeSortRec(arr,0,n-1,maxele);
}

ll fact(ll n){
  if(n<=1)return 1;
  return ((n%M)*(fact(n-1)%M))%M;
}

int main() {
    fast
    ll t;
    //cin>>t;
    t=1;
    while(t--){
      ld d,t,s;
      cin>>d>>t>>s;
      if(d/t<=s)cout<<"Yes";
      else cout<<"No";
    }
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int total = 0;
  if (a > b) {
    total += a;
    a -= 1;
  } else {
    total += b;
    b -= 1;
  }
    if (a > b) {
    total += a;
    a -= 1;
  } else {
    total += b;
    b -= 1;
  }
  cout << total;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import Counter

def main():
    N = int(input())
    a = list(map(int, input().split()))
    l = Counter(a)
    if len(l)==1 and 0 in l:
        print('Yes')
        exit()
    if N%3==0 and len(l)==2 and 0 in l and l[0] == N//3:
        print('Yes')
        exit()
    if N%3==0 and len(l)==3:
        x,y,z = l.keys()
        if l[x] == l[y] == N//3 and x^y^z == 0:
            print('Yes')
            exit()
    print('No')

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 14460
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int n,a[2005],i,j,st,dr,mij,val,nr,s;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(i=1;i<=n-2;i++)
    {
        for(j=i+1;j<=n-1;j++)
        {
            st=j+1;
            dr=n;
            s=a[i]+a[j];
            val=j;
            while(st<=dr)
            {
                mij=(st+dr)/2;
                if(s>a[mij])
                {
                    val=mij;
                    st=mij+1;
                }
                else
                {
                    dr=mij-1;
                }
            }
            nr=nr+val-j;
        }
    }
    cout<<nr;
    return 0;
}


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

int main() {
    int N, L;
    cin >> N >> L;
    if (1 - L > N) {
        cout << N * (L - 1) + N * (N + 1) / 2 - (L + N - 1) << endl;
    }
    else if (1 - L <= 0) {
        cout << N * (L - 1) + N * (N + 1) / 2 - L << endl;
    }
    else {
        cout << N * (L - 1) + N * (N + 1) / 2 << endl;
    }
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  if($n==1) {
    echo "Hello World";
    echo PHP_EOL;
    exit;
  }

    list($a) = explode(" ", trim(fgets(STDIN)));
  list($b) = explode(" ", trim(fgets(STDIN)));

  echo $a+$b;
  echo PHP_EOL;

Measured memory_bytes: 16236
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<pi,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const int N=1e6+3;
int n,dp[N][2];
string s;
int Solve(int i,int j)
{
    if(i==n)
        return j;
    int &ret=dp[i][j];
    if(ret+1) return ret;
    int x=s[i]-'0'+j;
    ret=1e9;
    if(x<10) ret=x+Solve(i+1,0);
    ret=min(ret,10-x+Solve(i+1,1));
    return ret;
}
int main()
{
    go;
    memset(dp,-1,sizeof dp);
    cin>>s;
    reverse(s.begin(),s.end());
    n=s.size();
    cout<<Solve(0,0);
    return 0;
}


Measured memory_bytes: 56092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long A,B,C,K;cin>>A>>B>>C>>K;
  long ans=0;
  if(A>=K){
    ans=K;
  }else if(A+B>=K){
    ans=A;
  }else{
    ans=A-(K-B-A);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3568
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let n = it.next().unwrap();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let k = it.next().unwrap();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let x = it.next().unwrap();

    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let y = it.next().unwrap();

    if n <= k {
        println!("{}", n * x);
        return;
    }
    // println!("{}", k * x);
    // println!("{}", ((n - k) * y));
    let ans = k * x + (n - k) * y;
    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())
array = list(map(int, input().split()))
tmp = 0
for i in range(N-1):
    if array[i] == 1:
        tmp = array[i]
        continue
    elif array[i] < array[i+1]:
        tmp = array[i]
        continue
    elif array[i] == array[i+1] and (tmp < array[i]):
        tmp = array[i] - 1
        continue
    elif array[i] == array[i+1]:
        tmp = array[i]
        continue
    elif (array[i] - array[i+1] == 1) and (tmp < array[i]):
        tmp = array[i] - 1
        continue
    else:
        print('No')
        exit()


print('Yes')


Measured memory_bytes: 14704
num = int(input())
values = list(map(int, input().split()))
costs = list(map(int, input().split()))

dp = [0]*(num+1)
for i in range(num):
    diff = values[i] - costs[i]
    dp[i+1] = max( dp[i] + diff, dp[i])
print(dp[num])

Measured memory_bytes: 3060
s = gets.chomp.split("")
array = Array.new(3) {0}
for i in 0..2 do
  if s[i] == "a"
    array[0] += 1
  elsif s[i] == "b"
    array[1] += 1
  elsif s[i] == "c"
    array[2] += 1
  end
end

if array == [1,1,1]
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 3836
#include<iostream>
using namespace std;
int n;
int cnt[1<<17];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a,b;cin>>a>>b;
		cnt[a]++,cnt[b+1]--;
	}
	for(int i=1;i<1<<17;i++)cnt[i]+=cnt[i-1];
	int ans=0;
	for(int i=0;i<1<<17;i++)if(cnt[i]+1>=i)ans=ans<i-1?i-1:ans;
	cout<<ans<<endl;
}



Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;

//139 A
int main(void) {
	string s, t;
	cin >> s >> t;
	ll ans = 0;
	rep(i, 0, 3) {
		if (s[i] == t[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 764
def sigma4jou(k):
    total = 0
    for i in range(k):
        total += 4 ** (i)
    return(total)

def pketa(N):
    k = 1
    while N - sigma4jou(k) > 0:
        k += 1
    return(2 * k - 1)

def mketa(N):
    k = 1
    while N + 2 * sigma4jou(k) < 0:
        k += 1
    return(2 * k)

def getResult(N):
    result = ""
    if N == 0:
        result += "0"
    elif N > 0:
        k = pketa(N)
        for i in range(k, 0, -2):
            j = int((i+1)/2)
            if abs((sigma4jou(j) - N) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((sigma4jou(j) - N)) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    elif N < 0:
        k = mketa(N)
        for i in range(k, 0, -2):
            j = int(i/2)
            if abs((N + 2 * sigma4jou(j)) // (2 ** (i-1))) % 2 == 0:
                result += "1"
            else:
                result += "0"
            if i > 1:
                if abs(((N + 2 * sigma4jou(j))) // (2 ** (i-2))) % 2 == 1:
                    result += "1"
                else:
                    result += "0"
    return(result)

N = int(input())
print(getResult(N))

Measured memory_bytes: 3064
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m, q = na()
cs = []
for i in range(q):
    cs.append(na())

def dfs(pos, a, m, cs):
    if pos == len(a):
        sc = 0
        for co in cs:
            if a[co[1]-1] - a[co[0]-1] == co[2]:
                sc += co[3]
        return sc

    ans = 0
    low = 1 if pos == 0 else a[pos-1]
    for i in range(low, m+1):
        a[pos] = i
        ans = max(ans, dfs(pos+1, a, m, cs))
    return ans

print(dfs(0, [0] * n, m, cs))


Measured memory_bytes: 80008
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
char str[15];
LL dp[15], g[15], num[15][15];

int main(){
	scanf("%s", str + 1);
	int n = strlen(str + 1);
	for(int i = 1; i <= n; i++){
		num[i][i - 1] = 0;
		for(int j = i; j <= n; j++){
			num[i][j] = num[i][j - 1] * 10 + (str[j] - '0');
		}
	}
	dp[0] = 0;
	g[0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < i; j++){
			dp[i] += dp[j] + g[j] * num[j + 1][i];
			g[i] += g[j];
		}
	}
	printf("%lld\n", dp[n]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
map<char,int>mp;
int a[105];
int main(){
    int n;
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    if(sum%10){
        cout<<sum<<endl;
        return 0;
    }
    for (int i=0;i<n;i++){
		if(a[i]%10){
			cout<<sum-a[i]<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*; 
import java.lang.*; 


public class Main{
    
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                long a = scan.nextLong();
                long b = scan.nextLong();
                long c = scan.nextLong();
                long d = scan.nextLong();
                
                long ans = 0;
               
                ans = Math.max(a*c,a*d);
                ans = Math.max(ans,b*c);
                ans = Math.max(ans,b*d);
                
                System.out.println(ans);
        }
}

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

// 5000,0000,0000,0000
int N, K;

int main(){
	cin >> N >> K;
	long long k=0;
	long long rk2=0;
	if(K%2 == 0){
		for(int i=1;i<=N;i++){
			if(i%K == 0)k++;
			else if(i%K == K/2) rk2++;
		}
	}else{
		for(int i=1;i<=N;i++){
			if(i%K == 0)k++;
		}
	}
	cout << k*k*k + rk2*rk2*rk2 << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1LL << 60;
const int MOD = 1000000007;

ll dp[3100][3100];

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

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

    for (int len = 1; len <= n; ++len) {
        for (int i = 0; i + len <= n; ++i) {
            int j = i + len;
            if ((n - len) % 2 == 0){
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);
            }
            else{
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
            }
        }
    }

    cout << dp[0][n] << endl;
}



Measured memory_bytes: 74112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void solve1()
{
    int n; cin >> n;
    vector<ll> a(n), b(n); rep(i, n) cin >> a[i] >> b[i];

    ll ans = 0;
    for(int i = n - 1; i >= 0; i--) {
        if((a[i]+ans)%b[i]) {
          ans += b[i] - (ans+a[i])%b[i];
        }
    }
    cout << ans << endl;
}

int main()
{
    solve1();
}


Measured memory_bytes: 4680
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7
N,Q = I()
edge = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = I()
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p,x = I()
    ans[p-1] += x
que = [0]
visited = {0}
while que:
    p = []
    for i in que:
        for j in edge[i]:
            if j in visited:
                continue
            visited.add(j)
            ans[j] += ans[i]
            p.append(j)
    que = p
print(*ans)

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

using namespace std;

#define INF 1000007
#define MOD 998244353
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}
signed main()
{
    int N;
    cin >> N;
    int x[N], y[N];
    rep(i, N)
    {
        cin >> x[i] >> y[i];
    }
    long double all = 0.0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i == j)
            {
                continue;
            }
            all += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
        }
    }
    cout << fixed << setprecision(10) << all / N << endl;
}

Measured memory_bytes: 256
lst_1 = input().split()

N = int(lst_1[0])
M = int(lst_1[1])

lst_A = []

ans_min = 1
ans_max = N

for i in range(M):
    lst_A.append(input().split())

for m in range(0, M, 1):

    com_min = int(lst_A[m][0])

    if com_min > ans_min:
        ans_min = com_min

    com_max = int(lst_A[m][1])

    if com_max < ans_max:
        ans_max = com_max

ans = ans_max - ans_min + 1

if ans < 1:
    ans = 0

print(ans)

Measured memory_bytes: 32156
n = int(input())
l_list = list(map(int, input().split()))

for i in range(n-1):
    if l_list[i+1]-l_list[i] == -1:
        l_list[i+1] += 1
    elif l_list[i+1]-l_list[i] < -1:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 85324
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int counta = 0, countb = 0;
  for (char a: S) {
    if(a == '0') counta++;
    else countb++;
  }
  cout << 2 * min(counta, countb) << endl;
  return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	string s;
	cin >> s;
	int count[3] = {0,0,0};
	REP(i, s.size()) {
		switch (s[i]) {
		case 'a':
			count[0]++;
			break;
		case 'b':
			count[1]++;
			break;
		case 'c':
			count[2]++;
			break;
		}
	}
	bool flag = true;
	REP(i, 3) {
		if (count[i] != 1) flag = false;
	}
	if (flag) cout << "Yes";
	else cout << "No";
	system("pause");
	return 0;
}

Measured memory_bytes: 504
void main(){
	int a, b;
	scanf("%d %d", &a, &b);
	writeln(a+b>=10?"error":(a+b).to!string);
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2564
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define PI 3.14159265359
#define rep(i,n) for(int i=0; i<n; ++i)
#define INF 1001001001
#define MAX_X 2002
#define MAX_Y 2002
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll x;
    cin >> x;

    ll money = 100;
    ll ans = 0;
    while (money < x) {
        money *= 1.01;
        ++ans;
    } 
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
  
int main(){
  
    int a = 0;
    int b = 0;
  
    scanf("%d %d", &a, &b);
  
    if (a < b){
        printf("a < b\n");
    }else if (a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
  
    return 0;
  
}

Measured memory_bytes: 1008
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char n,a,b,c;
    cin >> a>>b;
    if(a=='H'){
       if(b=='H'){
         cout << "H";
       }else{
        cout << "D";}
    }else{
      if(b=='H'){
      cout << "D";
    }else{
      cout << "H";
    }
}
}

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

using namespace std;

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

    int ans = *max_element(a, a + 3) - *min_element(a, a + 3);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	int ans = 0;
	for(int i=1;i<=n-1;i++){
		int res = 0;
		int lim = (n-1)/i;
		if( (n-1)%i == 0 ) lim =  ( (n-1)/i - 1 ) / 2;
		for(int j=1;j<=lim;j++){
			if( n-1-j*i <= i )break;
			res += a[j*i];
			res += a[n-1-j*i];
			if(res > ans)ans = res;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n, m, q;
	cin >> n >> m >> q;
	vi a(q), b(q), c(q), d(q);
	rep(i,q){
	    cin >> a[i] >> b[i] >> c[i] >> d[i];
	    a[i]--; b[i]--;
	}
    
    vi A(n, 1);
    A[0] = 1;
    ll ans = 0;
    
    for(A[1] = A[0]; A[1] <= m; A[1]++){
        for(A[2] = A[1]; A[2] <= m; A[2]++){
            for(A[3] = A[2]; A[3] <= m; A[3]++){
                for(A[4] = A[3]; A[4] <= m; A[4]++){
                    for(A[5] = A[4]; A[5] <= m; A[5]++){
                        for(A[6] = A[5]; A[6] <= m; A[6]++){
                            for(A[7] = A[6]; A[7] <= m; A[7]++){
                                for(A[8] = A[7]; A[8] <= m; A[8]++){
                                    for(A[9] = A[8]; A[9] <= m; A[9]++){
                                        ll tot = 0;
                                        rep(j,q){
                                            if(A[b[j]] - A[a[j]] == c[j]) tot += d[j];
                                        }
                                        //cout << "loop i: " << i << endl;
                                        //for(auto k : A) cout << k << " "; 
                                        //cout << endl;
                                        ans = max(ans, tot);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
	return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3656
//In The Name Of God
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 2e6 + 5, Mod = 1e9 + 7, P = 727, Lg = 17, TOF = 1900;


int A[N], B[N], Mark[N];
vector< int > V;
vector< pair< int, int > > St;
int main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n; cin >> n;
      for(int i = 1; i <= n; i++)
            cin >> A[i];
      for(int i = 1; i <= n; i++)
            cin >> B[i];
      for(int i = 1; i <= n; i++){
            if(A[i] >= B[i]){
                  if(A[i] > B[i])
                        St.pb(mp(A[i] - B[i], i));
                  continue;
            }
            V.pb(i);
      }
      sort(St.begin(), St.end());
      for(int i = 0; i < (int)V.size(); i++){
            int nd = B[V[i]] - A[V[i]];
            if(!St.size())
                  return cout << -1, 0;
            while(1){
                  Mark[(St.back()).S] = 1;
                  if((St.back()).F >= nd){
                        pair< int, int > u = (St.back());
                        u.F -= nd;
                        if(u.F)
                              St.back() = u;
                        break;
                  }
                  else{
                        if(St.size() == 1)
                              return cout << -1, 0;
                        nd -= (St.back()).F;
                        St.pop_back();
                  }
            }
      }
      int ans = (int)V.size();
      for(int i = 1; i <= n; i++){
            if(A[i] >= B[i] && Mark[i])
                  ans++;
      }
      cout << ans;
      return 0;
}


Measured memory_bytes: 7672
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc097/tasks/abc097_b

int main() {
    int X; cin >> X;
    vector<int> expo(X+5);
    expo[1] = 1;
    for (int i = 2; i < X; i++) {
        int v = i*i;
        while(v <= X) {
            expo[v] = true;
            v *= i;
        }
    }

    for (int i = X; i >= 0; i--) if (expo[i]){
            cout << i << "\n";
            return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(s[k-1] == 'A'){
        s[k-1] = 'a';
    }else if(s[k-1] == 'B'){
        s[k-1] = 'b';
    }else if(s[k-1] == 'C'){
        s[k-1] = 'c';
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3600
main :: IO ()
main = do
  input <- getLine
  let n = read input :: Int
  putStrLn . show $ executeB n

executeB :: Int -> Int
executeB n
  | n <= 9 = n
  | n <= 99 = 9
  | n <= 999 = 9 + n - 99
  | n <= 9999 = 909
  | n <= 99999 = 909 + n - 9999
  | n == 100000 = 90909

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
typedef pair<ll,ll> pll;

const int N = 12+2;
const int INF = 1e9;
int n, m, x;
int C[N], sum[N];
int ar[N][N];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> C[i];
        for (int j = 0; j < m; j++)
        {
            cin >> ar[i][j];
        }
    }
    int prob = (1<<n);
    int ans = INF;
    for (int i = 0; i < prob; i++)
    {
        memset(sum,0,sizeof(sum));
        int cost = 0;
        for (int j = 0; j < n; j++)
        {
            int cur = (i & (1<<j));
            cur = min(1,cur);
            cost += cur * C[j];
            for (int k = 0; k < m; k++)
            {
                sum[k] += cur * ar[j][k];
            }
        }
        bool good = 1;
        for (int j = 0; j < m && good; j++)
        {
            if (sum[j] < x)
                good = 0;
        }
        if (good)
            ans = min(ans,cost);
    }
    cout << (ans == INF ? -1 : ans) << '\n';
    return 0;
}

Measured memory_bytes: 3640
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
L = [0]*n
R = [0]*n
cnt=0
for i in range(n):
    L[i] = i+a[i]
    R[i] = i-a[i]
z1=Counter(L)
z2=Counter(R)
cnt=0
for k1,v1 in z1.items():
    v2 = z2[k1]
    cnt += v1*v2
print(cnt)

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

using namespace std;

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

const long long INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h.at(i);
    vector<long long> dp(n, INF);
    dp.at(0) = 0;
    for(int i = 1; i < n; i++) {
        chmin(dp.at(i), dp.at(i - 1) + abs(h.at(i) - h.at(i - 1)));
        if (i > 1) chmin(dp.at(i), dp.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
    }
    cout << dp.at(n - 1) << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int n,k; cin >> n >> k;
  vector<int> a(n);
  vector<int> v(n+1);
  rep(i,n){
    int tmp; cin >> tmp;
    tmp--;
    a[i] = tmp;
  }
  
  rep(i,n){
    v[i+1] = (v[i] + a[i])%k; 
  }
  map<int,int> mp;
  queue<int> q;
  
  ll ans = 0;
  rep(i,n+1){
    ans += mp[v[i]];
    mp[v[i]]++;
    q.push(v[i]);
    if(q.size() == k){
      mp[q.front()]--;
      q.pop();
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 12032
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    a = "zabcdefghijklmnopqrstuvwxy"
    N = int(input())
    # if N <= 26:
    #     print(a[N%26])
    #     return

    ans = []
    d = 1
    m = 26
    while N != 0:
        tmp = (N % m)
        ans.append(a[tmp//d])
        N -= tmp if tmp != 0 else m
        d *= 26
        m *= 26
    
    ans.reverse()
    print(''.join(ans))

main()

Measured memory_bytes: 9148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        
        String[] first = stdin.readLine().split(" ");
        int n = Integer.parseInt(first[0]);
        int q = Integer.parseInt(first[1]);
        
        int[] s = new int[n];
        int[] t = new int[n];
        int[] x = new int[n];
        int[] d = new int[q];
        for (int i = 0; i < n; i++) {
            String[] line = stdin.readLine().split(" ");
            s[i] = Integer.parseInt(line[0]);
            t[i] = Integer.parseInt(line[1]);
            x[i] = Integer.parseInt(line[2]);
        }
        for (int i = 0; i < q; i++) {
            d[i] = Integer.parseInt(stdin.readLine());
        }
        
        
        int[] answers = new int[q];
        Arrays.fill(answers, -1);
        TreeSet<Tuple> tuples = new TreeSet<>();
        for (int i = 0; i < q; i++) {
            tuples.add(new Tuple(i, d[i]));
        }
        int[] sections = IntStream.range(0, n)
                                  .boxed()
                                  .sorted(Comparator.comparingInt(i -> x[i]))
                                  .mapToInt(Integer::intValue)
                                  .toArray();
        for (int section : sections) {
            Tuple from = new Tuple(-1, s[section] - x[section]);
            Tuple to = new Tuple(-1, t[section] - x[section] );
            List<Tuple> removals = new ArrayList<>(tuples.subSet(from, to));
            for (Tuple tuple : removals) {
                answers[tuple.i] = x[section];
                tuples.remove(tuple);
            }
        }
        
        for (int answer : answers) {
            System.out.println(answer);
        }
    }

    private static class Tuple implements Comparable<Tuple> {
        private int i;
        private int d;
        
        public Tuple(int i, int d) {
            this.i = i;
            this.d = d;
        }
        
        @Override
        public int compareTo(Tuple o) {
            return Integer.compare(d, o.d);
        }
    }
}

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    ll n, s = 0;   cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
        s ^= a[i];
    }
    vector < ll > ans;
    rep(i, n){
        ans.pb(s^a[i]);
        cout << ans[i] << " ";
    } 
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 

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

using namespace std;

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

	int n, tw;
	cin >> n >> tw;
	vector<long long> dp(tw + 1);
	for (int i = 0; i < n; i++) {
		int w, v;
		cin >> w >> v;
		for (int j = tw; j >= w; j--) {
			dp[j] = max(dp[j], dp[j - w] + v);
		}
	}
	long long res = 0;
	for (int i = 0; i <= tw; i++) {
		res = max(res, dp[i]);
	}
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 505
#define M 100005
using namespace std;
typedef long long LL;
const LL oo=1e18;
const LL zero=1e12;
int Q[N],f[N],a[N],End[N],Next[M],Go[M],cnt;
LL Value[M],ans;
int n,m,S,T,i,j;
int BFS(){
  for (int i=1;i<=T;i++) f[i]=-1;
  int h=0,t=1;Q[1]=S;f[S]=1;
  while (h<t){
    int x=Q[++h];if (x==T) return 1;
    for (int i=End[x],y;i;i=Next[i])
      if (Value[i]&&f[y=Go[i]]==-1)
        f[y]=f[x]+1,Q[++t]=y;
  }return 0;
}
LL Dinic(int x,LL sum){
  if (x==T) return sum;LL os=sum;
  for (int i=End[x],y;i;i=Next[i])
    if (Value[i]){
      if (f[y=Go[i]]!=f[x]+1) continue;
      LL now=Dinic(y,min(os,Value[i]));
      os-=now;Value[i]-=now;Value[i^1]+=now;
    }
  if (sum==os) f[x]=-1;return sum-os;
}
void add(int u,int v,LL w){
  Go[++cnt]=v;Next[cnt]=End[u];End[u]=cnt;Value[cnt]=w;
}
void addedge(int u,int v,LL w){/*printf("%d->%d %lld\n",u,v,w);*/add(u,v,w);add(v,u,0);}
int main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	S=n+1;T=n+2;cnt=1; 
	for (i=1;i<=n;i++)
	  for (j=i+1;j<=n;j++)
	    if (j%i==0) 
			  addedge(j,i,oo);
	for (i=1;i<=n;i++) 
	  addedge(S,i,zero),addedge(i,T,zero-a[i]);
	ans=0;
	while (BFS())
	  ans+=Dinic(S,oo);
	//printf("%lld\n",ans);
	printf("%lld\n",zero*n-ans);
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long

template <class T>
T mymax(T a,T b){
    if(a>=b) return a;
    return b;
}
template <class T>
T mymin(T a,T b){
    if(a<=b) return a;
    return b;
}

ll gcd(ll a, ll b){
    if(a<b){
        swap(a,b);
    }
    while(b){
        ll r = a%b;
        a=b;
        b=r;
    }
    return a;
}

ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

struct XX{
    int a;
    int b;
    int z;
    int i;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.b) == (riRight.b)){
            return riLeft.i < riRight.i;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.b) > (riRight.b);
    }
};

//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}


int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //cin >> x >> y;
    //テスト用
    //ifstream ifs( "1_06.txt" );
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N,H;
    cin >> N >> H;
    XX x[100000];
    int maxa=0;
    int maxb=0;
    int maxai=0;
    for(int i=0;i<N;i++){
        cin >> x[i].a >> x[i].b;
        x[i].i=i;
        if(maxa<=x[i].a){
            maxa=x[i].a;
            maxb=x[i].b;
            maxai=i;
        }
    }
    sort(x,x+N,xxGreater());

    int ans=0;
    int res=0;
    for(int i=0;i<N;i++){
        if(x[i].i!=maxai && x[i].b>maxa){
            H-=x[i].b;
            ans++;
        }
        if(H<=0){
            cout << ans << endl;
            return 0;
        }
        if(H<=maxb){
            ans++;
            cout << ans << endl;
            return 0;
        }
        if(x[i].b<=maxa){
            res=x[i].b;
            break;
        }
    }
    H-=max(res,maxb);
    ans++;
    if(H<=0){
        cout << ans << endl;
        return 0;
    }
    int tmp=H/maxa;
    if(H%maxa!=0){
        tmp++;
    }
    cout << ans+tmp << endl;
    
    //ここまで
    //cout << "debug" << endl;
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,max=-1;
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		int add;
		cin>>add;
		sum+=add;
		max=max>add?max:add;
	}
	cout<<sum-max/2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
 int a,b; 
 cin >> a >> b; 
 cout << 6-(a+b) << endl;
}


Measured memory_bytes: 256
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split())) + [0]*(x+y)

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
eat = []
for i in range(x):
  eat.append(p[i])
for i in range(y):
  eat.append(q[i])  

eat.sort()
der = []
for i in range(len(eat)):
  if eat[i] < r[i]:
    der.append(r[i])
  else:
    der.append(eat[i])

print(sum(der))

Measured memory_bytes: 23328
#include<stdio.h>
int main(){
	int n,i,temp,Loan = 100000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		Loan *= 1.05;
		temp = Loan % 1000;
		if(temp != 0)
			Loan += (1000 - temp);
	}
	printf("%d\n",Loan);
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;

int main()
{
    int n;
    string a, b, c;
    
    cin >> a >> b >> c;
    
    cout << char(int(a[0])-32) << char(int(b[0])-32) << char(int(c[0])-32) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,a[55],s;
ll dfs(ll l,ll r){
	vector<ll> vec;
	for(int i=0;i<=l;i++) vec.push_back(a[i]);
	for(int i=r;i<n;i++) vec.push_back(a[i]);
	sort(vec.begin(),vec.end());
	ll maxs;
	maxs=k-vec.size();          
	if(maxs<0) return 0;
	s=0;
	for(int i=0;i<vec.size();i++){
		if(vec[i]<0&&maxs>0){
        	maxs--;
		}
		else{
			s+=vec[i];
		}
	}
	return s;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	ll ans=0;
	for(int i=-1;i<n;i++){
		for(int j=i+1;j<=n;j++){
        	ans=max(ans,dfs(i,j));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

ll N,A,B;
vector<ll> h(1e5 + 1);
bool check(ll t){
	ll cnt = 0;
	rep(i,N){
		if(h[i] > B*t){
			if((h[i]-B*t)%(A-B)==0){
				cnt += (h[i]-B*t)/(A-B);
			}
			else{
				cnt += (h[i]-B*t)/(A-B) + 1;
			}
		}
	}
	return cnt <= t;
}
int main() {
	cin>>N>>A>>B;
	rep(i,N)cin>>h[i];
	ll ng = 0, ok = 1e9+1;
	ll mid;
	while(1){
		if(ok - ng == 1){
			mid = ok;
			break;
		}
		mid = (ng + ok)/2;
		if(check(mid)){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	cout<<mid<<endl;
}

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

typedef long long int ll;
typedef pair<ll,ll> P;

int a[106];

int main(){
    int n,m;
    int count=0;
    int tvote=0;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        tvote+=a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]*4*m>=tvote){
            count++;
        }
    }
    cout<<((count>=m)?"Yes":"No")<<endl;

    return 0;
}

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

double root(double x){
	double e = 0.00000001;
	double a = x;
	double b = 0;
	double c;
	while(a - b > e){
		c = (a + b) / 2;
		if(c * c < x){
			b = c;
		}else{
			a = c;
		}
	}
	return c;
}

int main(){
	double x;
	double h;
	while(cin >> x >> h){
		if(x == 0 && h == 0) break;
		double area = x * x + 2 * root((x * x / 4) + (h * h)) * x;
		cout << showpoint << setprecision(15) << area << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

ll dp[1000002][2];
int main()
{
    string N;
    cin >> N;
    dp[0][1] = 1;

    rep(i, N.size()) {
        ll num = N[i] - '0';
        dp[i + 1][0] = min(dp[i][0] + num, dp[i][1] + (10 - num));
        dp[i + 1][1] = min(dp[i][0] + num + 1, dp[i][1] + (9 - num));
    }
    cout << dp[(int)N.size()][0] << endl;
    return 0;
}

Measured memory_bytes: 17028
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {
	int K, N;
	int[] A;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		K = Integer.parseInt(tokens[0]);
		N = Integer.parseInt(tokens[1]);
		A = new int[N];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(tokens[i]);
		}

	}

	void calc() {
		int result = A[N - 1] - A[0];
		for (int i = 0; i + 1 < N; ++i) {
			result = Math.min(result, K - (A[i + 1] - A[i]));
		}
		System.out.println(result);
	}

	void showResult() {
	}

}


Measured memory_bytes: 50524
h1, m1, h2, m2, k = list(map(int, input().split()))
if m2 < m1:
    while m2 < m1:
        h2 -= 1
        m2 += 60
tm = m2 - m1
th = h2 - h1
if k > (th*60 + tm):
    print (0)
else:
    print(th*60 + tm - k)

Measured memory_bytes: 61772
from random import randint, seed

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

def calc(ans):
    ret = 0
    L = [0] * D
    for d, t in enumerate(ans):
        ret += S[d][t]
        for c, l in zip(C, L):
            ret -= c * (d - l)
    return ret

mx = -10**18
ans = None
for i in range(1000):
    seed(i)
    A = [randint(0, 25) for _ in range(D)]
    res = calc(A)
    if mx < res:
        mx = res
        ans = A

print(*[a + 1 for a in A], sep='\n')


Measured memory_bytes: 10000
m, n = map(int, input().split())
mod = 10**9 + 7


def modpow(m, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * m % mod
        m = m * m % mod
        n >>= 1
    return res


print(modpow(m, n, mod))



Measured memory_bytes: 5600