akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.lang.*;


class Solution{

    void solve() throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        int N =  Integer.parseInt(bufferedReader.readLine());

        String[] input = bufferedReader.readLine().split(" ");

        int sum = 0;

        
        
        for(int i = 0 ; i < input.length ; i++){
            int number = Integer.parseInt(input[i]);
            sum+=number;
            
        }

        int mean  = (int)Math.round(sum/(double)input.length);


        int offset = 0;

        for(int i = 0 ; i < input.length ; i++){
            offset+=(int)Math.pow((Integer.parseInt(input[i])-mean),2);
        }

       System.out.println(offset);
    }    

}

class Main{
    public static void main(String[] args) throws IOException{
        new Solution().solve();
    }
}

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

int n, m, s, e, t1, t2;
char maze[1001][1001];
int cost[1001][1001];

queue<pair<int, int>> q, q_with_magic;

void runBfs() {
	cost[s][e]  = 0;
	q.push({s, e});
	int move[4][2] = {{1, 0},
		{0, 1},
		{ -1, 0},
		{0, -1}
	};
	while (!q.empty()) {
		while (!q.empty()) {
			q_with_magic.push(q.front());
			int x = q.front().first;
			int y = q.front().second;
			q.pop();
			for (int i = 0; i < 4; i++) {
				int new_x = x + move[i][0];
				int new_y = y + move[i][1];
				if (new_x >= 0 && new_x < n && new_y >= 0 && new_y < m && maze[new_x][new_y] != '#' && cost[new_x][new_y] == -1) {
					cost[new_x][new_y] =  cost[x][y];
					q.push({new_x, new_y});
				}
			}
		}
		while (!q_with_magic.empty()) {
			int x = q_with_magic.front().first;
			int y = q_with_magic.front().second;
			q_with_magic.pop();
			for (int i = -2; i <= 2; i++) {
				for (int j = -2; j <= 2; j++) {
					int new_x = x + i, new_y = y + j;
					if (new_x >= 0 && new_x < n && new_y >= 0 && new_y < m && maze[new_x][new_y] != '#' && cost[new_x][new_y] == -1) {
						cost[new_x][new_y] = cost[x][y] + 1;
						q.push({new_x, new_y});
					}
				}
			}
		}
	}
	cout << cost[t1][t2];
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> n >> m;
	cin >> s >> e;
	cin >> t1 >> t2;

	s--, e--, t1--, t2--;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> maze[i][j];
			cost[i][j] = -1;
		}
	}

	if (maze[s][e] == '#') {
		cout << -1;
		return 0;
	}
	runBfs();
	return 0;
}

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

int main() {
    int n;
    cin>>n;
    int a[3][n+1];
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    int max=0;
    for(int i=1;i<=n;i++){
        //i番目で曲がる
        int cnt=0;
        for(int j=1;j<=i;j++){
            cnt+=a[1][j];
        }
        for(int k=i;k<=n;k++){
            cnt+=a[2][k];
        }
        //printf("cnt=%d\n",cnt);
        if(max<cnt)max=cnt;
    }
    cout<<max<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
    int main(void){
    int a,b ;
    scanf("%d%d",&a,&b);
    if(a<b)
    printf("a < b\n");
    if(a>b)
    printf("a > b\n");
    if(a == b)
    printf("a == b\n");
    return 0 ;
    }

Measured memory_bytes: 580
# https://atcoder.jp/contests/abc129/tasks/abc129_e
# 問題文
# 正整数 L が二進数表記で与えられます。 
# 以下の条件を満たす非負整数 a,b の組 (a,b) がいくつ存在するか求めてください
# a+b≤L
# a+b=a XOR b
# ただし、この値は非常に大きくなることがあるので、
# 109+7 で割った余りを出力してください。
# XOR とは制約Lは二進数表記で与えられ、
# 先頭文字は必ず 1 である
# 1≤L<2**100001

# 1111111111111111111
# 162261460

MOD = (10**9) + 7

a = 1
b = 0
counter = 0
gets.chomp.bytes do |c|
  if c == 49
    b = (a + (b * 3)%MOD)%MOD
    a = (a * 2)%MOD
  else
    b = (b * 3)%MOD
  end
  counter += 1
end

puts (a+b)%MOD

Measured memory_bytes: 1916
H,W=map(int,input().split())
M=[list(input()) for i in range(H)]
for i in range(H):
    if '#'in M[i]:
        s=[]
        for x in range(W):
            t=[M[y][x] for y in range(H)]
            if '#'in t: s.append(M[i][x])
        print(''.join(s))

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

int w=0,e=0,S=0,n=0;

int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='W') w=1;
        else if(s[i]=='E') e=1;
        else if(s[i]=='S') S=1;
        else if(s[i]=='N') n=1;
    }
    if(w==e&&n==S)
      printf("Yes\n");
    else 
      printf("No\n");
    return 0;
 } 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
  unsigned int b;
  char step;
} Board;

int qlen=32202;

typedef enum { U, D, L, R } Direction;

typedef struct {
  int pos;
  Direction dir;
} Motion;

const Motion motion[9][5] =
  {{{1,L},{3,U},{-1}}, {{0,R},{2,L},{4,U},{-1}}, {{1,R},{5,U},{-1}},
   {{0,D},{4,L},{6,U},{-1}}, {{1,D},{5,L},{7,U},{3,R},{-1}},
   {{2,D},{8,U},{4,R},{-1}},
   {{3,D},{7,L},{-1}}, {{4,D},{8,L},{6,R},{-1}}, {{5,D},{7,R},{-1}} };

int findzero(unsigned int b)
{
  for (int i=0; i<9; i++) {
    if (b%10==0) return 8-i;
    b/=10;
  }
  return -1;
}

unsigned int sq[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000,1000000000 };

#define HISTLEN 8765432

int main()
{
  int i, j, k;
  int qhead, qtail;
  qhead = qtail = 0;
  Board board;
  fscanf(stdin, "%d %d %d\n", &i, &j, &k);
  board.b = i*sq[8]+j*sq[7]+k*sq[6];
  fscanf(stdin, "%d %d %d\n", &i, &j, &k);
  board.b += i*sq[5]+j*sq[4]+k*sq[3];
  fscanf(stdin, "%d %d %d\n", &i, &j, &k);
  board.b += i*100+j*10+k;
  short int *used = (short int*)malloc(sizeof(short int)*HISTLEN);
  for (i=0; i<HISTLEN; i++) used[i]=0;
  Board *Q = (Board*)malloc(sizeof(Board)*qlen);
  board.step=0;
  Q[qhead++] = board;
  
  while (qhead>qtail) {
    board = Q[qtail++ %qlen];
    if (board.b==123456780)   break;
    
    int space = findzero(board.b);
    for (i=0; motion[space][i].pos>=0; i++) {
      Board b = board;
      Motion m = motion[space][i];
      if (m.pos==0 && b.b/sq[8]==1) continue;
      if ((m.pos==1||m.pos==2) && b.b/sq[8]==1&&(b.b%sq[8])/sq[7]==2&&(b.b%sq[7])/sq[6]==3) continue;
      int nn=b.b%sq[8-m.pos+1]/sq[8-m.pos];
      b.b = nn*sq[8-space]+b.b-nn*sq[8-m.pos];
      b.step = board.step+1;
      k=b.b/100;
      if ((used[k] & (1<<(b.b%10)))==(1<<(b.b%10))) continue;
      used[k] |= (1<<(board.b%10));
      Q[qhead++ %qlen] = b;
    }
  }
  printf("%d\n", board.step);
  return 0;
}



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

#define rep(i, a) for (int i = 0; i < (a); i++ )
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<ll> A;
    rep(i,N) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    deque<ll> B;
    rep(i,N) {
        B.push_back(A[i]);
    }
    ll ans = 0;
    int nmax,nmin;
    nmax = B.back();
    nmin = B.front();
    ans += nmax - nmin;
    B.pop_back();
    B.pop_front();
    while(B.size()>0) {
        ll t1,t2;
        t1 = B.back();
        t2 = B.front();
        ll tmp11,tmp12,tmp21,tmp22;
        tmp11 = abs(t1-nmax);
        tmp12 = abs(t1-nmin);
        tmp21 = abs(t2-nmax);
        tmp22 = abs(t2-nmin);

        if (tmp11>=tmp12 && tmp11>=tmp21 && tmp11>=tmp22) {
            ans+=tmp11;
            nmax=t1;
            B.pop_back();
        }
        else if (tmp21>=tmp11 && tmp21>=tmp11 && tmp21>=tmp22) {
            ans+=tmp21;
            nmax=t2;
            B.pop_front();
        }
        else if (tmp12>=tmp11 && tmp12>=tmp21 && tmp12>=tmp22) {
            ans+=tmp12;
            nmin=t1;
            B.pop_back();
        }
        else {
            ans+=tmp22;
            nmin=t2;
            B.pop_front();
        }
    }
    cout << ans << endl;
}


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

Measured memory_bytes: 26064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,temp,x=0;
	string s;
	cin>>n>>s;
	temp=x;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
		x++;                                      //DDIDDII
		else
		x--;
		if(temp<x)
		temp=x;
	}
	cout<<temp<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
# D
N, M = map(int, input().split())
A_list = list(map(int, input().split()))

mod_dict = dict()
mod_dict[0] = 0
sum_k = 0
for a in A_list:
    sum_k += a
    r = sum_k % M
    if r not in mod_dict.keys():
        mod_dict[r] = 1
    else:
        mod_dict[r] += 1

res = 0
sum_k = 0

r = 0

for a in A_list:
    res += mod_dict[r]    
    sum_k += a
    r = sum_k % M
    mod_dict[r] -= 1
    
    
print(res)

Measured memory_bytes: 14408
import java.util.Scanner;
import java.util.*;
import java.lang.Character.*;

public class Main {
    static int map [][];
    static boolean memo[][];
    static boolean tmpmemo[][];
    static int w;
    static int h;
    static int islandcount;
    static boolean isnewland(int i, int j){
	return (map[i][j] == 1) && (memo[i][j] == false);
    }
    static void visitaround(int i, int j){
	if(i<0 || w<=i){
	    return;
	}
	if(j<0 || h<=j){
	    return;
	}
	if(map[i][j] == 0){
	    return;
	}
	if(tmpmemo[i][j] == true){
	    return;
	}

	if(isnewland(i, j)){
	    memo[i][j] = true;
	    tmpmemo[i][j] = true;
	}

	visitaround(i+1, j + 1);
	visitaround(i, j + 1);
	visitaround(i - 1, j + 1);
	visitaround(i + 1, j);
	visitaround(i - 1, j);
	visitaround(i + 1, j - 1);
	visitaround(i, j - 1);
	visitaround(i - 1, j - 1);
    }
    public static void main(String []args){
	Scanner sc = new Scanner(System.in);
	for(;;){
	    h = sc.nextInt();
	    w = sc.nextInt();
	    if(w == 0 && h == 0){
		break;	    }
	    map = new int[w][h];
	    memo = new boolean[w][h];
	    islandcount = 0;
	    for(int i=0; i<w;++i){
		for(int j=0; j<h;++j){
		    map[i][j] = sc.nextInt();
		}
	    }

	    for(int i=0; i<w;++i){
		for(int j=0; j<h;++j){
		    if(isnewland(i, j)){
			tmpmemo = new boolean[w][h];
			islandcount++;
			visitaround(i, j);
			
		    }
		}
	    }
	    System.out.println(islandcount);
	    
	}
    }
}

Measured memory_bytes: 47492
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(a+b>=x&&a<=x)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,i,j,mx,sum,a,b;
	scanf("%d %d",&n,&m);
	mx=0;
	sum=0;
	for(i=0;i<m;i++){
		scanf("%d %d",&a,&b);
		if(a<n){
			sum+=n-a;
			mx=max(mx,n-a);
		}
	}
	printf("%d\n",sum-mx);
	return 0;
}


Measured memory_bytes: 2768
<?php
define('N', 1000);

function trace(array $A, $n) {
  for ($i=0; $i<$n; $i++) {
    if($i > 0) printf(" ");
    printf("%d", $A[$i]);
  }
  printf("\n");
}

$n = intval(trim(fgets(STDIN)));
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

$count = 0;
for($i=0; $i<$n; $i++) {
  $minj = $i;
  for($j=$i; $j<$n; $j++) {
    if($A[$j] < $A[$minj]) {
      $minj = $j;
    }
  }
  if ($i != $minj) {
    $tmp = $A[$i];
    $A[$i] = $A[$minj];
    $A[$minj] = $tmp;
    $count++;
  }
}
trace($A, $n);
printf("%d", $count);
?>



Measured memory_bytes: 9324
n=parse(Int,readline())
x=[]
y=[]
for i=1:n
	a,b=map(x->parse(Int,x),split(readline()))
	push!(x,a)
	push!(y,b)
	if (abs(a)+abs(b))%2!=(abs(x[1])+abs(y[1]))%2
		println(-1)
		quit()
	end
end
a=1073741824
d=[]
while a>0
	push!(d,a)
	a=div(a,2)
end
if (abs(x[1])+abs(y[1]))%2==0
	push!(d,1)
end
println(length(d))
println(join(d,' '))
for i=1:n
	a=x[i]
	b=y[i]
	for j=1:length(d)
		if abs(a)>abs(b)
			if a>0
				a-=d[j]
				print('R')
			else
				a+=d[j]
				print('L')
			end
		else
			if b>0
				b-=d[j]
				print('U')
			else
				b+=d[j]
				print('D')
			end
		end
	end
	println()
end


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

int a[150];

int main()
{
	int n, mini = 100, maxi = -100, ans = 1e8;
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		if(a[i] < mini)
			mini = a[i];
		if(a[i] > maxi)
			maxi = a[i];
	}
	for(int i = mini; i <= maxi; ++i)
	{
		int temp = 0;
		for(int j = 1; j <= n; ++j)
			temp += (a[j] - i) * (a[j] - i);
		ans = min(temp, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define M 1000000007
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define N 1000005
#define U 998244353
#define bs binary_search
#define endl '\n'
#define FILEIO     freopen("input.txt","r",stdin); freopen("output.txt","w", stdout);
#define PI 3.1415926535
#define INF LLONG_MAX-5
using namespace std;
int po(int n, int exp){
    int prod=1;
    rep(i,0,exp)
        prod*=n;
    return prod;
}
int lcm(int a, int b){
    int g = __gcd(a,b);
    return (a/g)*b;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {
        int n;
        cin>>n;
        pair<int,int> p[n];
        rep(i,0,n){
            int a,b;
            cin>>a>>b;
            p[i] = {b,a};
        }
        sort(p,p+n);
        int cur=0;
        rep(i,0,n){
            if(p[i].fr>=cur+p[i].sc){
                // cout<<p[i].sc<<" "<<p[i].fr<<" "<<cur<<endl;
                cur += p[i].sc;
                continue;
            }
            else{
                cout<<"No";
                r0;
            }
        }
        cout<<"Yes";
    }   
}   

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  int N, M;
  cin >> N >> M;
  ll mn = -INF, mx = INF;
  REP(i, M) {
    ll L, R;
    cin >> L >> R;
    mn = max(L, mn), mx = min(R, mx);
  }
  cout << max((ll)0, mx - mn + 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
 
signed main(){
    int n , m;
    cin >> n >> m;

    cout << (1900 * m + 100 * (n - m)) * pow(2, m) << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val s = sc.next()

        var ans = 0L
        var aCnt = 0L
        var i = 0
        while (i < s.length) {
            when (s[i]) {
                'A' -> aCnt++
                'B' -> {
                    if (i + 1 < s.length && s[i + 1] == 'C') {
                        ans += aCnt
                        i++
                    } else {
                        aCnt = 0L
                    }
                }
                else -> aCnt = 0L
            }
            i++
        }

        println(ans)
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

Measured memory_bytes: 42032
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int main(){
  char n[18];
  char s[2];
  int t,i;
  int flag = 0;
  int sum = 0;

  s[0] = n[0];

  scanf("%s", n);

  t = strlen(n);
  t--;

  for(i = 1;i <= t;i++){
    sum += '9' - n[i];
  }

  if(sum == 0) printf("%d\n", (n[0] - '0') + 9*t);
  else printf("%d\n", (n[0] - '1') + 9*t);

  return 0;
}


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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 200005;
unordered_set<int> g[N][2];
char lb[N];
int vis[N];

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, m; cin >> n >> m;
	cin >> lb;
	REPU(i, 0, m) {
		int a, b; cin >> a >> b;
		--a, --b;
		g[a][lb[b] - 'A'].insert(b);
		g[b][lb[a] - 'A'].insert(a);
	}
	queue<int> que;
	REPU(i, 0, n) {
		int msk = 0;
		if (!g[i][0].empty()) msk |= 1;
		if (!g[i][1].empty()) msk |= 2;
		if (msk != 3) {
			vis[i] = 1;
			que.push(i);
		}
	}
	while (!que.empty()) {
		int v = que.front(); que.pop();
		int c = lb[v] - 'A';
		REPU(i, 0, 2) {
			for (int u : g[v][i]) if (u != v && vis[u] == 0) {
				g[u][c].erase(v);
				if (g[u][c].empty()) {
					vis[u] = 1;
					que.push(u);
				}
			}
		}
		g[v][0].clear();
		g[v][1].clear();
	}
	REPU(i, 0, n) if (vis[i] == 0) {
		puts("Yes"); return 0;
	}
	puts("No");

	return 0;
}


Measured memory_bytes: 44544
n = int(input())
a = input().split(' ')
mul = 1
mul1 = 1
for i in range(n):
	if int(a[i]) == 0:
		mul1 = 0
for i in range(n):
	mul = mul * int(a[i])
	if mul > (10 ** 18) :
		break
if mul1 == 0 :
	print (0)
elif mul > (10 ** 18):
	print (-1)
else :
	print (mul)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define sz(x) ((long long)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define int long long
const ld eps = 1e-9;
const ld pi = acosl(-1);
const int mod = 998244353;
const int mod1 = 1e9 + 7;

mt19937_64 rnd(time(0));

void faster()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
}

signed main() {
    faster();
    // freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
    //______________________________________
    /*__*/double start = clock();/*__*/
    //_____________________________________
    int n;
    cin >> n;
    int a[n];
    pair <int, int> dp[n][n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        dp[i][i] = {a[i], 0};
    }
    for (int szq = 1; szq < n; szq++)
    {
        for (int l = 0; l + szq < n; l++)
        {
            int r = l + szq;
            if (dp[l][r - 1].second + a[r] > dp[l + 1][r].second + a[l])
            {
                dp[l][r] = {dp[l][r - 1].second + a[r], dp[l][r - 1].first};
            }
            else
                dp[l][r] = {dp[l + 1][r].second + a[l], dp[l + 1][r].first};
            //  cout << l << " " << r << ' ' << dp[l][r].first << " " <<dp[l][r].second << endl;
        }
    }
    auto ans = dp[0][n - 1];
    cout << ans.first - ans.second;
    //______________________________________
    cerr << "Time " << (clock() - start)  * 1.0 / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 140928
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    int n;
    cin>>n;
    vector<int> p(n);
    vector<int> q(n);
    vector<int> s(n);
    vector<int> ss(n);
        rep(i,n){
        s[i]=i+1;
        ss[i]=i+1;
        cin>>p[i];
    }
    rep(i,n){
        cin>>q[i];
    }

    int pp=0;

    do{
        pp++;
        bool f = true;
        rep(i,n){
            if(p[i]!=s[i]){
                f=false;
                break;
            }
        }
        if(f){
            break;
        }
    }while(next_permutation(s.begin(),s.end()));
   



    int qq=0;
    do{

        qq++;
        bool f = true;
        rep(i,n){
            if(q[i]!=ss[i]){
                f=false;
                break;
            }
        }
        if(f){
            break;
        }
    }while(next_permutation(ss.begin(),ss.end()));



    cout<<abs(qq-pp)<<endl;






    return 0;
}


Measured memory_bytes: 256
#D
n=int(input())
a=list(map(int,input().split()))
for i in range(n-1):
    if a[i]<0:
        a[i]*=(-1)
        a[i+1]*=(-1)
if a[n-1]>=0:
    print(sum(a))
else:
    a[n-1]*=(-1)
    print(sum(a)-2*min(a))

Measured memory_bytes: 14412
alph=[chr(i) for i in range(97,97+26)]
alph_3=alph[3:26]+alph[0:3]
alph_3=[i.upper() for i in alph_3]
alph=[[alph_3[i],alph[i]] for i in range(26)]
S=[i for i in input()]
for i in range(len(S)):
    for j in range(26):
        if S[i]==alph[j][0]:
            S[i]=alph[j][1]
S="".join(S)
print(S.upper())


Measured memory_bytes: 5568
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;

	return 0;
}


Measured memory_bytes: 3684
#include<stdio.h>
#include<stdlib.h>

int main()
{
	char a[99];
	int i,n;
	for(i = 0; ; i++)
	{
		scanf("%c", a + i);
		if(a[i] == 10) 
		{
			a[i] = 0;
			break;
		}
	}
	n = i;
	int flag = 1;
	for(i = 0; i < (n-1)*0.5;i++)
	{
		if(a[i] != a[n-i-1])
			flag = 0;
	}
	if(n%4 == 3)
	{
	for(i = 0; i < (n-3)*0.25;i++)
	{
		if(a[i] != a[(int) ((n-3)*0.5 - i)])
			flag = 0;
	}
	
	for(i = 0; i < (n-3)*0.25;i++)
	{
		if(a[(int)(i + (n+1)*0.5)] != a[n-i-1])
			flag = 0;
	}
	}
	else
	{
	for(i = 0; i < (n-3)*0.25;i++)
	{
		if(a[i] != a[(int) ((n-3)*0.5 - i)])
			flag = 0;
	}
	
	for(i = 0; i < (n-3)*0.25;i++)
	{
		if(a[(int) (i + (n+1)*0.5)] != a[n-i-1])
			flag = 0;
	}
	}
	
	
	if(flag)
	{
		printf("Yes");
	}
	else printf("No");
}

Measured memory_bytes: 128
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<deque>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
const int mod=1e9+7;
const double eps=1e-6;
const double pi=acos(-1);
const int inf=0x7fffffff;
typedef long long int ll;
typedef unsigned long long ull;
using namespace std;

int a[100010];
ll jiecheng[100010];
int vis[100010];

void init(void)
{
    jiecheng[0]=jiecheng[1]=1;
    for(int i=2; i<=1e5+8; i++)
        jiecheng[i]=jiecheng[i-1]*i%mod;
}

ll qpow(ll x,ll y)
{
    ll res=1;
    while(y)
    {
        if(y&1)res=res*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return res;
}

ll c(int n,int k)
{
    if(k>n || k<0)return 0ll;
    if(k==n || k==0)return 1ll;
    ll res=qpow(jiecheng[k],mod-2ll);
    res=res*qpow(jiecheng[n-k],mod-2ll)%mod;
    res=res*jiecheng[n]%mod;
    return res;
}

int main()
{
    init();
    int n,xx;
    scanf("%d",&n);
    n++;
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        if(!vis[a[i]])vis[a[i]]=i;
        else xx=n-i+vis[a[i]]-1;
    }
    for(int i=1;i<=n;i++)
    {
        printf("%lld\n",(c(n,i)+mod-c(xx,i-1))%mod);
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
#define endl '\n'

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    vi d(4);
    REP(i, 3){
        int u, v;
        cin >> u >> v; u--; v--;
        d[u] ++; d[v] ++;
    }
    cout << (*max_element(ALL(d)) < 3 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> r(n);
	vector<pair<int, int>> b(n);

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

	for (int i = 0; i < n;i++) {
		int c, d;
		cin >> c >> d;
		b[i] = make_pair(c, d);
	}

	sort(r.begin(), r.end());
	sort(b.begin(), b.end());
	vector<bool> made_pair(n,false);
	int cnt = 0;
	for (int i = 0; i < n;i++) {
		int j_maxY = -1;
		int maxY = -1;
		for (int j = 0; j < n; j++) {
			
			if ( b[i].first > r[j].first) {
				if (!made_pair[j] && b[i].second > r[j].second) {
					if (maxY < r[j].second) {
						maxY = r[j].second;
						j_maxY = j;
					}
				}
			}
			else {
				break;
			}
		}
		
		if (maxY != -1) {
			cnt++;
			made_pair[j_maxY] = true;
		}
	}

	cout << cnt << endl;
}

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

aaa = {}
nums = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    if s in aaa.keys():
        aaa[s].append(p)
    else:
        aaa[s] = [p]
    nums.append(p)

for key in sorted(aaa.keys()):
    for num in sorted(aaa[key])[::-1]:
        print(nums.index(num) + 1)


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int N;
    cin >> N;
    vector<int> A(N, 0);
    rep(i, N) cin >> A[i];
    sort(all(A), greater<int>());

    int n       = A[0];
    int mi_diff = 2e9, r_ans = 0;
    for (int i = 1; i < N; i++) {
        int r    = A[i];
        int diff = abs(n / 2 - r);
        if (diff < mi_diff) {
            mi_diff = diff;
            r_ans   = r;
        }
    }
    cout << n << " " << r_ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//ll inf=1000000007;
const ll maxinput=3005;
const ll mod=998244353;
#define mp make_pair
ll n,mat[16][16],cost[(1<<16)+5]; //cost[i] is the money earned if mask i is in same group, if i=13 (1101) then cost i is the money if we have element 4,3,1 in same group
ll inf=100000000000000017;
ll dp[(1<<16)+5];//dp[i] contains the answer if we only have to solve the problem for mask i, that is given elements in mask what is the maximum profit if we divide the elements in mask in 1 or more number of group
ll getcost(ll mask)
{
    if(cost[mask]!=-inf)
        return(cost[mask]);

    ll temp=0;
    for(ll i=n-1;i>=0;i--)
    {
        if(mask&(1<<i))
        {
            ll maskwith_ithbit_off=mask^(1<<i);
            ll c1=getcost(maskwith_ithbit_off);
            for(ll j=0;j<i;j++)
            {
                if(maskwith_ithbit_off&(1<<j))
                    temp+=mat[i][j];
            }
            cost[mask]=temp+c1;
            return(cost[mask]);
        }
    }
}
ll maxprofit(ll mask)
{
    //cout<<mask<<"\n";
    if(__builtin_popcountll(mask)<=1)
        return(cost[mask]);

    if(dp[mask]!=-inf)
        return(dp[mask]);

    ll s=mask;
    ll temp=cost[mask];
    while(s>0)
    {
        s=(s-1)&mask;
        if(s==0)
            break;
        temp=max(temp,maxprofit(s)+maxprofit(s^mask));
    }
    dp[mask]=temp;
    return(temp);
}
int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            cin>>mat[i][j];

    for(ll i=0;i<(1<<16)+5;i++)
        cost[i]=-inf,dp[i]=-inf;
    for(ll i=0;i<(16);i++)
        cost[1<<i]=0;
    cost[0]=0;
    for(ll i=0;i<(1<<n);i++)
    {
        if(cost[i]==-inf)
            getcost(i);
    }
    //cout<<cost[(1<<n)-1];
    cout<<maxprofit((1LL<<n)-1)<<"\n";
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>
int main(void){
  char sentence[101],abb[5];
  int length,between;
  scanf("%s",sentence);
  length = strlen(sentence);
  between = length - 2;
  sprintf(abb,"%c%d%c",sentence[0],between,sentence[length-1]);
  printf("%s\n",abb);
  return 0;
}

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

a_sorted = sorted(a, reverse=True)
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 1:
        alice += a_sorted[i]
    else:
        bob += a_sorted[i]
print(abs(alice-bob))

Measured memory_bytes: 9036
#ifndef ___Class_BIT
#define ___Class_BIT
#include <cstdlib>
template <class Type>
class BIT {
private:
	int size_; Type *v;
	inline Type sum(int r) { Type ret = 0; while (r > 0) ret += v[r], r -= r & -r; return ret; }
public:
	BIT() {};
	BIT(int size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v = (Type *)malloc(sizeof(Type) * (size_ + 1));
		for (int i = 0; i <= size_; i++) v[i] = 0;
	}
	inline void add(int i, Type x) { i++; while (i <= size_) v[i] += x, i += i & -i; }
	inline Type sum(int l, int r) { return sum(r) - sum(l); }
};
#endif

#include <cstdio>
int n, q, c, x, y;
int main() {
	scanf("%d%d", &n, &q);
	BIT<int> b(n);
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d", &c, &x, &y);
		if (!c) b.add(x - 1, y);
		else printf("%d\n", b.sum(x - 1, y));
	}
	return 0;
}

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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

int cmp(int a, int b) {
    if (a == b) {
        return 0;
    }
    return a < b ? -1 : 1;
}

void solve() {
    int a, b, x;
    read(a, b, x);
    int c = (b / x) - (a / x);
    if (a % x == 0) c++;
    print(c);
    
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
//    read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
    }
    
}



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

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

class Dice{
private:
  int tmp;
public:
  int d[6];
 
  void rollN(){
    tmp = d[0];
    d[0] = d[1];
    d[1] = d[5];
    d[5] = d[4];
    d[4] = tmp;
  }
  
  void rollE(){
    tmp = d[0];
    d[0] = d[3];
    d[3] = d[5];
    d[5] = d[2];
    d[2] = tmp;
  }
 
  void rollS(){
    tmp = d[0];
    d[0] = d[4];
    d[4] = d[5];
    d[5] = d[1];
    d[1] = tmp;
  }
 
  void rollW(){
    tmp = d[0];
    d[0] = d[2];
    d[2] = d[5];
    d[5] = d[3];
    d[3] = tmp;
  }

  void rotation(){
    tmp = d[1];
    d[1] = d[3];
    d[3] = d[4];
    d[4] = d[2];
    d[2] = tmp;
  }

  int getRight(int top,int front){
    rep(i,3){
      rollN();
      if(top == d[0]){
        break;
      }
      rollW();
      if(top == d[0]){
        break;
      }
    }
    rep(i,3){
      if(front == d[1]){
        break;
      }
      rotation();
    }

    return d[2];
  }

  bool judge(Dice &D){
    rep(i,6){
      if(d[i] != D.d[i]){
        return false;
      }
    }
    return true;
  }

  bool equals(Dice &D){
    rep(i,3){
      rollN();
      if(d[0] == D.d[0]){
        break;
      }
      rollW();
      if(d[0] == D.d[0]){
        break;
      }
    }
    rep(i,4){
      if(judge(D)){
        return true;
      }
      rotation();
    }
    return false;
  }
};
 
int main(){
  int N;
  Dice dice[MAX];
 
  cin >> N;
  rep(i,N){
    rep(j,6){
      cin >> dice[i].d[j];
    }
  }

  bool ok = true;
  rep(i,N-1){
    for(int j = i+1 ; j < N ; j++){
      if(dice[i].equals(dice[j])){
        ok = false;
        goto end;
      }
    }
  }
 end:
  cout << (ok ? "Yes" : "No") << endl;
 
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = (1e9)+7;
#define all(v) v.begin(),v.end()
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

  int d, n;
  cin >> d >> n;
  if(n == 100){
    n ++;
  }
  cout << n;
  rep(i,d){
    cout << "00";
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()	
{
	int n,a,p=1,sum=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		if(a==p)
		{
			sum++;
			p++;
		}
	}
	if(sum)cout<<n-sum<<endl;
	else cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
n = int(input())
m = 1000000007
d = [[-1 for i in range(100000)] for j in range(2)]
v = [[] for j in range(100000)]

def f(x, c, p):
    if d[c][x] != -1: return d[c][x]
    d[c][x] = 1
    for i in v[x]:
        if i != p:
            t = f(i, 0, x)
            if c == 0: t += f(i, 1, x)
            t %= m
            d[c][x] = (d[c][x]*t)%m
    return d[c][x]

for i in range(n-1):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    v[x].append(y)
    v[y].append(x)
ans = (f(0, 0, -1) + f(0, 1, -1))%m
print(ans)


Measured memory_bytes: 101296
#include<iostream>
#include<string>
#include<stack>
#include<algorithm>
#include<queue>
#include<cmath>
#include<numeric>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<iomanip>
#include<functional>
#include<bitset>

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

using namespace std;
typedef long long ll;

int main(){
    int k;
    string s;
    cin>>k>>s;
    if(s.length() <=k){
        cout<<s<<endl;
    }
    else{
        s.erase(k);
        cout<<s<<"..."<<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  let [, s, , t] = content
    .trim()
    .split('\n')
    .map(line => line.split(' ').map(n => +n));
  
  // s is sorted
  let cnt = 0;
  for (let num of t) {
    if (binSearch(s, num) > -1) {
      cnt++;
    }
  }

  console.log(cnt);
});


const binSearch = (arr, n) => {
  let start = 0;
  let end = arr.length;
  while (start < end) {
    let mid = Math.floor((end + start) / 2);
    const num = arr[mid];
    if (num === n) {
      return mid;
    } else if (num < n) {
      start = mid + 1;
    } else {
      end = mid;
    }
  }

  return -1;
};


Measured memory_bytes: 31584
fn main() {
    let (h,w,k) = {
        let s = rv::<usize>();
        (s[0],s[1],s[2])
    };
    let mut f = vec![1;w+1];
    for i in 2..w+1 {
        f[i] = f[i-1]+f[i-2];
    }
    let mut dp = vec![vec![0;w];h+1];
    dp[0][0]=1;
    for i in 0..h {
        for j in 0..w {
            let s = dp[i][j]*f[j]*f[w-j-1];
            let l = if j>0 {dp[i][j-1]*f[j-1]*f[w-j-1]} else {0};
            let r = if j<w-1 {dp[i][j+1]*f[j]*f[w-j-2]} else {0};
            dp[i+1][j] = (s+l+r)%MOD;
        }
    }
    println!("{}",dp[h][k-1]);
}
const MOD: u64=1000000007;
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<long long> L(N+1);
  L.at(0)=2;
  L.at(1)=1;
  for(int i=2;i<N+1;i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  reverse(L.begin(),L.end());
  cout<<L.at(0)<<endl;
  return 0;
}

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

int main(){
	int n,c,i,j;
	bool a=false;
	cin >> n >> c;
	c /= 1000;
	for (i = 0; i <= n; i++) {
		for (j = 0; j <= n; j++) {
			if (((c - (10 * i) - (5 * j)) == n - j - i) && (n-j-i>=0)) {
					a = true; break;
			}
		}
		if (a == true) { break; }
	}
	if (a == true) { cout << i << " " << j << " " << n - i - j; }
	else {
		cout << "-1 -1 -1";
	}
	return 0;
}

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

const int MAX = 50;

//2D cumulative sum(座標は1-indexedであることに注意せよ)
int64_t sum[MAX][MAX];



int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    long double x;
    cin >> x;
    x *= 1e9;
    vec[i] = round(x);
  }
  
  vector<int> T(N);
  vector<int> F(N);
  
  //掛け算して10^18 = 2^18 * 5^18で割れれば良い
  
  for(int i=0; i<N; i++){
    int two = 0;
    int five = 0;
    int64_t x = vec[i];
    while(x %2 == 0){
      x /= 2;
      two++;
    }
    while(x %5 == 0){
      x /= 5;
      five++;
    }
    T[i] = two;
    F[i] = five;
    sum[two][five]++;
  }
  
  
  int64_t ans = 0;
  
  for(int i=0; i<N; i++){
    int64_t x = vec[i];
    for(int j=max(0,18-T[i]); j<MAX; j++){
      for(int k=max(0,18-F[i]); k<MAX; k++){
        ans += sum[j][k];
        if(j == T[i] && k == F[i]){
          ans--;
        }
      }
    }
  }
  
  cout << ans / 2 << endl;
  
}

Measured memory_bytes: 6500
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  map<int, int> okashi;
  
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      okashi[a] = 1;
    }
  }
  
  cout << N - okashi.size() << endl;
  
}

Measured memory_bytes: 3636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5;

template<class T> bool ckmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template <typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template <typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template <class X, class Y>
std::ostream & operator << (std::ostream & os, std::pair <X, Y> const& p) {
    return os << p.first << " " << p.second;
}

template <class Ch, class Tr, class Container>
std::basic_ostream <Ch, Tr> & operator << (std::basic_ostream <Ch, Tr>& os, Container const& x) {
    bool first = true;
    for(auto& y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CMonstersBattleRoyale {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vi A(n);
        in >> A;
        int res = accumulate(all(A), 0, [&](int x, int y) {
            return gcd(x, y);
        });
        out << res << '\n';
	}

	void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
	CMonstersBattleRoyale solver;
    solver.setup();
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) sort(v.begin(), v.end())
typedef long long ll;
using Graph = vector<vector<int>>;

int main(){
  int n;
  cin>>n;
  int cnt=0;
  rep(i,n){
    int a;
    int b;
    cin>>a>>b;
    if(a==b){
      cnt++;
    }else{
      cnt=0;
    }
    if(cnt==3){
      cout<<"Yes"<<endl;
      exit(0);
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3628