akhauriyash/Code-Regression huggingface dataset:
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 = sc.nextInt();
        int m = sc.nextInt();
        int[] x = new int[m];
        if (n >= m) {
            System.out.println(0);
            return;
        }
        for (int i = 0 ; i < m ; i++ ) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        int[] div = new int[m - 1];
        for (int i = 0 ; i < m - 1 ; i++) {
            div[i] = x[i + 1] - x[i];
        }
        Arrays.sort(div);
        int ans = x[m - 1] - x[0];
        for (int i = 0 ; i < n - 1 ; i++) {
            ans -= div[m- 2 - i];
        }
        System.out.println(ans);

    }

}

Measured memory_bytes: 49624
#include <bits/stdc++.h>
 
using namespace std;
 
typedef unsigned long long ull;
 
ull sum(int x)
{
    return x * (x + 1ULL) / 2ULL;
}
 
ull lcm(ull a, ull b)
{
    return a / (ull)__gcd(a, b) * b;
}
 
int main()
{
    ull n, m;
    while (cin >> n >> m, n) {
        vector<ull> p(m);
        for (int i = 0; i < m; i++) {
            cin >> p[i];
        }
        int a = 0, b = 0;
        ull N = n;
        double res = sum(n);
        for (int i = 1; i < (1<<m); i++) {            
            int cnt = 0;
            ull l = 1;
            for (int j = 0; j < m; j++) {
                if (i >> j & 1) {
                    cnt++;
                    l = lcm(l, p[j]);
                }
            }
            if (cnt & 1) {
                N -= n/l;
            } else {
                N += n/l;
            }
            l = l * sum(n / l);
            if (cnt & 1) {    
                res -= l;
            } else {
                res += l;
            }
        }
        if (res == 0) {
            printf("%.10f\n", 0);      
        } else {
            printf("%.10f\n", res/N);
        }
    }
    return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<string.h>


int main(void)
{
 int m, i, j;
 char x[201], y[101];
 scanf("%s %s", x, y);
 
 m = strlen(x);
 
 for(i=0;i<m;i++) x[i+m] = x[i];

 puts(strstr(x, y) == NULL ? "No" : "Yes");

 return 0;

 }

Measured memory_bytes: 524
#include <iostream>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <unordered_set>

using namespace std;

template <class K, class V>
bool contains(unordered_map<K, V> map, K key) {
  return map.find(key) != map.end();
}

template <class K>
bool contains(unordered_set<K> set, K key) {
  return set.find(key) != set.end();
}

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

  // int cache[n][n]; // 配列だと大きすぎて、segmentation faultになる
  // for(int i = 0; i < n; i++) {
  //   for(int j = 0; j < n; j++) {
  //     cache[i][j] = -1;
  //   }
  // }
  vector<vector<int>> cache(n, vector<int>(n, -1));

  int result = 0;

  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      int a = i;
      int b = j;
      int match_length = 0;
      while (true) {
        if (a >= n-1) { break; }
        if (b >= n) { break; }
        if (a >= j) { break; }
        if (s[a] != s[b]) { break; }
        if (cache[a][b] != -1) { match_length = cache[a][b]; break; }
        a++;
        b++;
      }

      while (a > i) {
        a--;
        b--;
        match_length++;
        cache[a][b] = match_length;
      }

      result = max(result, cache[i][j]);
    }
  }

//  for(int i = 0; i < n; i++) {
//    for(int j = 0; j < n; j++) {
//      cout << "i: " << i << "j: " << j << "cache: " << cache[i][j] << endl;
//    }
//  }


  cout << result << endl;
}


Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n,min,c=1;
  cin >> n;
  int arr[n];
  for (int i=0;i<n;i++)
  cin >> arr[i];
  
  min=arr[0];
  for (int i=1;i<n;i++)
  {
      if (arr[i]<min)
      {c++;
      
      min=arr[i];}
  }
  cout << c;
  
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>

using namespace std;

const int MAX_N = 10005;
int arr[MAX_N];

int main() {
    int n;
    scanf("%d", &n);
    while (n != 0) {
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            scanf("%d", arr + i);
            sum += arr[i];
        }
        int cnt = 0;
        for (int j = 0; j < n; ++j) {
            if (arr[j] * n <= sum)
                cnt++;
        }
        printf("%d\n", cnt);
        scanf("%d", &n);
    }
    return 0;
}


Measured memory_bytes: 2724
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	takoyakiTastes := io.ScanInts(n)

	var sum int
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			sum += takoyakiTastes[i] * takoyakiTastes[j]
		}
	}
	fmt.Println(sum)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2172
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>


using namespace std;


int GreatestCommonDivisor(long long a, long long b)
{
  long long p = a, q = b;
  if ( p < q ) swap( p, q);
  
  while ( true )
  {
    long long yo = p % q;
    if ( yo == 0 ) return q;
    p = q;
    q = yo;
  }
  return 0;
}

//最小公倍数
long long LeastCommonMultiple(long long a, long long b)
{
  return (a*b) / GreatestCommonDivisor(a,b);
}


int main()
{
  long long a, b;
  cin >> a;
  cin >> b;
  cout << LeastCommonMultiple(a,b);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e-a <= k) {
        cout << "Yay!" <<endl;
    }else{
        cout << ":(" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const double EPS = 1e-11;
const double PI = 2 * acos(0.0);
using ll = long long;
using ull =  unsigned long long;

#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define pf printf
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sll(x,y) scanf("%lld %lld",&x,&y)

#define pii pair<int,int>
#define nl '\n'
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define uniq(a) a.erase(unique(a.begin(), a.end()), a.end())
#define out(x) cout <<"#x = "<<x<<endl
#define outt(x,y) cout <<"# "<<x<<" "<<y<<endl
#define mem(array,value) memset(array,value,sizeof(array))

const int MX = 1e5+1;

std::vector<int>node[MX];
bool vis[MX];
int dp[MX];
int n,m;

void dfs(int s)
{
	//if(!vis[s])return 0;
	vis[s]=1;
	for(auto d:node[s]){
		if(!vis[d]){
			dfs(d);
		}
		dp[s]=max(dp[s],dp[d]+1);
	}
}
int main()
{
	//fast_io
	sii(n,m);
	for(int i=0;i<m;i++){
		int a,b;
		// cin >>a>>b;
		sii(a,b);
		node[a].pb(b);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,dp[i]);
	}
	pf("%d\n",ans);
	//cout <<ans<<endl;
	return 0;
}

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

int main(void)
{
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2])
  {
    cout << "No" << endl;
  }else
  {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define db double
#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define fir first
#define sec second
#define pb push_back
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pii pair<int,int>
#define sc(x) scanf("%d",&(x))
#define sz(x) (int)(x).size()
#define ms(x) memset((x),0,sizeof(x));
#define all(x) (x).begin(), (x).end()
#define er(x) cerr<<(x)<<" ";
#define err(x) cerr<<#x<<": "<<(x)<<" ";
#define errn cerr<<endl;
using namespace std;
#define mod 1000000007
const db pi=acos(-1.0);
template <class T> void R(T &x) { cin>>x; }
void R(int &x) { scanf("%d",&x); }
void R(ll &x) { scanf("%lld",&x); }
void R(double &x) { scanf("%lf",&x); }
void R(char &x) { scanf(" %c",&x); }
void R(char *x) { scanf("%s",x); }
ll _pow(ll a,ll b) { ll res=1ll; while(b){ if(b&1)
res=res*a%mod; a=a*a%mod; b>>=1; } return res; }
///_____________________________________________

#define mxn 100005

int main()
{
    char ch;
    string s;
    set<string> q;
    int n;
    R(n);
    bool flag=0;
    cin>>s;q.insert(s);
    ch=s.back();
    for(int i=1;i<n;i++)
    {
        cin>>s;
        if(s[0]!=ch) flag=1;
        q.insert(s);
        ch=s.back();
    }
    if(flag||q.size()!=n) puts("No");
    else puts("Yes");
    return 0;
}



Measured memory_bytes: 256
import bisect

INF = 1 << 64
A, B, Q = map(int, input().split())
S = [int(input()) for a in range(A)]
T = [int(input()) for b in range(B)]

def cost(S, A, x):
    index_s = bisect.bisect_left(S, x)
    ws = INF if index_s == 0 else x - S[index_s - 1]
    es = INF if index_s == A else S[index_s] - x
    return ws, es


for q in range(Q):
    x = int(input())
    ws, es = cost(S, A, x)
    wt, et = cost(T, B, x)

    print(min(max(ws, wt), max(es, et), min(ws, et) + ws + et, min(es, wt) + es + wt))


Measured memory_bytes: 12128
using System;

class Program
{
    static void Main()
    {
            int i, j, x;
            int[] h = new int[2000];
            int[] w = new int[2000];
            for (i = 0; i < 2000; i++)
            {
                string inp = Console.ReadLine();
                string[] data = inp.Split();
                h[i] = int.Parse(data[0]);
                w[i] = int.Parse(data[1]);
                if (h[i] == 0 && w[i] == 0)
                {
                    break;
                }
            }
            for (x = 0; x < 2000; x++)
            {
                if (h[x] == 0 && w[x] == 0)
                {
                    break;
                }
                for (i = 0; i < h[x]; i++)
                {
                    for (j = 0; j < w[x]; j++)
                    {
                        if (i == 0 || j == 0 || i == h[x]-1 || j == w[x]-1)
                        {
                            Console.Write("#");
                        }else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }
    }
}


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

public class Main{
    public static void main(String[] args){
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    
    try{
        String str = br.readLine();
        StringTokenizer st = new StringTokenizer(str, " ");
        
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        
        int[] num = {a,b,c};
        
        Arrays.sort(num);
        
            for (int i = 0; i < num.length; i++){
                System.out.print(num[i]);
                    
                    if (i != 2){
                    System.out.print(" ");
                    }
                    
                
            }
        System.out.print("\n");
    }catch(IOException e){}
    

    }
}

Measured memory_bytes: 24292
import numpy as np
n,m,x = map(int,input().split())
l = []
for i in range(n):
    l.append(np.array(input().split(),dtype=int)) 
import itertools
num = [i for i in range(n)]
min = 1000000000000000000000000
k = 1
while k <n+1:
    a = list(itertools.combinations(num, k))
    for i in range(len(a)):
        total =np.zeros(m+1,dtype=int)
        for j in range(len(a[i])):
            total +=l[a[i][j]]
        if np.sum(np.where(total < x)[0]) <=0:
            if min > total[0]:
                min = total[0]
                
    k +=1
if min == 1000000000000000000000000:
    print(-1)
else:
    print(min)

Measured memory_bytes: 27676
//????????????1???????????±????´???????????????????????????????????????§????????????????????§????????????????????????????????????
#include <iostream>
using namespace std;

int main() {
	int n;
	
	while (cin >> n) {
		if (!n) break;
		
		bool know[100][100] = {false};
		bool ng[100] = {false};
		
		for (int i = 0; i < n; i++) {
			int m;
			cin >> m;
			for (int j = 0; j < m; j++) {
				int p;
				cin >> p; p--;
				know[i][p] = true;
			}
		}
		int k;
		cin >> k;
		for (int i = 0; i < k; i++) {
			int p; cin >> p; p--;
			ng[p] = true;
		}
		
		int cnt = 0;
		int ans;
		for (int i = 0; i < n; i++) {
			int j;
			for (j = 0; j < n; j++) {
				if (ng[j] && !know[i][j]) break;
			}
			if (j == n) {
				cnt++;
				ans = i;
			}
		}
		if (cnt != 1) { cout << -1 << endl; }
		else { cout << ans + 1 << endl; }
	}
	return 0;
}

Measured memory_bytes: 3100
def main():
    h, w = map(int, input().split())
    c = [list(map(int, input().split())) for _ in range(10)]
    a = [list(map(int, input().split())) for _ in range(h)]

    dp = c.copy()

    for k in range(10):
        for i in range(10):
            for j in range(10):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

    magic = 0
    for row in a:
        for num in row:
            if num == -1:
                continue
            magic += dp[num][1]

    print(magic)


if __name__ == "__main__":
    main()


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

using namespace std;
int main() {
    int a, b, c, d;
    int ans = 0;

    cin >> a >> b >> c >> d;

    if (a < c) {
        ans = min(b-c, d-c);
    } else {
        ans = min(d-a, b-a);
    }

    ans = max(0, ans);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
m,d = map(int,input().split())

ans = 0
for i in range(1,m+1):
    for j in range(1,d+1):
        x = str(j)
        if len(x) == 2:
            if (int(x[0]) >= 2 and 
                int(x[1]) >= 2 and 
                int(x[0]) * int(x[1]) == i):
                ans += 1
print(ans)       


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long i64;
using namespace std;
 
i64 cross(pair<i64,i64>P,pair<i64,i64>Q,pair<i64,i64> R)//if return >0 then point R is upper of lineseg PQ else down
    {
        return  (Q.first-P.first)*(R.second-P.second)-(R.first-P.first)*(Q.second-P.second);
    }
void hull(vector<pair<i64,i64> > &P,vector<pair<i64,i64> > &L,vector<pair<i64,i64> > &U)
    {
        int j=0,k=0,n=P.size();
        sort(P.begin(),P.end());
        U.resize(2*n);
        L.resize(2*n);
        for(int i=0;i<n;i++)
         {
            while(j>=2 && cross(L[j-2],L[j-1],P[i])<=0)//p[i] is making right turn we need left turn
                j--;
            while(k>=2 && cross(U[k-2],U[k-1],P[i])>=0)//p[i] is making left turn we need right
                k--;
            L[j++]=P[i];
            U[k++]=P[i];
        }
        U.resize(k);
        L.resize(j);
    }
i64 fun(pair<i64,i64> P ,pair<i64,i64> Q)
    {
        return abs(P.first-Q.first)+abs(P.second-Q.second);
    }

int main()
    {
        i64 t,n,k1,k2;
        vector<pair<i64,i64> >v,U,L;
        
        v.clear();
        U.clear();
        L.clear();
        cin>>n;
        for(int i=0;i<n;i++)
         cin>>k1>>k2,v.push_back(make_pair(k1,k2));
     
        hull(v,L,U);
      
        /*cout<<"lower hull\n";
        for(int i=0;i<L.size();i++)
            cout<<L[i].first<<" "<<L[i].second<<endl;
        cout<<"upper hull"<<endl;
        for(int i=0;i<U.size();i++)
            cout<<U[i].first<<" "<<U[i].second<<endl;*/
        int i=0,j,m;
        j=L.size()-1;
        m=U.size()-1;
        i64 dist=-1;
        while(i<m || j>0)
        {
            dist=max(dist,fun(U[i],L[j]));
            if(i==m)
                j--;
            else if(j==0)
                i++;
            else
            {
                if ( (U[i+1].second-U[i].second) * (L[j].first-L[j-1].first) > (L[j].second-L[j-1].second) * (U[i+1].first-U[i].first) )
                i++;
            else
                j--;
            }
        }
        cout<<dist<<endl;
        
    }   

Measured memory_bytes: 19032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200005];
int main()
{
ll k,n;
cin>>k>>n;
for(int i=0;i<n;i++)
    cin>>a[i];
ll l=a[0]+k-a[n-1];
for(int i=0;i<n-1;i++)
{
 l=max(a[i+1]-a[i],l);
}

cout<<k-l<<endl;
}


Measured memory_bytes: 1792
'use strict'

function gcd (x, y) {
  if (y == 0) return x
  else return gcd(y, x % y)
}

const main = (INPUT) => {
  const [A, B] = INPUT.split('\n')[0].split(' ')
  console.log(A * B / gcd(A, B))
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main(){
    int N;
    int H[100000];
    cin >> N;
    for(int i=0;i<N;++i) cin >> H[i];
    for (int i=N-1;i>0;i--){
        if(H[i]+1==H[i-1]){
            H[i-1]-=1;
        }else if(H[i]<H[i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
  string S,T,U;
  int A,B;
  cin >> S >> T >> A >> B >> U;
  if(S==U){
    A--;
    cout << A << " " << B << endl;
  }
  else{
    B--;
    cout << A << " " << B << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sum_a = sum(a)
sum_b = sum(b)
if sum_a <= sum_b:
    cnt = 0
    for i in range(n):
        if a[i] > b[i]:
            cnt += a[i] - b[i]
        elif a[i] < b[i]:
            cnt -= (b[i] - a[i]) // 2
    if cnt <= 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 4596
import itertools

N,X,Y=map(int, input().split())

l=list(range(1,N+1))
cnt=[0]*(N-1)

for p in itertools.combinations(l, 2):
    a=p[1]-p[0]
    b=abs(p[1]-Y)+abs(p[0]-X)+1
    cnt[min(a,b)-1]+=1

for k in cnt:
    print(k)

Measured memory_bytes: 3572
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			int [] count = new int[26];
			for (int i=0; i<26; i++) count[i] = 0; //初期化
			String eng = "";
			while (sc.hasNext()) {
				eng += sc.nextLine();
			}
			count = Count(eng,count);
			Output(count);
		}
	}

	static int[] Count(String s, int[] c) {
		for (int i=0; i<s.length(); i++) {
			int a = s.charAt(i);
			if ((a>=65) && (a<=90)) {
				int b = 26- (90-a)-1;
				c[b]++;
			}
			else if ((a>=97) && (a<=122)) {
				int b = 26-(122-a)-1;
				c[b]++;
			}
		}
		return c;
	}

	static void Output(int[] c) {
		for (int i=0; i<26; i++) {
			int a = i + 97;
			System.out.print(Character.toChars(a));
			System.out.println(" : " + c[i]);
		}
	}
}



Measured memory_bytes: 26344
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var N = Number(line[0]);
	var A1 = line[1].split(" ");
	var A2 = line[2].split(" ");
	var S1 = [];
	var S2 = [];
	var sum1 = 0;
	var sum2 = 0;
	for(var i = 0; i < N; i++){
		sum1 += Number(A1[i]);
		sum2 += Number(A2[N-1-i]);
		S1[i] = sum1;
		S2[N-1-i] = sum2;
	}
	var ans = 0;
	for(var j = 0; j < N; j++){
		if(S1[j]+S2[j] >= ans) ans = S1[j]+S2[j];
	}
	console.log(ans);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import math
a=list(map(int,input().split()))
a.sort()
cnt=0
if a[0]==a[1]==a[2]:
  print(0)
  exit()
if a[0]==[1]:
  print(a[2]-a[1])
  exit()
if a[1]==a[2]:
  if (a[2]-a[0])%2==0:
    print(math.ceil((a[2]-a[0])/2))
    exit()
  else:
    print(math.ceil((a[2]-a[0])/2+1))
    exit()
cnt+=a[2]-a[1]
a[0]+=cnt
if (a[2]-a[0])%2==0:
  cnt+=math.ceil((a[2]-a[0])/2)
else:
  cnt+=math.ceil((a[2]-a[0])/2+1)
print(cnt)


Measured memory_bytes: 3188
def main():
    from bisect import bisect_right
    n=int(input())
    num=list(map(int,input().split()))
    num.sort()
    
    i=bisect_right(num,num[-1]//2)
    if i==0:
        ans=num[0]
    else:
        if num[-1]>num[i]+num[i-1]:
            ans=num[i]
        else:
            ans=num[i-1]
    print(num[-1],ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 14428
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
//const int MAX=;

//dp[i][j]はi番目までのコインで裏がj枚出る確率
long double dp[3000][3000];

int main(){
	int N;
	cin>>N;
	long double p[3001];
	rep(i,N)cin>>p[i];
  
	dp[0][0]=1;
	rep(i,N)rep(j,i+1){
		dp[i+1][j]+=dp[i][j]*p[i];
		dp[i+1][j+1]+=dp[i][j]*(1-p[i]);
	}
	long double ans=0;
	rep(i,N/2+1)ans+=dp[N][i];
	cout<<fixed<<setprecision(12)<<ans;
}

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

int main() {
  int N,A;
  cin >> A;
  N = A/100000000 + (A/10000000) % 10 + (A/1000000) % 10 + (A/100000) % 10 + (A/10000) % 10  + (A/1000) % 10+ (A/100) % 10 + (A/10) % 10 + A % 10;
  if(A%N==0){
    cout <<  "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
parseline(str=readline()) = parse.(Int, split(str))
function BrickBreak()
    N = parse(Int, readline())
    A = parseline()
    counter = 0
    now = 1
    for a in A
        if a == now
            now += 1
        else
            counter += 1
        end
    end
    println(counter<N ? counter : -1)
end
BrickBreak()

Measured memory_bytes: 197084
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char map[505][505];
int def[505][505];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	ll count = 1;
	ll acount = 0;
	ll bcount = 0;
	ll ccount = 0;
	for (int i = 0; i < s.size()-1; i++) {
		if (s[i] != s[i + 1]) {
			count++;
		}
	}
	if ((s.size()==1&&count == 1)||(count==2&&s.size()==2)) {
		cout << "YES" << endl;
		return 0;
	}
	if (count != 3) {
		cout << "NO" << endl;
		return 0;
	}
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'a') {
			acount++;
		}
		if (s[i] == 'b') {
			bcount++;
		}
		if (s[i] == 'c') {
			ccount++;
		}
	}
	if (abs(acount - bcount) < 2 && abs(bcount - ccount) < 2 && abs(acount - ccount) < 2) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
/*
[abc132] B - Ordinary Number
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 20;

int N;
int p[MAX_N];

ll solve() {
    int ans = 0;
    for (int i = 1; i < N - 1; i++) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) ||
            (p[i - 1] > p[i] && p[i] > p[i + 1])) {
            ans++;
        }
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


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

int main(void){
    int a, b;
    cin >> a >> b;
    if(a == b)
        cout << max(a, b) * 2 << endl;
    else
        cout << max(a, b) * 2 - 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int x, a, b;

int main(void)
{
	
	scanf( "%d %d %d", &x, &a, &b );
	
	if ( (a -= x) < 0 ) a = -a;
	if ( (b -= x) < 0 ) b = -b;
	
	if ( a < b ) printf( "A\n" );
	else printf( "B\n" );
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define mod 1e9 +7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(ll n){
    stringstream ss;
    ss << bitset<8>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vi> a(n);
    rep(i,m){
        int s, g;
        cin >> s >> g;
        s--; g--;
        a[s].push_back(g);
        a[g].push_back(s);
    }
    //rep(i,n)cout << a[i].size() << " ";
    //cout << endl;
    rep(i, a[0].size()){
        rep(j, a[a[0][i]].size())if(a[a[0][i]][j] == n-1){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
} 

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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n, m;
	cin >> n >> m;
	VI a(m);
	IN(m, a);

	FOR(0, m) n -= a[i];
	
	if (n < 0) cout << "-1";
	else cout << n;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n, d;
    cin >> n >>d;
    vector<vector<int > > X(n, vector<int>(d, 0));
    REP(i,n){
        REP(j,d){
            cin >> X[i][j];
        }
    }
    
    int cnt = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(! (i<j) ) continue;
            // cout << i << ' ' << j << endl;
            double dist = 0.0;
            for(int k = 0; k<d; k++){
                dist += pow(X[i][k]-X[j][k], 2);
            }
            dist = sqrt(dist);
            // cout << "dist " << dist << endl;
            if (dist == ceil(dist)) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 2000000
#define M 100050
int n,m,i,j,c[M],b[M];
struct lwn{
	int l,r,opt;
	bool operator < (const lwn &jb)const{
		return r<jb.r||r==jb.r&&opt<jb.opt;
	}
} a[N];
inline int rd()
{
	char ch=getchar();int ret=0;
	while (ch<'0' || ch>'9') ch=getchar();
	while (ch>='0' && ch<='9') ret=(ret<<3)+(ret<<1)+ch-'0',ch=getchar();
	return ret;
}
int main()
{
	n=rd();m=rd();int q=n;
	for (i=1;i<=n;i++) a[i].l=rd(),a[i].r=rd();
	for (i=1;i<=m;i++)
	for (j=0;j<=m/i;j++) n++,a[n].l=i*j,a[n].r=min(i*(j+1)-1,m),a[n].opt=i;
	sort(a+1,a+n+1);int psz=0;
	for (i=1;i<=n;i++) if (a[i].opt){
		int tot=0;
		for (j=a[i].l;j>=1;j-=(j&(-j))) tot+=c[j];
		b[a[i].opt]+=psz-tot;
	}else{
		psz++;
		for (j=a[i].l;j<=m;j+=(j&(-j))) c[j]++;
	}
	for (i=1;i<=m;i++) printf("%d\n",q-b[i]);
	return 0;
}

Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();

ll GCD(ll a, ll b) {
    if (a > b) swap(a, b);
    while (b != 0) {
        ll c = b;
        ll d = a % b;
        a    = c;
        b    = d;
    }
    return a;
}

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

    ll ans = 0;
    cin >> ans;
    REP2(i, 1, N) {
        ll x;
        cin >> x;
        ans = ans / GCD(ans, x) * x;
    }
    PR(ans);
    return 0;
}

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

set<ll>s;

void primeFactors(ll n)
{

    while (n%2 == 0)
    {
        //printf("%d ", 2);
        s.insert(2);
        n = n/2;
    }


    for (ll i = 3; i <= sqrt(n); i = i+2)
    {

        while (n%i == 0)
        {
            //printf("%d ", i);
            s.insert(i);
            n = n/i;
        }
    }


    if (n > 2)
        //printf ("%d ", n);
        s.insert(n);

}

int main(){

    double n;
    cin>>n;
    printf("%.10f\n",(ceil(n/2.0)/n));



}



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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
if(n%2==0){
ll sum=0;
rep(i,n){
  if(i%2)sum+=a[i];
}
ans=sum;
rep(i,n/2){
  sum+=a[i*2]-a[i*2+1];
  ans=max(ans,sum);
}
}
else{
vector<vector<ll>> v(n+1, vector<ll>(3,0) );
rep(i,n){
  if(i%2){
    v[i+1][0]=v[i][0];
    v[i+1][1]=max(v[i][0],v[i][1]+a[i]);
    v[i+1][2]=v[i][2];
  }
  else{
    v[i+1][0]=v[i][0]+a[i];
    v[i+1][1]=v[i][1];
    if(i!=0)v[i+1][2]=max(v[i][1],v[i][2]+a[i]);
  }
}
ans=max({v[n][1],v[n][2]});
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 15568
#include <iostream>
#include "cmath"
using namespace std;
int main() {
    long long int x,k,d;
    cin >> x >> k >> d;
    long long int right = abs(x)%d;
    long long int left = abs(d - right);
    long long int f_steps = abs(x)/d;

    if(k<=f_steps){
        cout << abs(x) - k*d << endl;
        return 0;
    }
    long long int s_steps = k - f_steps;

    if(s_steps%2==0){
        cout << right << endl;
    } else{
        cout << left << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

int main(void){
    int N; cin >> N;
    vector<ll> H(N,0); for(int i = 0; i < N; i++) cin >> H[i];
    
    ll count = 0;
    ll ans = 0;
    for(int i = 0; i < N-1; i++){
        if(H[i] >= H[i+1]) count++;
        else{
            count = 0;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
n,k=list(map(int, input().split()))
V=list(map(int, input().split()))
ans=0
r=min(n,k)
for a in range(r+1):
    for b in range(r+1-a):
        if b==0:
            v=V[:a]
        else:
            v=V[:a]+V[-b:]
        v.sort()
        for i in range(k+1-a-b):
            if i>=len(v):
                break
            if v[i]>=0:
                break
        ans=max(ans,sum(v[i:]))
print(ans)

Measured memory_bytes: 3064
h,w = map(int,input().split())
left = 0
ok = True
flag = "ok"
for i in range(h):
    dum = input()
    for j in range(0,w):
        if j < left and dum[j] == "#":
            print("Impossible")
            exit()
        if dum[j] == "#":
            left_o = j
            flag = "ng"
    left = left_o
    flag = "ok"
print("Possible")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main(){
    string s;
    cin >> s;
    int w;
    cin >> w;
    for(int i=0;i<s.size();i+=w){
        cout << s[i];
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  cin >> n;
  ll a = 0, b, sum = 0;
  for(int i = 0; i < n; i++){
    cin >> b;
    if(b == 0) sum += a / 2, a = 0;
    a += b;
  }
  cout << sum + a / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct lazysegtree{
	using F=function<T(T,T)>;
	using G=function<T(T,T,int,int)>;
	const F calcfn,lazycalcfn;
	const G updatefn;
	int n;
	T defvalue,lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	lazysegtree(int n_=0,T defvalue_=0,
		const F calcfn_=[](T a,T b){return a+b;},
		const F lazycalcfn_=[](T a,T b){return a+b;},
		const G updatefn_=[](T a,T b,int l,int r){return a+b*(r-l);},
		T lazydefvalue_=0
	):defvalue(defvalue_),lazydefvalue(lazydefvalue_),
		calcfn(calcfn_),lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
		lazy.assign(2*n-1,lazydefvalue);
		lazyflag.assign(2*n-1,false);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
	}
	void eval(int i,int l,int r)
	{
		if(lazyflag[i])
		{
			dat[i]=updatefn(dat[i],lazy[i],l,r);
			if(r-l>1)
			{
				lazy[2*i+1]=lazycalcfn(lazy[2*i+1],lazy[i]);
				lazy[2*i+2]=lazycalcfn(lazy[2*i+2],lazy[i]);
				lazyflag[2*i+1]=lazyflag[2*i+2]=true;
			}
			lazy[i]=lazydefvalue;
			lazyflag[i]=false;
		}
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]=lazycalcfn(lazy[k],x);
			lazyflag[k]=true;
			eval(k,l,r);
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=calcfn(dat[2*k+1],dat[2*k+2]);
		}
	}
	T query(int a,int b,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return defvalue;
		else if(a<=l&&r<=b)return dat[k];
		else return calcfn(
			query(a,b,2*k+1,l,(l+r)/2),
			query(a,b,2*k+2,(l+r)/2,r)
		);
	}
};
int N,M;
vector<pair<pair<int,int>,int> >E;
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int l,r,c;cin>>l>>r>>c;
		l--;
		E.push_back(make_pair(make_pair(l,r),c));
	}
	sort(E.begin(),E.end());
	auto calcfn=[](long a,long b){return a<b?a:b;};
	auto lazycalcfn=[](long a,long b){return a<b?a:b;};
	auto updatefn=[](long a,long b,int l,int r){return a<b?a:b;};
	lazysegtree<long>P(N,1e18,calcfn,lazycalcfn,updatefn,1e18);
	P.update(0,1,0);
	for(pair<pair<int,int>,int>p:E)
	{
		long X=P.query(p.first.first,p.first.second);
		P.update(p.first.first,p.first.second,X+p.second);
	}
	long ans=P.query(N-1,N);
	cout<<(ans<1e18?ans:-1)<<endl;
}


Measured memory_bytes: 5620
#include<stdio.h>
#include<math.h>
#define N 102

int main(){
  int n,i,j,k,c,l;
  int x[N],m[N][N];

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

  for( i = 1 ; i <= n ; i++ ){
    m[i][i] = 0;
  }

  for( i = 2 ; i <= n ; i++ ){
    for( j = 1 ; j <= n-i+1 ; j++ ){
      l = i + j - 1;
      m[j][l] = INFINITY;
      for( k = j ; k <= l-1 ; k++ ){
        c = m[j][k] + m[k+1][l] + x[j-1]*x[k]*x[l];
        if( m[j][l] > c )m[j][l] = c;
      }
    }
  }

  printf("%d\n",m[1][n]);
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n,m;
  cin >> n >> m;
  ll ans = 0;
  ll a[n];
  REP(i,n) {
    cin >> a[i];
    ans += a[i];
  }
  sort(a,a+n);
  pair<ll,ll> b[m];
  REP(i,m) {
    cin >> b[i].se >> b[i].fi;
  }
  sort(b,b+m);
  reverse(b,b+m);
  int pos = 0;
  REP(i,m) {
    while (pos < n && a[pos] < b[i].fi && b[i].se > 0) {
      b[i].se--;
      ans += b[i].fi - a[pos++];
    }
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]){
  int case_num = 1;
  // while (1) if (solve()) break;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>

std::string solve(std::string s, int k)
{
  const char k_char = s[k - 1];
  for (auto& c : s) {
    if (c != k_char) c = '*';
  }
  return s;
}

int main()
{
  int n, k;
  std::string s;
  std::cin >> n >> s >> k;

  std::cout << solve(s, k) << std::endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using lli=long long int;
const lli mod=1000000007;

lli powern(lli n){
  lli ans = 1;
  for(lli i = 0; i < n; i++){
    ans *= 2;
    ans %= mod;
  }
  return ans;
}

int main(){
  int N;
  std::cin >> N;
  std::vector<lli> c_arr(N);
  for(int i = 0; i < N; i++) std::cin >> c_arr[i];
  std::sort(c_arr.begin(), c_arr.end());

  lli ans = 0;
  const lli powern_1 = powern(N-1);
  const lli powern_2 = powern(N-2);
  for(int i = 0; i < N; i++){
    int l = N-1-i;
    lli tmp = (powern_1+(l*powern_2)%mod)%mod;
    tmp = (c_arr[i]*tmp)%mod;
    ans = (ans+tmp)%mod;
  }

  for(int i = 0; i < N; i++){
    ans = (ans*2)%mod;
  }

  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;
ll a, b, n;

int main()
{
    cin >> n >> a >> b;
    ll k = n / (a + b);
    ll p = min(a, n % (a + b));
    cout << k * a + p << endl;
    return 0;
}


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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 200000;

int h[MAXN + 2];
ll dp[MAXN + 2];

int main() {
	int N;
	cin >> N;
	for(int i = 0; i < N; i++)
		cin >> h[i];
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		ll k = 0;
		for(int j = h[i]; j; j ^= j & -j)
			k = max(k, dp[j]);
		k += a;
		for(int j = h[i]; j <= N; j += j & -j)
			dp[j] = max(dp[j], k);
	}
	ll ans = 0;
	for(int i = N; i; i ^= i & -i)
		ans = max(ans, dp[i]);
	cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    double a, b, x;
    cin >> a >> b >> x;

    // x /= a;

    if (a*a*b / 2 >= x) {
        double len = x / a / b * 2;
        // cout << len << endl;
        printf("%.10f", atan(b / len) * 180 / M_PI);
    } else {
        double len = 2 * x / (a*a) - b;
        // cout << len << endl;
        printf("%.10f", atan((b-len) / a) * 180 / M_PI);
    }
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin

n = int(stdin.readline().rstrip())
S = list(map(int, stdin.readline().rstrip().split()))
q = int(stdin.readline().rstrip())
T = list(map(int, stdin.readline().rstrip().split()))

def binary_search(A,key):
  left = 0
  right = n
  while left < right:
    mid = (left + right) // 2
    if A[mid] == key:
      return mid
    elif key < A[mid]:
      right = mid
    else:
      left = mid + 1
  else:
    return -1

cnt = 0
for t in T:
  if binary_search(S, t) != -1:
    cnt += 1
print(cnt)



Measured memory_bytes: 16716
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


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

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		
		for (int i=0;i<n;i++) {
			x[i] = sc.nextInt();
		}
		
		int[] s_x = x.clone();
		Arrays.sort(s_x);
		for (int e : x) {
			if (e >= s_x[n/2]) {
				System.out.println(s_x[n/2-1]);
			} else {
				System.out.println(s_x[n/2]);
			}
		}
	}
}

Measured memory_bytes: 86904
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,D,A;
int X[200010],H[200010];
P p[200010];
int num[200010];

signed main(){
	cin>>N>>D>>A;
	REP(i,N){
		cin>>p[i].first>>p[i].second;
	}
	sort(p,p+N);
	REP(i,N){
		X[i]=p[i].first,H[i]=p[i].second;
	}
	int ans=0;
	REP(i,N){
		H[i]+=num[i];
		DEB(H[i])END
		if(H[i]>0){
			int R=ceil2(H[i],A);
			num[i]-=A*R;
			int pos=distance(X,upper_bound(X,X+N,X[i]+D*2));
			num[pos]+=A*R;
			ans+=R;
			DEB(R)DEB(pos)
		}
		num[i+1]+=num[i];
		DEB(num[i])END
	}
	cout<<ans<<endl;
	return 0;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s,t;cin>>s>>t;
    vvl dp(3010,vl(3010,0));
    rep(i,s.size()){
        rep(j,t.size()){
            if(s[i]==t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }
    //out(dp[s.size()][t.size()]);
    
    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 71168
N = int(input())
S = [input() for _ in range(N)]

answer = [0 for _ in range(4)]
for i in range(N):
    if S[i] == "AC":
        answer[0]+=1
    elif S[i] == "WA":
        answer[1]+=1
    if S[i] == "TLE":
        answer[2]+=1
    if S[i] == "RE":
        answer[3]+=1

print("AC x "+str(answer[0]))
print("WA x "+str(answer[1]))
print("TLE x "+str(answer[2]))
print("RE x "+str(answer[3]))

Measured memory_bytes: 79152
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s,t;
  cin >> s >> t;
  int n = s.size()-t.size()+1;
  int ans = t.size();
  rep(i,n){
    int res = 0;
    rep(j,int(t.size())){
      if(s[i+j]!=t[j]) ++res;
    }
    ans = min(ans,res);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628