akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

#define MAX 2000000
#define INFINITY (1<<30)

class PriorityQueue
{
    long long H[MAX + 1];
    int size;

public:
    PriorityQueue()
    {
        size = 0;
    }

    void insert(long long k)
    {
        size++;
        H[size] = -INFINITY;
        heapIncreaseKey(size, k);
    }

    void heapIncreaseKey(int i, long long k)
    {
        if(H[i] > k)
        {
            return;
        }

        H[i] = k;

        while(i > 1 && H[i] > H[i / 2])
        {
            swap(H[i],H[i/2]);
            i = i / 2;
        }
    }

    long long extractMax()
    {
        if (size < 1)
        {
            return -INFINITY;
        }

        long long max = H[1];
        H[1] = H[size];
        size--;
        maxHeapify(1);
        return max;
    }

    void maxHeapify(int i)
    {
        int l, r, largest;

        l = i * 2;
        r = i * 2 + 1;

        largest = i;

        if (l <= size &&  H[l] > H[i])
        {
            largest = l;
        }

        if (r <= size &&  H[r] > H[largest])
        {
            largest = r;
        }

        if (largest != i)
        {
            swap(H[i],H[largest]);
            maxHeapify(largest);
        }
    }
};

int main()
{
    PriorityQueue *pq = new PriorityQueue();

    string message;

    while (cin >> message)
    {
        //cout << message << endl;

        if (message == "end")
        {
            break;
        }

        if (message == "insert")
        {
            long long key;
            cin >> key;
            pq->insert(key);
        }
        else if (message == "extract")
        {
            cout << pq->extractMax() << endl;
        }
    }
}


Measured memory_bytes: 10944
import re
import copy
pattern = r'([0-9])'
repatter = re.compile(pattern)

n = int(input())
text = input()

*lists, = text.split(" ")
lists2 = copy.copy(lists)
lists3 = copy.copy(lists)


# バブルソート
def bubble_sort(a):
    flag = 1
    i = 0
    while flag:
        flag = 0
        for j in range(n-1, i, -1):
            x = repatter.findall(a[j])
            y = repatter.findall(a[j-1])
            if x < y:
                a[j], a[j-1] = a[j-1], a[j]
                flag = 1
        i += 1
    print(*a)
    print("Stable")


# 選択ソート
def select_sort(a):
    for i in range(n):
        min_j = i
        for j in range(i+1, n):
            x = repatter.findall(a[j])
            y = repatter.findall(a[min_j])
            if x < y:
                min_j = j
        a[i], a[min_j] = a[min_j], a[i]
    print(*a)


def isStable(before, after):
    flag = True
    for i in range(n):
        for j in range(i+1, n):
            for a in range(n):
                for b in range(a+1, n):
                    x = repatter.findall(before[i])
                    y = repatter.findall(before[j])
                    if x == y and before[i] == after[b] and before[j] == after[a]:
                        flag = False
    if flag is True:
        print("Stable")
    else:
        print("Not stable")


bubble_sort(lists)
select_sort(lists2)
isStable(lists3, lists2)


Measured memory_bytes: 6600
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <map>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

using namespace std;

using ll = long long;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;
typedef vector<int> IntVector;
typedef list<int> IntList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  int a, b;
  cin >> a >> b;
  
  if(a < b){
    for(int i=0;i<b;i++){
      cout << a;
    }
  }else{
    for(int i=0;i<a;i++){
      cout << b;
    }
  }
  
  cout << endl;
}

Measured memory_bytes: 256
program swap_and_flip
  implicit none
  integer, parameter :: inf = 1e9
  integer :: n, a(18) = 0, b(18) = 0, i, j, k, x, y, u, v
  integer, allocatable :: dp(:,:)
  read(*,*) n
  read(*,*) a(1:n)
  read(*,*) b(1:n)
  u = lshift(1,n)-1
  allocate(dp(0:u,0:50))
  dp = inf
  dp(0,0) = 0
  do k = 0, u
    do i = 1, 50
      dp(k,i) = min(dp(k,i),dp(k,i-1))
    end do
    x = popcnt(k)
    do i = 1, n
      if (btest(k,i-1)) cycle
      if (modulo(x-i+1,2) == 1) then
        v = b(i)
      else
        v = a(i)
      end if
      y = popcnt(rshift(k,i-1))
      j = ibset(k,i-1)
      dp(j,v) = min(dp(j,v),dp(k,v)+y)
    end do
  end do
  x = minval(dp(u,:))
  if (x == inf) x = -1
  write(*,'(i0)') x
end program swap_and_flip

Measured memory_bytes: 52480
#include<stdio.h>

int main(void)
{
    int x, y;
    
    while (1) {
        scanf("%d %d", &x, &y);
        
        if ( x == 0 && y == 0)
            break;
        if ( x <= y)
            printf("%d %d\n", x, y);
        else
            printf("%d %d\n", y, x);
    }
}


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

using namespace std;

int main()
{
	char x, y;
	int xNum, yNum;
	cin >> x >> y;
	xNum = x - 'A';
	yNum = y - 'A';
	if (xNum < yNum)
	{
		cout << "<";
	}
	else if (xNum > yNum)
	{
		cout << ">";
	}
	else
	{
		cout << "=";
	}
	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static int Main()
    {
        string[] inp = Console.ReadLine().Split(' ');
        int a = int.Parse(inp[0]), b = int.Parse(inp[1]);
        Console.WriteLine((b + (b % a == 0 ? a : -a)).ToString("d"));
        return 0;
    }
}

Measured memory_bytes: 11092
/*************************************************************************
    > File Name: 3.cpp
    > Author: cy
    > Mail: 1002@qq.com 
    > Created Time: 15/5/13 20:28:00
 ************************************************************************/

#include<iostream>
#include<cstring>
#include <algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>

const int maxn=1000+5;

#define inf 0x3f3f3f3f
  #define INF 0x3FFFFFFFFFFFFFFFLL
#define rep(i,n) for(i=0;i<n;i++)
 #define reP(i,n) for(i=1;i<=n;i++)

#define ull unsigned long long
 #define ll long long

#define cle(a) memset(a,0,sizeof(a))

using namespace std;
int n,m;
struct node
{
	int be,en;
}tree[maxn];
vector<node>V;
void init(){
	V.clear();
}
bool cmp(node a,node b){
	return a.be<b.be;
}
void doit(){
	node a;
	V.push_back(tree[0]);
    for(int i=1;i<m;i++){
		a=V[V.size()-1];
		if(tree[i].en>a.en&&tree[i].be<=a.en){
			a.en=tree[i].en;
		V[V.size()-1]=a;
		}
		else if(tree[i].be>a.en){
			V.push_back(tree[i]);
		}
	}
}
ll ans;
ll work(){
	int now=0;
	ans=0;
	int len=V.size();
	for(int i=0;i<len;i++)
	{
		ans+=(V[i].en-now);
		ans+=(2*(V[i].en-V[i].be));
		now=V[i].en;
	}
	ans+=(n+1-now);
	return ans;
}
int main()
{
#ifndef ONLINE_JUDGE
     //freopen("in.txt","r",stdin);
     //freopen("out.txt","w",stdout);
#endif
    while(cin>>n>>m){
		init();
	    for(int i=0;i<m;i++){
			cin>>tree[i].be>>tree[i].en;
		}
		sort(tree,tree+m,cmp);
		doit();
		work();
		cout<<ans<<endl;
	}	
    return 0;
}

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

int MOD;

int main(void){
    lint K;
    cin >> K;
    MOD=K;
    lint ten[K+100]={};
    ten[0]=1;
    for(int i=1;i<=K+20;i++) ten[i]=(ten[i-1]*10)%MOD;
    if(K%2==0) cout << -1 << endl;
    else{
        int ans=1;
        lint div=7%K;
        while(true){
            if(div==0) break;
            div=(div+ten[ans]*7)%MOD;
            ans++;
            if(ans>=K+1){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << ans << endl;
    }
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI p(n);
	rep(i, n) cin >>p[i];
	int ans=0, cr=1<<28;
	rep(i, n){
		if(p[i] < cr) ans++;
		cr = min(cr, p[i]);
	}
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
set<int>s;
int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        if(k>=1&&k<=399)
            s.insert(1);
        else if(k>=400&&k<=799)
            s.insert(2);
        else if(k>=800&&k<=1199)
            s.insert(3);
        else if(k>=1200&&k<=1599)
            s.insert(4);
        else if(k>=1600&&k<=1999)
            s.insert(5);
        else if(k>=2000&&k<=2399)
            s.insert(6);
        else if(k>=2400&&k<=2799)
            s.insert(7);
        else if(k>=2800&&k<=3199)
            s.insert(8);
        else ans++;
    }
    if(s.size()==0&&ans)
    {
        printf("1 %d\n",ans);
        return 0;
    }
    printf("%d %d\n",s.size(),s.size()+ans);
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC150
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] P = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] Q = Console.ReadLine().Split().Select(int.Parse).ToArray();

            //int[] A = new int[(int)Math.Pow(N, N)];
            long resP = 0;
            long resQ = 0;

            int[] existP = new int[N + 10];
            int[] existQ = new int[N + 10];
            for (int i = 0; i < N - 1; i++)
            {
                long count = 0;
                existP[P[i]] = 1;
                for (int j = 0; j < N; j++)
                {
                    if (j < P[i] && 0 < existP[j]) count++;
                }
                if (count == 0) resP += Factorial((N - 1) - i) * (P[i] - 1);
                else resP += Factorial((N - 1) - i) * (P[i] - 1 - count);

                count = 0;
                existQ[Q[i]] = 1;
                for (int j = 0; j < N; j++)
                {
                    if (j < Q[i] && 0 < existQ[j]) count++;
                }
                if (count == 0) resQ += Factorial((N - 1) - i) * (Q[i] - 1);
                else resQ += Factorial((N - 1) - i) * (Q[i] - 1 - count);
            }
            Console.WriteLine(Math.Abs(resP - resQ));
        }

        public static long Factorial(int n)
        {
            if (n == 0)
                return 1L;
            return n * Factorial(n - 1);
        }

    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

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

		 str = scan.nextLine();
		 p =  scan.nextLine();
		 str = str+str;
				
				if(str.lastIndexOf(p)==-1){
					System.out.println("No");
				}else{
					System.out.println("Yes");
				}

	}
}

Measured memory_bytes: 26196
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <math.h>

int main(void) {
	int a, b, lC;
	double lS, lL, h;
	double cRad;

	scanf("%d %d %d", &a, &b, &lC);
	cRad = lC / 180.0 * M_PI;

	lS = a * b * sin(cRad) / 2;
	lL = a + b + sqrt(a * a + b * b - 2 * a * b * cos(cRad));
	h = 2 * lS / a;

	printf("%f\n%f\n%f\n", lS, lL, h);
	return 0;
}

Measured memory_bytes: 2996
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();
        String ans = "";
        int[] a = new int[n];
        int[] b = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum += a[i];
        }
        Arrays.sort(a);
        for (int i = 0; i < n; i++) {
            b[n - 1 - i] = a[i];
        }

        double mi = Double.parseDouble(Integer.toString(b[m-1]));
        double sumi = Double.parseDouble(Integer.toString(sum));
        double m4 = 4 * m;
        if (mi < sumi / m4) {
            ans = "No";
        } else {
            ans = "Yes";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

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


void solve()
{
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll i;
    for(i=0;i<n;i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No\n";
            return;
        }
    }
    cout<<"Yes\n";
    return;
}


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s; cin >> s;
  int l = 0, r = s.size()-1;
  while(s[l] != 'A')l++;
  while(s[r] != 'Z')r--;
  cout << r-l+1 << endl;
  system("pause");
}

Measured memory_bytes: 764
#include <stdio.h>

int main(){
 char str[20], str2[20];
 int i=0, j=0;
 scanf("%s", str);
 while( str[i] != '\0'){
 	i++;
 }

 while( i >= 0){
   str2[j++] = str[--i];
 }
 str2[j-1] = '\0';
 printf("%s\n", str2);

 return 0;
}

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

using namespace std;

int main()
{

    int n;

    cin>>n;

    int v[n],c[n],r=0;


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

        r=r+max(0,v[i]-c[i]);
    }

    cout<<r<<endl;

    return  0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define _n "\n"



void Main()
{
	int X,N;
	cin>>X>>N;
	int ue=X,sita=X;
	if(N==0){
		cout<<X<<_n;
		return;
	}
	vec(v,N);
	vin(v);
	sort(all(v));
	rep(i,N){
		if(ue==v[i]) ue++;
	}
	int i = X;
	while(i--){
		int t=v[i];
		if(sita==t) sita--;
	}
	dout<<"ue:"<<ue<<"sita"<<sita<<_n;
	if((ue-X)>=(X-sita))cout<<sita<<_n;
	else cout<<ue<<_n;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/perl

my ($x,$k,$d) = map { $_ - 0 } split(/\s+/,<STDIN>);

if( $x < 0 ){
  $x = - $x ;
}

my $t = $x % $d;

if( $t == 0 ){
  my $t2 = $x / $d;
  if( $t2 <= $k ){
    if( ( $t2 % 2 ) == ( $k % 2 ) ){
      print "0\n";
    } else {
      print "$d\n";
    }
    exit(0);
  }
  my $v = abs($x - $d * $k);
  print "$v\n";
} else {
  my $v1 = $t;
  my $v2 = abs($t - $d);
  
  my $c1 = ( $x - $t ) / $d;
  
  if( $c1 <= $k ){
    if( ( $c1 % 2 ) == ( $k % 2 ) ){
      print "$v1\n";
    } else {
      print "$v2\n";
    }
  } else {
    my $v = abs($x - $d * $k);
    print "$v\n";
  }
  
}

exit(0);



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

const int maxn = 100100;
vector<int> g[maxn];

void fail() {
  cout << "No\n";
  exit(0);
}

bool dfs(int u, int b, int e, int prev = -1) {
  if (u == e) {
    return false;
  }
  if (u == b && prev != -1) {
    return true;
  }
  for (int v : g[u]) {
    if (v == prev) {
      continue;
    }
    if (dfs(v, b, e, u)) {
      return true;
    }
  }
  return false;
}

signed main() {
#ifdef LOCAL
  assert(freopen("c.in", "r", stdin));
#endif
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int d = 0;
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    if ((int) g[i].size() % 2 != 0 || g[i].empty()) {
      fail();
    }
    int w = (int) g[i].size() / 2 - 1;
    d += w;
    if (w > 0) {
      a.push_back(i);
    }
  }
  if (d == 2 && (int) a.size() == 2) {
    if (!dfs(a[0], a[0], a[1])) {
      fail();
    }
  }
  if (d < 2) {
    fail();
  }
  cout << "Yes\n";
}


Measured memory_bytes: 7296
S = input()[::-1]
T = input()[::-1]

for k in range(1+len(S)-len(T)):
    f = len(T)
    for j in range(len(T)):
        if S[k+j]==T[j] or S[k+j]=="?":
            f-=1
    if f==0:
        print((S[:k]+T+S[k+len(T):]).replace("?","a")[::-1])
        exit(0)

print("UNRESTORABLE")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define ll long long int 
#define gof for(long long int i = 0 ; i < n ; i++)
#define for1(i,s,e) for(long long int i = s ; i < e ; i++)
#define mkar(a,n) long long int *a = NULL; a = new long long int [n];

ll dp[3001][3001][2];
ll a[3000];
ll solve(ll i, ll j, ll who){

	if(i>j){
		return 0;
	}

	if(dp[i][j][who] != -1){
		return dp[i][j][who];
	}

	if(who == 0){
		dp[i][j][who] = max(solve(i+1,j,who+1)+a[i],solve(i,j-1,who+1)+a[j]);
	}

	else{
		dp[i][j][who] = min(solve(i + 1, j, who - 1) - a[i], solve(i, j - 1, who - 1) - a[j]);
	}

	return dp[i][j][who];
}
int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	for1(i,0,3001){
		for1(j,0,3001){
			dp[i][j][0] = -1;
			dp[i][j][1] = -1;
		}
	}
	ll n;
	cin >> n;
	gof cin >> a[i];
	cout << solve(0,n-1,0) << endl;
	return 0;
}

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

print(sum(n for n in range(1, N+1) if n % 3 != 0 and n % 5 != 0))
"""
n3 = (N // 3)
n5 = (N // 5)
n15 = (N // 15)

total = N * (N+1) // 2
print(total, n3, n5, n15)
print(total - n3 - n5 + n15)
"""


Measured memory_bytes: 9096
def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()


def main():
    N= iRaw()
    ans = (N+1)//2
    return ans



if __name__ == "__main__":
    print(main())


Measured memory_bytes: 38384
#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>>;
const int mod = 1000000007;

int main()
{
  int k, n;
  cin >> n >> k;
  //vector<int> A(n);
  vector<int> cnt(200001);
  int max = 0;
  rep(i, n)
  {
    int a;
    cin >> a;
    if (a > max)
    {
      max = a;
    }
    cnt.at(a)++;
  }
  all(cnt);
  reverse(cnt.begin(), cnt.end());
  int ans = 0;
  for (int i = k; i <= max; i++)
  {
    ans += cnt.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4032
#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 Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll a,b;
	cin >> a >> b;
	cout << 6-a-b << endl;
    return 0;
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int a = ri();
	int b = ri();
	int res;
	if (a >= 13) res = b;
	else if (a >= 6) res = b / 2;
	else res = 0;
	std::cout << res << std::endl;
	return 0;
}


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

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

void main() {
    int K, T; scanf("%d %d\n", &K, &T);
    auto A = readln.chomp.split(" ").map!(to!int).array;
    BinaryHeap!(Array!int, "a < b") Q;
    foreach (a; A) Q.insert(a);
    while (Q.length >= 2) {
        auto x = Q.front; Q.popFront;
        auto y = Q.front; Q.popFront;
        Q.insert(x - y);
    }
    writeln(max(0, Q.front - 1));
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
long long int n,c,k,t[100001],ans;
queue <long long int> wtd;
int main(){
	scanf("%lld %lld %lld",&n,&c,&k);
	for(int i=0;i<n;++i)
	scanf("%lld",t+i);
	sort(t,t+n);
	wtd.push(t[0]);
	for(int i=1;i<n;++i){
		if(t[i]-wtd.front()>k){			
			while(!wtd.empty()&&t[i]-wtd.front()>k){
				++ans;
				for(long long i=0;i<c&&!wtd.empty();++i)
				wtd.pop();
			}
		}
		wtd.push(t[i]);
	}
	while(!wtd.empty()){
				++ans;
				for(long long i=0;i<c&&!wtd.empty();++i)
				wtd.pop();
			}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){

int N, M, ma = 100001, mi = 0, l, r;
  cin >> N >> M;

  
  for(int i = 0;i < M;i++){
  cin >> l >> r;
    mi = max(mi, l);
    ma = min(ma, r);
  }

  
  if(mi <= ma) cout << ma - mi + 1 << endl;
  else cout << 0 << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

mat memo;
vec a;
ll f (ll L, ll R) {
    if (L == R) return memo[L][R] = 0;
    if (memo[L][R] != -1) return memo[L][R];
    ll tmp = inf;
    for (ll i = L; i < R; i++) {
        chmin(tmp, f(L, i) + f(i+1, R));
    }

    for (ll i = L; i <= R; i++) {
        tmp += a[i];
    }

    return memo[L][R] = tmp;
}

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

    ll N;
    cin >> N;
    a.assign(N, 0);
    Rep (i, N) {
        cin >> a[i];
    }

    memo.assign(N, vec(N, -1));

    cout << f(0, N-1) << endl;

}

Measured memory_bytes: 4500
N, Ma, Mb = map(int, input().split())
Items = [list(map(int, input().split())) for i in range(N)]

# dp[i][a][b] := i個目の薬品までで薬品Aがaグラム、薬品Bがbグラムの混合液を作るために必要な最小予算
dp = [[[float('inf')] * 401 for j in range(401)] for i in range(N + 1)]
dp[0][0][0] = 0

for i in range(N):
    ai, bi, ci = Items[i]
    for a in range(401):
        for b in range(401):
            if a + ai <= 400 and b + bi <= 400:
                dp[i + 1][a + ai][b + bi] = min(dp[i][a][b] + ci, dp[i + 1][a + ai][b + bi])
            dp[i + 1][a][b] = min(dp[i][a][b], dp[i + 1][a][b])

ans = float('inf')
i = 1
while Ma * i <= 400 and Mb * i <= 400:
    ans = min(ans, dp[N][Ma * i][Mb * i])
    i += 1

print(ans if ans != float('inf') else -1)


Measured memory_bytes: 135644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;


//System.out.println();
public class Main implements Runnable { //クラス名はMain

    public static void main(String[] args) {
    	Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    public void run() {
    	try {
	    	FastScannerMain3 sc = new FastScannerMain3(System.in);
	        int N = sc.nextInt();
	        int[] X = new int[100];

	        for(int i =0 ; i< N; i ++) {
	        	X[i] = sc.nextInt();
	        }

	        int[] sum = new int[100];
	        for(int p =0 ; p< 100; p ++) {
	        	sum[p] = 0;
	        	for(int k =0 ; k < N; k ++) {
	        		sum[p] += Math.abs(X[k] - (p+1)) * Math.abs((X[k] - (p+1)));
	        		//System.out.println(p + " , " + k + " " + Math.abs(X[k] - (p+1)) * Math.abs((X[k] - (p+1))));
		        }
	        	//System.out.println(sum[p]);
	        }

	        //System.out.println(Arrays.toString(sum));
	        System.out.println(Arrays.stream(sum).min().getAsInt());


    	}catch(Exception e) {
    		e.printStackTrace();
    	}

    }
}


//高速なScanner
class FastScannerMain3 {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMain3(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N;
    cin >> N;
    vector<ll> A;
    REP(i, 1 << N)
    {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    REP(i, N)
    {
        vector<ll> B;
        REP(j, A.size() / 2)
        {
            ll a = A[2 * j];
            ll b = A[2 * j + 1];
            if (a == b)
                B.push_back(a);
            else if (a > b)
                B.push_back(a - b);
            else
                B.push_back(b - a);
        }
        swap(A, B);
    }
    cout << A[0] << endl;
    return 0;
}

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

import static java.lang.System.in;

class Main{
    static int N;
    static long[] sum;
    public static void main(String[] args)throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String temp = reader.readLine();
        N = Integer.parseInt(temp.split(" ")[0]);
        sum = new long[N+1];
        temp = reader.readLine();
        String[] buf = temp.split(" ");
        for(int i=1;i<=N;i++) sum[i] = sum[i-1]+Long.parseLong(buf[i-1]);
        long ans = Long.MAX_VALUE;
        for(int i=2;i<=N-2;i++){
            long difLeft = halfClo(1,i);
            long P = (sum[i]+difLeft)/2;
            long Q = (sum[i]-difLeft)/2;
            long difRight = halfClo(i+1,N);
            long R = (sum[N]-sum[i]+difRight)/2;
            long S = (sum[N]-sum[i]-difRight)/2;
            long[] cur = new long[]{P,Q,R,S};
            Arrays.sort(cur);
            ans = Math.min(ans,cur[3]-cur[0]);
        }
        System.out.println(ans);
    }
    static long halfClo(int left, int right){
        long hi = sum[right]-sum[left-1];
        long lo = 0;
        while(hi-lo>1){
            long mid = (hi+lo)/2;
            if(check(left,right,mid)) hi = mid;
            else lo = mid;
        }
        return hi;
    }
    static boolean check(int left, int right, long target){
        long all = sum[right]-sum[left-1];
        int hi = right-1;
        int lo = left;
        while(hi-lo>1){
            int mid = (hi+lo)/2;
            long cur = sum[mid]-sum[left-1];
            if(2*cur>=all-target&&2*cur<=all+target) return true;
            if(2*cur<all-target) lo = mid;
            else hi = mid;
        }
        boolean b1 = 2*(sum[hi]-sum[left-1])>=all-target&&2*(sum[hi]-sum[left-1])<=all+target;
        boolean b2 = 2*(sum[lo]-sum[left-1])>=all-target&&2*(sum[lo]-sum[left-1])<=all+target;
        return b1||b2;
    }
}


Measured memory_bytes: 52768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] pixel = new String[h];

		for (int i = 0; i < h; i++) {
			pixel[i] = sc.next();
			System.out.println(pixel[i]);
			System.out.println(pixel[i]);
		}

	}

}


Measured memory_bytes: 24276
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;


int32_t main()
{
   
   
    crap;
    
     string s; 
     cin>>s;
     int a=0,b=0;
     for(int i=0;i<3;i++){
      if(s[i]=='A' ){
        a = 1;
      }
      else if(s[i]=='B')
        b = 1;
     }
     if(a==1 && b==1) cout<<"Yes"<<endl;
     else cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 7,Len = 4000 + 10,mod = 998244353;

char str[Len];
typedef bitset <Len> Bs;
bool X[Len],A[N][Len],Gcd[Len],cur[Len],Mul[Len];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void Getstr(bool S[]) {
	scanf("%s",str);
	int len = strlen(str);
	reverse(str,str + len);
	For(i,0,len - 1) S[i] = str[i] - '0';
}

inline int Length(bool a[]) {
	Fordown(i,Len - 1,0) if(a[i]) return i;
	return 0;
}

inline void Plus(bool a[],bool b[],int Delta) {
	For(i,Delta,Len - 1) a[i] = a[i] ^ b[i - Delta];
}

inline void gcd(bool a[],bool b[],bool c[]) {
	int Lena = Length(a),Lenb = Length(b);
	if(Lena < Lenb) swap(a,b),swap(Lena,Lenb);
	if(Lenb == 0 && b[0] == 0) { For(i,0,Len - 1) c[i] = a[i]; return; }
	Plus(a,b,Lena - Lenb);
	gcd(b,a,c);
}

int main() {
	int n = read();Getstr(X);
	For(i,1,n) Getstr(A[i]);
	For(i,1,n) {
		For(j,0,Length(Gcd)) cur[j] = Gcd[j];
		gcd(A[i],cur,Gcd);
	}
	int ans = 0,LenG = Length(Gcd);
	Fordown(i,Length(X),LenG) ans = ((ans << 1) + X[i]) % mod;
	Fordown(i,Length(X),LenG) if(Mul[i] ^ X[i]) Plus(Mul,Gcd,i - LenG);

	Fordown(i,LenG - 1,0) {
		if(Mul[i] < X[i]) break;
		if(Mul[i] > X[i]) { ans--;break; }
	}

	printf("%d\n",ans + 1);

	return 0;
}

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

using namespace std;

int n, u[30005];
vector <int> ans;

int main(){
      cin >> n;

      if(n == 3){
            cout << "2 5 63";
            return 0;
      }

      int odd = 15;

      ans.push_back(3);
      ans.push_back(9);
      n -= 2;
      if(n % 3 == 1){
            n -= 2;
            ans.push_back(15);
            ans.push_back(21);
            odd = 27;
      }

      for(int i = 2; i <= 30000; i += 2){
            if(n > 0){
                  ans.push_back(i);
                  n --;
            }
      }

      if(n % 2){
            n ++;
            ans.pop_back();
      }

      while(n > 0){
            ans.push_back(odd);
            ans.push_back(odd + 6);
            odd += 12;
            n -= 2;
      }

      for(auto i : ans)
            cout << i << " ";
}


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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=1e7+50, mod=1e9+7;
inline int add(int x,int y) {return (x+y>=mod) ? (x+y-mod) : (x+y);}
inline int dec(int x,int y) {return (x-y<0) ? (x-y+mod) : (x-y);}
inline int mul(int x,int y) {return (long long)x*y%mod;}
inline int power(int a,int b,int rs=1) {for(;b;b>>=1,a=mul(a,a)) if(b&1) rs=mul(rs,a); return rs;}
int X[7],Y[7],ans;
struct binom {
	int fac[N],ifac[N];
	binom() {
		fac[0]=1;
		for(int i=1;i<N;i++) fac[i]=mul(fac[i-1],i);
		ifac[N-1]=power(fac[N-1],mod-2);
		for(int i=N-2;~i;i--) ifac[i]=mul(ifac[i+1],i+1);
	}
	inline int C(int a,int b) {return mul(fac[a],mul(ifac[b],ifac[a-b]));}
} C;

inline int path0(int x,int y) {
	int in=C.C(y-Y[1]+x-X[1]+2,y-Y[1]+1)-C.C(y-Y[1]+x-X[2]+1,y-Y[1]+1);
	in=((LL)in-C.C(y-Y[2]+x-X[1]+1,y-Y[2])+C.C(y-Y[2]+x-X[2],y-Y[2]))%mod;
	return (in%mod+mod)%mod;
}
inline int path1(int x,int y) {
	int out=C.C(Y[6]-y+X[6]-x+2,Y[6]-y+1)-C.C(Y[6]-y+X[5]-x+1,Y[6]-y+1);
	out=((LL)out-C.C(Y[5]-y+X[6]-x+1,Y[5]-y)+C.C(Y[5]-y+X[5]-x,Y[5]-y))%mod;
	return (out%mod+mod)%mod;
}
int main() {
	for(int i=1;i<=6;i++) cin>>X[i];
	for(int i=1;i<=6;i++) cin>>Y[i];
	for(int i=X[3];i<=X[4];i++) {
		int v=mul(path0(i,Y[3]-1),path1(i,Y[3]));
		ans=dec(ans,mul(i-X[3]+1,v));
	}
	for(int i=Y[3];i<=Y[4];i++) {
		int v=mul(path0(X[3]-1,i),path1(X[3],i));
		ans=dec(ans,mul(i-Y[3]+1,v));
	}
	for(int i=X[3];i<=X[4];i++) {
		int v=mul(path0(i,Y[4]),path1(i,Y[4]+1));
		ans=add(ans,mul(i-X[3]+1+Y[4]-Y[3]+1,v));
	}
	for(int i=Y[3];i<=Y[4];i++) {
		int v=mul(path0(X[4],i),path1(X[4]+1,i));
		ans=add(ans,mul(i-Y[3]+1+X[4]-X[3]+1,v));
	}
	cout<<ans<<'\n';
}


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

ll maxima(ll W, ll wt[], ll val[], ll n)
{
   ll i, w;
   ll K[n+1][W+1];

   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }

   return K[n][W];
}

int main(){
 ll n,w;
 cin>>n>>w;
 ll weight[n], value[n];
 for(ll i=0; i<n; i++){
    cin>>weight[i]>>value[i];
 }

 cout<<maxima(w, weight, value, n);
 return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
  int n;

  cin >> n;

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

  sum  /= n;

  long long ans = 0,temp = 0;
  for(int i = 0;i < n;i++) {
    ans += (x[i] - sum) * (x[i] - sum);
  }
  sum++;
  for(int i = 0;i < n;i++) {
    temp += (x[i] - sum) * (x[i] - sum);
  }

  if(ans > temp) ans = temp;

  sum -= 2;

  for(int i = 0;i < n;i++) {
    temp += (x[i] - sum) * (x[i] - sum);
  }

  if(ans > temp) ans = temp;

  cout << ans << endl;

  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <iterator>
#include <list>
#include <stack>
#include <queue>
#include <cstdlib>
using namespace std;

int main()
{
    string a,b,c;
    cin >> a >> b;
    int flag = 0;
    for(int i = 0;i < 3;i++)
    {
        if(a[i] != b[2-i])
        {
            flag = 1;
            break;
        }
    }
    if(flag == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

#define SIZE 200010

int main(){
    int i,j,k;
    char array[SIZE];
    long long sum=0;

    scanf("%s",array);

    j = 0;
    for(i=0;array[i]!='\0';i++){
        if(array[i]=='W'){
            sum += (i-j);
            j++;
        }
    }
    
    printf("%lld",sum);

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fort(i,a,n) for(i=a;i<=n;i++)
#define ford(i,n,a) for(i=n;i>=a;i--)
typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned long long ull;
const int N=3e5;
ll n,m,i,l,r,mid,anss,a[N],bo;
ll pd(ll k)
{
	ll i,l,r,mid,ans;
	ans=0;
	fort(i,1,n)
	{
		if (a[i]<0)
		{
			l=i+1; r=n;
			bo=i;
			while (l<=r)
			{
				mid=(l+r)/2;
				if (a[mid]*a[i]>=k)
				{
					l=mid+1;
					bo=mid;
				} else r=mid-1;
			}
			ans+=n-bo;
		} else {
			l=i+1; r=n;
			bo=i;
			while (l<=r)
			{
				mid=(l+r)/2;
				if (a[mid]*a[i]<k)
				{
					l=mid+1;
					bo=mid;
			    }else {
			    	r=mid-1;	
			    }
			}
			ans+=bo-i;
		}
	}
	return ans;
}//how many small
int main()
{
	cin>>n>>m;
	fort(i,1,n) 
	  scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	l=-1e18; r=1e18;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (pd(mid)<m)
		{
			l=mid+1;
			anss=mid;
		} else r=mid-1;
	}
	cout<<anss<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
//素数判定
bool prime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
ll a[114514], b[114514], c[114514];
//i日目にjを選んだ時の最大の幸福度
ll dp[114514][3];
signed main() {
	ll n;
	cin >> n;
	rep(i, n)cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
	for (int i = 1; i < n; i++) {
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	cout << max({ dp[n - 1][0],dp[n - 1][1],dp[n - 1][2] }) << endl;
	ggr
}


Measured memory_bytes: 5376
import java.util.*;

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

        int n = sc.nextInt();

        int[] p = new int[n];
        int maxIndex = 0;
        for (int i = 0; sc.hasNext(); i++) {
            p[i] = sc.nextInt();
            if (p[i] > p[maxIndex]) {
                maxIndex = i;
            }
        }

        int out = p[maxIndex] / 2;
        p[maxIndex] = 0;

        System.out.println(Arrays.stream(p).sum() + out);
    }
}

Measured memory_bytes: 28500
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, pair<ll, ll> > p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int x;
    cin >> x;

    if(x >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3684
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()
    if(s.length + 1 == t.length && s == t.substring(0, t.length-1)) println("Yes") else println("No")
}

fun abc000b() {
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 36432
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    cin >> A >> B;
    
    if(A == 1){
        A = 13;
    }
    else{
        A--;
    }
    
    if(B == 1){
        B = 13;
    }
    else{
        B--;
    }
    
    
    if(A == B){
        cout << "Draw" << endl;
    }
    else if(A > B){
        cout << "Alice" << endl;
    }
    else{
        cout << "Bob" << endl;
    }

}

Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N = I()
d = set()
for i in range(N):
  d.add(I())
print(len(d))

Measured memory_bytes: 38256
/*A - Frog 1*/
#include <bits/stdc++.h>
using namespace std;
using Long = long long;

Long minCost(const vector <Long>& altura, int pos);
vector <Long> memo(1e5, -1);

int main(){

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

	int tam;

	cin >> tam;

	vector <Long> altura(tam);

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

	cout << minCost(altura, 0);

	return 0;
}

Long minCost(const vector <Long>& altura, int pos){

	if(pos == altura.size() - 1){
		return 0;
	}

	if(memo[pos] == -1){

		Long aux;

		aux = abs(altura[pos] - altura[pos + 1]) + minCost(altura, pos + 1);

		if(pos + 2 < altura.size()){
			aux = min(aux, abs(altura[pos] - altura[pos + 2]) + minCost(altura, pos + 2));
		}

		memo[pos] = aux;
	}

	return memo[pos];
}

Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(){
  
  int n,x,t;
  int i;
  int a;
  
  cin>>n>>x>>t;
  
  for(i=1;i<1000;i++){
    a=x*i;
    if(a>=n){
      break;
    }
  }
  cout<<i*t;
  
  return 0;
}


Measured memory_bytes: 3172
N,*A=`dd`.split.map &:to_i
h=Hash.new 0
A.each{|e|h[2.downto(0).find{|i|e%2**i==0}]+=1}
a=(0..2).find{|i|h[i]>0}
h[a]-=1
while h.values.any?{|e|e>0}
	st=2-a
	a=(st..2).find{|i|h[i]>0}
	if !a
		puts :No
		exit
	end
	h[a]-=1
end
puts :Yes

Measured memory_bytes: 13072
N = int(input())
s = [int(input()) for i in range(N)]
ans = sum(s)
s.sort()
if ans % 10 != 0:
    print(ans)
else:
    for i in range(N):
        if (ans - s[i]) % 10 != 0:
            ans -= s[i]
            break
    if ans % 10 == 0:
        print(0)
    else:
        print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstring>
#include <math.h>
#include <stdio.h>
using namespace std;

int a[1000];
int opa[2000],opb[2000];

int main()
{
    int n,mx=0,f=1,pos=1,cnt=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if(abs(a[i])>mx){
            pos=i;
            mx=abs(a[i]);
        }
    }

    for(int i=1;i<=n;i++){
        if(i!=pos){
            a[i]+=a[pos];
            opa[cnt]=pos;
            opb[cnt]=i;
            cnt++;
        }
    }
    if(a[pos]>0){
        for(int i=1;i<n;i++){
            a[i+1]+=a[i];
            opa[cnt]=i;
            opb[cnt]=i+1;
            cnt++;
        }
    }else{
        for(int i=n;i>1;i--){
            a[i-1]+=a[i];
            opa[cnt]=i;
            opb[cnt]=i-1;
            cnt++;
        }
    }

    printf("%d\n",cnt);

    for(int i=0;i<cnt;i++){
        printf("%d %d\n",opa[i],opb[i]);
    }

    return 0;
}


Measured memory_bytes: 256