akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
vector<pll> ls, rs;
bool used[100010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; ++i){
        int L, R;
        cin >> L >> R;
        ls.push_back({L, i});
        rs.push_back({R, i});
    }
    sort(ls.rbegin(), ls.rend());
    sort(rs.begin(), rs.end());

    int cnt = 0;
    int l = 0, r = 0;
    ll x = 0;
    ll res = 0;
    while(cnt < N){
        cnt++;
        bool flag = false;
        if(cnt % 2){
            while(l < N){
                if(used[ls[l].second]) l++;
                else break;
            }
            if(N == l || ls[l].first < x) flag = true;
            else{
                used[ls[l].second] = true;
                res += ls[l].first - x;
                x = ls[l].first;
            }
        }else{
            while(r < N){
                if(used[rs[r].second]) r++;
                else break;
            }
            if(N == r || rs[r].first > x) flag = true;
            else{
                used[rs[r].second] = true;
                res += x - rs[r].first;
                x = rs[r].first;
            }
        }
        if(flag) break;
    }
    ll ans = res + abs(x);
    memset(used, 0, sizeof(used));
    l = 0, r = 0;
    x = 0;
    res = 0;
    cnt = 1;
    while(cnt <= N){
        cnt++;
        bool flag = false;
        if(cnt % 2){
            while(l < N){
                if(used[ls[l].second]) l++;
                else break;
            }
            if(N == l || ls[l].first < x) flag = true;
            else{
                used[ls[l].second] = true;
                res += ls[l].first - x;
                x = ls[l].first;
            }
        }else{
            while(r < N){
                if(used[rs[r].second]) r++;
                else break;
            }
            if(N == r || rs[r].first > x) flag = true;
            else{
                used[rs[r].second] = true;
                res += x - rs[r].first;
                x = rs[r].first;
            }
        }
        if(flag) break;
    }
    cout << max(res + abs(x), ans) << endl;
    return 0;
}

Measured memory_bytes: 5608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include<climits>
using namespace std;

int main()
{
  while (true)
  {
    long long n, tmp = LLONG_MAX;
    cin >> n;

    if (n == 0)
      exit(0);

    vector<long long> v(n, 0);
    for (int i = 0; i < n; i++)
      cin >> v[i];

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

    for (int i = 1; i < n; i++)
    {
      if (v[i] - v[i - 1] < tmp)
        tmp = v[i] - v[i - 1];
    }

    cout << tmp << endl;
  }

}



Measured memory_bytes: 3076
N = int(input())
A = list(map(int,input().split()))
ans = 0
p = {}
m = {}
for i in range(N):
    if p.get(i+A[i]) is None:
        p[i+A[i]] = 1
    else:
        p[i+A[i]] += 1
for i in range(N):
    if m.get(i-A[i]) is None:
        m[i-A[i]] = 1
    else:
        m[i-A[i]] += 1
for x in range(min(p),max(m)+1):
    if x in p and x in m:
        ans += p[x] * m[x]
print(ans)

Measured memory_bytes: 138868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int n;
	cin >> n;
	vector<int> p(n), q(n);
	rep(i,n) {
		cin >> p[i];
		p[i]--;
		q[p[i]] = i;
	}
	int k = 1, maxk = 1;
	rep(i,n-1) {
		if (q[i] < q[i+1]) {
			k++;
			if (k > maxk) maxk = k;
		} else {
			k = 1;
		}
	}
	cout << n - maxk << endl;
	return 0;
}


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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<string> s(n + 1, "");
	vector<int> p(n + 1, 0);
	vector<int> num(n + 1, 0);
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> p[i];
		num[i] = i + 1;
	}

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (s[i] > s[j]) {
				swap(s[i], s[j]);
				swap(p[i], p[j]);
				swap(num[i], num[j]);
			}
			else if (s[i] == s[j]) {
				if (p[i] < p[j]) {
					swap(s[i], s[j]);
					swap(p[i], p[j]);
					swap(num[i], num[j]);
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << num[i] << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

struct point{
int x,y;
void rd(){x=read(),y=read();}
}a[105],b[105];
int n,pp[105],vis[105],dp[105][105];

int dfs(int p){
for (int i=1;i<=n;++i){
  if (dp[p][i]&&!vis[i]){
    vis[i]=1;
    if (!pp[i]||dfs(pp[i])) return pp[i]=p,1;
    }
  }return 0;
}
int main(){
int i,j;n=read();
for (i=1;i<=n;++i) a[i].rd();
for (i=1;i<=n;++i) b[i].rd();
for (i=1;i<=n;++i){
  for (j=1;j<=n;++j){
    if (a[i].x<b[j].x&&a[i].y<b[j].y) dp[i][j]=1;
    }
  }
int llx=0;
for (i=1;i<=n;++i) memset(vis,0,sizeof vis),llx+=dfs(i);
write(llx);
}

Measured memory_bytes: 256
fn main() {
    let n: usize = read();
    let n = n % 10;
    let hon = [2, 4, 5, 7, 9];
    let pon = [0, 1, 6, 8];
    let bon = [3];
    for &h in hon.iter() {
        if n == h {
            println!("hon");
            exit(0);
        }
    }
    for &h in pon.iter() {
        if n == h {
            println!("pon");
            exit(0);
        }
    }
    for &h in bon.iter() {
        if n == h {
            println!("bon");
            exit(0);
        }
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::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")
}

// =========


Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
#define ttttyyyy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fo(i,n,m) for(int i=n;i<m;i++)
#define pb(x) push_back(x)
#define mk(a,b) make_pair(a,b)
#define all(x) x.begin(),x.end()
#define ft first
#define se second
#define ci(x) int x; cin>>x
int main(){
    ttttyyyy
    ll n;cin>>n;
    cout<<n*6.2831853<<endl;
    return 0;
}



Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1)
#define nui 100
#define INF 100000000000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define F(i,a,n) for(ll i=a;i<n;i++)
#define B(i,a,n) for(ll i=n-1;i>=a;i--)
#define tc int t;cin>>t;while(t--)
#define tcf int t;cin>>t;for(int w=1;w<=t;w++)



using namespace std;


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

ll fermat_inv(ll y) {return binpow(y, mod - 2);}



int main()
{

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

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n, x, t;
    cin >> n >> x >> t;
    ll k = n / x;
    if (n % x)
    {
        k++;
    }
    cout << k*t << "\n";

    return 0;

}

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

int n;
ll a[200];
ll Max=INT_MIN;
bool b[105];

void dfs(int p,ll c){
	if(p==n+1){
		Max=max(Max,c);
		return;
	}
	ll cnt=0;
	for(int i=p;i<=n;i++){
		if(!b[i]&&a[i]>0)cnt+=a[i];
	}
	if(c+cnt<Max)return;
	if(b[p]==1)dfs(p+1,c);
	else{
		map<int,int>d;
		for(int j=p;j<=n;j+=p){
			d[j]=b[j];
			b[j]=1;
		}
		dfs(p+1,c);
		for(int j=p;j<=n;j+=p){
			b[j]=d[j];
		}
		dfs(p+1,c+a[p]);
	}
}
int main(){
	/*for(int i=1;i<=100;i++){
		int cnt=0;
		for(int j=1;j<=100;j++){
			if(i%j==0)cnt++;
		}
		cout<<i<<' '<<cnt<<endl;
	}*/
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	dfs(1,0);
	cout<<Max<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> P(M), Y(M);
  vector<pair<ll, ll>> PY(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i] >> Y[i];
    PY[i] = {P[i], Y[i]};
  }
  sort(PY.begin(), PY.end());
  vector<map<ll, ll>> m(100005);
  int p_prev = -1, p, y = 1;
  int cnt = 1;
  for (auto py : PY) {
    p = py.first;
    if (p != p_prev) {
      p_prev = p;
      cnt = 1;
    }
    y = py.second;
    m[p][y] = cnt;
    cnt++;
  }
  for (int i = 0; i < M; i++) {
    printf("%06d%06d\n", P[i], m[P[i]][Y[i]]);
  }
  return 0;
}

Measured memory_bytes: 17228
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
const int inf = 1e18;

int m, tree[400400], tree2[400400];
set<pii> s;

void update(int x, int val, int *T) {
    T[x+m-1] = val;
    for (x=(x+m-1)/2; x>0; x/=2) T[x] = min(T[x*2], T[x*2+1]);
}

int solve(int le, int ri, int *T) {
    int ret = inf;
    for (le+=m-1, ri+=m-1; le<=ri; le/=2, ri/=2) {
        if (le&1) ret = min(ret, T[le++]);
        if (~ri&1) ret = min(ret, T[ri--]);
    }
    return ret;
}


signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>>n>>m;
    for (int i=1; i<=m; i++) {
        s.insert({i, 0});
        tree2[m+i-1] = -i;
    }
    tree2[2*m] = inf;
    for (int i=m-1; i>0; i--) {
        tree2[i] = min(tree2[i*2], tree2[i*2+1]);
    }
    for (int i=1; i<=n; i++) {
        int a,b; cin>>a>>b;
        if (solve(1, m, tree) >= 1e9) {
            cout << "-1\n";
            continue;
        }
        int tmp = solve(1, b+1, tree2) + b+1;
        auto it = s.lower_bound({a, 0});
        while (it != s.end()) {
            if (it->fi > b+1) break;
            update(it->fi, inf, tree);
            update(it->fi, inf, tree2);
            it = s.erase(it);
        }
        if (b < m) {
            s.insert({b+1, tmp});
            update(b+1, tmp, tree);
            update(b+1, tmp-b-1, tree2);
        }
        int res = solve(1, m, tree);
        cout << (res >= 1e9 ? -1 : res+i) << '\n';
    }
    return 0;
}

Measured memory_bytes: 22404
n=int(input())
m=list(map(int,input().split()))
h=m[::-1]
for i in range(1,n):
    if h[i]>h[i-1]+1:
        print('No')
        exit()
    elif h[i]==h[i-1]+1:
        h[i]-=1
print('Yes')

Measured memory_bytes: 20700
import java.util.Scanner;

class Main {

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

		int n, b, f, r, v;
		
		n = scan.nextInt();
		
		int a[][][];
		a = new int[10][3][4];
		
		for(int i = 0;i < n;i++){
			b = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			v = scan.nextInt();
			if(r <= 10 && f <= 3 && b <= 4){
				a[r-1][f-1][b-1] += v;
				if(a[r-1][f-1][b-1] > 9){
					a[r-1][f-1][b-1] = 9;
				}
				if(a[r-1][f-1][b-1] < 0){
					a[r-1][f-1][b-1] = 0;
				}
			}
		}
		
		for(int j = 0; j < 4; j++){
			for(int k = 0; k < 3; k++){
				for(int l = 0; l < 10; l++){
					System.out.print(" " + a[l][k][j]);
				}
				System.out.println();
			}
			if(j != 3){
				System.out.println("####################");
			}
		}
	}	
}

Measured memory_bytes: 29780
'use strict';
(function(stdin) { 
  var inputs = stdin.toString();
  var params = inputs.split('\n')[0].split(' ').map(Number);
  (function(a,b,c) {
    if(a<b && b<c){
      console.log('Yes');
    }else{
      console.log('No');
    }
    //????????????????????????
 
  }(params[0],params[1],params[2])); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7380
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second

signed main(){
	int n,s=0;
	cin>>n;
	int a[n];
	r(i,n)cin>>a[i];
	for(int i=1;i<n-1;i++){
		if(a[i-1]<a[i]&&a[i]<a[i+1])s++;
		if(a[i+1]<a[i]&&a[i]<a[i-1])s++;
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
 
  int d1[6],d2[6],i,j,blank;
 
  for(i = 0; i < 6; i++){
 
    scanf("%d",&d1[i]);
     
  }
   
  for(i = 0; i < 6; i++){
     
    scanf("%d",&d2[i]);
     
  }
 
  for(i = 0; d1[1] != d2[1] && i < 3; i++){
     
    //3S
    blank=d2[0];
    d2[0]=d2[4];
    d2[4]=d2[5];
    d2[5]=d2[1];
    d2[1]=blank;
     
  }
   
  if(d1[1] != d2[1]){
     
    //1E
    blank=d2[0];
    d2[0]=d2[3];
    d2[3]=d2[5];
    d2[5]=d2[2];
    d2[2]=blank;
 
    for(i = 0; d1[1] != d2[1] && i < 3; i++){
 
      //3S
      blank=d2[0];
      d2[0]=d2[4];
      d2[4]=d2[5];
      d2[5]=d2[1];
      d2[1]=blank;
 
    }
 
  }
 
  if(d1[1] != d2[1]){
 
    printf("No\n");
 
    return 0;
 
  }
   
  for(i = 0; d1[0] != d2[0]; i++){
     
    //3E
    blank=d2[0];
    d2[0]=d2[3];
    d2[3]=d2[5];
    d2[5]=d2[2];
    d2[2]=blank;
 
  }
 
  if(d1[0] != d2[0]){
     
    printf("No\n");
     
    return 0;
     
  }
 
  if(d1[2] == d2[2] && d1[3] == d2[3] && d1[4] == d2[4] && d1[5] == d2[5]){
 
    printf("Yes\n");
 
  } else {
 
    printf("No\n");
 
  }
 
  return 0;
 
}



Measured memory_bytes: 2100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] h = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int max = 0;
            int cnt = 0;
            for (int i = 0; i < n - 1; i++)
            {
                if (h[i] >= h[i + 1])
                {
                    cnt++;
                }
                else
                {
                    if (max < cnt)
                    {
                        max = cnt;
                    }
                    cnt = 0;
                    if (max >= (n - i-2)) break;
                }
            }
            if (max < cnt)
            {
                max = cnt;
            }
            Console.WriteLine(max);

        }
    }
}

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

using namespace std;

int main(){

unsigned long long int n,a,b,k,p ;

    cin>> n>> a>> b;

    if(a == 0)
        cout << "0\n";
    else if(n < a+b && n<a)
        cout << n<<"\n";
    else if(n < a+b && n>=a)
        cout << a<<"\n";
    else{
        
        p =n%(a+b);
        if(n%(a+b) >= a) p = a;
        
        cout << (n/(a+b))*a + p<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
n,k,q=map(int,input().split())
a=[int(input())for _ in range(q)]

w=k-q
e=abs(w)
b=[w]*n

if w>0:
  for _ in range(n):
    print("Yes")
  exit()

for i in a:
  b[i-1]+=1

for j in range(n):
  if b[j]>0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 9984
#include<iostream>

using namespace std;

int main(){
  int n;
  int a;

  cin >> n;
  
  int max=-1000100;
  int min=1000100;
  long long sum=0;
  for(int i=0;i<n;i++){
    cin >> a;
    if (a > max)
      max = a;
    if(a < min)
      min = a;
    sum+=a;
  }
  cout << min << " " << max << " " << sum << endl; 
}
  

Measured memory_bytes: 3088
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

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

    string t1 = s.substr(0, n / 2);
    string t2 = s.substr(n / 2, n / 2);

    bool valid = true;
    if(t1 != t2 || n % 2) valid = false;

    cout << (valid ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;
    cin>>n;

    vll a1(n);
    vll a2(n);
    rep(i,n)cin>>a1[i];
    rep(i,n)cin>>a2[i];

    ll ans=0;
    rep(i,n){
        ll tmp=0;
        for(int k=0;k<=i;k++)tmp+=a1[k];
        for(int j=i;j<n;j++)tmp+=a2[j];
        chmax(ans,tmp);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3620
import itertools

flag=True
while flag == True:
    N,X = map(int,input().split())
    if N==0 and X==0:
        exit()

    seq = (i for i in range(1,N+1))
    ptr = list(itertools.combinations(seq,3)) # 組み合わせ列挙
    #print(ptr)

    ans=0
    for i in ptr:
        if sum(i) == X:
            ans+=1

    print(ans)


Measured memory_bytes: 31424
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            string[] s1 = Console.ReadLine().Split(' ');
            int a = int.Parse(s1[0]), b = int.Parse(s1[1]);
            if (a <= 5) b = 0;
            else if (a <= 12) b /= 2;


            Console.WriteLine(b);
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

class Main {
    static Scanner scanner = new Scanner();

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int m = (n - 1) * (n - 2) / 2;
        if (m < k) {
            System.out.println(-1);
        } else {
            System.out.println(n + m - k - 1);
            for (int i = 1; i < n; i++) {
                System.out.println(n + " " + i);
            }
            for (int i = 1; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (m-- == k) {
                        return;
                    }
                    System.out.println(i + " " + j);
                }
            }
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return tokenizer.nextToken();
        }

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

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

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

Measured memory_bytes: 24276
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n;
		long num;
		String str;
		char[] ch;
		int ans; 
		while(true){
			n = scan.nextInt();
			if(n == 0)break;
			
			ans = 0;
			num = n;
			
			while(num >= 5){
				ans += num / 5;
				num /= 5;
			}
			
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 26048
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
typedef long long ll;
typedef double db;
#define lp1(i, n)  for(int i=0; i<(int)(n); ++i)
#define lp2(i, n)  for(int i=0; i<(int)(n-1); ++i)
#define lp3(j, n)  for(int j=1; j<=(int)(n); ++j)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];
int main(){

    int n,ans=0,a1[N],a2[N];
    cin>>n;
    lp1(i,n){
     cin>>a1[i];
     a2[i]=a1[i];
     }

     sort(a2,a2+n);
    lp1(i,n)
    {
        if(a1[i]!=a2[i])
          ans++;
    }

    if(ans==2  || ans==0)
    cout<<"YES";
    else
        cout<<"NO";


go;
}



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

bool isPrime(int a){
  for(int i=2;i*i<=a;i++)if(a%i==0)return 0;
  return 1;
}

int main(){
  int n;
  cin>>n;
  int ans=0;
  while(n--){
    int num;
    cin>>num;
    ans+=isPrime(num);
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
struct edge{int from,to,cost;};
 
int n,m,s;
vector<edge>v;
int d[100009];
 
void Bellman(){
    fill(d,d+100009,1e9);
    d[s]=0;
    for(int i=0;i<n;i++){
        int update=0;
        for(int j=0;j<m;j++){
            edge e=v[j];
            if(d[e.from]!=1e9&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                update=1;
                if(i==n-1){
                    cout<<"NEGATIVE CYCLE"<<endl;
                    return;
                }
            }
        }
        if(!update)break;
    }
    for(int i=0;i<n;i++){
        if(d[i]==1e9)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
}
int main(){
    cin>>n>>m>>s;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        v.push_back({a,b,c});
    }
    Bellman();
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i=0; i<n; i++)
        cin >> a[i];
    vector<int> b(m);
    for (int i=0; i<m; i++)
        cin >> b[i];

    vector<int> c = convolution(a, b);
    for (int x : c)
        cout << x << " ";
    cout << "\n";

    return 0;
}


Measured memory_bytes: 19084
#include <iostream>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

int N,d;

int main() {
    scanf("%d",&N);
    int lo=1,hi=10000;
    while (lo<hi) {
        int mid=(lo+hi)>>1;
        if (mid*(mid+1)<2*N) {
            lo=mid+1;
        } else {
            hi=mid;
        }
    }
    d=lo*(lo+1)/2-N;
    for (int i=1;i<=lo;i++) {
        if (i!=d) printf("%d ",i);
    }
    printf("\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, a, lt=1, md, rt=3, ans=1e18, s[200005];
ll f(ll p, ll q, ll r, ll s) {
	ll mx = max(max(p,q), max(r,s));
	ll mn = min(min(p,q), min(r,s));
	return mx-mn;
}

int main() {
	cin>>n;
	for (ll i=1; i<=n; i++) scanf("%lld", &a), s[i] = s[i-1] + a;
	for (md=2; md<=n-2; md++) {
		while (abs(s[md] - 2*s[lt+1]) < abs(s[md] - 2*s[lt])) lt++;
		while (abs(s[n] - 2*s[rt+1] + s[md]) < abs(s[n] - 2*s[rt] + s[md])) rt++;
		ans = min(ans, f(s[lt], s[md]-s[lt], s[rt]-s[md], s[n]-s[rt]));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
import heapq
n, m = map(int, input().split())

lis = []
for i in range(n):
  a, b = map(int, input().split())
  heapq.heappush(lis, [-a,-b])

s = []
while lis:
  x, y = heapq.heappop(lis)
  r = m-len(s)
  if -x > r:
    heapq.heappush(s, -y)
    heapq.heappop(s)
  else:
    heapq.heappush(s, -y)
print(sum(s))

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

int factorial(int x){
    int num;
    for(int i=1; i<=x; i++){
        num*=i;
    }
    return num;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> p(n),q(n);
    int i,j;
    for(i=0; i<n; i++){
        cin >> p.at(i);
    }
    for(i=0; i<n; i++){
        cin >> q.at(i);
    }
    for(i=0; i<n; i++){
        a.at(i)=i+1;
    }

    map<vector<int>, int> mp;
    i=0;
    do{
        mp[a]=i;
        i++;
    }while(next_permutation(a.begin(), a.end()));
    int ans=abs(mp[p]-mp[q]);
    cout << ans << endl;
}

Measured memory_bytes: 8652
n=int(input())
s=[input() for _ in range(n)]
cnt=0
cnt_xa=0
cnt_bx=0
cnt_ba=0
for i in range(n):
    cnt += s[i].count('AB')
    if s[i][-1] == 'A' and s[i][0] != 'B':
        cnt_xa += 1
    elif s[i][0] == 'B' and s[i][-1] != 'A':
        cnt_bx += 1
    elif s[i][-1] == 'A' and s[i][0] == 'B':
        cnt_ba += 1
    else: continue
if cnt_xa==0:
    if cnt_ba>0:
        cnt_xa=1
        cnt_ba-=1
if cnt_bx==0:
    if cnt_ba>0:
        cnt_bx=1
        cnt_ba-=1
cnt += cnt_ba
cnt += min(cnt_xa,cnt_bx)
print(cnt)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define scs(ch) scanf("%s", ch)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

ll ara[1000];


int main()
{
    ll n,m,x,y,z;
    scl(n);
    x=n*360;
    x/=__gcd(n,360ll);
    cout<<x/n<<endl;

    return 0;
}





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

  int N , M , O ;
  cin >> N >> M >> O ;
  if( N == 1 ) cout << "Hello World" << endl;
  else cout << M + O << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text.RegularExpressions;
class Test{
 public static void Main(){
   var NK = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToList();
   var N = NK[0];
   var K = NK[1];
   var p = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToList();
   p.Sort();
   var ans =0;
   for(int i = 0; i<K; i++){
     ans += p[i];
   }
   Console.Write(ans);
 }
}

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

int main(){
  int n;
  cin >> n;
  bool res = false;
  for(int i=1; i<10; i++){
    if(n%i == 0){
      if(n/i < 10){
        cout << "Yes" << endl;
        res = true;
        break;
      }
    }
  }
  if(!res) cout << "No" << endl;
}

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

int main()
{

    int n,a,b;
    cin>>n>>a>>b;

    if(n==2)
        cout<<"Borys"<<endl;
    else{
        
        int diff=abs(a-b)+1;

        if(diff%2==0)
            cout<<"Borys"<<endl;
        else
            cout<<"Alice"<<endl;
        }

    return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
 
int main()
{
    string s, t;
    cin >> s >> t;

    const int n = s.length();

    vector<int> sc(26, 0);
    vector<int> tc(26, 0);

    for (int i = 0; i < n; i++) {
        sc[s[i] - 'a']++;
        tc[t[i] - 'a']++;
    }

    sort(sc.begin(), sc.end());
    sort(tc.begin(), tc.end());

    bool flag = true;
    for (int i = 0; i < 26; i++) {
        if (sc[i] != tc[i]) flag = false;
    }

    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;

#define ll  long long
#define ld long double
#define f first
#define s second
#define matrix vector<vector<char>>
#define zero(n,m) matrix(n , vector<char>(m,'0'))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<int,int>
#define point complex<ld>
#define angle(a) (atan2((a).imag() , (a).real() ))
#define pi acos(-1)
#define X real()
#define Y imag()
const int N = 2e5+5;

ll n,x,m,xx;
ll vis[N],pre[N];

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

    cin >> n >> x >> m;
    xx=x;

    ll sum = 0;
    for(int i=1; i<=min(n , (ll)200000); i++)
    {
        if (x==0)
        {
            return cout << sum << '\n' , 0;
        }
        sum += x;
        x = (x*x)%m;
    }

    x=xx;
    ll tmp=0 , len=0 , ans=0 , numOfCy;
    sum = 0;
    for(int i=1; i<=min(n,(ll)200000); i++)
    {
        if (vis[x])
        {
            pre[i] = (pre[i-1]+x);
            tmp = pre[i] - pre[vis[x]];
            len = i - vis[x]; //len of cycle

            //ans without cycles
            ans = pre[vis[x]-1]; //not cycle

            //ans of cycles
            n -= (vis[x]-1);
            numOfCy = n / len;
            ans += tmp*numOfCy;
            n -= len*numOfCy;

            for(int j=1; j<=n; j++)
            {
                ans += x;
                x = (x*x)%m;
            }
            return cout << ans << '\n' , 0;
        }

        sum += x;
        vis[x] = i;
        pre[i] = (pre[i-1]+x);

        x = (x*x)%m; //nxt x
    }

    cout << sum << '\n';

    return 0;
}

Measured memory_bytes: 4760
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  ll N,x;
  cin>>N>>x;
  vector<ll> L(N);
  for(int i=0;i<N;i++) cin>>L[i];

  ll now=0;
  int ans=1;
  for(int i=0;i<N;i++){
    now=now+L[i];
    if(now<=x) ans++;
  }

  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;
typedef long long ll;
ll mod =1e9+7;
 
int main(){
    int n;cin>>n;
    vector<vector<int>> v;
    int sum=0;

    for(int i=0;i<n;i++){
        int a,b;cin>>a>>b;
        //v[i].push_back(a);
        //v[i].push_back(b);
        if(a==b) sum+=1;
        else sum=0;
        if(sum==3) break;
    }

    if(sum==3)cout<<"Yes";
    else cout<< "No";

}

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

int main() {
  int n;
  cin >> n;
  
  int cnt = 0;
  
  for (int i=0; i<=25; i++){
    for (int j=0; j<29; j++){
      if (n == i*4+j*7) cnt++;
    }
  }
  
  if (cnt == 0) cout << "No" << endl;
  else cout << "Yes" << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	private int n;
	private int[][] map;
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		while (sc.hasNextLine() == true) {
			n = Integer.parseInt(sc.nextLine());
			if (n == 0) break;
	
			map = new int[n][n];
			for (int i = 0; i < n; i++) {
				String line = sc.nextLine();
				
				int width = 0;
				for (int j = 0; j < n; j++) {
					int index = n - j - 1;
					
					if (line.charAt(index) == '*') width = 0;
					else width++;
					
					map[i][index] = width;
				}
			}
			
			int max = 0;
			for (int j = 0; j < n; j++) {
				boolean flag = true;
				while (flag == true) {
					flag = false;

					int height = 0;
					for (int i = 0; i < n; i++) {
						if (map[i][j] > max) {
							height++;
							
							if (height == (max + 1)) {
								max++;
								flag = true;
								break;
							}
						} else {
							height = 0;
						}
					}
				}
			}
			System.out.println(max);
		}
	}
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)

#define X() real()
#define Y() imag()
#define x(p) (p).X()
#define y(p) (p).Y()
#define curr(P, i) P[i];
#define next(P, i) P[(i+1)%P.size()]
#define prev(P, i) P[(i-1+P.size())%P.size()]

typedef double D;
typedef complex<D> P;

namespace std{
  bool operator <(const P& a, const P& b) {
    return x(a) != x(b) ? x(a) < x(b) : y(a) < y(b);
  }
}

struct L : public vector<P> {
  L(){}
  L(const P& a, const P& b) {
    push_back(a);
    push_back(b);
  }
};

D dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
D cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if(cross(b, c) > 0) return +1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

const D EPS = 1e-9;

bool interSS(const L& s, const L& t) {
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
    ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}

P crossP(const L& a, const L& b) {
  D A = cross(a[1] - a[0], b[1] - b[0]);
  D B = cross(a[1] - a[0], a[1] - b[0]);
  if(abs(A) < EPS && abs(B) < EPS) return b[0];
  return b[0]+ B / A * (b[1] - b[0]);
}

P makeP(D arg, D r = 1.0) {
  return r * P{cos(arg), sin(arg)};
}
P rotP(const P& a, D arg) {
  return a * makeP(arg);
}
D getArgP(const P& a) {
  return atan2(y(a), x(a));
}

struct M{
  P p;
  int a, b;
  bool operator < (const M& m) const {
    return p != m.p ? p < m.p :(a != m.a ? a < m.a : b < m.b);
  }
};

int calc(int idx, int isUp, const vector<M>& ms) {
  int n = ms.size();
  if(idx == n) return 0;
  int f = (ms[idx].a ^ ms[idx].b) == 0;
  return calc(idx+1, f, ms) + (f == isUp ? 0 : 1);
}

void printP(const P& p) {
  cout << x(p) << " " << y(p);
}
void printL(const L& l) {
  printP(l[0]);
  cout << " ";
  printP(l[1]);
  cout << endl;
}

int main() {
  int datSet;
  cin >> datSet;
  while(datSet--) {
    L l;
    {
      D xa, ya, xb, yb;
      cin >> xa >> ya >> xb >> yb;
      l = L(P{xa, ya}, P{xb, yb});
      //if(l[1] < l[0]) swap(l[0], l[1]);
    }
    int n;
    cin >> n;
    vector<L> ls(n);
    vector<int> a(n), b(n);
    rep(i, n) {
      D xa, ya, xb, yb;
      cin >> xa >> ya >> xb >> yb >> a[i] >> b[i];
      ls[i] = L(P{xa, ya}, P{xb, yb});
    }
    vector<M> ms;
    rep(i, n) {
      if(interSS(l, ls[i])) {
	// cout << "intersect : " << i << endl;
	ms.push_back(M{crossP(l, ls[i]), a[i], b[i]});
      }
    }
    sort(ms.begin(), ms.end());
    cout << min(calc(0, 0, ms), calc(0, 1, ms)) << endl;
    // cout << ms.size() << endl; 
    //printL(l);
    //rep(i, n) printL(ls[i]);
  }
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(std::string S)
{
    if (S[0] == 'S')
        cout << "Cloudy" << endl;
    else if (S[0] == 'C')
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
}

int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 55;

ll A[N], B[N], C[N], D[N];
ll n,m,q;
ll ans;
ll p;

void dfs(ll f, ll g, V v){
	v.pb(f);
	if(g == n){
		ll cnt = 0;
		rep(i,0,q){
			if(v[B[i]-1] - v[A[i]-1] == C[i])
				cnt += D[i];
		}
		ans = max(ans, cnt);
		return;
	}
	rep(i,f,m+1){
		dfs(i,g+1,v);
	}
	return;
}

void solve(){
	cin>>n>>m>>q;
	rep(i,0,q)	cin>>A[i]>>B[i]>>C[i]>>D[i];
	rep(i,1,m+1){
		dfs(i, 1, {});
	}
	cout<<ans<<endl;
	return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll no;
	// cin>>no;
	no = 1;
	while(no--){
		solve();
	}
    return 0;
}

Measured memory_bytes: 3660
/***
 ** "Learn to forgive the ones who deserve it?and?the ones who don?t."
 **
***/

/**
  *  Author: dhruv_gheewala
  *  Problem: __________
  *  Date:   24.07.2020
  *  Time:   11:24:46
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;
    
    #define fundri 108
    #define debug(...) 1729
#endif

#define int int64_t
typedef pair<int, int> pii;
typedef vector<int> vi;

const bool testcases = false;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(), s.end()

// if vector isn't soted then it will remove consecutive same elements
#define make_unique(vec) vec.erase(unique(all(vec)), vec.end())
#define test int TC = 1;if(testcases)cin >> TC;for(int tc = 1 ; tc <= TC ; tc++)solve(), fundri
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

int seed; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = INT_MAX) {return uniform_int_distribution<int>(l, r)(rng);}

inline bool in_range(int a, int l, int r) {return (a >= l && a <= r);}
template<typename H, typename ...T>void inp(H &head) {cin >> head;}
template<typename H, typename ...T>void inp(H &head, T &...tail) {cin >> head;inp(tail...);}
template<typename T>bool isPrime(T n) {for(T i = 2; i * i <= n; i++)if(n % i == 0)return false; return n >= 2;}
template<typename T>inline istream &operator >>(istream &in, vector<T> &a) {for(T &x : a)in >> x; return in;}
template<typename T, typename U>inline istream &operator >>(istream &in, pair<T, U> &a) {in >> a.ff >> a.ss; return in;}

void solve();
void fast_io();

int32_t main(int32_t argc, char **argv)
{
    fast_io();
    test;
    return 0;
}

void solve()
{
    int n, t, ans;
  	t = 1;
    // cin >> t;
    ans = INT_MIN;

    for(int i = 0 ; i < t ; i++) {
        cin >> n;
        vi a(n);
        cin >> a;
        sort_by(a, lhs > rhs);

        int cnt = 1;
        int sum = (a.size() == 1 ? 0 : a[0]);
        
        for(int i = 1 ; i < n ; i++) {
            if(cnt == n - 1)
                break;
            sum += a[i];
            cnt++;
            if(cnt == n - 1)
                break;
            sum += a[i];
            cnt++;
        }
        ans = max({ans, sum});
    }
    cout << ans << endl;
}

void fast_io()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef DHRUV_GHEEWALA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
int n;
vector<vector<int>> v;
vector<string> w;
void foo(int a,int b){
    cout<<string(a,'.')<<w[b]<<endl;
    for(int x:v[b]){
        foo(a+1,x);
    }
}
int main(){
    cin>>n;
    v.resize(n);
    w.resize(n);
    rep(i,n){
        int t;
        cin>>t;
        cin>>w[i];
        if(t==0) continue;
        v[t-1].push_back(i);
    }
    foo(0,0);
}

Measured memory_bytes: 1444
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"

using namespace std;

#include <cstdio>
#include <cstring>


int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24;

}

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

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;

  if (right > left) {
    cout << "Right" << endl;
  } else if (right < left) {
    cout << "Left" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

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

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

		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next()) - i - 1;
		}

		Arrays.sort(a);
		long ans = 0;
		int p = 0;

		if (n % 2 == 0) {
			p = (a[n / 2 - 1] + a[n / 2]) / 2;
		} else {
			p = a[n / 2];
		}

		for (int i = 0; i < n; i++) {
			ans += Math.abs(a[i] - p);
//			System.out.println(a[i] + " " + p + " " + ans);
		}

		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 51180
#include <stdio.h>
int main(){
	int a[3];
	int	tmp, i, j;
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	for (i = 0; i < 2; i++)
	{
		for (j = i + 1; j < 3; j++)
		{
			if (a[i] > a[j])
			{
				tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	printf("%d %d %d\n", a[0], a[1], a[2]);
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, M;
  cin>>N>>M;
  vector<vector<pair<int, int> > > edge(N);
  int a, b, c;
  for(int i=0;i<M;++i) {
    cin>>a>>b>>c;
    a--;
    b--;
    edge[a].push_back(mp(b, c));
    edge[b].push_back(mp(a, c));
  }
  int dist[N][N];
  for(int i=0;i<N;++i) {
    for(int j=0;j<N;++j) {
      if(i==j) dist[i][j] = 0;
      else dist[i][j] = inf;
    }
  }
  for(int i=0;i<N;++i) {
    for(int j=0;j<edge[i].size();++j) {
      dist[i][edge[i][j].fi] = min(dist[i][edge[i][j].fi], edge[i][j].se);
    }
  }
  for(int k=0;k<N;++k) {
    for(int i=0;i<N;++i) {
      for(int j=0;j<N;++j) {
        dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
      }
    }
  }
  int ans = 0;
  for(int i=0;i<N;++i) {
    for(int j=0;j<edge[i].size();++j) {
      if(dist[i][edge[i][j].fi]<edge[i][j].se) ans++;
    }
  }
  cout<<ans/2<<endl;
}



Measured memory_bytes: 3648
# -*- coding: utf-8 -*-
S = str(input())

acgt_list = ["A", "C", "G", "T"]

count = 0
count_list = []
count_list.append(0)
list_S = list(S)
length = len(list_S)

for i in range(0, length):
  if list_S[i] in acgt_list:
    for j in range(i, length):
      if list_S[j] in acgt_list:
        count += 1
      else:
        count_list.append(count)
        count = 0
        break
      if j == length -1:
        count_list.append(count)
        count = 0
print(max(count_list))

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#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 (ll i = m; i < n; i++)

int dp[105][10005]{};

int main() {
    int n,W,v[105],w[105];
    cin >> n >> W;
    REP(i,n)cin >> v[i] >> w[i];
    REP(i,n){
        REP(j,W+1){
            if(j>=w[i])dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}



Measured memory_bytes: 7000
#include<stdio.h>
#include<string.h>
	
int main(void){
	char str[101], p[101];
	int slen, plen, last, index, i, j, k, flag = 0;
	
	scanf("%s\n", str);
	scanf("%s\n", p);
	slen = strlen(str);
	plen = strlen(p);
	last = plen-1;
	for(i = 0; i < slen; i++){
		if(str[i] == p[0]){
			index = i-1;
			for(j = 0; j < plen; j++){
				index++;
				if(index == slen){
					index = 0;
				}
				if(str[index] != p[j]){
					break;
				}
				if(j == last){
					printf("Yes\n");
					goto EXIT;
				}
			}
		}
	}
	printf("No\n");				
	
	EXIT:			
	return 0;
}


Measured memory_bytes: 2140