akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
void chmin(int &a, int b) {if(a > b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    int h,w;
    cin >> h >> w;
    char maze[h+1][w+1];
    ll dp[h+1][w+1] = {0};
    rep(i,0,h){
        rep(j,0,w){
            cin >> maze[i][j];
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            if(maze[i][j] == '#') {
                if(i == 0 && j == 0) dp[i][j] = 0;
                else if(j == 0) dp[i][j] = dp[i-1][w-1];
                else dp[i][j] = dp[i][j-1];
                continue;
            }
            ll dis[h+1][w+1];
            rep(a,0,h){
                rep(b,0,w){
                    dis[a][b] = inf;
                }
            }
            ll tmpmax = 0;
            queue<P> q;
            q.push(P(i, j));
            dis[i][j] = 0;
            while(q.size()){
                P p = q.front();
                q.pop();
                rep(l,0,4){
                    int nx = p.first + dx[l];
                    int ny = p.second + dy[l];
                    if(nx >= 0 && nx < h && ny >= 0 && ny < w && maze[nx][ny] != '#' && dis[nx][ny] == inf){
                        dis[nx][ny] = dis[p.first][p.second] + 1;
                        q.push(P(nx, ny));
                        if(dis[nx][ny] > tmpmax) tmpmax = dis[nx][ny];
                    }
                }
            }
            if(i == 0 && j == 0){dp[i][j] = tmpmax;}
            else if(j == 0){dp[i][j] = max(dp[i-1][w-1], tmpmax);}
            else{dp[i][j] = max(dp[i][j-1], tmpmax);}
        }
    }
    

    cout << dp[h-1][w-1];
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1
typedef struct{int p,l,r;}Node;
Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u, int d){
  if(u == NIL)return;
  D[u] = d;
  setDepth(T[u].l,d+1);
  setDepth(T[u].r,d+1);
}
int setHeight(int u){
  int h1 = 0,h2 =0;
  if(T[u].l != NIL)h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL)h2 = setHeight(T[u].r) + 1;
  if(h1 > h2)H[u] = h1;
  else H[u] =h2;
  return H[u];
}

int getSibling(int u){
  if(T[u].p == NIL)return NIL;
  if(T[T[u].p].l != u && T[T[u].p].l != NIL)return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NIL)return T[T[u].p].r;
  return NIL;
}

void print(int u){
  int deg = 0;
  printf("node %d:",u);
  printf(" parent = %d, ",T[u].p);
  printf("sibling = %d, ",getSibling(u));
  if(T[u].l != NIL)deg++;
  if(T[u].r != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p == NIL){
    printf("root\n");
  }else if(T[u].l == NIL && T[u].r == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,i,root=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)T[i].p  = NIL;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }
  for(i=0;i<n;i++)if(T[i].p == NIL)root = i;
  setDepth(root,0);
  setHeight(root);
  for(i=0;i<n;i++)print(i);
  return 0;
}



Measured memory_bytes: 2052
from collections import deque

h,w = map(int,input().split())#行,列
C = list(map(int,input().split()))
D = list(map(int,input().split()))
S = [list(input()) for _ in range(h)]

seen = [[0]*w for _ in range(h)]
cost = [[-1]*w for _ in range(h)]
cost[C[0]-1][C[1]-1]=0
cost_base = 0
for i in range(h):
    for j in range(w):
        if S[i][j]=='#':
            cost[i][j]=-2

ok = True

q=deque()
q.append(C)
                
while len(q)>0:
    #移動A
    now = q.popleft()
    if seen[now[0]-1][now[1]-1] == 1:
        continue
    costnow = cost[now[0]-1][now[1]-1]
    seen[now[0]-1][now[1]-1] = 1

    for i in range(-1,2,2):
        if now[0]+i<1 or now[0]+i>h:
            continue
        if cost[now[0]+i-1][now[1]-1]==-1 or cost[now[0]+i-1][now[1]-1]>costnow:
            cost[now[0]+i-1][now[1]-1]=costnow
            q.appendleft([now[0]+i,now[1]])
    for i in range(-1,2,2):
        if now[1]+i<1 or now[1]+i>w:
            continue
        if cost[now[0]-1][now[1]+i-1]==-1 or cost[now[0]-1][now[1]+i-1]>costnow:
            cost[now[0]-1][now[1]+i-1]=costnow
            q.appendleft([now[0],now[1]+i])

    #移動B
    for i in range(-2,3):
        for j in range(-2,3):
            if now[0]+i<1 or now[0]+i>h:
                continue
            if now[1]+j<1 or now[1]+j>w:
                continue

            if cost[now[0]+i-1][now[1]+j-1]==-1:
                cost[now[0]+i-1][now[1]+j-1]=costnow+1
                q.append([now[0]+i,now[1]+j])

print(cost[D[0]-1][D[1]-1])

Measured memory_bytes: 144760
N = list(input())
n = len(N)
N.reverse()
ans = 0

i = 0

while i < n:
    if N[i] == 'm':
        if N[i+1]=='a' and N[i+2]=='e' and N[i+3]=='r' and N[i+4]=='d':
            i += 5
            continue
        else:
            ans = 1
            break

    elif N[i] == 'e':
        if N[i+1]=='s' and N[i+2]=='a' and N[i+3]=='r' and N[i+4]=='e':
            i += 5
            continue
        else:
            ans = 1
            break

    elif N[i] == 'r':
        if N[i+1]=='e' and N[i+2]=='m':
            if N[i + 3] == 'a' and N[i + 4] == 'e' and N[i + 5] == 'r' and N[i + 6] == 'd':
                i += 7
                continue
            else:
                ans = 1
                break
        elif N[i+1]=='e' and N[i+2]=='s':
            if N[i + 3] == 'a' and N[i + 4] == 'r' and N[i + 5] == 'e':
                i += 6
                continue
            else:
                ans = 1
                break
        else:
            ans = 1
            break
    i += 1

if ans == 0:
    print('YES')
else:
    print('NO')

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

long long S;
// d = 1000000000
// S = dq + r (0 <= r < d)
// S = dx - y = d * (x - 1) + d - y
// x - 1 = q, d - y = r
// x = q + 1, y = d - r

int main(){
    cin >> S;
    if(S == 1000000000000000000LL){
        cout << 0 << " " << 0 << " " << 1000000000 << " " << 0 << " " << 0 << " " << 1000000000 << endl;
    }else{
        cout << 0 << " " << 0 << " " << 1 << " " << 1000000000 << " " << S / (1000000000LL) + 1 << " " << 1000000000 - S % 1000000000LL << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double a[200100];
double s[200100];
int main(){
	 int n,k;
	 cin>>n>>k;
	 for(int i=0;i<n;i++){
		double t;
		cin>>t;
		a[i]=(t+1)/2.0;
	}
	s[0]=a[0];
 for(int i=1;i<n;i++){
	s[i]=s[i-1]+a[i];
  }
  double mx=s[k-1];
	double l=a[0];
  for(int i=k;i<n;i++){
		s[i]-=l;
		l+=a[i-k+1];
		mx=max(mx,s[i]);
	}
	printf("%.7f\n",mx);
}


Measured memory_bytes: 3328
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int ans = 0;
        for (int i = 0; i < 4; i++) {
            if (s.charAt(i) == '+') ans++;
            else ans--;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>


int main()
{
    int n;
    scanf("%d", &n);
    std::vector<int> a(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d", &a[i]);
    std::sort(a.begin(), a.end());
    int result = 0;
    for (int i = 0, j = 1; i < n; i = j ++) {
        while (j < n && a[j] == a[i]) ++ j;
        int cnt = j - i;
        if (cnt < a[i])
            result += cnt;
        else
            result += cnt - a[i];
    }
    printf("%d\n", result);
}


Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: String = read();
    let b: String = read();
    let mut ans: String = "".to_string();
    if a == "H" {
        if b == "H" {
            ans = "H".to_string();
        } else { 
            ans = "D".to_string();
        }
    } else {
        if b == "H" {
            ans = "D".to_string();
        } else { 
            ans = "H".to_string();
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
/*           pmaik
    ░▒▓█►─═ Maneesh ═─◄█▓▒░


          ( •̪●)
        ███████]▄▄▄▄▄▄▄▄▃  ▃  ▃ 
    ▂▄▅█████████▅▄▃▂
   [███████████████████]
  ...◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤......  */

#include<bits/stdc++.h>
using namespace std;
#define inf() ifstream cin("in00.txt")
#define onf() ofstream cout("out00.txt")
#define ll long long int
#define pb push_back
#define pf push_front
#define mp make_pair
#define pii pair<ll,ll>
#define fi first
#define se second
#define M 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

 
int main()
{
    fastio;
    ll k;
    cin>>k;

    ll r=7;
    ll res=0;
    ll f=0;

    unordered_map<ll, ll>mp;
    while(k%2==1)
    {
        res++;
        if(r%k==0)
        {
            f=1;
            break;
        }

        r=r*10+7;
        if(mp.find(r)!=mp.end())
        {
            f=0;
            break;
        }
        else
        {
            mp[r]=1;
        }

        r=r%k;
    }

    if(f==1)
        cout<<res<<endl;
    else
        cout<<"-1"<<endl;

    return 0;
}


Measured memory_bytes: 42564
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

#include <iomanip>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const ll INF = 1e17;
// ll dp[100005][13];
ll dp[10005];

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

signed main(void) {
  ll bingo[3][3];
  rep(i, 3) {
    rep(j, 3) {
      cin >> bingo[i][j];
    }
  }
  
  ll N;
  cin >> N;
  rep(i, N) {
    ll tmp;
    cin >> tmp;
    rep(j, 3) {
      rep(k, 3) {
        if (bingo[j][k] == tmp) {
          bingo[j][k] = 0;
        }
      }
    }
  }

  string ans = "No";
  // 縦
  rep(i, 3) {
    if (bingo[0][i] == 0 && bingo[1][i] == 0 && bingo[2][i] == 0) {
      ans = "Yes";
      break;
    }
  }

  // 横
  rep(i, 3) {
    if (bingo[i][0] == 0 && bingo[i][1] == 0 && bingo[i][2] == 0) {
      ans = "Yes";
      break;
    }
  }

  // 斜め
  if (bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0) {
    ans = "Yes";
  }
  if (bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0) {
    ans = "Yes";
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
/*

                                  In the name of Allah, Most Gracious, Most Merciful


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

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********

int main()
{
    IOS;
    ll n,i,j,k,cnt = 0;
    cin>>n;
    vll v(n);
    fn(i,n)
    cin>>v[i];

    f(i,0,n)
     f(j,i+1,n)
       f(k,j+1,n)
         if((v[i]+v[j] > v[k]) && (v[j]+v[k] > v[i]) && (v[i]+v[k] > v[j]) && (v[i] != v[j] && v[i] != v[k] && v[j] != v[k]))
             cnt++;


             cout<<cnt<<endl;

return 0;
}



Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n;

void s(ll b) {
	ll a = b % n;
	cout << " ";
	if (a == 0)a = n;
	cout << a;
}
int main() {
	cin >> n;
	if (n == 2) cout << -1 << endl;
	else {
		REPO(i, n) {
			REPO(j, n - 2) {
				if (n % 2 == 1 or j != n / 2) {
					ll a = (j + i) % n;
					if (j != 1)cout << " ";
					if (a == 0)a = n;
					cout << a;
				}
			}
			if (n % 2 == 1) {
				s(n - 1 + i);
			}
			else if (n / 2 >= i) {
				s(n - 1 + i);
				s(n / 2 + i);
			}
			else {
				s(n / 2 + i);
				s(n - 1 + i);
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
d=[]
for i in range(a):
    n=list(map(int,input().split()))
    d.append(n)
ans=[]
q=len(d)
for i in range(2**q):
    score=[0]*b
    total=0
    n=0
    for j in range(q):
        if ((i>>j)&1):
            for m in range(b):
                score[m]+=d[j][m+1]
            total+=d[j][0]
    for mm in range(b):
        if score[mm]>=c:
            n+=1
    if n==b:
        ans.append(total)

if ans==[]:
    print(-1)
else:
    print(min(ans))


Measured memory_bytes: 74120
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	long long int a, b;
	cin >> a >> b;

	long long int c = 1000000000000;
	if (a < b) {
		c = min(c, b-a);
	}
	if (-a <= b) {
		c = min(c, b-(-a)+1);
	}
	if (a <= -b) {
		c = min(c, -b-a+1);
	}
	if (-a <= -b) {
		c = min(c, -b-(-a)+2);
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>
const long long INF=1e18;

using namespace std;

int main(void) {
    int N,K;
    cin>>N>>K;
    int ans=0;

    vector<double>A(N);

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

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

    for(int i=0;i<K;i++){
        ans+=int (A[i]);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int d(int a) {
    int cnt = 0;
    while (a > 0) {
        cnt++;
        a /= 10;
    }
    return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (d(i) % 2 == 1) cnt++;
    }
    cout << cnt << endl;


    return 0;
}



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

long long calc(long long N) {
	long long res = 0;
	while(N > 0) {
		res += N % 10;
		N /= 10;
	}
	return res;
}

void solve(long long N){
	long long res = calc(N);
	long long t = 10;
	while (t <= N) {
		long long m = (N / t - 1) * t + (t - 1);
		res = max(res, calc(m));
		t *= 10;
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()

int main() {

	//clock_t start, end;
	//start = clock();

	int A, B;
	string S;
	
	cin >> A >> B >> S;

	if (S[A] != '-') {
		cout << "No" << endl;
		return 0;
	}

	for (int i = 0; i <= A + B; i++) {
		if (i == A) continue;
		if (S[i] < '0' || '9' < S[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	//end = clock();
	//printf("%f sec.\n", double(end - start) / CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 256
/*
  Contest 104
  B - AcCepted
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

bool check_lower(const std::string& s, std::size_t pos) {
    for (std::size_t i = 1; i < s.size(); ++i) {
        if (i != pos && !(s[i] >= 'a' && s[i] <= 'z'))
            return false;
    }
    return true;
}

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

    std::string s;
    std::getline(std::cin, s);
    std::string r = "WA";
    if (s[0] == 'A') {
        const std::size_t pos = s.find('C');
        if (pos != std::string::npos) {
            if (pos >= 2 && pos <= s.size() - 2) {
                if (check_lower(s, pos)) {
                    r = "AC";
                }
            }
        }
    }
    std::cout << r << std::endl;

    return 0;
}


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

int main() {
	int n;
	int a[2][100];
	cin >> n;
	for(int i=0;i<2;i++) for(int j=0;j<n;j++) {
		cin >> a[i][j];
	}
	int sum = a[0][0];
	for(int i=0;i<n;i++) sum += a[1][i];
	int max = sum;
	for(int i=1;i<n;i++) {
		sum += a[0][i] - a[1][i-1];
		if(sum > max) max = sum;
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int Abs(int n) {
	if (n >= 0)return n;
	else return -n;
}

int main() {
	int a[4];
	for (int i = 0; i < 4; i++) {
		scanf("%d", &a[i]);
	}
	if (Abs(a[0] - a[2]) <= a[3]) {
		printf("Yes\n");
	}
	else if (Abs(a[1] - a[0]) <= a[3] && Abs(a[2] - a[1]) <= a[3]) {
		printf("Yes\n");
	}
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

s = [0]*(n+1)
s[1] = 1
for i in range(2, n+1):
  s[i] = s[i-1]*i

x = 0
l = [i for i in range(1, n+1)]
for i in p:
  x += l.index(i) * s[len(l) - 1]
  l.remove(i)

y = 0
l = [i for i in range(1, n+1)]
for i in q:
  y += l.index(i) * s[len(l) - 1]
  l.remove(i)
  
print(abs(x-y))

Measured memory_bytes: 3064
#include<string.h>
#include<iostream>
int main()
{
  char weather1[20],weather2[20];
  std::cin>>weather1;
  if(strcmp(weather1, "Sunny")==0)strcpy(weather2,"Cloudy");
  if(strcmp(weather1, "Cloudy")==0)strcpy(weather2,"Rainy");
  if(strcmp(weather1, "Rainy")==0)strcpy(weather2,"Sunny");
  printf("%s",weather2);
}

Measured memory_bytes: 256
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local n, d = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = {}
  for j = 1, d do
    t[i][j] = io.read("*n")
  end
end
local cnt = 0
for i = 1, n - 1 do
  for j = i + 1, n do
    local sumsq = 0
    for k = 1, d do
      sumsq = sumsq + (t[i][k] - t[j][k]) * (t[i][k] - t[j][k])
    end
    local cand = mfl(msq(sumsq))
    if cand * cand == sumsq or (cand + 1) * (cand + 1) == sumsq then
      cnt = cnt + 1
    end
  end
end
print(cnt)


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    string S;int K;cin>>S>>K;
    bool ok=true;
    REP(i,K){
        if(S[i]!='1'){
            cout<<S[i]<<endl;
            ok=false;
            break;
        }
    }
    if(ok)cout<<1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
using namespace std;
     
int main() {
    string s;
    cin >> s;
    stack<int> st;
    int no_rem = 0;
    for (int i = 0; i < s.length(); i++) {
        if (!st.empty()) {
          	if (st.top() == 1 && s[i] == '0') {
                no_rem++;
                st.pop();
            }
            else if (st.top() == 0 && s[i] == '1') {
                no_rem++;
                st.pop();
            } 
            else {
                st.push(s[i] - '0');
            }
        } else {
            st.push(s[i] - '0');
        }
    }
    cout << no_rem * 2;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	int N;
	cin>>N;
	vector<int> A(N);
	FDS(i,N){
		cin>>A[i];
	}
	vector<int> L(N);//左からの累積GCD
	vector<int> R(N);//右からの累積GCD
	L[0]=A[0];
	FOR(i,1,N){
		L[i]=G_C_D(L[i-1],A[i]);
	}

	VREV(A);
	R[0]=A[0];
	FOR(i,1,N){
		R[i]=G_C_D(R[i-1],A[i]);
	}
	VREV(A);
	int ans=max(R[N-2],L[N-2]);
	FOR(i,1,N-1){
		ans=max(ans,G_C_D(R[i-1],L[N-2-i]));
	}
	cout<<ans<<endl;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int n, avr;
  cin >> n >> avr;
  vector<map<int, int>> m(n + 1);
  m[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    t -= avr;
    for (int j = -2500; j <= 2500; j++) {
      m[i][j] = m[i - 1][j - t] + m[i - 1][j];
    }
  }
  cout << m[n][0] - 1 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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

int main()
{
    long long k;
    cin >> k;

    if(k%2 == 1) {
        long long value = k /2;
        cout << value*(value+1);
    }
    else {
        long long value = k /2;
        cout << value*(value);
    }

    return 0;
}



Measured memory_bytes: 256
mod=2019

l, r=map(int, input().split())

l_shou=l//mod
r_shou=r//mod

l_amari=l%mod
r_amari=r%mod


maxi=max(l_amari, r_amari)
mini=min(l_amari, r_amari)

if l_shou!=r_shou:
    print(0)
else:
    ans=-1
    for i in range(mini, maxi):
        for j in range(i+1, maxi+1):
            if ans==-1:
                ans=(i*j)%mod
            else:
                if ans>(i*j)%mod:
                    ans=(i*j)%mod
    print(ans)


Measured memory_bytes: 41964
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

template <typename T>
void printV(vector<T>& v) {
    for(int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

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

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

    ans /= 2;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define in insert
#define bs binary_search   

int opc(int arr[],int n,int dp[])
{
    if(n<=0)
        return 0;
    else if(dp[n]!=-1)
        return dp[n];
    else if(n==1)
        dp[n]=opc(arr,n-1,dp)+abs(arr[n]-arr[n-1]);
    else
        dp[n]=min(opc(arr,n-2,dp)+abs(arr[n]-arr[n-2]),opc(arr,n-1,dp)+abs(arr[n]-arr[n-1]));
    return dp[n];
}
int main()
{
    int n;
    cin>>n;
    int arr[n],dp[n];
    for(int i=n-1;i>=0;i--)
    {
        cin>>arr[i];
        dp[i]=-1;
    }
    cout<<opc(arr,n-1,dp);
    return 0;
}

Measured memory_bytes: 8832
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n;
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

long long s[maxn];

void solve() {
  sort(a, a + n);
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + a[i];
  }
  int res = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (2 * s[i] < a[i]) {
      break;
    }
    res++;
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<stack>
#include<string>
#include<cstdlib>
using namespace std;
int main() {
    stack<string> s;
    int cnt = 0;
    while (1) {
        string a;
        cin >> a;
        if (a == "=") {
            cout << s.top() << endl;
            return 0;
        }
        cnt++;
        s.push(a);
        string op;
        int n1, n2;
        if (cnt >= 3 && cnt % 2 != 0) {
            n2 = atoi(s.top().c_str());
            s.pop();
            op = s.top();
            s.pop();
            n1 = atoi(s.top().c_str());
            s.pop();
            if (op == "+") {
                s.push(to_string(n1 + n2));
            } else if (op == "-") {
                s.push(to_string(n1 - n2));
            } else if (op == "*") {
                s.push(to_string(n1 * n2));
            } else {
                s.push(to_string(n1 / n2));
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3236
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto rs = new int[](10^^4+1);
    foreach (x; 1..101) foreach (y; 1..101) foreach (z; 1..101) {
        auto n = x^^2 + y^^2 + z^^2 + x*y + y*z + z*x;
        if (n > 10^^4) continue;
        ++rs[n];
    }
    auto N = readln.chomp.to!int;
    foreach (i; 1..N+1) writeln(rs[i]);
}

Measured memory_bytes: 2760
MOD=998244353
N,K=map(int,input().split())

lrlist=[]
for _ in range(K):
  l,r=map(int,input().split())
  lrlist.append((l,r))
#print(lrlist)

class SegTree:
  #init(init_val, ide_ele): 配列init_valで初期化 O(N)
  def __init__(self, init_val, segfunc, ide_ele):
    #init_val: 配列の初期値
    #segfunc: 区間にしたい操作
    #ide_ele: 単位元
    #n: 要素数
    #num: n以上の最小の2のべき乗
    #tree: セグメント木(1-index)
    n = len(init_val)
    self.segfunc = segfunc
    self.ide_ele = ide_ele
    self.num = 1 << (n - 1).bit_length()
    self.tree = [ide_ele] * 2 * self.num
    # 配列の値を葉にセット
    for i in range(n):
      self.tree[self.num + i] = init_val[i]
    # 構築していく
    for i in range(self.num - 1, 0, -1):
      self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

  #update(k, x): k番目の値をxに更新 O(logN)
  def update(self, k, x):
    #k番目の値をxに更新
    #k: index(0-index)
    #x: update value
    k += self.num
    self.tree[k] = x
    while k > 1:
      self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
      k >>= 1

  #query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
  def query(self, l, r):
    #[l, r)のsegfuncしたものを得る
    #l: index(0-index)
    #r: index(0-index)
    res = self.ide_ele
    l += self.num
    r += self.num
    while l < r:
      if l & 1:
        res = self.segfunc(res, self.tree[l])
        l += 1
      if r & 1:
        res = self.segfunc(res, self.tree[r - 1])
      l >>= 1
      r >>= 1
    return res
  
#segfunc
def segfunc(x,y):
  return x+y #区間和
#ide_ele
ide_ele=0 #区間和

#初期化
seg=SegTree([0]*(N+1), segfunc, ide_ele)
seg.update(1,1)

for i in range(2,N+1):
  sum_intv=0
  for l,r in lrlist:
    left=i-r
    right=i-l    
    if right<1:
      continue
    elif left<1:
      left=1
      
    sum_intv+=seg.query(left,right+1)
    
  seg.update(i,sum_intv%MOD)
  #print(i,left,right,sum_intv%MOD)
    
print(seg.query(N,N+1))

Measured memory_bytes: 78464
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
int a[100010];
signed main() {
	int h, n;
	cin >> h >> n;
	rep(i, n) {
		cin >> a[i];
	}
	int sum = 0;
	rep(i, n) {
		sum += a[i];
	}
	if (sum >= h)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main{
	public static void main(String[] args){
		solve();
	}
	private static void solve() {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		int r = sc.nextInt();
		@SuppressWarnings("unchecked")
		List<Edge>[] edges = Stream.generate(ArrayList::new).limit(V).toArray(List[]::new);
		for(int i=0;i<E;i++){
			edges[sc.nextInt()].add(new Edge(sc.nextInt(), sc.nextInt()));
		}
		int[] dist = new int[V];
		int[] pred = new int[V];
		shortestPaths(edges, r, dist, pred);
		for(int i=0;i<V;i++){
			if(dist[i]==Integer.MAX_VALUE){
				System.out.println("INF");
				continue;
			}
			System.out.println(dist[i]);
		}
	}
	public static void shortestPaths(List<Edge>[] edges, int s, int[] prio, int[] pred) {
		Arrays.fill(pred, -1);
		Arrays.fill(prio, Integer.MAX_VALUE);
		prio[s] = 0;
		PriorityQueue<Long> q = new PriorityQueue<>();
		q.add((long) s);
		while (!q.isEmpty()) {
			long cur = q.remove();
			int curu = (int) cur;
			if (cur >>> 32 != prio[curu])
				continue;
			for (Edge e : edges[curu]) {
				int v = e.t;
				int nprio = prio[curu] + e.cost;
				if (prio[v] > nprio) {
					prio[v] = nprio;
					pred[v] = curu;
					q.add(((long) nprio << 32) + v);
				}
			}
		}
	}

	static class Edge {
		int t;
		int cost;

		public Edge(int t, int cost) {
			this.t = t;
			this.cost = cost;
		}
	}

}

Measured memory_bytes: 326104
let flood_bits bits =
  List.fold_left (fun bits shamt ->
    bits lor (bits lsr shamt)) bits
  [1; 2; 4; 8; 16; 32]
let highest_bit bits =
  bits land lnot (flood_bits bits lsr 1)

let rec generate_pattern k =
  if k = 0 then [0]
  else begin
    let highest = highest_bit k in
    highest - 1 :: List.map (( lor ) highest) (generate_pattern (k land lnot highest))
  end

let () =
  let n, k = Scanf.scanf "%d %d\n" (fun n k -> n, k) in
  let abs = Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun a b -> a, b)) in
  generate_pattern k
  |> List.map (fun pat ->
      Array.fold_left (fun b' (a, b) ->
        if a land lnot pat = 0 then b + b' else b') 0 abs)
  |> List.fold_left max 0
  |> Printf.printf "%d\n"

Measured memory_bytes: 6784
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 10 == 3 || i / 10 % 10 == 3 || i / 100 % 10 == 3 || i / 1000 % 10 == 3){
            printf(" %d", i);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 3212
#include<iostream>

using namespace std;

signed main()
{
    long long n;
    cin>>n;
    string A[n];
    for(int i=0; i<n; i++)
        cin>>A[i];
    string C[n];
    for(int i=0; i<n; i++)
        C[i]=A[i];
    int ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=n-1; j>i; j--)
        {
            if(C[j][1]<C[j-1][1])
            {
                swap(C[j],C[j-1]);
            }
        }
    }
    string x[10],y[10];
    for(int i=0; i<n; i++)
    {
        x[A[i][1]-'0']+=A[i][0];
        y[C[i][1]-'0']+=C[i][0];
    }
    ans=1;
    for(int i=0; i<10; i++)
        ans&=x[i]==y[i];
    for(int i=0; i<n; i++)
        cout<<C[i]<<" \n"[i==n-1];
    cout<<(ans?"Stable":"Not stable")<<endl;
    for(int i=0; i<n; i++)
        C[i]=A[i];
    for(int i=0; i<n; i++)
    {
        int minj=i;
        for(int j=i; j<n; j++)
        {
            if(C[j][1]<C[minj][1])
            {
                minj=j;
            }
        }
        if(i!=minj)
            swap(C[i],C[minj]);
    }

    for(int i=0; i<10; i++)
        x[i]=y[i]="";
    for(int i=0; i<n; i++)
    {
        x[A[i][1]-'0']+=A[i][0];
        y[C[i][1]-'0']+=C[i][0];
    }
    ans=1;
    for(int i=0; i<10; i++)
        ans&=x[i]==y[i];
    for(int i=0; i<n; i++)
        cout<<C[i]<<" \n"[i==n-1];
    cout<<(ans?"Stable":"Not stable")<<endl;
    return 0;
}



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

const int maxn = 2e5 + 50;
int a[maxn];

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", a + i);
    sort(a, a + n);
    long long ans = 0;
    for (int i = n/2; i < n; ++i)
        ans += a[i];
    for (int i = (n+1)/2; i < n-1; ++i)
        ans += a[i];
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4620
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int[] mod = new int[2019];
        mod[0]++;
        int now = 0;
        int d = 1;
        for (int i = S.length()-1; i >= 0; i--) {
            int a = S.charAt(i)-'0';
            now += d*a;
            now %= 2019;

            mod[now]++;

            d *= 10;
            d %= 2019;
        }

        long ans = 0;
        for (int i = 0; i < 2019; i++) {
            if (mod[i] > 1) {
                ans += (long)mod[i]*(mod[i]-1)/2;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 40512
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program {

	static int testN = 3;
	static long mod = 1000000007;
	//static long mod =998244353; 
	static System.IO.StringReader sr;
		static void Main(string[] args) {
			char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";

		int res = 0;

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int n = vals[0];
		int x = vals[1]-1;
		int y = vals[2]-1;

		int[] d = new int[n];
		for(int i = 0; i < n-1; i++){
			for(int k = i+1; k < n; k++) {
				int min = Math.Abs(i - k);
				int tox= Math.Abs(i - x);
				int toy= Math.Abs(i - y);
				int rootx = tox + 1 + (Math.Abs(y - k));
				int rooty = toy + 1 + (Math.Abs(x - k));
				min = Math.Min(min, rootx);
				min = Math.Min(min, rooty);
				d[min]++;

			}
		}




		for(int i = 1; i < n; i++) {
			Console.WriteLine(d[i]);
		}

		//Console.WriteLine(res);
			return;

		
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 11204
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	int maxA = 0;
	for(int i = 0; i < n; ++i) {
		if( maxA > a[i] + 1 ) {
			cout << "No" << endl;
			return 0;
		}
		
		maxA = max(maxA, a[i]);
	}
	
	cout << "Yes" << endl;
	
	return 0;
}


Measured memory_bytes: 3724
/* https://atcoder.jp/contests/abc084/tasks/abc084_c */

#include <iostream>
#include <vector>

/* {{{ Variables */
int N;
std::vector<int> C, S, F;
/* }}} */

int main(int argc, char *argv[])
{
  /* {{{ Input */
  std::cin >> N;

  C = std::vector<int>(N-1);
  S = std::vector<int>(N-1);
  F = std::vector<int>(N-1);

  for (int i = 0; i < N-1; ++i) {
    std::cin >> C.at(i) >> S.at(i) >> F.at(i);
  }
  /* }}} */

  /* {{{ Output */

  for (int i = 0; i < N; ++i) {
    if (i == N-1) {
      std::cout << 0 << std::endl;
      break;
    }

    int e_time = 0;

    for (int j = i; j < N-1; ++j) {
      int c = C.at(j);
      int f = F.at(j);
      int s = S.at(j);

      if (e_time < s) {
        e_time = s;
      }

      int lack_time = (f - e_time%f)%f;

      e_time += c + lack_time;
    }

    std::cout << e_time << std::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;
typedef long long ll;

const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<int> to[MAXV];
int id[MAXN][MAXN];
int toId(int i, int j) {
  if (i > j) swap(i,j);
  return id[i][j];
}

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV]; // max length of path from v
int dfs(int v) {
  if (visited[v]) {
    if (!calculated[v]) return -1;
    return dp[v];
  }
  visited[v] = true;
  dp[v] = 1;
  for (int u : to[v]) {
    int res = dfs(u);
    if (res == -1) return -1;
    dp[v] = max(dp[v], res+1);
  }
  calculated[v] = true;
  return dp[v];
}

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n-1));
  rep(i,n) {
    rep(j,n-1) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  int V = 0;
  rep(i,n)rep(j,n) {
    if (i < j) {
      id[i][j] = V++;
    }
  }
  rep(i,n) {
    rep(j,n-1) {
      a[i][j] = toId(i,a[i][j]);
    }
    rep(j,n-2) {
      to[a[i][j+1]].push_back(a[i][j]);
    }
  }
  int ans = 0;
  rep(i,V) {
    int res = dfs(i);
    if (res == -1) {
      puts("-1");
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 38528
import java.util.Scanner;

public class Main {
	static boolean DEBUG = false;
	boolean[][] m1;
	boolean[][] m2;
	int[][] map;
	int w, h;

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			w = scan.nextInt();
			h = scan.nextInt();
			if (w + h == 0)
				return;
			
			m1 = new boolean[h][w - 1];
			m2 = new boolean[h - 1][w];
			map = new int[h][w];

			for (int i = 0; i < 2 * h - 1; i++) {
				if (i % 2 == 0) {
					for (int j = 0; j < w - 1; j++)
						m1[i / 2][j] = scan.nextInt() == 1;
				} else {
					for (int j = 0; j < w; j++)
						m2[i / 2][j] = scan.nextInt() == 1;
				}
			}

			if (DEBUG) {
				for (int i = 0; i < 2 * h - 1; i++) {
					if (i % 2 == 0) {
						for (int j = 0; j < w - 1; j++)
							System.out.print(" " + (m1[i / 2][j] ? 1 : 0));
					} else {
						for (int j = 0; j < w; j++)
							System.out.print((m2[i / 2][j] ? 1 : 0) + " ");
					}
					System.out.println();
				}
			}
			map[0][0] = 0;
			bfs(0, 0, 0);
			if (map[h - 1][w - 1] == 0)
				System.out.println(0);
			else
				System.out.println(map[h - 1][w - 1] + 1);
		}
	}
	void bfs(int y, int x, int deep) {
		if (map[y][x] != 0 && map[y][x] <= deep)
			return;
		if (y < 0 || x < 0 || y >= h || x >= w)
			return;

		map[y][x] = deep;
		if (y != h - 1 && !m2[y][x])
			bfs(y + 1, x, deep + 1);
		if (y != 0 && !m2[y - 1][x])
			bfs(y - 1, x, deep + 1);
		if (x != w - 1 && !m1[y][x])
			bfs(y, x + 1, deep + 1);
		if (x != 0 && !m1[y][x - 1])
			bfs(y, x - 1, deep + 1);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 68700
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k;
string s;

string solve() {
    for (int i = 0; i < n; i++) {
        if (s[i] != s[k-1]) {
            s[i] = '*';
        }
    }
    return s;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3028