akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,m;
    while(cin >> n >> m, n){
        vector<vp> v(n);
        rep(i,n){
            int k;
            cin >> k;
            rep(j,k){
                int x,d;
                cin >> x >> d;
                v[i].push_back(pii(x,d));//列、すべりやすさ
            }
        }
        vector<vector<vi> > dp(n,vector<vi>(10,vi(n,LINF)));
        rep(i,v[0].size())dp[0][i][0] = 0;
        rep(i,v[1].size())dp[1][i][1] = 0;
        rep(i,n)rep(j,v[i].size())rep(x,n)if(dp[i][j][x] < LINF){
            loop(k,1,3)if(i+k<n){
                rep(l,v[i+k].size()){
                    //v[i][j]からv[i+k][l]へのジャンプ
                    int d = abs(v[i][j].first - v[i+k][l].first);
                    int sum = v[i][j].second + v[i+k][l].second;
                    dp[i+k][l][x+(k==2)] = min(dp[i+k][l][x+(k==2)], dp[i][j][x]+sum*d);
                }
            }
        }
        int ans = LINF;
        rep(i,v[n-1].size())rep(j,m+1)ans = min(ans, dp[n-1][i][j]);
        rep(i,v[n-2].size())rep(j,m)ans = min(ans, dp[n-2][i][j]);
        cout << ans << endl;
    }
}



Measured memory_bytes: 4736
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   998244353
#define    inf  9223372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound 
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(x==0)return 0;if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}



int main()
{       io 
int testcases=1;     //   cin>>testcases;
while(testcases--)
{




ld a,b;
cin>>a>>b;

a*=b;
cout<<(ll)a;








}return 0;}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t a,b;
  cin >> a >> b;
  vector<vector<int>> A(a,vector<int>(2));
  vector<vector<int>> B(b,vector<int>(2));
  for(M:A){
    for(N:M){
      int a;
      cin >> a;
      N = a;
    }
  }
  for(M:B){
    for(N:M){
      int a;
      cin >> a;
      N = a;
    }
  }
    
  for(int i = 0;i<a;i++){
    int m = 0;
    int min = 200000000;
    for(int j = 0;j<b;j++){
      if(min > abs(A.at(i).at(0)-B.at(j).at(0)) + abs(A.at(i).at(1)-B.at(j).at(1))){
        m = j;
        min = abs(A.at(i).at(0)-B.at(j).at(0)) + abs(A.at(i).at(1)-B.at(j).at(1));
      }
      //cout << min << endl;
    }
    cout << m+1 << endl;
  }
}

Measured memory_bytes: 256
# coding: utf-8

item_count = int(input().rstrip())
require_time = list(map(int, input().rstrip().split(" ")))
drink_count = int(input().rstrip())

total = sum(require_time)

ans = []
for i in range(drink_count):
    (p,x) = map(int, input().rstrip().split(" "))
    tmp = total - require_time[p-1] + x
    ans.append(tmp)


for i in ans:
    print(i)


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

int main() {
  int N, A, k, x;
  cin >> N >> A;
  k = N / 500;
  x = N - 500 * k;
  if (x <= A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  int n,m;
  cin>>n>>m;
  int u,k=0;
  for(int i=0;i<m;i++)
    {
    cin>>u;
    k+=u;
    }
  if(k>=n)
    cout<<"Yes";
  else
    cout<<"No";
  }
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
// #define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
typedef vector<int> vi;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };
const ll MOD = 1000000007;

int N,K;
int p[1010];
signed main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> p[i];
  sort(p, p+N);
  int ans=0;
  for (int i = 0; i < K; i++) {
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a;
    b=a/(60*60);
    c=a%(60*60)/60;
    d=a-b*(60*60)-c*60;
    cout<<b<<":"<<c<<":"<<d<<endl;// Your code here!
    
}



Measured memory_bytes: 3112
#include <iostream>

using namespace std;

int main() {
	int res = 1;
	int n, x;
	cin >> n >> x;
	int l;
	int t = 0;
	for (int i = 0; i < n; i++) {
		cin >> l;
		t += l;
		if (t <= x) res++;
		else break;
	}
	cout << res;
}

Measured memory_bytes: 504
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int N;
    vector<long long int> a;

    if (scanf("%d", &N) < 1) return 0; 

    a.resize(3 * N);

    for (int i = 0; i < a.size(); i++)
    {
        if (scanf("%lld", &a[i]) < 1) return 0;
    }

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

    int cnt = 0;
    long long int ans = 0;
    for (int i = a.size() - 2; i >= 1; --i)
    {
        if (cnt == N) break;
        cnt++;
        ans += a[i];
        --i;
    }

    printf("%lld\n", ans);
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << (((1 + (b - a)) * (b - a)) / 2 - b) << endl;
    return 0;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = input().rstrip('\n')
    if N[-1] == "3":
        print("bon")
    elif N[-1] in ["0", "1", "6", "8"]:
        print("pon")
    else:
        print("hon")


if __name__ == '__main__':
    main()


Measured memory_bytes: 62080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

ll S(ll n){
	ll res = 0;
  	while(n){
    	res += n % 10;
      	n /= 10;
    }
  	return res;
}

int main(void){
    ll n; cin >> n;
  	if(n % S(n) == 0) cout << "Yes" << endl;
  	else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3560
### subroutines

def formula
  dim0 = term()
  return nil if dim0.nil?

  while $fml[$pos] == '+' || $fml[$pos] == '-'
    $pos += 1
    dim1 = term()
    return nil if dim1.nil? || dim0 != dim1
  end
  dim0
end

def term
  dim0 = factor()
  return nil if dim0.nil?
  dim = dim0.clone

  while $fml[$pos] == '*' || $fml[$pos] == '/'
    op = $fml[$pos]
    $pos += 1

    dim1 = factor()
    return nil if dim1.nil?

    if op == '*'
      (0...dim0.length).each{|i| dim[i] += dim1[i]}
    else
      (0...dim0.length).each{|i| dim[i] -= dim1[i]}
    end
  end
  dim
end

def factor
  if $fml[$pos] == '('
    $pos += 1
    dim = formula()
    return nil if dim.nil? || $fml[$pos] != ')'
    $pos += 1
    return dim
  end

  dim = $fml[$pos]
  $pos += 1
  dim
end

### main

loop do
  n, m, pn = gets.split.map(&:to_i)
  break if (n | m | pn) == 0

  nm2dim = {}
  dim2nm = {}

  m.times do
    namei = gets.strip
    dsi = gets.split.map(&:to_i)
    nm2dim[namei] = dsi
    dim2nm[dsi] = namei
  end
  #p nm2dim
  #p dim2nm

  fstr = gets.strip

  vars = {}
  pn.times do
    vari, namei = gets.strip.split
    vars[vari] = namei
  end
  #p vars

  fs = fstr.split(/(\+|\-|\*|\/|\(|\)|[A-Za-z]+)/).select{|s| ! s.empty?}
  $fml = fs.map{|f| vars[f].nil? ? f : nm2dim[vars[f]]}
  #p fstr
  #p $fml

  $pos = 0

  dim = formula()

  if dim.nil?
    puts 'error'
  else
    nm = dim2nm[dim]
    puts (nm.nil? ? 'undefined' : nm)
  end
end

Measured memory_bytes: 6168
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  double tho,tan,c,ans,pi = 3.141592653589793;
  tho=m*6;
  tan=30*h+0.5*m;
  c=abs(tho-tan);
  if(c>180) c=360-c;
  ans=sqrt(pow(b,2)+pow(a,2)-2*a*b*cos((pi/180)*c));
  printf("%.20f",ans);
  return 0;
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t,c;
	inline void gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			c=s==t?EOF:*s++;
		}else c=*s++;
	}
	template<class IT>inline void gi(IT &x){
		x=0;gc();while(c<'0'||c>'9')gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
	}
	char buf0[20];int a;
	template<class IT>inline void pi(IT x){
		if(x<0){putchar('-');x=-x;}
		do buf0[++a]=x%10+48;while(x/=10);
		while(a)putchar(buf0[a--]);
		putchar('\n');
	}
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;
priority_queue<pii>S;
int a[N],b[N];
int main(){
	int n,m,i,s,t;ll ans=0ll;
	scanf("%d",&n);m=n-1;
	rep(i,1,n)scanf("%d",&a[i]);
	rep(i,1,n)scanf("%d",&b[i]);
	rep(i,1,n)if(b[i] <a[i]){puts("-1");return 0;}
	rep(i,1,n)if(b[i] >a[i])S.push(mp(b[i],i));
	while(!S.empty()){
		i=S.top().se;S.pop();
		if(i==1)s=b[2]+b[n];else if(i==n)s=b[1]+b[m];else s=b[i-1]+b[i+1];
		t=b[i]-a[i];
//		printf("i=%d t=%d s=%d t/s=%d\n",i,t,s,t/s);
		if(t<s){puts("-1");return 0;}
		else{ans+=t/s;if(t%=s)S.push(mp(b[i]=t+a[i],i));else b[i]=a[i];}
	}
	rep(i,1,n)if(b[i]!=a[i]){puts("-1");return 0;}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll H, W;
string s[444];
ll dx[]={-1, 0, 1, 0};
ll dy[]={0, -1, 0, 1};
ll used[444][444];
ll g[444][444];
ll b[200000], w[200000];

void dfs(ll x, ll y, ll clr) {
    g[x][y]=clr;
    
    if(s[x][y]=='#') b[clr]++;
    else w[clr]++;
    
    for(ll i=0; i<4; i++) {
        ll tx=x+dx[i];
        ll ty=y+dy[i];
        
        if(tx<0 || ty<0 || tx>=H || ty>=W) continue;
        if((s[x][y]=='#' && s[tx][ty]=='#') || (s[x][y]=='.' && s[tx][ty]=='.')) continue;
        if(g[tx][ty]!=-1) continue;
        
        dfs(tx, ty, clr);
    }
}

int main(void) {
    ll i, j;
    cin >> H >> W;
    ll clr=0;
    for(i=0; i<H; i++) {
        cin >> s[i];
    }
    ll ans=0;
    memset(g, -1, sizeof(g));
    for(i=0; i<H; i++) {
        for(j=0; j<W; j++) {
            if(s[i][j]=='#') {
                dfs(i, j, clr);
                clr++;
            }
        }
    }
    
    for(i=0; i<clr; i++) {
        ans+=b[i]*w[i];
    }
    
    pr(ans);
}


Measured memory_bytes: 17536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		String S = scan.next();

 		// c[i]がアルファベットの何番目か
		for(int i = 0; i < S.length(); i++) {
				
				System.out.print((char)((S.charAt(i) - 'A' + N)%26 + 'A'));
		}

	}
}


Measured memory_bytes: 26708
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
 
typedef long long int ll;
typedef string str;
 
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}
 
ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);
}
 
void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	
	ll t,n,m,k,i,j,a,b;
	// cin >> t;
    str st,s;
    cin >> n >> m;
    vector<ll> adj[n+2];
    ll vis[n+2]={0};
    for(i=0;i<m;i++)
    {
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    k=0;
    for(i=1;i<=n;i++)
    {
        // deb(i,vis[i],k)
        if(vis[i]>0)
            continue;
        queue <ll> q;
        ll cnt=1;
        q.push(i);
        vis[i]=1;
        while(!q.empty())
        {
            a=q.front();
            q.pop();
            for(j=0;j<adj[a].size();j++)
            {
                b=adj[a][j];
                if(vis[b]==0)
                {
                    q.push(b);
                    vis[b]=1;
                    cnt++;
                }
            }
        }
        k=max(k,cnt);
    }
    cout << k << "\n";
    return 0;
}

Measured memory_bytes: 18664
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize,
      mut aa: [usize; n]
    };

    rsort(&mut aa);

    // 最初の1つは1回のみ
    let mut ans = aa[0];

    // 1~(n / 2 - 1)までの要素は2つ取れる
    let sum: usize = aa[1..n / 2].iter().map(|&a| a * 2).sum();

    ans += sum;

    // nが奇数個の場合は追加で1つピックできる ex) [5, 4, 3, 2, 1] ->  1, 2, 1
    if n % 2 != 0 {
        ans += aa[n / 2];
    }

    println!("{}", ans);
}

fn rsort(x: &mut Vec<usize>) {
    x.sort_unstable_by(|a, b| b.cmp(a));
}


Measured memory_bytes: 5536
A, B, C, X, Y = map(int, input().split())

kakaku = [[A, 'a'], [B, 'b'], [C, 'c']]
buff = [[X, 0], [Y, 1]]
huta = A+B

ab = C*2

if ab > huta:
    print(A*X+B*Y)
    exit()
else:
    buff.sort()
    # print(buff)
    ans = buff[0][0]*ab
    diff = buff[1][0]-buff[0][0]
    # print(kakaku)
    # print(buff)
    # print(buff[0][1])
    mn = kakaku[buff[1][1]][0]
    # print(mn)
    if mn > ab:
        print(ans+(diff*ab))
        # print('kotti')
        exit()
    else:
        print(ans+(diff*mn))
        exit()

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int h[4] = {-1, -1, -1}, x, y, t;
    for(x = 0;x < 10; x++){
        scanf("%d", &h[3]);
        for(y = 2; y >= 0; y--){
            if(h[y+1] <= h[y]) break;
            t = h[y+1];
            h[y+1] = h[y];
            h[y] = t;
        }
    }
    printf("%d\n%d\n%d\n", h[0], h[1], h[2]);
    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,i;
	t = 1;
	while(t--) {
	  cin >> n;
          int arr[n],brr[n];
          for(i = 0; i < n; i++) {
           cin >> arr[i];
           brr[i] = arr[i];
          }
          sort(brr, brr + n);
          for(i = 0; i < n; i++) {
           if(brr[n - 1] != brr[n - 2]) {
            if(arr[i] == brr[n - 1])
             cout << brr[n - 2] << endl;
            else
             cout << brr[n - 1] << endl;
           }
           else
            cout << brr[n - 1] << endl;
          }
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll x, ll y) { return y == 0 ? x : gcd(y, x%y);}

int main () {
  int x, y;
  cin >> x >> y;
  cout << gcd(x,y) << endl;
  return 0;
}


Measured memory_bytes: 3132
#include <iostream>
using namespace std;
int BubbleSort(int A[],int N){
    int sw=0;
    bool fl=1;
    for (int i = 0; fl ; ++i) {
        fl=0;
        for (int j = N-1; j >= i+1; --j) {
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                fl=1;
                sw++;
            }
        }
    }
    return sw;
}
int main() {
    int n,i,j,a[110],sw;
    cin>>n;
    for (i = 0; i < n; ++i) cin>>a[i];
    sw=BubbleSort(a,n);
    for (int i = 0; i < n; ++i) {
        if(i) cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<sw<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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


int main()
{
  int N, K; cin >> N >> K;
  vector<int> h(N); REP(i, N) cin >> h[i];
  sort(ALL(h));
  int ans = INF;
  for (int i = 0; i < N - K + 1; i++) {
    ans = min(h[i + K - 1] - h[i], ans);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a[10],b[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	   }
	for(int j=0;j<10;j++){
		cin>>b[j];
	   }
	sort(a,a+10);
	sort(b,b+10);
	cout<<a[7]+a[8]+a[9]<<" "<<b[7]+b[8]+b[9]<<endl;
	return 0;
	}



Measured memory_bytes: 3136
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll mod = 1e9 + 7;
    string L;
    cin >> L;

    int length = L.length();

    vector<vector<ll>> dp(length, vector<ll>(2));

    dp[0][1] = 2;
    dp[0][0] = 1;

    for(int i=1; i<length; i++) {
        dp[i][0] = (3 * dp[i-1][0]) % mod;
        if(L[i] == '1') {
            dp[i][1] = (2 * dp[i-1][1]) % mod;
            dp[i][0] = (dp[i][0] + dp[i-1][1]) % mod;
        }
        else {
            dp[i][1] = dp[i-1][1];
        }
    }

    // REP(i, length) cerr << dp[i][1] << " "; cerr << endl;
    // REP(i, length) cerr << dp[i][0] << " "; cerr << endl;
    cout << (dp[length-1][0] + dp[length-1][1]) % mod << endl;
    return 0;
}

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


#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n, q; scanf("%d%d", &n, &q);
  fenwick_tree<long long> fw(n+5);
  for (int a, i = 0; i < n; ++i) {
    scanf("%d", &a);
    fw.add(i, a);
  }
  while (q--) {
    int t, u, v; scanf("%d%d%d", &t, &u, &v);
    if (t) {
      printf("%lld\n", fw.sum(u, v));
    } else {
      fw.add(u, v);
    }
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

int check(int x){
  int result = 1;
  for(int i=2;i*i<=x;++i){
    if(x%i!=0)continue;
    int tmp = 1;
    while(x%i==0){
      x/=i;
      ++tmp;
    }
    result *= tmp;
  }
  if(x!=1)result *= 2;
  return result;
}

int main(){
  int N;
  cin >> N;
  int i = 1;
  while(true){
    int res = check(i);
    if(res==N){
      cout << i << endl;
      break;
    }
    ++i;
  }
  return 0;
}

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

int main()
{
    int n,a[10009],b[10009];
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    LL acnt=0,bcnt=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>b[i])bcnt+=a[i]-b[i];
        else
        {
            if((b[i]-a[i])%2)
            {
                b[i]++;
                bcnt++;
            }
            acnt+=(b[i]-a[i])/2;
        }
    }
    if(acnt>=bcnt)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    int N; cin >> N;
    string s; int p;
    vector<tuple<string, int, int>> tup;
    rep(i, N) {
        cin >> s >> p;
        tup.emplace_back(s, 100 - p, i);
    }
    sort(ALL(tup));

    rep(i, N) {
        cout << get<2>(tup[i]) + 1 << endl;
    }
}

Measured memory_bytes: 3580
# -*- coding: utf-8 -*-
def logic():
  n = int(input())
  b = list(map(int, input().split()))
  count = 0
  i = 1
  while i < n - 1:
    if b[i] < b[i - 1]:
      if b[i] > b[i + 1]:
        count += 1
    elif b[i] < b[i + 1]:
      if b[i] > b[i - 1]:
        count += 1
    i += 1
  print(count)



if __name__ == '__main__':
    logic()

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long ll;

int main(){
    ll A, B, C, K;
    scanf("%lld %lld %lld %lld", &A, &B, &C, &K);

    ll ans;
    if(K<A){
        ans = K;
    }else if(A+B >= K){
        ans = A;
    }else{
        ans = A - (K-(A+B));
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3824
#include<stdio.h>

int main(void){
   int a,b,k;

   scanf("%d %d %d",&k,&a,&b);
   int max = (b/k)*k;
   if(a<=max){
      printf("OK\n");
   } else {
      printf("NG\n");
   }
   return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
	    double num1 = scan.nextInt();
		scan.close();
		
			if (num1 % 2 != 0) {
				double num2 = (int) Math.ceil(num1 / 2);
				double output_odd = num2 / num1;
				System.out.println(output_odd);
			} else {
			double output = (num1 / 2) / num1;
			System.out.println(output);
			}
		}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int main() {
	int N;
	cin >> N;
	ll dp[110][4][4][4];
	//dp[N][i][j][k]でN文字目まで確定していてN-2文字目がi,N-1文字目がj,N文字目がk
	//Aなら0,Cなら1,Gなら2,Tなら3
	for (int i = 0; i < 110; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				for (int l = 0; l < 4; ++l) {
						dp[i][j][k][l] = 0;
				}
			}
		}
	}
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				if ((i == 0 && j == 2 && k == 1) || (i == 0 && j == 1 && k == 2) || (i == 2 && j == 0 && k == 1)) {
					continue;
				}
				dp[3][i][j][k] = 1;
			}
		}
	}
	for (int i = 3; i < 105; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				for (int l = 0; l < 4; ++l) {
					for (int m = 0; m < 4; ++m) {
						if (j == 0 && k == 2 && l == 1)continue;
						if (j == 2 && k == 0 && l == 1)continue;
						if (j == 0 && k == 1 && l == 2)continue;
						if (m == 0 && k == 2 && l == 1)continue;
						if (m == 0 && j == 2 && l == 1)continue;
						dp[i + 1][j][k][l] += dp[i][m][j][k];
						dp[i + 1][j][k][l] %= INF;
					}
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				ans += dp[N][i][j][k];
			}
		}
	}
	cout << ans % INF << endl;
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,a,b;
string s;

void input(){
	cin>>n>>s;
	return;
}

void solve(){
	for(int i=0;i<n;i++){
		if(s[i]=='R')a++;
		else b++;
	}
	if(a>b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;
int main() {
    // input
    int n, m; cin >> n >> m;
    vector<vector<int> > g(n);
    repeat (i,m) {
        int u, v; cin >> u >> v; -- u; -- v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    // decompose
    int a_components = 0, a_nodes = 0; // connected graph: |V|  = 1
    int b_components = 0, b_nodes = 0; // connected graph: |V| >= 2 and no odd cyles
    int c_components = 0, c_nodes = 0; // connected graph: |V| >= 2 and odd cycles exist
    vector<char> used(n);
    repeat (root,n) if (not used[root]) {
        bool is_bipartite = true;
        int size = 0;
        queue<int> que;
        que.push(root);
        used[root] = 'A';
        while (not que.empty()) {
            int i = que.front(); que.pop();
            ++ size;
            for (int j : g[i]) {
                if (used[j]) {
                    if (used[i] == used[j]) is_bipartite = false;
                } else {
                    used[j] = (used[i] == 'A' ? 'B' : 'A');
                    que.push(j);
                }
            }
        }
        if (size == 1) {
            ++ a_components; a_nodes += size;
        } else if (is_bipartite) {
            ++ b_components; b_nodes += size;
        } else {
            ++ c_components; c_nodes += size;
        }
    }
    // output
    ll ans = 0;
    ans += a_nodes *(ll) a_nodes; // A A
    ans += 2 * a_nodes *(ll) b_nodes; // A B ; B A
    ans += 2 * a_nodes *(ll) c_nodes; // A C ; C A
    ans += b_components *(ll) b_components * 2; // B B
    ans += 2 * b_components *(ll) c_components; // B C ; C B
    ans += c_components *(ll) c_components; // C C
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint a, b, c; cin >> a >> b >> c;
    cout << (b - a == c - b ? "YES" : "NO") << "\n";
}

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

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

    vector<int> group = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

    if(group.at(X-1) == group.at(Y-1)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
import sys
A,B=map(int,input().split())
S=input()
for i in range(A):
    try:
        num=int(S[i])
    except:
        print("No")
        sys.exit()
if S[A]!="-":
    print("No")
    sys.exit()
for i in range(B):
    try:
        num=int(S[i+A+1])
    except:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 9196
N,W = map(int,input().split())
WV = [ list(map(int,input().split())) for i in range(N) ]

def dp():
  inf = float("inf")
  dp=[[-inf for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1): dp[0][i]=0
    
  for i in range(N):
    w = WV[i][0]
    v = WV[i][1]
    for j in range(W+1):
      if w<=j: #dp[i][w-weight[i]の状態にi番目の荷物が入る可能性がある
        dp[i+1][j]=max(dp[i][j-w]+v, dp[i][j])
      else: #入る可能性はない
        dp[i+1][j]=dp[i][j]
  return dp[N][W]
print(dp())

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

using namespace std;

#define F 		first
#define S 		second
#define ll 		long long
#define ld 		long double
#define pii		pair<int, int>
#define vi 		vector<int>
#define mii 	map<int, int>
#define umii 	unordered_map<int, int>
#define pb		push_back
#define mk		make_pair
#define ask(x) 	cerr << #x << " = " << x << "\n";
#define INF 	1000000007
#define hell 	998244353

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

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

	int n, m, x, s, c[15], a[15][15], res = INF;

	cin >> n >> m >> x;
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (int j = 0; j < m; ++j)
			cin >> a[i][j];
	}

	for (s = 0; s < (1 << n); ++s) {
		int curr = 0;
		vi t(m);
		for (int i = 0; i < n; ++i) {
			if (s & (1 << i)) {
				curr += c[i];
				for (int j = 0; j < m; ++j)
					t[j] += a[i][j];
			}
		}
		bool flag = 0;
		for (int j = 0; j < m; ++j)
			if (t[j] < x)
				flag = 1;
		if (!flag) {
			res = min(res, curr);
		}
	}
	cout << (res == INF ? -1 : res);

	return 0;
}

Measured memory_bytes: 3660
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int K = in.nextInt();
            int[] l = new int[N];
            for (int i = 0; i < N; i++) {
                l[i] = in.nextInt();
            }

            Arrays.sort(l);

            int sum = 0;
            for (int i = 0; i < K; i++) {
                sum += l[N - 1 - i];
            }

            System.out.println(sum);
        }
    }
}


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

struct ISLAND
{
	int treasure;
	int bridge;
};

int main()
{
	int n;
	while (cin >> n)
	{
		if (n == 0) break;
		vector<ISLAND> island;
		ISLAND temp;
		for (int i = 0; i < n; i++)
		{
			cin >> temp.treasure >> temp.bridge;
			island.push_back(temp);
		}

		//bridge基準でバブルソート、bridge小さいほうが若く
		for (int i = 0; i < n - 1; i++)
		{
			for (int j = n - 1; j > i; j--)
			{
				if(island[j].bridge < island[j - 1].bridge)
				{
					ISLAND temp;
					temp = island[j];
					island[j] = island[j - 1];
					island[j - 1] = temp;
				}
			}
		}

		int burden = 0;
		bool flag = true;
		for (int i = 0; i < n; i++)
		{
			burden += island[i].treasure;
			if (burden > island[i].bridge)
			{
				cout << "No" << endl;
				flag = false;
				break;
			}
		}
		if (flag)
		{
			cout << "Yes" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1208
n = int(input())
h = [int(x) for x in input().split()]

ans = 0
count = 0
for i in range(n-1):
   if h[i+1] <= h[i]:
      count += 1
   else:
      ans = max(ans, count)
      count = 0

ans = max(ans, count)
print(ans)


Measured memory_bytes: 14252
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

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



Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    int n, t, tbef, taft;
    long long x;
    cin >> n >> t >> tbef;
    x = t;
    for(int i = 1; i < n; i++){
        cin >> taft;
        if(taft - tbef < t) x += taft - tbef;
        else x += t;
        tbef = taft;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

x1 = set()
x2 = set()
x3 = set()

for n in range(N):
    z = int(S[n])
    for n3 in x2:
        z3 = n3 * 10 + z
        if not(z3 in x3):
            x3.add(z3)
    for n2 in x1:
        z2 = n2 * 10 + z
        if not(z2 in x2):
            x2.add(z2)
    if not(z in x1):
        x1.add(z)

print(len(x3))

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

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

  map<string, int> ans;
  for(int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    ans[s]++;
  }
  cout << "AC x " << ans["AC"] << endl;
  cout << "WA x " << ans["WA"] << endl;
  cout << "TLE x " << ans["TLE"] << endl;
  cout << "RE x " << ans["RE"] << endl;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3636
s=input()
if len(s)>9 or len(s)<5:
    print('NO')
    exit()
a=['AKIHABARA','KIHABARA','KIHBARA','KIHBAR','KIHBRA','KIHABAR','KIHABRA','KIHABR','KIHBR','AKIHBARA','AKIHBRA','AKIHBR','AKIHBAR','AKIHABRA','AKIHABR','AKIHABAR']
if s in a:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N = 5e3 + 11;
#define LL long long
LL f[N][N], A, B, a[N];
int n;
int main(){
	cin>>n>>A>>B;
	memset(f, 127, sizeof(f));
	f[0][0] = 0;
	for(int i = 1;i <= n; i++)cin>>a[i];
	for(int i = 0;i < n; i++){
		LL x = a[i+1];
		for(int j = 0;j <= n; j++){
			if(j <= x){
				f[i+1][j] = min(f[i+1][j], f[i][j] + A);
				f[i+1][x] = min(f[i+1][x], f[i][j]);
			}
			if(j > x){
				f[i+1][j] = min(f[i+1][j], f[i][j] + B);
			}
		}
	}
	LL ans = 1e18;
	for(int i = 0;i <= n; i++){
		ans = min(ans, f[n][i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 196608
//Parallel/Orthogonal
#include <iostream>
#include <math.h>

using namespace std;

static const double ESP = 1e-10;

bool equals(double a, double b) { return fabs(a - b) < ESP; }

class Point {
public:
    double x, y;

    explicit Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point &p) { return Point(x + p.x, y + p.y); }
    Point operator - (Point &p) { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(a / x, a / y); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < ESP && fabs(y - p.y) < ESP;
    }
};

typedef Point Vector;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

bool isParallel(Vector v1, Vector v2) {
    return equals(cross(v1, v2), 0.0);
}

bool isOrthogonal(Vector v1, Vector v2) {
    return equals(dot(v1, v2), 0.0);
}

int main() {
    int q, x0, y0, x1, y1, x2, y2, x3, y3;
    cin >> q;
    for(int i = 0; i < q; i++) {
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Point s0 = Point(x0, y0);
        Point s1 = Point(x1, y1);
        Point s2 = Point(x2, y2);
        Point s3 = Point(x3, y3);

        Vector v1 = s1 - s0;
        Vector v2 = s3 - s2;

        if(isParallel(v1, v2)) cout << 2 << endl;
        else if(isOrthogonal(v1, v2)) cout << 1 << endl;
        else cout << 0 << endl;
    }
}



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

using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    int k; cin>>k;
    vector<vector<int>> fin(h, vector<int>(w, 0));
    vector<int> fill_later;
    set<int> done;
    string s;
    int last = 0, cnt = 0;
    for(int i=0; i<h; i++){
        cin>>s;
        bool present = false;
        int last_col=0, j=0;
        for(; j<w; j++){
            if(s[j] != '#') continue;
            last_col = j;
            present = true;
            cnt++;
            fin[i][j] = cnt;
            for(int k=j-1; k>=0; k--){
                if(s[k] == '#') break;
                fin[i][k] = cnt;
            }
        }
        j = last_col+1;
        for(; j<w; j++) fin[i][j] = cnt;
        if(present){
            last = i;
            for(auto &x: fill_later){
                for(int j=0; j<w; j++) fin[x][j] = fin[i][j];
            }
            fill_later.clear();
        }
        else if(!present){
            fill_later.push_back(i);
            continue;
        }
    }
    for(auto &x: fill_later){
        for(int j=0; j<w; j++) fin[x][j] = fin[last][j];
    }
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            cout<<fin[i][j]<<" \n"[j==w-1];
}


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

int main() {
	int k;
	string s;

	cin >> k;
	cin >> s;

	if (s.length() <= k) {
		cout << s << endl;
	} else {
		for (int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "..." << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 21;
char dn[dm], * di = dn, dt;
inline void putint(ll X) {
	int keta = 0;
	char C[20];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int N;
ll D[100001];
int E[200001], Ed[200001], E2[200001], H[100001];
void dfs(int A, ll B) {
	*(D + A) = B;
	for (int i = H[A]; i; i = E2[i]) if (!(*(D + E[i]))) dfs(E[i], B + Ed[i]);
}

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


	int N = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint();
		int b = getint();
		int c = getint();
		E[k] = b;
		Ed[k] = c;
		E2[k] = H[a];
		H[a] = k++;
		E[k] = a;
		Ed[k] = c;
		E2[k] = H[b];
		H[b] = k++;
	}
	int Q = getint();
	int K = getint();
	dfs(K, 1);
	rep(i, Q) {
		int x = getint();
		int y = getint();
		putint(*(D + x) + *(D + y) - 2);
	}

	fwrite_unlocked(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 9984