akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int ans,dp[100003];
int main(void){
 int n;
 cin>>n;
 for(int i=0;i<n;i++){
     int x;
     cin>>x;
     dp[x]++;
     dp[x+1]++;
     dp[x+2]++;
     
 }
    for(int i=0;i<100003;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int Alice=0;
  int Bob=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      Alice+=a[i];
    }else{
      Bob+=a[i];
    }
  }
  cout<<Alice-Bob<<endl;
}

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

typedef long long ll;

bool isPrime(int n){
    for(int i=2;i<sqrt(n);i++){
        if(n%i==0) return false;
    }
    return true;
}

int main(){
    int n; cin >> n;
    while(true){
        if(isPrime(n)) break;
        n++;
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
int main() {
	int n, x;
	cin >> n >> x;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	int cnt = 0;
	int i = 0;
	while (x >= a[i]) {
		x -= a[i];
		cnt++;
		i++;
      	if(i==n){break;}
	}
  	if(x>0&&i==n)cnt--;
  	if(cnt<0)cnt=0;
	cout << cnt << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

    public static void main(String[] argv) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int v = Integer.parseInt(str[0]);
        int e = Integer.parseInt(str[1]);

        long[][] map = new long[v][v];
        for(long[] obj: map)
            Arrays.fill(obj, Long.MAX_VALUE/2);
        for(int i=0; i<v; i++)
            map[i][i] = 0;

        for(int j=0; j<e; j++){
            str = br.readLine().split(" ");
            int from = Integer.parseInt(str[0]);
            int to = Integer.parseInt(str[1]);
            int cost = Integer.parseInt(str[2]);

            map[from][to] = cost;
        }
        for (int k = 0; k < v; k++) {
            for(int i=0; i<v; i++) {
                for (int j = 0; j < v; j++) {
                    if (map[i][j] > map[i][k] + map[k][j])
                        map[i][j] = map[i][k] + map[k][j];
                }
            }
        }

        for (int i=0; i<v; i++) {
            if (map[i][i] < 0){
                System.out.println("NEGATIVE CYCLE");
                System.exit(0);
            }
        }

        for(int i=0; i<v; i++) {

            String[] out = new String[v];
            for (int j = 0; j < v; j++) {
                if (map[i][j] > Long.MAX_VALUE/3) {
                    out[j] = "INF";
                } else {
                    out[j] = String.valueOf(map[i][j]);
                }
            }
            System.out.println(String.join(" ", out));
        }

    }
}

Measured memory_bytes: 36348
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

pii A[MAXN];
pii B[MAXN];
int permu[MAXN];
bool vis[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>A[i].f;
        A[i].s = i;
    }

    for(int i=0;i<n;i++){
        cin>>B[i].f;
        B[i].s = i;
    }

    sort(A,A+n);
    sort(B,B+n);

    for(int i=0;i<n;i++){
        if(B[i].f<A[i].f){
            cout<<"No\n";
            return 0;
        }
    }

    bool judge = true;

    for(int i=1;i<n;i++){
        judge&=(A[i].f!=A[i-1].f);
        judge&=(B[i].f!=B[i-1].f);
    }

    for(int i=1;i<n;i++){
        judge&=(A[i].f>B[i-1].f);
    }

    if(!judge){
        cout<<"Yes\n";
        return 0;
    }

    for(int i=0;i<n;i++)
        permu[B[i].s] = A[i].s;

    cur = 0;

    while(!vis[cur]){
        vis[cur] = true;
        cur = permu[cur];
    }

    for(int i=0;i<n;i++)
        if(vis[i])cnt++;

    if(cnt==n)cout<<"No\n";
    else cout<<"Yes\n";

    return 0;
}


Measured memory_bytes: 3584
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String X = sc.next();
    String Y = sc.next();
    char[]a = X.toCharArray();
    char[]b = Y.toCharArray();
    

    if(a[0]-55 == b[0]-55){
	System.out.println("=");
    }else if(a[0]-55 > b[0]-55){
	System.out.println(">"); 
    }else{
    System.out.println("<");     
    }
    }
}

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

int n;
long long a[200010];

int main(){
  cin >> n;
  cin >> a[0];
  long long tmp;
  for(int i = 1; i < n; i++){
    cin >> tmp;
    a[i] = tmp + a[i-1];
  }
  long long ans = 100100100100100100;
  for(int i = 0; i < n-1; i++)
    ans = min(ans, abs(2*a[i] - a[n-1]));
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  cin>>n;
  
  int res = 0;
  for(int i=1;i<=n;i++){
    if (i*i <= n){
      res = i*i;
    }
    else{
      break;
    }
  }
  cout << res << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

const int MOD = 1e9 + 7;

ll conv(ll x) {
    return (x + MOD) % MOD;
}

int main() {
    int n, m;
    cin >> n >> m;

    queue<ll> que;
    for (int i = 0; i < m - 1; i++)que.push(0);
    que.push(1);
    ll sum = 1;
    for (int i = 1; i <= n; i++) {
        que.push(sum);
        sum += que.back() - que.front();
        sum = conv(sum);
        que.pop();
    }

    ll all = 1;
    for (int i = 0; i < n; i++)all = conv(all * 2);

    cout << conv(all - sum) << endl;
    return 0;

}


Measured memory_bytes: 3676
N=int(input())
X = list(map(int,input().split()))
Y=set(X)
Z=list(Y)
NN=len(Z)
AA=0
for i in range(NN-2):
  for ii in range(NN-2-i):
    for iii in range(NN-2-i-ii):
      A=[Z[i], Z[ii+i+1], Z[iii+ii+i+2]]
      if max(A)<Z[i]+Z[ii+i+1]+Z[iii+ii+i+2]-max(A):
        AA+=X.count(Z[i])*X.count(Z[ii+i+1])*X.count(Z[iii+ii+i+2])
if N<3:
  print(0)
else:
  print(AA)

Measured memory_bytes: 9228
def bfs(maze):
    d = [[0] * 65 for i in range(65)]
    d[1][1] = 1
    que = [(1, 1)]
    while que:
        x, y = que.pop(0)
        if x == 2 * w - 1 and y == 2 * h - 1:
            return d[y][x]
        for dx, dy in ((0, 1), (-1, 0), (0, -1), (1, 0)):
            mx, my = x + dx, y + dy
            nx, ny = mx + dx, my + dy
            if nx < 0 and w < nx and ny < 0 and h < ny:
                continue
            if maze[my][mx] == 0 and d[ny][nx] == 0:
                que.append((nx, ny))
                d[ny][nx] = d[y][x] + 1
    return 0

while True:
    w, h = map(int, input().split())
    maze = [[0] * 65 for i in range(65)]
    if w == h == 0:
        break
    for x in range(w * 2 + 1):
        maze[0][x] = maze[h * 2][x] = 1
    for y in range(h * 2 + 1):
        maze[y][0] = maze[y][w * 2] = 1

    for y in range(1, h * 2):
        a = [int(i) for i in input().split()]
        if y % 2 == 1:
            for x in range(w - 1):
                maze[y][2 * x + 2] = a[x]
        else:
            for x in range(w):
                maze[y][2 * x + 1] = a[x]

    print(bfs(maze))

Measured memory_bytes: 7944
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    lint N,K;
    cin >> N >> K;
    lint A[N];
    rep(i,N) cin >> A[i];
    bool dp[K+1]={};
    for(int i=0;i<=K;i++){
        bool check=false;
        rep(j,N) if(i-A[j]>=0) if(!dp[i-A[j]]) check=true;
        dp[i]=check;
    }
    cout << (dp[K]?"First":"Second") << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

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

using ll = long long;
using R = long double;

int main(void){
	ll n,m,a,b,p,q;
	cin >> n >> m >> a >> b >> p >> q;

	if(a == 1 and b == 1){
		ll ticket = p + q;
		const ll used = min(n,m/ticket);
		ll ans = abs(m - ticket * used);
		if(used+1<=n) ans = min(ans,abs(m - ticket * (used+1)));
		cout << ans << endl;
		return 0;
	}

	vector<ll> ticket;
	n = min(n,40LL);

	rep(i,n){
		ll cur = p * pow<ll>(a,i) + q * pow<ll>(b,i);
		if(1.0 * p * pow<R>(a,i) + 1.0 * q * pow<R>(b,i) > 1e18) break;
		ticket.push_back(cur);
		if(cur > m) break;
	}

	n = ticket.size();

	vector<ll> item[2];
	const ll half[2] = {n/2,n-n/2};
	const ll offset[2] = {0,n/2};

	rep(k,2)rep(mask,1 << half[k]){
		ll cur = 0LL;
		rep(i,half[k]) if(mask & (1 << i)) cur += ticket[i+offset[k]];
		item[k].push_back(cur);
	}

	
	ll ans = m;
	sort(begin(item[1]),end(item[1]));
	
	for(auto &it:item[0]){
		const ll arg = m - it;
		auto it2 = upper_bound(begin(item[1]),end(item[1]),arg);

		if(it2 != end(item[1])) ans = min(ans, abs(m - it - *it2));
		it2--;
		ans = min(ans, m - it - *it2);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,co;
  co=0;
  cin>>n;
  int a[n];
  vector<int> b(n);
  rep(i,n){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(b.begin(),b.end());
  rep(i,n){
    if(a[i]!=b[i]){
      co++;
    }
  }
  if(co==2||co==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


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

int main() {
    int x; cin >> x;
    int ans = 0;
    Int sum = 0;
    int i = 0;
    while (1) {
        i++;
        sum += i;
        ans++;
        if (sum >= (Int)x)
            break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int start = x - (k - 1);
        int end = x + (k - 1);
        for (int i = start; i <= end; i++) {
            if (i != end) {
                System.out.print(i + " ");
            } else {
                System.out.println(i);
            }
        }
    }
}


Measured memory_bytes: 21204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        ArrayList<Integer>[] adj = (ArrayList<Integer>[]) new ArrayList[n];
        int ans[] = new int[n];

        for (int i = 0; i < n; i++) {
            adj[i] = new ArrayList<Integer>();
            ans[i] = -1;
        }
        for (int i = 0; i < m; i++) {
            int x, y;
            x = scanner.nextInt();
            y = scanner.nextInt();
            adj[x - 1].add(y - 1);
            // adj[y - 1].add(x - 1);
        }
        boolean visited[] = new boolean[n];
        int maxPath = Integer.MIN_VALUE;
        for (int i = 0; i < visited.length; i++) {
            if (!visited[i]) {
                maxPath = Math.max(getPath(adj, visited, i, ans), maxPath);
            }
        }

        System.out.println(maxPath - 1);

    }

    public static int getPath(ArrayList<Integer> graph[], boolean visited[], int vertex, int ans[]) {
        if (ans[vertex] != -1) {
            return ans[vertex];
        }
        int path = Integer.MIN_VALUE;
        for (int i = 0; i < graph[vertex].size(); i++) {

            visited[graph[vertex].get(i)] = true;
            path = Math.max(1 + getPath(graph, visited, graph[vertex].get(i), ans), path);
        }

        if (path == Integer.MIN_VALUE) {
            path = 1;
        }
        ans[vertex] = path;
        return ans[vertex];

    }

}

Measured memory_bytes: 74868
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m,q;
  cin>>n>>m>>q;
  string s[n+1];
  for(int i=0;i<n;i++) cin>>s[i];
  int im[3][n+1][m+1];
  memset(im,0,sizeof(im));
  {
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
	im[0][i+1][j+1]=im[0][i+1][j]+(s[i][j]=='1');
    for(int i=0;i<n;i++)
      for(int j=0;j<=m;j++)
	im[0][i+1][j]+=im[0][i][j];
  }
  
  {
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
	im[1][i+1][j+1]=im[1][i+1][j]+(s[i][j]=='1'&&i>0&&s[i-1][j]=='1');
    for(int i=0;i<n;i++)
      for(int j=0;j<=m;j++)
	im[1][i+1][j]+=im[1][i][j];
  }
  //cout<<im[1][n][m]<<endl;
  
  {
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
	im[2][i+1][j+1]=im[2][i+1][j]+(s[i][j]=='1'&&j>0&&s[i][j-1]=='1');
    for(int i=0;i<n;i++)
      for(int j=0;j<=m;j++)
	im[2][i+1][j]+=im[2][i][j];
  }
  //cout<<im[2][n][m]<<endl;
  
  for(int i=0;i<q;i++){
    int sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;
    sx--;sy--;
    //cout<<sx<<" "<<sy<<":"<<gx<<" "<<gy<<endl;
    //cout<<im[0][gx][gy]<<" "<<im[0][gx][sy]<<" "<<im[0][sx][gy]<<" "<<im[0][sx][sy]<<endl;
    int ans=im[0][gx][gy]-im[0][gx][sy]-im[0][sx][gy]+im[0][sx][sy];
    sx++;
    ans-=im[1][gx][gy]-im[1][gx][sy]-im[1][sx][gy]+im[1][sx][sy];
    //cout<<sx<<" "<<sy<<":"<<gx<<" "<<gy<<endl;
    //cout<<im[1][gx][gy]<<" "<<im[1][gx][sy]<<" "<<im[1][sx][gy]<<" "<<im[1][sx][sy]<<endl;
    sx--;
    sy++;
    ans-=im[2][gx][gy]-im[2][gx][sy]-im[2][sx][gy]+im[2][sx][sy];
    sy--;
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 100224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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;}

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

int main(){
    int a,b,c,sum=0;
    char S[3];
    cin>>S;
    a=S[0];
    b=S[1];
    c=S[2];
    sum=a+b+c;
    if(sum==294&&a!=b&&b!=c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> nums;
  for (int i=0; i<N; i++){
    int a;
    cin >> a;
    nums.push_back(a);
  }
  
  sort(nums.begin(), nums.end());
  reverse(nums.begin(), nums.end());
  
  int sum1 = 0;
  int sum2 = 0;
  for (int i=0; i<N; i++){
    if (i%2==0)    sum1 += nums.at(i);
    else sum2 += nums.at(i);
  }
  
  cout << sum1 - sum2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

bool IsPrime(int num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0)  {
            return false;
        }
    }
    return true;
}

int main()
{
    int x;
    cin >> x;
    bool ok = false;
    while(ok == false) {
        ok = IsPrime(x);
        x++;
    }
    cout << x - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
    unsigned short *A,*B;

    int C[VMAX + 1];
    int n,j,i;
    scanf("%d",&n);

    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);

    for(i = 0;i <= VMAX;i++) C[i] = 0;

    for(i = 0;i < n;i++){
        scanf("%d",&A[i+1]);
        C[A[i + 1]]++;
    }

    for(i = 1;i <= VMAX;i++) C[i] = C[i] + C[i - 1];

    for(j = 1; j <= n;j++){
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for(i = 1;i <= n; i++){
        if(i > 1) printf(" ");
         printf("%d",B[i]);
    }

    printf("\n");

    return 0;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define ll long long
#define inf 100000000000000000
#define mod 1000000007
#define endl '\n'
#define omarshagar                    \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
using namespace std;

int main()
{

   omarshagar
  int n,k;
   cin>>n>>k;
   int arr[n];
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   ll res=1;
   n-=min(k,n);
   res+=ceil(n/(double)(k-1));
   cout<<res<<endl;
}


Measured memory_bytes: 640
import numpy as np
from collections import deque
n = int(input())
a_ls = list(map(int, input().split()))
q = deque(a_ls)

if n != 1:
    l_ls = [0] * int(np.floor(0.5*n))
    r_ls = [0] * max(0,(n-1)//2)
    first = q.popleft()
    count = 2
    while True:
        a = q.popleft()
        if count % 2 == 0:
            l_ls[count//2-1] = a
        else:
            r_ls[count//2-1] = a
        count += 1
        if count > n:
            break
    ans = []
    if n % 2 ==0:
        for i in range(len(l_ls)):
            l = l_ls.pop()
            ans.append(l)
        ans.append(first)
        for i in range(len(r_ls)):
            ans.append(r_ls[i])
    else:
        for i in range(len(r_ls)):
            l = r_ls.pop()
            ans.append(l)
        ans.append(first)
        for i in range(len(l_ls)):
            ans.append(l_ls[i])

    ans = [str(b) for b in ans]
    print(' '.join(ans))

else:
    print(a_ls[0])

Measured memory_bytes: 50792
N,K = map(int,input().split(" "))
H = sorted([int(input()) for _ in range(N)])
Min = 10**10
for i in range(K-1,len(H))[::-1]:
    Abs = H[i]-H[i-(K-1)]
    if Abs<Min:
        Min = Abs
print(Min)

Measured memory_bytes: 8280
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,x;cin>>n>>x;
	int a[108]={0};
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		x-=a[i];
	}
	int ans=n;
	sort(a,a+n);
	cout<<ans+x/a[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
int A,B,C,D,E,N,M,x,y,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
    char S[10],W[10],s[10],X,Y;
   scanf("%d %d",&A,&B);
   if(A+B<24){
       printf("%d",A+B);
   }else{
       printf("%d",(A+B)-24);
   }
    return 0;
}

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

using namespace std;

int main(void)
{
  string s;

  cin>>s;
  int count = 0;
  int res = 0;

  for(int i=0;i<s.size();i++)
  {
    if(s[i] == 'A' || s[i] == 'G' ||s[i] == 'C' ||s[i] == 'T' )
    {
      while(s[i] == 'A' || s[i] == 'G' ||s[i] == 'C' ||s[i] == 'T' )
      {
        count++;
        i++;
      }
      if(res<count)
      {
        res=count;
      }
      count=0;
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
	set<string> st;
	rep(i,n){
		string s; cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
	return 0;
}


Measured memory_bytes: 19136
/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;

vvi g;
vvi w;
vi dp, used;
void dfs(int v){
    used[v] = 1;
    for (int i = 0; i < g[v].size(); i++){
        int to = g[v][i];
        if (!used[to]){
            dfs(to);
            dp[v] = max(dp[v], dp[to] + 1);
        }else dp[v] = max(dp[v], dp[to] + 1);
    }
}
main(){
    int n, m;
    cin >> n >> m;
    g.resize(n);
    w.resize(n);
    dp.resize(n, 0);
    used.resize(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        w[b].pb(a);
    }
    vi q;
    rep(i, n){
        if (!w[i].size()){
            q.pb(i);
        }
    }
    int flex = q.size();
    rep(i, flex){
        dfs(q[i]);
    }
    int maxn = 0;
    rep(i, n)
        maxn = max(maxn, dp[i]);
    cout << maxn;
}


Measured memory_bytes: 16640
/* ***********************************************
Author        :yang12138
Created Time  :2017年04月12日 星期三 21时07分01秒
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=55;
int cnt[N][26];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		char s[N];
		scanf("%s",s);
		for(int j=0;s[j];j++){
			cnt[i][s[j]-'a']++;
		}
	}
	for(int i=0;i<26;i++){
		int cou=1000;
		for(int j=1;j<=n;j++){
			cou=min(cou,cnt[j][i]);
		}
		while(cou--) putchar('a'+i);
	}
	puts("");
    return 0;
}


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

const int N = 1e6 + 1;

int a[N];

int main() {
    string str;
    cin >> str;
    long long sum = 0;
    int keep = 0;
    int n = str.length() + 1;
    for (int i = 1; i <= n; i++) {
        a[i] = keep;
        if (str[i - 1] == '<') keep += 1;
        else keep = 0;
    }
    keep = 0;
    for (int i = n; i >= 1; i--) {
        a[i] = max(keep, a[i]);
        if (str[i - 2] == '>') keep += 1;
        else keep = 0;
    }
    // for (int i = 1; i <= n; i++) cout << a[i] << " ";
    // cout << endl;
    cout << accumulate(a+1, a+1+n, (long long)0) << endl;
    return 0;
}

Measured memory_bytes: 2820
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

signed main(void)
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s[i];

  int black = 0;
  REP(i, h) REP(j, w) black += (s[i][j] == '#');

  int sx = 0, sy = 0, gx = w-1, gy = h-1;
  VVI d(h, VI(w, 0));
  queue<PII> que;
  REP(i, h) REP(j, w) d[i][j] = INF;
  que.push(PII{sx, sy});
  d[sy][sx] = 0;

  while(que.size()) {
    PII p = que.front(); que.pop();
    if(p.first == gx && p.second == gy) break;
    REP(i, 4) {
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(IN(0LL, w, nx) && IN(0LL, h, ny) && s[ny][nx] != '#' && d[ny][nx] == INF) {
        que.push(PII{nx, ny});
        d[ny][nx] = d[p.second][p.first] + 1;
      }
    }
  }

  if(d[gy][gx] == INF) cout << -1 << endl;
  else cout << h*w - black - d[gy][gx] - 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
int p2[201010], p5[201010];
int cnt[60][30];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	
	rep(i, 0, N) {
		string s; cin >> s;

		ll x = 0;
		bool f = false;
		int rest = 9;
		fore(c, s) {
			if (c != '.') {
				x = x * 10 + c - '0';
				if (f) rest--;
			}
			else f = true;
		}
		rep(j, 0, rest) x *= 10;

		while (x % 2 == 0) x /= 2, p2[i]++;
		while (x % 5 == 0) x /= 5, p5[i]++;
	}
	rep(i, 0, N) cnt[p2[i]][p5[i]]++;

	ll ans = 0;
	rep(i, 0, N) {
		int need2 = max(18 - p2[i], 0);
		int need5 = max(18 - p5[i], 0);
		rep(i2, need2, 60) rep(i5, need5, 30) ans += cnt[i2][i5];
		if (need2 <= p2[i] && need5 <= p5[i]) ans--;
	}
	ans /= 2;
	cout << ans << endl;
}







Measured memory_bytes: 5160
use std::cmp::{max, min};
use std::collections::{BinaryHeap, VecDeque};
use std::io::{stdin, Read};
use std::rc::Rc;
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
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")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let aa = (0..3 * n).map(|_| read::<i64>()).collect::<Vec<_>>();

    let mut qa = BinaryHeap::new();
    let mut a = 0;
    for i in 0..n {
        a += aa[i];
        qa.push(-aa[i]);
    }

    let mut sum_a = vec![0; n + 1];
    sum_a[0] = a;
    for i in 0..n {
        let next = aa[n + i];
        qa.push(-next);
        let discard = -qa.pop().unwrap();
        a += (next - discard);
        sum_a[i + 1] = a;
    }

    let mut qb = BinaryHeap::new();
    let mut b = 0;
    for i in 2 * n..3 * n {
        b += aa[i];
        qb.push(aa[i])
    }

    let mut sum_b = vec![0; n + 1];
    sum_b[0] = b;
    for i in 0..n {
        let next = aa[n * 2 - 1 - i];
        qb.push(next);
        let discard = qb.pop().unwrap();
        b += (next - discard);
        sum_b[i + 1] = b;
    }

    let mut ans = i64::min_value();
    for i in 0..n + 1 {
        ans = max(sum_a[i] as i64 - sum_b[n - i] as i64, ans);
    }
    println!("{}", ans)
}


Measured memory_bytes: 12540
#include "iostream"
#include "algorithm"
#include "string"
using namespace std;

int main() {
	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;
	int cnt1 = 0, cnt2 = 0;
	int w1 = 0, w2 = 0;
	while (w1 < p) {
		w1++;
		cnt1 += a;
	}
	cnt2 += b;
	while (w2 < p) {
		if (w2 >= c) {
			cnt2 += d;
		}
		w2++;
	}
	cout << min(cnt1, cnt2) << endl;
}


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

using namespace std;

map <int, int> cnt;

int main()
{
    #ifdef HOME
    freopen("input.txt", "rt", stdin);
    #endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        cnt[a + 1]++;
        cnt[a]++;
        cnt[a - 1]++;
    }
    int ans = 0;
    for (auto i : cnt){
        ans = max(ans, i.second);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

int main() {
	int n;
	cin >> n;

	vector<int> a(n, 0);

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

	if (n == 1) {
		cout << a[0] << endl;
		return 0;
	}

	int index = n-1;
	
	while (true) {
			cout << a[index];

			index -= 2;

			cout << " ";

			if (index < 0) {
				break;
			}

		
	}

	if (n % 2 == 0) {
		index = 0;
	}
	else {
		index = 1;
	}
	

	while (true) {
		cout << a[index];

		index += 2;
		if (index > n-1) {
			break;
		}

		cout << " ";
	}

	cout << endl;

	
}

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

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num1=0,num2=0;
        String s = br.readLine();
        String[] str = s.split(" ");
        int[] x = new int[str.length];
        for(int i=0; i<str.length; i++){
            x[i] = Integer.parseInt(str[i]);
        }
        Arrays.sort(x);
        for(int i=0; i<str.length-1; i++){
            System.out.print(x[i] +" ");
        }
        System.out.println(x[str.length-1]);
    }
}

Measured memory_bytes: 17088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	dunk(x < 1200 ? "ABC" : "ARC");
	return 0;
}

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

int s;
string a;
int main()
{
    cin >> a;
    for (int i =1; i < a.size(); i++) {
        if (a[i] != a[i - 1]) s++;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;


int main(void){
   int N;
   cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   int cur=1;
   int ans=0;
   for(int i=0;i<N;i++){
      if(a[i]==cur){
         ans++;
         cur++;
      }
   }
   ans=N-ans;
   if(ans<N){
      cout<<ans<<endl;
   }else{
      cout<<-1<<endl;
   }
   return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;

int main() {
	int N;
	while (1) {
		cin >> N;
		if (N == 0)break;
		vector<int> know[101];
		for (int i = 1; i <= N; i++) {
			int M;
			cin >> M;
			for (int j = 0; j < M; j++) {
				int a;
				cin >> a;
				know[a].push_back(i);
			}
		}
		int K;
		cin >> K;
		int cnt[101] = {};
		for (int i = 0; i < K; i++) {
			int a;
			cin >> a;
			for (int j = 0; j < know[a].size(); j++)cnt[know[a][j]]++;
		}
		int who = -1;
		int c = 0;
		for (int i = 1; i <= N; i++) {
			if (cnt[i] == K)c++, who = i;
		}
		if (c == 1)cout << who << endl;
		else cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 3212
#!/usr/bin/env python3
import sys
INF = float("inf")


def main():
    M, K = map(int, input().split())

    # コーナーケース
    if M == 0:
        if K == 0:
            print("0 0")
        else:
            print("-1")
        return
    elif M == 1:
        if K == 0:
            print("0 0 1 1")
        else:
            print("-1")
        return

    # 一般
    if K >= (1 << M):
        print("-1")
        return

    # 実現可能ケース
    ans = []
    for i in range(1 << M):
        if i == K:
            continue
        ans.append(i)
    ans = ans[::-1] + [K] + ans + [K]
    print(" ".join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 97908
import java.util.Scanner;

//Misterious Gems
public class Main{

	public static int dir(char c){
		return c=='N'?0:c=='E'?1:c=='S'?2:3;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] move = {{0,1}, {1,0},{0,-1},{-1,0}};
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int get = 0;
			boolean[][] g = new boolean[21][21];
			for(int i=0;i<n;i++){
				int x = sc.nextInt();
				int y = sc.nextInt();
				g[x][y] = true;
			}
			int m = sc.nextInt();
			int px = 10;
			int py = 10;
			while(m--!=0){
				int k = dir(sc.next().charAt(0));
				int d = sc.nextInt();
				while(d--!=0){
					px += move[k][0];
					py += move[k][1];
					if(g[px][py]){
						g[px][py] = false;
						get++;
					}
				}
			}
			System.out.println(get==n?"Yes":"No");
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int dp[20001];
const int INF = 1001001001;

int main() {
  int h,n;
  cin >> h >> n;
  vi a(n,0),b(n,0);
  int ma=0;
  rep(i,n) {
    cin >> a.at(i) >> b.at(i);
    ma=max(ma,a.at(i));
  }
  rep(i,h+ma) dp[i] = INF;

  dp[0] = 0;
  orep(j,h+ma-1) rep(i,n) {
    if(j-a[i] >= 0) dp[j] = min(dp[j],dp[j-a.at(i)]+b.at(i));
  }
  int ans = INF;
  srep(i,h,h+ma) ans=min(ans,dp[i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// ABC176 F
                                                                                                                                                                                                                                                                                                                                
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////        ////////////        ////////////        ////////////        ////////////        ////////////        ///
////////  /////  ///////////  /////  ///////////  /////  ///////////  /////  ///////////  /////  ///////////  /////  ///
///////  /////  ///////////  /////  ///////////  /////  ///////////  /////  ///////////  /////  ///////////  /////  ////
//////        ////////////        ////////////        ////////////        ////////////        ////////////        //////
/////  //////////////////  //////////////////  //////////////////  //////////////////  //////////////////  /////////////
////  //////////////////  //////////////////  //////////////////  //////////////////  //////////////////  //////////////
///  //////////////////  //////////////////  //////////////////  //////////////////  //////////////////  ///////////////
//  //////////////////  //////////////////  //////////////////  //////////////////  //////////////////  ////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
a;f;n;s;u;v;w;C[37000];D[3001][3001];M[3001];*c=C;
main(m){
  for(;++n%3+scanf("%d",&w);u=v,w-=v=w)
    for(
      s=2;
      n%3<1&&(
        s++<6e3+2?
          u-v|v-w||n*s<10?
            *++c=u,*++c=s/3,*++c=fmax(v-w?:D[s/3][v]+1,M[s/3]),
            *++c=v,*++c=w,*++c=n*s<10?1e7:fmax(D[u][u]+1,m)
          :++f
        :c>C&&(
          w=*c--,v=*c--,u=*c--,
          D[u][v]>w||(D[u][v]=D[v][u]=w),M[u]>w||(M[u]=w),M[v]>w||(M[v]=w),m=m>w?m:w
        )
      );
      u=v,v=w,w=a
    )a=u;
  printf("%d",m+=f/6e3-1e7);
}


Measured memory_bytes: 25740
N = 10**6


def f(x):
    return x


M = 10**5
arr = list(range(M))
for i in range(N):
    t = (i + i * i - i) % M  # 四則演算
    b = arr[t]  # 配列ランダムアクセス
    b = f(b)  # 関数呼び出し

# 答え
a = int(input())
print(a + a**2 + a**3)


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

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

  if ((a == 1 && b == 2) || (a ==2 && b == 1)) {
    cout << 3 << endl;
  }
  else if ((a == 2 && b ==3) || (a == 3 && b == 2)){
    cout << 1 << endl;
  }
  else {
    cout << 2 << endl;
  }
}


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

string toUpper(string s){
	string t = s;
	for (int i = 0; i < s.size(); i++){
		t[i] = toupper(s[i]);
	}
	return t;
}

int main()
{
	string target, source;

	cin >> target;
	target = toUpper(target);

	int cnt = 0;

	while (1){
		cin >> source;

		if (source == "END_OF_TEXT") break;
		source = toUpper(source);

		if (target == source) cnt++;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3140
let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let rec read_ss ss i =
    if i = n then
      ss
    else
      let value = Scanf.scanf "%d\n" (fun n -> n) in
      read_ss (value :: ss) (i + 1)
  in
  let x = read_ss [] 0 |> List.sort compare |> List.rev in
  (List.hd x / 2) :: List.tl x |> List.fold_left (+) 0 |>
  string_of_int |> print_endline



Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  const int X = 30;
  vector<ll> n(X, 1);
  FOR(i, 1, X) n[i] = n[i - 1] * 3;
  function<void()> solve = [&]() {
    ll a, b, c, d; cin >> a >> b >> c >> d; --a; --b; --c; --d;
    ll ans = abs(c - a) + abs(d - b);
    for (int level = X; level > 0; --level) {
      ll a_div = a / n[level - 1], b_div = b / n[level - 1], c_div = c / n[level - 1], d_div = d / n[level - 1];
      // cout << a_div << ' ' << b_div << ' ' << c_div << ' ' << d_div << '\n';
      if (a_div != c_div && b_div != d_div) break;
      if (a_div == c_div && b_div == d_div) continue;
      if (a_div == c_div && a_div % 3 == 1 && abs(b_div - d_div) >= 2) {
        ans += min({a % n[level - 1] + 1, c % n[level - 1] + 1, n[level - 1] - a % n[level - 1], n[level - 1] - c % n[level - 1]}) * 2;
        break;
      } else if (b_div == d_div && b_div % 3 == 1 && abs(a_div - c_div) >= 2) {
        ans += min({b % n[level - 1] + 1, d % n[level - 1] + 1, n[level - 1] - b % n[level - 1], n[level - 1] - d % n[level - 1]}) * 2;
        break;
      }
    }
    cout << ans << '\n';
  };
  int q; cin >> q;
  while (q--) solve();
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

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



int N;
string s;

int z_algorithm(string &s) {
  vector<int> prefix(s.size());

  int ans = 0;

  for (int i=1,j=0;i<s.size();++i) {
    if (i + prefix[i-j] < j + prefix[j]) {
      prefix[i] = prefix[i-j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while (i + k < s.size() && s[k] == s[i+k]) ++k;
      prefix[i] = k;
      j = i;
      if (i >= k) ans = max(ans, k);
    }
  }

  return ans;
}

int main () {
  cin >> N;
  cin >> s;

  int ans = 0;

  Rep(i, N) {
    string str = s.substr(i, N-i);
    ans = max(ans, z_algorithm(str));
  }

  cout << ans << "\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll n,x[101],ans=1e9;

void init(){
	cin>>n;
	rep(i,n)cin>>x[i];
}

int main(void){
	init();
	reg(p,1,100){
		ll sum=0;
		rep(i,n){
			sum+=(x[i]-p)*(x[i]-p);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int h, w, n;
    vector<int> line;

    cin >> h >> w >> n;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        for (int j = 0; j < temp; j++) {
            line.push_back(i + 1);
        }
    }
    
    for (int h1 = 0; h1 < h / 2; h1++) {
        for (int w1 = 0; w1 < w; w1++) {
            cout << line[2 * h1 * w + w1] << ' ';
        }
        cout << endl;
        for (int w2 = 0; w2 < w; w2++) {
            cout << line[2 * (h1 + 1) * w - w2 -1] << ' ';
        }
        cout << endl;
    }
    if (h % 2 != 0) {
        for (int w1 = 0; w1 < w; w1++) {
            cout << line[(h - 1) * w + w1] << ' ';
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
def readinput():
    n=int(input())
    x=list(map(int,input().split()))
    return n,x

def mean(x):
    sum=0
    for _ in x:
        sum+=_
    return sum/len(x)

def rss(x,xbar):
    sum=0
    for _ in x:
        sum+=(_-xbar)**2
    return sum

def main(n,x):
    ans=0
    xbar=mean(x)
    xbar_int=xbar//1
    if(xbar-xbar_int >0.5):
        xbar_int+=1
    ans=rss(x,xbar_int)
    return int(ans)

def main2(n,x):
    xmin=min(x)
    xmax=max(x)
    minsum=1000000

    for p in range(xmin,xmax+1):
        sum=0
        for xx in x:
            sum+=(xx-p)**2
        if(sum<minsum):
            minsum=sum

    return minsum

if __name__=='__main__':
    n,x=readinput()
    ans=main2(n,x)
    print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
import heapq


class Reverse:
    def __init__(self, val):
        self.val = val

    def __lt__(self, other):
        return self.val > other.val

    def __repr__(self):
        return repr(self.val)


class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            for i in range(len(arr)):
                arr[i] = Reverse(arr[i])
        self.desc = desc
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        if self.desc:
            return heapq.heappop(self.hq).val
        else:
            return heapq.heappop(self.hq)

    def push(self, a):
        if self.desc:
            heapq.heappush(self.hq, Reverse(a))
        else:
            heapq.heappush(self.hq, a)

    def top(self):
        if self.desc:
            self.hq[0].val
        else:
            return self.hq[0]


def solve(N: int, M: int, A: "List[int]"):
    hq = Heapq(A, desc=True)
    while M > 0:
        MD = hq.pop()
        M -= 1
        hq.push((MD//2))
        if MD <= 0:
            break
    ans = 0
    while A:
        a = hq.pop()
        ans += a
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll a,b;
  cin >> a >> b;
  ll k=(a+b)/2;
  if((a+b)%2==0) cout << k << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#define int long long int

signed main()
{
	int n,W;
	std::cin>>n>>W;
	
	std::vector<std::vector<int>> dp;
	for (int j=0; j<n; j++)
	{
		std::vector<int> a;
		for (int i=0; i<W+1; i++)
		{
			a.push_back(0);
		}
		dp.push_back(a);
	}
	std::vector<int> w;
	std::vector<int> v;
	for (int j=0; j<n; j++)
	{
		int a,b;
		std::cin>>a>>b;
		w.push_back(a);
		v.push_back(b);
	}
	for (int j=0; j<=W; j++)
	{
		if (j>=w[0])
		{
			dp[0][j]=v[0];
		}
	}
	for (int i=1; i<n; i++)
	{
		for (int j=0; j<=W; j++)
		{
			if (j>=w[i])
			{
				dp[i][j]=std::max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
			}
			else
			{
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	std::cout<<dp[n-1][W];
}

Measured memory_bytes: 79460