akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF=1e9;

using namespace std;

int n,m;
int c[21];
int dp[50004];
int main() {
    cin>>n>>m;
    rep(i,m) cin>>c[i];

    rep(i,50004) dp[i]=INF;
    dp[0]=0;

    rep(i,m) rep(j,n+1) {
        if(j-c[i]>=0)
            dp[j]=min(dp[j],dp[j-c[i]]+1);
    }

    cout<<dp[n]<<endl;

}

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


int main (){
    int n,m;
    cin >> n >> m;
    int k;
    int l;
    int ans =0;
    int a[m] = {0};
    rep(i,n){
        cin>> k;
        rep(j,k){
            cin>> l;
            a[l-1]++;
        }
    }
    rep(i,m){
        if(a[i] == n){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

void solve()
{
	string S;
	int A[26] = {};
	cin >> S;
	for (int i = 0; i < S.size(); i++)
	{
		A[S[i] - 'a']++;
	}
	int odd = 0, even = 0;
	for (int i = 0; i < 26; i++)
	{
		if (A[i] % 2 == 1)
		{
			odd++;
		}
	}
	if (odd <= 1)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << (odd / 2) << endl;
	}
}

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


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n;
  cin>>n;
  int d,x;
  cin>>d>>x;
  vector<int> a(n);
  for(int i=0;i<n;i++){
      cin>>a.at(i);
  }
  int count=0;
  for(int i=0;i<n;i++){
      int c=1;
      while(c<=d){
          count++;
          c+=a.at(i);
      }
  }
  cout<<x+count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct point{
	double x,y;
	point(){}
	point(double _x,double _y){
		x=_x;y=_y;
	}
	point operator +(const point &b) const{
		return point(x+b.x,y+b.y);
	}
	point operator -(const point &b) const{
		return point(x-b.x,y-b.y);
	}
	double operator ^(const point &b) const{
		return (x*b.x)+(y*b.y);
	}
	double operator *(const point &b) const{
		return x*b.y-y*b.x;
	}
	point operator *(const double &b) const{
		return point(x*b,y*b);
	}
};
point a[105];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>a[i].x>>a[i].y;
	double ans=0;
	for(int i=0;i<n;++i)
		if((a[(i+1)%n]-a[i])*(a[(i+2)%n]-a[i])<0)puts("0"),exit(0);
	puts("1");
	return 0;
} 


Measured memory_bytes: 3212
h, w = map(int, input().split())
s = [input().split() for i in range(h)]
a = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
     "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
     "W", "X", "Y", "Z"]
for i in range(h):
    for j in range(w):
        if s[i][j] == "snuke":
            print("{}{}".format(a[j], i + 1))

Measured memory_bytes: 3064
import numpy as np
import itertools

N,M = map(int,input().split())
xyz = [[int(x) for x in input().split()] for _ in range(N)]
xyz = np.array(xyz,dtype=np.int64)

answer = 0

# 正か負どちらで取るかを決める。
# ソートして大きいものからとる。
for sgn in itertools.product([1,-1],repeat = 3):
  x = (xyz * sgn).sum(axis = 1)
  x.sort()
  # M = 0で危ない
  if M > 0:
    answer = max(answer, x[-M:].sum())
  
print(answer)

Measured memory_bytes: 12528
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include <set>

#define DIV 1000000007
using namespace std;
using ll = long long;
ll K;

bool check(ll X,vector<ll>&a,vector<ll>&f){
    ll total = 0;
    int N = a.size();

    for (int i = 0; i < N; i++) {
        if (a[i] * f[i]  <= X) continue;
        total += (a[i] * f[i] - X + (f[i] - 1)) / f[i];
    }

    if (total <= K) return true;
    else return false;

}

int main() {
    ll N;
    cin >> N >> K;

    vector<ll> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    sort(a.begin(), a.end());

    vector<ll> f(N);
    for (int i = 0; i < N; i++)
        cin >> f[i];
    sort(f.begin(), f.end(), greater<ll>());

    ll left = 0, right = 1e12;
    while (left != right) {
        ll mid = (left + right) / 2;
        if (check(mid,a,f)) right = mid;
        else left = mid+1;
       // cout << "mid= " << mid << endl;
    }

    cout << left << endl;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans;
    if (a == b && a == c) ans = 1;
    else{
        if(a==b || a==c || b==c) ans = 2;
        else ans = 3;
    }
    cout << ans << endl;
    return 0;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
  int n,x,t;
  cin >> n >> x >> t;
  if(n%x==0){
    cout << (int)(floor(n/x))*t << endl;
  }else{
    cout << (int)(floor(n/x)+1)*t << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
int main(){
    int n,tho,hun,ten;
    scanf("%d",&n);
    tho=n/1000;
    n=n%1000;
    hun=n/100;
    n=n%100;
    ten=n/10;
    n=n%10;
    if((tho==hun&&hun==ten)||(hun==ten&&ten==n))
    printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

int n;
    string s;
    cin>>n>>s;
    rep(i,s.size()){
        s[i]=(s[i]-'A'+n+26)%26+'A';
    }
    fin(s);



//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
def main() :
    W, H, x, y, r = [int(i) for i in input().split()]

    if ((x-r)>=0) and ((x+r)<=W) and ((y-r)>=0) and ((y+r)<=H) :
        print("Yes")
    else :
        print("No")

if __name__ == '__main__' :
    main()

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

int main() {
  int N;
  cin >> N;
  std::vector<int> a(N);
  for (int& a_i: a) {
    std::cin >> a_i;
  }
  sort(a.rbegin(), a.rend());
  int alice_point = 0;
  int bob_point = 0;
  for (int i = 0; i < a.size(); i++) {
    if (i % 2 == 0) {
      alice_point += a.at(i);
    } else {
      bob_point += a.at(i);
    }
  }
  int diff = alice_point - bob_point;
  cout << diff << endl;
}


Measured memory_bytes: 256
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	int inf = (int)1e9;

	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int n = Integer.parseInt(scanner.nextLine());
		Map<String, Integer> map = new HashMap<>();

		for (int i=0; i<n; i++) {
			String line = scanner.nextLine();
			map.putIfAbsent(line, 0);
			map.put(line, map.get(line) + 1);
		}

		List<Num> list = new ArrayList<>();
		for (String str : map.keySet()) {
			list.add(new Num(str, map.get(str)));
		}

		Collections.sort(list, new ComparatorNum());
		int max_cnt = list.get(0).cnt;

		for (Num u : list) {
			if (u.cnt != max_cnt) break;
			System.out.println(u.val);
		}

		return;
	}



	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}

class Num {
	public String val;
	public int cnt;
    public Num(String val, int cnt) {
        this.val = val;
        this.cnt = cnt;
    }
}


class ComparatorNum implements Comparator<Num> {
    public int compare(Num a, Num b) {
        if (a.cnt == b.cnt) {
            return a.val.compareTo(b.val);
        } else {
            return b.cnt - a.cnt;
        }
    }
}


Measured memory_bytes: 177616
x, y = map(int, input().split())
l = []
if x <= y:
    l.append(y - x)
if -x <= y: # 最初に1回符号反転
    l.append(y + x + 1)
if x <= -y: # 最後に1回符号反転
    l.append(-y - x + 1)
if -x <= -y: # 両方符号反転
    l.append(-y + x + 2)

ans = min(l)
print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll p,ll n){
   ll result=1;
   while(n!=0){
   if(n%2==0){
    n/=2;
    p*=p;
   }
   else{
    n--;
    result=result*p;
   }
   }
    return result;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   ll n,t,a,b,c;
   ll mod =1e9+7;
   string s1,s2;
   cin>>s1>>s2;
   ll cnt=0;
   for(ll i=0;i<s1.length();i++){
    if(s1[i]!=s2[i]){
        cnt++;
    }
   }
   cout<<cnt<<endl;
}


Measured memory_bytes: 3836
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 1299710
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vector<bool>IsPrime(MAX+1,true);
    vector<int>Prime(MAX+1,0); //Primearray
    int Primecounter =0;                  //Primearray counter;
    for(int i = 2; i<MAX+1;i++){
        if(IsPrime[i]){
            for(int j = 2;i*j<MAX;j++)
                IsPrime[i*j] = false;//?´???°??????Primearray???????´??????????????????°?????¨???false???
            Prime[Primecounter] = i;
            Primecounter++;
        }
    }
    ll hoge;
    while(cin>>hoge,hoge){
    ll a,b;
    for(ll i=hoge; ;i++){
        if(IsPrime[i]){
            a=i; break;
        }
        
    }
    for(ll j=hoge;; j--){
        if(IsPrime[j]){
            b=j; break;
        }
    }
    cout<<a-b<<endl;
    }
}

Measured memory_bytes: 7848
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long L = scanner.nextLong();
    long A = scanner.nextLong();
    long B = scanner.nextLong();
    long M = scanner.nextLong();

    long[][] m = new long[3][3];
    for (int i = 0; i < 2; i++) m[1][i] = 1;
    for (int i = 1; i < 3; i++) m[2][i] = 1;

    long[] res = new long[] {0, A % M, B % M};
    long k = 10;
    long l = 0;
    while (A > k) k *= 10;
    while (l < L) {
      m[0][0] = k % M;
      long r = Math.min((k - A - 1) / B, L - 1);
      res = mult(res, modpow(m, r - l + 1, M), M);
      l = r + 1;
      k *= 10;
    }

    System.out.println(res[0]);
  }

  private static long[][] modpow(long[][] m, long c, long M) {
    if (c == 0) return new long[][] {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
    if (c == 1) return m;
    if (c % 2 == 0) {
      long[][] m1 = modpow(m, c / 2, M);
      return mult(m1, m1, M);
    } else {
      long[][] m1 = modpow(m, c - 1, M);
      return mult(m1, m, M);
    }
  }

  private static long[] mult(long[] a, long[][] b, long M) {
    long[] r = new long[3];
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        r[i] += a[j] * b[j][i] % M;
        if (r[i] >= M) r[i] -= M;
      }
    }
    return r;
  }

  private static long[][] mult(long[][] a, long[][] b, long M) {
    long[][] r = new long[3][3];
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        for (int k = 0; k < 3; k++) {
          r[i][j] += a[i][k] * b[k][j] % M;
          if (r[i][j] >= M) r[i][j] -= M;
        }
      }
    }
    return r;
  }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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, k;
  cin >> n >> k;
  vector<int> h = vector<int>(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end(), greater<>());
  ll ans = 0;
  rep(i, n) {
    if(i < k) continue;
    ans += h[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

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

int main() {
    int size = 5;
    vector<int> Antennas(size);
    int k;
    rep(i, size) scanf("%d", &Antennas[i]);
    scanf("%d", &k);

    string ans = "Yay!";
    rep(i, Antennas.size()) {
        for (int j = 1; j < Antennas.size(); ++j) {
            if ((Antennas[j] - Antennas[i]) > k) ans = ":(";
        }
    }

    printf("%s\n", ans.c_str());
    return 0;
}


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

int main() {
  int N;
	cin >> N;
	
	int s, h, j, i;
	s = N/1000;
	h = (N%1000)/100;
	j = ((N%1000)%100)/10;
	i = ((N%1000)%100)%10;

	if (s == h && h == j){
		cout << "Yes" << endl;
	}
	else if (h == j && j == i){
		cout << "Yes" << endl;
	}
	else {
	cout << "No"<< endl;
	}
}


Measured memory_bytes: 256
import bisect

s = input()
t = input()

s_dict = {}
for i, si in enumerate(s):
    if si not in s_dict:
        s_dict[si] = [i]
    else:
        s_dict[si].append(i)

# print(s_dict)

s_len = len(s)
counter = 0
fail = False
for ti in t:
    if ti not in s_dict:
        fail = True
        break
    # counter in s
    c_in_s = counter % s_len
    c = bisect.bisect_left(s_dict[ti], c_in_s)
    if c == len(s_dict[ti]):
        counter += s_len - c_in_s
        counter += s_dict[ti][0]
        counter += 1
    else:
        counter += s_dict[ti][c] - c_in_s
        counter += 1

print(counter if not fail else '-1')

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int32_t main(){
    
    int t;
    cin >> t;
    if(t >= 30){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main(){
	int x,y,i;
	for(;;){
		cin>>x>>y;
		if(x==0&&y==0)break;
		else if(y<x){ swap(x,y);
		 cout<<x<<" "<<y<<endl;
		}
		else{
			cout<<x<<" "<<y<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define maxn 200100
using namespace std;
typedef long long ll;
typedef pair<ll,int> par;
struct edge{
	int r,nxt,w;
}e[maxn<<1];
struct data{
	int u,v;
	ll w;
	int operator<(const data& d)const{return w<d.w;}
}d[maxn*100];
int f[maxn],head[maxn],tp,esz,num,mn,rt,vis[maxn],sz[maxn],A[maxn],a[maxn],n;
void addedge(int u,int v,int w){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;e[esz].w=w;
	e[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;e[esz].w=w;
}
void pre(int u,int f){
	num++;
	for(int t=head[u];t;t=e[t].nxt)if(!vis[e[t].r]&&e[t].r!=f)
		pre(e[t].r,u);
}
int findrt(int u,int f){
	int sz=1,s=0,mxsize=0;
	for(int t=head[u];t;t=e[t].nxt)if(!vis[e[t].r]&&e[t].r!=f){
		s=findrt(e[t].r,u),sz+=s;
		if(mxsize<s)mxsize=s;
	}
	if(mxsize<num-sz)mxsize=num-sz;
	if(mxsize<mn)mn=mxsize,rt=u;
	return sz;
}
par cal(int u,int f,ll d){
	par ret=par(a[u]+d,u);
	for(int t=head[u];t;t=e[t].nxt)if(!vis[e[t].r]&&e[t].r!=f)
		ret=min(ret,cal(e[t].r,u,d+e[t].w));
	return ret;
}
void join(int u,int f,ll d,par p){
	::d[++tp]=data{u,p.second,p.first+a[u]+d};
	for(int t=head[u];t;t=e[t].nxt)if(!vis[e[t].r]&&e[t].r!=f)
		join(e[t].r,u,d+e[t].w,p);
}
void sol(int u){
	num=0,mn=1<<30,rt=u;
	pre(u,0),findrt(u,0);
	vis[u=rt]=1;
	int ptr=0;
	par mn(a[u],u);
	for(int t=head[u];t;t=e[t].nxt)if(!vis[e[t].r])A[++ptr]=t;
	for(int i=1,t;i<=ptr;++i){
		t=A[i];
		join(e[t].r,u,e[t].w,mn);
		mn=min(mn,cal(e[t].r,u,e[t].w));
	}
	mn=par(a[u],u);
	for(int i=ptr,t;i>=1;--i){
		t=A[i];
		join(e[t].r,u,e[t].w,mn);
		mn=min(mn,cal(e[t].r,u,e[t].w));
	}
	::d[++tp]=data{u,mn.second,mn.first+a[u]};
	for(int t=head[u];t;t=e[t].nxt)if(!vis[e[t].r])sol(e[t].r);
}
int find(int x){
	return x==f[x]?x:f[x]=find(f[x]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=2,u,v,w;i<=n;++i){
		scanf("%d%d%d",&u,&v,&w);
		addedge(u,v,w);
	}
	sol(1);
	sort(d+1,d+tp+1);
	long long sum=0;
	for(int i=1;i<=n;++i)f[i]=i;
	for(int i=1;i<=tp;++i){
		int u=find(d[i].u),v=find(d[i].v);
		if(u!=v)sum+=d[i].w,f[u]=v;
	}
	printf("%lld",sum);
}

Measured memory_bytes: 121600
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    chutiyaap;
    int x;cin>>x;
    for(int i=-200;i<=200;i++)
    {
    	for(int j=-200;j<=200;j++)
    	{
    		if(pow(i,5)-pow(j,5)==x)
    		{
    			if(i>j)
    			{
    				cout<<i<<" "<<j;
    				return 0;
    			}
    			else
    			{
    				cout<<j<<" "<<i;
    				return 0;
    			}

    		}
    	}
    }
}


Measured memory_bytes: 4024
s1,s2,s3 = input().split()
print(s1[0].upper()+s2[0].upper()+s3[0].upper())





# import java.util.*;
# public class Main{
#     public static void main(String[] args){
#         Scanner stdIn = new Scanner(System.in);
#         String s1 = stdIn.next();
#         String s2 = stdIn.next();
#         String s3 = stdIn.next();
#
#         System.out.println(s1.charAt(0)+s2.charAt(0)+s3.charAt(0));
#
#
#     }
# }


Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
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; }
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 pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	sort(A.rbegin(), A.rend());
	priority_queue<P>q;
	q.push({ min(A[0],A[1]),max(A[0],A[1]) });
	q.push({ min(A[0],A[1]),max(A[0],A[1]) });
	int ans = A[0];
	for (int i = 2; i < N; i++) {
		P p = q.top();
		ans += p.first;
		q.pop();
		q.push({ min(p.first,A[i]),max(p.first,A[i]) });
		q.push({ min(p.second,A[i]),max(p.second,A[i]) });
	}
	cout << ans;
}

Measured memory_bytes: 9000
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ll n;
    cin>>n;
    ll ar[n+1];
    for(ll i=1;i<=n;i++)cin>>ar[i];
    ll dp[n+1]={0};
    dp[1]=0;
    dp[2]=abs(ar[1]-ar[2]);
    for(ll i=3;i<=n;i++)
    {
        dp[i]=min( dp[i-1]+abs(ar[i]-ar[i-1]) ,dp[i-2]+abs(ar[i]-ar[i-2]));
    }
    cout<<dp[n];
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define maxn 105
using namespace std;
int b[maxn],n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        scanf("%d",&b[i]);
    }
    int res=b[1]+b[n-1];
    for(int i=2;i<n;i++){
        res+=min(b[i-1],b[i]);
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 200005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	nfs_mw;
	int i,j,n,a,maxm = 0;
	cin>>n;
	for(i=1; i<=n; i++){
		cin>>a;
		if(a == (maxm+1)) maxm++;
	}
	cout<<((!maxm)?-1:n-maxm);
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    map<int, vector<int>> e;
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    vector<int> v(n);
    iota(ALL(v), 1);
    int t = 0;
    do {
        bool all_ok = true;
        for (int i = 0; i < n - 1; i++) {
            bool ok = false;
            for (const auto x : e[v[i]]) {
                if (v[i + 1] == x) {
                    ok = true;
                    break;
                }
            }
            if (!ok) {
                all_ok = false;
                break;
            }
        }
        if (all_ok) {
            t++;
        }
    } while(next_permutation(ALL(v)) && v[0] == 1);

    cout << t << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
   a = a * b;
   if(a <= c){
   System.out.println(a);
   } else {
   System.out.println(c);
   }
 } 
}

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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;

inline int add(int a, int b)
{
	return ((ll)a+b+modn)%modn;
}

inline int mul(int a, int b)
{
	return ((ll)a*b)%modn;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<vector<int>> dp(n+1,  vector<int>(n+1));
	//~ assignVV(dp, -1);
	for(int i=1; i<=n; i++) {
		dp[1][i]=1;
	}
	for(int i=2; i<=n; i++) {
		if(s[i-2]=='<') {
			for(int j=1; j<=i; j++) {
				dp[i][j]=dp[i-1][j-1];
			}
		}
		else {
			for(int j=1; j<=i; j++) {
				dp[i][j]=add(dp[i-1][n], -dp[i-1][j-1]);
			}
		}
		for(int j=1; j<=n; j++) {
			dp[i][j]=add(dp[i][j], dp[i][j-1]);
		}
	}
	cout<<dp[n][n]<<"\n";
	//~ printVV(dp);
    return 0;
}



Measured memory_bytes: 35584
N = int(input())
x = list(map(int,input().split()))

mod = 10**9+7
inv = [0,1]
for i in range(2,N):
  inv.append(inv[mod % i]*(mod - mod//i) % mod)

fac = 1
for i in range(1,N):
    fac *= i
    fac %= mod

ans = 0
cur = 0
for i in range(1,N):
    cur += fac*inv[i]
    cur %= mod
    ans += cur*(x[i]-x[i-1])
    ans %= mod
print(ans)

Measured memory_bytes: 90364
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

long long mod = 998244353;
int main(){
    long long n;
    cin >> n;

    vector<long long> d(n);
    vector<long long> count(n, 0);

    for(long long i = 0; i < n; i++){
        cin >> d[i];
        if(i == 0){
            if(d[i] != 0){
                printf("0\n");
                return 0;
            }
            count[d[i]]++;
            continue;
        }

        if(d[i] == 0){
            printf("0\n");
            return 0;
        }
        count[d[i]]++;
    }

    bool flag = true;

    for(long long i = 0; i < count.size(); i++){
        if(flag == true and count[i] == 0){
            flag = false;
        }
        else if(flag == false and count[i] > 0){
            printf("0\n");
            return 0;
        }
    }

    long long ans = 1;

    for(long long i = 0; i < count.size()-1; i++){
        if(count[i] != 0 and count[i+1] != 0){
            for(long long j = 1; j <= count[i+1]; j++){
                ans *= count[i];
                ans %= mod;
            }
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 1792
n = gets.to_i
a=gets.split.map &:to_i
b=gets.split.map &:to_i
c=n.times.map{|i|(a[i]-b[i]).abs}
p c.sum
p c.map{|i| i**2}.inject(:+)**0.5
p c.map{|i| i**3}.inject(:+)**(1/3.to_f)
p c.max


Measured memory_bytes: 6924
s=input()
d=s.replace("x","")
rd=d[::-1]
if d!=rd:print(-1)
else:
    ans=0
    x,y=0,len(s)-1
    while y-x>0:
        if s[x]==s[y]:
            x+=1;y-=1
        elif s[x]=="x":
            ans+=1;x+=1
        else:
            ans+=1;y-=1
    print(ans)

Measured memory_bytes: 3316
if __name__ == '__main__':
    n = input()
    li = list(map(int, input().split(' ')))
    flag, cnt = True, 0

    while flag:
        for list_index in range(len(li)):
            value = li[list_index]
            if value % 2 == 0:
                li[list_index] /= 2
            else:
                flag = False
                break

        if flag:
            cnt += 1

    print(cnt)


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

int main(void){
    ll H, W,ans=0;
    cin >> H >> W;
    string S[2000];
    rep(i,H) cin >> S[i];
   // rep(i,H) cout << S[i] << endl;
    
    ll D[H][W],U[H][W],L[H][W],R[H][W];
    
    rep(i,H){
        rep(j,W){
            if(j > 0){
                if(S[i][j] =='#' || S[i][j-1] == '#')L[i][j] = 0;
                else L[i][j] = L[i][j-1] + 1;
            }
            else L[i][j] = 0;
            if(j > 0){
                if(S[i][W-1-j] =='#' || S[i][W-j] == '#')R[i][W-j-1] = 0;
                else  R[i][W-j-1] = R[i][W-j] + 1;
            }
            else R[i][W-1-j] = 0;
            
            if(i > 0){
                if(S[i][j] =='#' || S[i-1][j] == '#')U[i][j] = 0;
                else  U[i][j] = U[i-1][j] + 1;
            }
            else U[i][j] = 0;
            
            if(i > 0){
                if(S[H-1-i][j] =='#' || S[H-i][j] == '#')D[H-1-i][j] = 0;
                else  D[H-1-i][j] = D[H-i][j] + 1;
            }
            else D[H-1-i][j] = 0;
        }
    }
    
    rep(i,H){
        rep(j,W){
            if(S[i][j] == '.' )ans = max(ans,D[i][j] + U[i][j]+L[i][j] + R[i][j]+1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 129408
nl=[]
al=[]
while 1:
    n=input()
    if n=="0":
        break
    nl.append(int(n))

    a = list(map(lambda x: int(x), input().split()))
    al.append(a)

for i in range(len(nl)):
    ave = sum(al[i]) / nl[i]
    num = len(list(filter(lambda x: x <= ave, al[i])))
    print(num)




Measured memory_bytes: 7360
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int X =(A + D -1)/D;
  int Y =(C + B -1)/B;
  if (X >= Y)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
  
  

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

int main() {
	int A, B;
	cin >> A >> B;
	if (A > B) {
		int tmp = A;
		A = B; B = tmp;
	}
	int C = B - A;
	if (C % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << A + C / 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,x;
	bool a[100000];
	cin >> x >> n;
	while(n--){
		ll z;
		cin >> z;
		a[z]=1;
	}
	ll jwb=-1e9;
	for(int i=-10000; i<=10000; i++){
		if(abs(i-x)<abs(jwb-x) && !a[i]){
			jwb=i;
		}
	}
	cout << jwb << endl;
}

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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

struct Combination {
  vector<ModInt<>> _fact, _rfact, _inv;
  Combination(long long nsize = 5000000)
      : _fact(nsize + 1), _rfact(nsize + 1), _inv(nsize + 1) {
    _fact[0] = _rfact[nsize] = _inv[0] = 1;
    for (int i = 1; i <= nsize; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[nsize] /= _fact[nsize];
    for (int i = nsize - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for (int i = 1; i <= nsize; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }
  inline ModInt<> fact(int k) const { return _fact[k]; }

  inline ModInt<> rfact(int k) const { return _rfact[k]; }

  inline ModInt<> inv(int k) const { return _inv[k]; }

  ModInt<> P(int n, int r) const {
    if (r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  ModInt<> C(int p, int q) const {
    if (q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
  // n types,choose r
  ModInt<> H(int n, int r) const {
    if (n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

int main() {
  int x, y;
  Combination com;
  cin >> x >> y;
  ModInt<> res;
  for (int i = 0; i <= x; i += 2) {
    int two = i >> 1, one = x - i;
    if (two + one * 2 != y) continue;
    res += com.C(one + two, one);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 61636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readD(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readD(String str) {
		String[] strArr = str.split("\\s+");
		HashMap<Integer, Integer> hist = new HashMap<Integer, Integer>();
		int dmax = 1;
		for (int i = 0; i < N; i++) {
			int d = Integer.parseInt(strArr[i]);
			if (hist.containsKey(d)) {
				hist.put(d, hist.get(d) + 1);
			} else {
				hist.put(d, 1);
			}
			if (d > dmax)
				dmax = d;
		}
		int cnt = 0;
		int h = 0;
		for (int i = 0; i < dmax && h <= N / 2; i++) {
			if (hist.containsKey(i)) {
				h += hist.get(i);
			}
			if (h == N / 2)
				cnt++;
		}
		System.out.println(cnt);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 47396
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;

//const int MOD=998244353;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,k;
    cin>>n>>k;
    
    cout<<(k<= (n/2+(n%2))?"YES":"NO");
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
long ans = 0;
long before = 1;
long before2 = 2;
  for(int i = 2;i <= N;i++){
	  ans = before + before2;
	  before2 = before;
	  before = ans;
  }
  if(N==0)System.out.println("2");
  else if(N==1)System.out.println("1");
  else System.out.println(ans);
}}


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

using namespace std;

typedef long long ll;

int main(){
    int n;
    cin >> n;
    int m[99999] = {0};
    int q=0;int p = 1;
    while(true){
        m[q+p] = p;
        q = q+p;
        p++;
        if(q > 100000)break;
    }
    if(m[n] == 0) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        cout << m[n]+1 << endl;
        int e = 1;int f = m[n]-2;
        for(int a = 0; a < m[n]+1; a++){
            int b;
            cout << m[n] << ' ';
            int ch = a;int k = m[n]-1;
            for(b = 0; b < a; b++){
                cout << ch << ' ';
                ch += k;
                k--;
            }
            for(int c = b; c < m[n]; c++){
                cout << e << ' ';
                e++;
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

void insertionSort(int *,int);
void print(int *,int);

int main()
{
  int N,i;
  
  scanf("%d",&N);

  int number[N];
  
  for(i=0;i<N;i++){
    scanf("%d",&number[i]);
  }
  
  insertionSort(number,N);

  return 0;
}

void insertionSort(int *number,int n)
{
  int i,j,v;

  print(number,n);

  
  for(i=1;i<n;i++){
    v = number[i];
    j = i-1;
    while(j>=0 && number[j]>v){
      number[j+1] = number[j];
      j--;
    }
    number[j+1] = v;
    print(number,n);
  }
}

void print(int *number,int n)
{
  int i;
  for(i=0;i<n;i++){
    printf("%d",number[i]);
    if(i < n-1) printf(" ");
    else printf("\n");
  }
}


    
  
  



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll ans =0;
	cin >>n;
	
	rep2(i, 1, n+1){
		if(i%3==0 || i%5==0) continue;
		ans +=i;
	}
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 3624
N, M = map(int, input().split())
city_list = []
for i in range(M):
    a,b = map(int,input().split())
    city_list.append([a,b,0,i])

city_list.sort(key=lambda city_list:city_list[1])
city_list.sort(key=lambda city_list:city_list[0])

city_id = 1
city_cnt = 1
i = 0

while True:
    if i + 1 > M:
        break

    elif city_id == city_list[i][0]:
        city_list[i][2] = city_cnt
        city_cnt += 1
        i += 1
    
    elif city_id <= N+1:
        city_cnt = 1
        city_id += 1

    else:
        break
            
city_list.sort(key=lambda city_list:city_list[3])

for city in city_list:
    print('{:0>6}{:0>6}'.format(city[0],city[2]))

Measured memory_bytes: 28964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  priority_queue<int> pq;
  for(int i = 0;i < n;i++) {
    cin >> a[i];
    pq.push(a[i]);
  }
  int max1 = pq.top();
  pq.pop();
  int max2 = pq.top();
  vector<int> ans(n);
  for(int i = 0;i < n;i++) {
    if (a[i] == max1) ans[i] = max2;
    else ans[i] = max1;
    cout << ans[i] << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1e9+7;


ll a[maxN];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a,a+n);
	reverse(a,a+n);
	ll ans = 0;
	for(int i=1;i<n;i++)
	{
		ans += a[i/2];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5232
N = int(input())

A = []
b_sum = 0

for i in range(N):
    a,b = map(int,input().split())
    A.append((a+b, a, b))
    b_sum += b

A.sort(reverse=True)

#print(A)
count = 0


for i in range(0,N,2):
    count += A[i][0]

print(count-b_sum)


Measured memory_bytes: 20996
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

bool cmp(pii l, pii r)
{
  return (l.Se > r.Se);
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  for (int n, m; cin >> n >> m, n || m; ){
    vector<pii> cnt(m);
    REP(i, m) cnt[i] = mp(i + 1, 0);

    REP(i, n){
      REP(j, m){
        int in;
        cin >> in;
        cnt[j].Se += in;
      }
    }
    stable_sort(cnt.begin(), cnt.end(), cmp);

    REP(i, m){
      if (i == 0) cout << cnt[i].Fi;
      else cout << " " << cnt[i].Fi;
    }
    print("");
  }

  return (0);
}

Measured memory_bytes: 1216
/*||>>>> Praveen Ojha <<<<>>>> 01 June 2019 <<<<>>>> 17:23:37 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf 1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	string s;
	cin>>s;
	int n=s.length();
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]=='x')
			cnt++;
	}
	if(15-cnt<8)
		cout<<"NO\n";
	else
		cout<<"YES\n";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    ll ans = 0;
    rep(i, n){
        int a;
        cin >> a;
        mp[a]++;
        ans += a;
    }
    int q;
    cin >> q;
    rep(i, q){
        ll b, c;
        cin >> b >> c;
        ll cnt = mp[b];
        ans -= cnt * b;
        mp[b] = 0;
        mp[c] += cnt;
        ans += cnt * c;
        cout << ans << endl;
    }
}

Measured memory_bytes: 7872
import sys
def MI(): return map(int, sys.stdin.readline().split())
sx, sy, tx, ty = MI()
dx = tx - sx
dy = ty - sy
print('U'*dy+'R'*dx+'D'*dy+'L'*dx+'L'+'U'*(dy+1)+'R'*(dx+1)+'DR'+'D'*(dy+1)+'L'*(dx+1)+'U')


Measured memory_bytes: 38256
n=int(input())
r=range(1,int(2*n**.5)+1)
l=[0]*-~n
for i in r:
  for j in r:
    for k in r:
      t=(j+k)**2+(k+i)**2+(i+j)**2
      if t<=n*2 and t%2<1: l[t//2]+=1
for i in range(n): print(l[i+1])

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

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 main(){
  int h,w;
  string g[10];
  int dx[] = {0,1,1,1,0,-1,-1,-1},dy[] ={-1,-1,0,1,1,1,0,-1};
  int lm;

  while(cin>> h >> w &&(h||w)){
    for(int i=0;i<h;i++)cin >> g[i];

    map<string,int> m;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	for(int k=0;k<8;k++){
	  string tmp;
	  tmp += g[i][j];
	  int sx = j,sy = i;
	  if(k&1)lm = lcm(h,w);
	  else if(!(k%4))lm = h;
	  else lm = w;
	  for(int t=1;t<lm;t++){
	    sx = (sx+w+dx[k])%w;
	    sy = (sy+h+dy[k])%h;
	    tmp += g[sy][sx];
	    m[tmp]++;
	  }
	}


    string ans = "A";
    map<string,int>::iterator ite;
    for(ite=m.begin();ite!=m.end();ite++)
      if((*ite).second>1){
	string tmp = (*ite).first;
	if(ans.size()<tmp.size() || (ans.size()==tmp.size()&&ans>tmp))ans = tmp;
      }
    if(ans.size()>1)cout << ans << endl;
    else cout << 0 << endl;
  }
}

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

int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  printf("%s", (a + b + c) == 2 * max(c, max(a, b)) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();

        if (s.equals("SUN")) System.out.println(7);
        if (s.equals("MON")) System.out.println(6);
        if (s.equals("TUE")) System.out.println(5);
        if (s.equals("WED")) System.out.println(4);
        if (s.equals("THU")) System.out.println(3);
        if (s.equals("FRI")) System.out.println(2);
        if (s.equals("SAT")) System.out.println(1);
    }
}


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

using namespace std;
#define ll long long

const int N = 10005, P = 1000000007;
int n, ans, a[N], f[1000005];
int Pow(ll x, int y=P-2){
	int ans=1;
	for(; y; y>>=1, x=x*x%P) if(y&1) ans=ans*x%P;
	return ans;
}
int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; ++i){
		scanf("%d", a+i);
		int x=a[i];
		for(int j=2; j*j<=x; ++j) if(x%j==0){
			int cnt=1;
			while((x/=j)%j==0) ++cnt;
			f[j]=max(f[j], cnt);
		}
		if(x>1) f[x]=max(f[x], 1);
	}
	int s=1;
	for(int i=1; i<=1000000; ++i) while(f[i]--) s=(ll)s*i%P;
	for(int i=1; i<=n; ++i) ans=(ans+(ll)s*Pow(a[i]))%P;
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 4224
#include<stdio.h>

int main()
{
    int a,b,c,d,e;
    scanf("%d %d %d",&a,&b,&c);
    for(d=a;d<(b+1);d++){
    	if(c%d==0)
    		e++;
    }
    printf("%d\n",e);
    return 0;
}

Measured memory_bytes: 596