akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = list(map(int, input().split()))

num4 = 0
num2 = 0
for i in range(n):
    if a[i]%4 == 0:
        num4 += 1
    elif a[i]%2 == 0:
        num2 += 1

#print(num4, num2)



if n-num4*2 <= 1:
    print("Yes")
elif n-num4*2 <= num2:
    print("Yes")
else:
    print("No")


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

public class Main {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		//String array[] = str.split("");
		char[] array = str.toCharArray();
		char[] chara = new char[26];
		int count[] = new int[26];
		int i = 0;
		char c = 97;
				
		while(i < 26) {
			chara[i]  = c;
			
			c++;
			i++;
		}
		//Arrays.sort(array);
		//count[0] = Integer.parseInt(array[0]);
		//System.out.println(count[0]);
		//int chara = 0;
		i = 0;
		while(i < array.length){
			//System.out.println((int)array[i]);
			count[((int)array[i]-97)]++;
			//System.out.println(count[i]);
			//System.out.println(count[i]);
			i++;
		}
		
		i = 0;
		c = 97;
		while(i < 26){
			
			//System.out.println(count[array[i]]);
			//System.out.println(c + " " + count[i]);
			c++;
			i++;
		}
		
		i=0;
		while(i < 26){
			//System.out.println(count[i]);
			if(count[i] == 0){
				System.out.println(chara[i]);
				break;
			}
			else if(i == 25){
				System.out.println("None");
			}
			i++;
		}
		
		/*int i = 0;
		String count[] = new String[N];
		while(i < str_array.length) {;
			count[str_array[i] - 'a']++;
			i++;
		}

		int j = 0;
		while(j < 26){
			if(count[j] == 0){
				System.out.print(count[j]);
			j++;
		}
		System.out.println("");*/

	}

}

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

int main() {
  int S,K,sum=0; cin>>K>>S;
  for(int i=0; i<=K; i++) for(int j=0; j<=K; j++) {
  	if(0 <= S-i-j && S-i-j <= K) sum++;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3636
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import permutations
from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    searched = [False for _ in range(node)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        if searched[cur_node] or cost > dist[cur_node]:
            continue
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
        searched[cur_node] = True
        
        if sum(searched) == node:
            break
    
    return dist

n,m,r = li()
r = list(li_())
graph = [[] for _ in range(n)]
for _ in range(m):
    a,b,c = li()
    a -= 1
    b -= 1
    graph[a].append((c,b))
    graph[b].append((c,a))
    
dists = []
for i in range(n):
    dists.append(dijkstra(graph, n, i))

ans = 2**64-1
for route in permutations(r):
    temp = 0
    for i in range(len(route)-1):
        temp += dists[route[i]][route[i+1]]
        
    ans = min(ans,temp)
    
print(ans)

Measured memory_bytes: 8356
from math import sqrt
from sys import stdin, stdout
readline = stdin.readline
write = stdout.write
while 1:
    n = int(readline())
    if n == 0:
        break
    C = [map(int, readline().split()) for i in xrange(n)]
    P = {(0, 0): C[0][:2], (n, 0): C[-1][:2]}
    # calculate intersections of the circles
    for i in xrange(n-1):
        x0, y0, r0 = C[i]
        x1, y1, r1 = C[i+1]
        rr = (x1 - x0)**2 + (y1 - y0)**2; rd = sqrt(rr)
        rc = (r0**2 + rr - r1**2) / (2 * rd); rs = sqrt(4*r0**2*rr - (r0**2 + rr - r1**2)**2) / (2 * rd)
        ex = (x1 - x0) / rd; ey = (y1 - y0) / rd
        bx = x0 + ex * rc; by = y0 + ey * rc
        P[i+1, 0] = (bx + ey * rs, by - ex * rs)
        P[i+1, 1] = (bx - ey * rs, by + ex * rs)

    def calc((x0, y0), (x1, y1)):
        return sqrt((x1 - x0)**2 + (y1 - y0)**2)
    def cross((x0, y0), (x1, y1), (x2, y2)):
        return (x1-x0) * (y2-y0) - (x2-x0) * (y1-y0)
    INF = 10**18
    dist = {(0, 0): 0}
    gp = P[n, 0]
    for i, j in sorted(P):
        pos = P[i, j]
        left = p_left = right = p_right = None
        d = dist[i, j]
        for k in xrange(i+1, n):
            lp = P[k, 0]; rp = P[k, 1]
            # update left and right
            if left is None or cross(pos, left, lp) >= 0:
                left = lp
            if right is None or cross(pos, rp, right) >= 0:
                right = rp
            # check if left <= right
            if cross(pos, left, right) < 0:
                break

            # propagate cost from P[i][j] to P[k][0] or P[k][1] if possible
            if p_left != left:
                dist[k, 0] = min(dist.get((k, 0), INF), d + calc(pos, left))
                p_left = left
            if p_right != right:
                dist[k, 1] = min(dist.get((k, 1), INF), d + calc(pos, right))
                p_right = right
        else:
            # P[i][j] -> goal
            # check if left <= goal <= right
            if (left is None and right is None) or (cross(pos, left, gp) >= 0 and cross(pos, gp, right) >= 0):
                dist[n, 0] = min(dist.get((n, 0), INF), d + calc(pos, gp))
    write("%.06f\n" % dist[n, 0])

Measured memory_bytes: 6576
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x: x[0])
ans = 0
cur = 0
for i in range(n):
  if cur+ab[i][1]<m:
    ans += ab[i][0]*ab[i][1]
    cur += ab[i][1]
  else:
    ans += (m-cur)*ab[i][0]
    break
print(ans)

Measured memory_bytes: 29028
/*
    handle - pruvi007
    questionName - 
    Contest - 
    Topic - 
    Platform - 
*/
#include<bits/stdc++.h>
using namespace std;
#define ll          long long int
#define fast         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INF          1e18
#define MOD          1000000007
#define Vi           vector<ll> 
#define Vs           vector<string>
#define VI           vector<vector<ll> >
#define PII          pair<ll,ll> 
#define PSI          pair<string,ll>
#define PB           push_back


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

int main()
{
    fast;
    ll a,b;
    cin >> a >> b;
    cout << a*b<<endl;
}

Measured memory_bytes: 3688
#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
s=input()
if s[-1]!='s':
    ans=s+'s'
else:
    ans=s+'es'
print(ans)

Measured memory_bytes: 9108
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
INF = 10 ** 18

dp = defaultdict(lambda: -INF)
dp[(0, 0, 0)] = 0

for i, e in enumerate(a, 1):
    for j in range((i - 1) // 2, (i + 1) // 2 + 1):
        dp[(i, j, 0)] = max(dp[(i-1, j, 0)], dp[(i-1, j, 1)])
        dp[(i, j, 1)] = dp[(i-1, j-1, 0)] + e

ans = max(dp[(n, n//2, 0)], dp[(n, n//2, 1)])
print(ans)


Measured memory_bytes: 191828
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 305;
const int mo = 1e+9+7;

int f[N][N][N];
int n,m;
int ad[N][N][N],v[4];

int add(int x,int y){return x+y>=mo?x+y-mo:x+y;}

int main(){
	//freopen("data.in","r",stdin);
//	freopen("data.out","w",stdout);
	n=get();m=get();
	fo(t,1,m){
		int l=get(),r=get(),x=get();
		if (x==1){
			ad[r][0][l]++,ad[r][0][r+1]--;
			ad[r][l][0]++,ad[r][r+1][0]--;
		}
		if (x==2){
			ad[r][0][0]++,ad[r][0][l]--,ad[r][l][0]--;
			ad[r][r+1][0]++,ad[r][0][r+1]++;
			ad[r][l][l]+=2;
			ad[r][r+1][l]-=2,ad[r][l][r+1]-=2;
			ad[r][r+1][r+1]+=2;
		}
		if (x==3){
			ad[r][0][0]++;
			ad[r][l][l]--,ad[r][r+1][l]++,ad[r][l][r+1]++,ad[r][r+1][r+1]--;
		}
	}
	fo(i,1,n)
		fo(j,0,n)
			fo(k,0,n){
				//ad[i][j][k]=(ad[i][j][k]+ad[i][j-1][k]+ad[i][j][k-1]-ad[i][j-1][k-1]);
				if (j)ad[i][j][k]+=ad[i][j-1][k];
				if (k)ad[i][j][k]+=ad[i][j][k-1];
				if (j&&k)ad[i][j][k]-=ad[i][j-1][k-1];
			}
	f[0][0][0]=1;
	fo(i,0,n)
		fo(j,i,n)
			fo(k,j,n){
				if (ad[k][i][j])f[i][j][k]=0;
				else{
					int w=max(i,max(j,k));
					f[j][k][w+1]=add(f[j][k][w+1],f[i][j][k]);
					f[i][k][w+1]=add(f[i][k][w+1],f[i][j][k]);
					f[i][j][w+1]=add(f[i][j][w+1],f[i][j][k]);
				}
			}
	int ans=0;
	fo(i,0,n)fo(j,0,n)ans=add(ans,f[i][j][n]);
	fo(i,0,n)fo(k,0,n)ans=add(ans,f[i][n][k]);
	fo(j,0,n)fo(k,0,n)ans=add(ans,f[n][j][k]);
	//ans=1ll*ans*6%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 221056
n,m = map(int,input().split())
data = []
sum=0


for i in range(0,n):
    a,b = map(int,input().split())
    data.append((a,b))

data.sort()

while m>0:
    num = m if m<data[0][1] else data[0][1]
    sum+=data[0][0]*num
    m-=num
    del data[0]

print(sum)

Measured memory_bytes: 16908
#include <bits/stdc++.h>
#define LL               long long
#define PB               push_back
using namespace std;

int main (){
    LL t,d;
    cin>> t>>d;
    LL d2=d*d;
    LL c=0;
    while (t--){
        LL x,y;
        cin >> x>>y;
        if((x*x)+(y*y)<=d2) c++;
    }
    cout<<c<<endl;
    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> d){
    LL ans = 0;
    REP(i, N) {
        REP2(j, i+1, N) {
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	fmt.Println(abc174a(os.Stdin))
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func abc174a(r io.Reader) string {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)

	x := nextInt(sc)

	if x < 30 {
		return "No"
	}

	return "Yes"
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr(a,b,c) for(a=b-1;a>=c;a--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pi  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define test4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define test5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define test6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
/*
    //string with spaces
    std::string str;
    std::getline(std::cin >> std::ws, str);
*/
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    // fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    cin>>str;
    cin>>str1;
    ll res =0;
    rep(i,0,str.length()){
        if(str[i]!=str1[i]){
            res++;
        }
    }
    cout<<res;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;

int main() {
    int n, tmp;
    scanInt(n);
    int worker[n];
    rep(i, n) worker[i] = 0;
    rep(i, n - 1) {
       scanInt(tmp); 
       worker[tmp-1] += 1;
    }
    rep(i, n) printInt(worker[i]);
    return 0;
}

Measured memory_bytes: 4504
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int K, N;
vector<int> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> K >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    int ai;
    cin >> ai;
    A[i] = ai;
  }

  int ans = INF;
  for (int i = 0; i < N; i++) {
    if (i == N - 1) {
      ans = min(ans, K - abs(K - A[i]) - abs(A[0]));
    } else {
      ans = min(ans, K - abs(A[i + 1] - A[i]));
    }
  }

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

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){

  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n)cin >> v[i];
  sort(ALL(v));
  vector<ll> s(n+1,0);
  rep(i,n)s[i+1] = s[i]+v[i];
  for(int i = n-1;i >= 0;i--){
    if(s[i]*2 < v[i]){
      cout << n-i << endl;
      return 0;
    }
  }



  return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

if sum(A) < sum(B) :
    print(-1)
    exit()

les = 0
ans = 0
Over = []
for i in range(N) :
    Over.append(A[i]-B[i])
    if A[i] < B[i] :
        les += B[i] - A[i]
        ans += 1

Over.sort(reverse = True)
for ov in Over :
    if les <= 0 :
        print(ans)
        break
    les -= ov
    ans += 1


Measured memory_bytes: 84784
date = input().split()
N = date[0]
M = date[1]
dict = {}
sum = 0
flag = 0
for i in range(int(M)):
    date = input().split()
    s = date[0]
    c = date[1]
    if s in dict.keys():
        if dict[s] != c:
            print("-1")
            flag = 1
            break
    else:
        dict[s] = c
dict = sorted(dict.items(), key=lambda x: x[0])
for i in dict:
    if int(i[1]) == 0 and int(N) != 1 :
        if int(i[0])==1:
            print(-1)
            flag = 1
            break
    else:
        sum += 10 ** (int(N) - int(i[0])) * int(i[1])
if flag == 0:
    str = str(sum)
    l   = len(str)
    if l < int(N):
        if int(N) == 2:
            sum += 10
        else:
            sum += 100
    print(sum)

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

using namespace std;

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

#define int ll


main(){
	int h,w,k;
	cin >> h >> w >> k;
	char s[h][w];
	for(int i=0;i<h;i++) cin >> s[i];

	int ans = 0;
	
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			char v[h][w];
			for(int a=0;a<h;a++){
				for(int b=0;b<w;b++){
					v[a][b] = s[a][b];
				}
			}
			for(int a=0;a<h;a++){
				if((i>>a) & 1){
					for(int b=0;b<w;b++){
						v[a][b] = 'R';
					}
				}
			}
			for(int b=0;b<w;b++){
				if((j>>b) & 1){
					for(int a=0;a<h;a++){
						v[a][b] = 'R';
					}
				}
			}
			int tmp = 0;
			for(int a=0;a<h;a++){
				for(int b=0;b<w;b++){
					if(v[a][b]=='#') tmp++;
				}
			}
			if(tmp==k) ans++;
		}
	}

	cout << ans << endl;


	return 0;
}


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

using namespace std;
using ll = long long;

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> dp(H + 1, vector<int>(W, 0));
  dp[0][0] = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = 0; k < 1 << (W - 1); k++) {
        bool flag = true;
        for (int l = 0; l < W - 2; l++)
          if (((k >> l) & 1) && ((k >> (l + 1)) & 1))
            flag = false;
        if (!flag)
          continue;
        if (1 <= j && ((k >> (j - 1)) & 1))
          dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j]) % MOD;
        else if (j <= W - 2 && ((k >> j) & 1))
          dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
        else
          dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
      }
    }
  }
  cout << dp[H][K - 1] << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, b, c;
int a[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cout <<(n-1)/2<< "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

#define DATA_MAX     (52)
#define MAX(a,b)    ((a)>(b)?(a):(b))

int scan_line(int *buf){
    int cnt;
    char c;
    cnt = 0;
    while( (scanf("%d%c",&buf[cnt],&c)>0) && (++cnt) && (c!='\n') );
    return cnt;
}

int main(){
    int buf[2][DATA_MAX];
    int cnt[2];
    int now,pre;
    int i;

    cnt[0] = scan_line( buf[0] );
    pre = 0;
    now = 1;

    while( (cnt[now] = scan_line( buf[now] )) && (cnt[now] > 0) ){
        if(cnt[pre]<cnt[now]){
            /* upper half */
            /*     0       1     */
            /*   /   \   /   \   */
            /* 0       1       2 */
            /* +       +       + */
            /* 0    MAX(0,1)   1 */
            buf[now][0] += buf[pre][0];
            for(i=1;i<cnt[now]-1;i++){
                buf[now][i] += MAX(buf[pre][i-1], buf[pre][i]);
            }
            buf[now][cnt[now]-1] += buf[pre][cnt[now]-2];
        }else{
            /* lower half */
            /* 0       1       2 */
            /*   \   /   \   /   */
            /*     0       1     */
            /*     +       +     */
            /* MAX(0,1) MAX(1,2) */
            for(i=0;i<cnt[now];i++){
                buf[now][i] += MAX(buf[pre][i], buf[pre][i+1]);
            }
        }
        pre = now;
        now = 1-pre;
    }

    printf("%d\n",buf[pre][0]);

    return 0;
}

Measured memory_bytes: 600
program Main
    integer(8) n
    integer(8) :: i= 0
    integer(8) :: c0 = 0
    integer(8) :: c1 = 0
    integer(8) :: c2 = 0
    integer(8) :: c3 = 0
    character(3) str
    read *, n
    do
        if(i == n)exit
        read *, str
        if(str .eq. "AC")then
            c0 = c0 + 1
        else if(str .eq. "WA")then
            c1 = c1 + 1
        else if(str .eq. "TLE")then
            c2 = c2 + 1
        else if(str .eq. "RE")then
            c3 = c3 + 1
        end if
        i = i + 1
    end do
    print "('AC x ',i0)", c0
    print "('WA x ',i0)", c1
    print "('TLE x ',i0)", c2
    print "('RE x ',i0)", c3
end program

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10 , MOD = 1e9 + 7;
int pow_mod(int x , int n , int mod)
{
	int res = 1;
	while(n)
	{
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}
int dp[N];
signed main()
{
	int n , k , ans = 0;
	cin >> n >> k ;
	for(int i = k ; i ; i --)
	{
		dp[i] = pow_mod(k / i , n , MOD);
		for(int j = 2 * i ; j <= k ; j += i) dp[i] -= dp[j];
		ans = ans + i * dp[i];
		ans %= MOD;
	}
	cout << (ans + MOD) % MOD << '\n' ;
	return 0;
}

Measured memory_bytes: 4376
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {
	public static void main(String[] args) {
		// code to read values
		// code to call required method
		// code to display the result
		// System.out.println(Math.ceil(2.5));
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[1000001];
		long sum = 0;
		for (int i = 0; i < n; i++) {
			int val = sc.nextInt();
			arr[val]++;
			sum += val;
		}
		int k = sc.nextInt();
		while (k > 0) {
			// System.out.println("hey");
			int old = sc.nextInt();
			int recent = sc.nextInt();
			arr[recent] += arr[old];
			long newSum = - (arr[old] * old) + (arr[old] * recent);
			arr[old] = 0;
			sum += newSum;
			System.out.println(sum);
			k--;
		}
	}

}

Measured memory_bytes: 63004
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		long L = sc.nextLong();
		long R = sc.nextLong();
		long min = 2018;

		if (R - L < 2019) {

			long a = L % 2019;

			for (long i = a; i < a + R - L; i++)
				for (long j = i + 1; j <= a + R - L; j++)

					min = Math.min(min, (i * j) % 2019);

		} else
			min = 0;

		System.out.println(min);

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 22484
#include<stdio.h>

int main(){
	int n[4],i,j;
	scanf("%d %d %d", &n[0], &n[1], &n[2]);
	for (i = 0; i < 3; i++){
		for (j = i + 1; j < 3; j++){
			if (n[i] > n[j]){
				n[3] = n[i];
				n[i] = n[j];
				n[j] = n[3];
			}
		}
	}

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

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

int main() {
    int N;
    cin >> N;
    string ans;
    if (N / 100 >= N % 10 && N / 100 >= (N / 10) % 10) {
         ans = string(3, to_string(N / 100)[0]);
    } else {
        ans = string(3, to_string(N / 100 + 1)[0]);
    }
    cout << ans << endl;
}



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

int n,a[(1<<18)+3];
multiset<int> s,t,l;

int main()
{
	int i;
	cin>>n;
	for (i=1;i<=(1<<n);i++)
	{
		cin>>a[i];
		t.insert(-a[i]);
	}
	s.insert(*t.begin());t.erase(t.begin());
	while (n--)
	{
		l=s;
		for (multiset<int>::iterator it=s.begin();it!=s.end();it++)
		{
			multiset<int>::iterator x=t.upper_bound(*it);
			if (x==t.end())
			{
				puts("No");
				return 0;
			}
			l.insert(*x);t.erase(x);
		}
		s=l;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 25856
def solve(n, m, s, c):
    slot = [-1] * n
    for si, ci in zip(s, c):
        if (slot[si-1] != -1) and (slot[si-1] != ci):
            return -1
        slot[si-1] = ci
    if slot[0] == 0:
        return 0 if n == 1 else -1
    if (slot[0] == -1) and (n == 1):
        return 0
    for i in range(n):
        if slot[i] == -1:
            slot[i] = int(i == 0)
    return "".join(map(str, slot))

n, m = map(int, input().split())
s = [0] * m
c = [0] * m
for i in range(m):
    s[i], c[i] = map(int, input().split())
print(solve(n, m, s, c))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 #define int long long
vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
signed main(){

    int N,ans;
    cin>>N;
    vector<int>ret=divisor(N);

    rep(i,ret.size()){
        if((N/ret[i]-1<=ret[i]))continue;
        ans+=max(N/ret[i]-1,0LL);
    }
    cout<<ans<<endl;



 
}

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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>data(n);
  for(int i = 0;i < n;i++) cin >> data[i];
  sort(data.begin(),data.end());
  for(int i = 0;i < n-2;i++){
    for(int j = i+1;j < n-1;j++){
      for(int k = j+1;k < n;k++){
        if(data[k] < data[j]+data[i]) ans++;
        else break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = gets.to_i
strs = gets.split.map(&:to_i)
 
b_ary = []
strs.each_with_index do |str, idx|
  b_ary << str - (idx+1)
end
b_ary.sort!
b_middle_num = b_ary[N/2]
sums = 0
strs.each_with_index do |str, idx|
  sums += (str - (b_middle_num + idx+1)).abs
end
puts sums

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

int main() {
	bool find=false;
	string s;
	cin>>s;
	int count[26]={0};
	for (int i=0;i<s.length();i++){
		count[s[i]-97]++;
	}
	for (int i=0;i<26;i++){
		if (count[i]>1) {
			find=true;
		break;
		}
	}
	if (find) cout<<"no";
	else cout<<"yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e;
string s;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a;
    b=(a/500)*1000+((a%500)/5)*5;
    cout<<b;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;
//西暦⇒時代の歴
ll a[100010];
int main()
{
    ll N, K;
    cin >> N >> K;

    if (K == 0)
    {
        cout << N * N << endl;
        return 0;
    }
    ll ans = 0;
    for (ll i = K + 1; i <= N; ++i)
    {
        // aは適当な数字に固定 b = i;
        ans += N / i * (i - K);
        ans += max(0LL, (N % i) - K + 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  string S;
  int N,T;
  cin>>N>>S;
  for(int i=0;i<S.size();i++){
    T=S[i]-'A';
    S[i]='A'+(T+N)%26;
    cout<<S[i];
  }
return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    string w;
    cin >> w;
    vector<int>cnt('z' - 'a' + 1);
    for (int i = 0; i < w.size(); i++)cnt[w[i] - 'a']++;

    for (int i = 0; i < cnt.size(); i++){
        if (cnt[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
	
	char c;
	int i,j,k;
	int cnt;
	long sum;
	char str[1000][1200]={0};
	
	sum = 0;
	
	for(i=0; i<1000; i++){
		for(j=0; j<1200; j++){
			scanf("%c",&str[i][j]);
			if(str[i][j] == '\n'){
				break;
			}
		}
		if(str[i][0] == '0'){
			break;
		}
	}
	
	cnt = i;
	
	for(i=0; i<cnt; i++){
		for(j=0; j<1200; j++){
			if(str[i][j] == '\n'){
				break;
			}
			sum += str[i][j] - '0';
		}
		printf("%ld\n",sum);
		sum = 0;
	}
	
	return 0;
}




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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    int d,g;
    cin >> d >> g;
    vector<int> p(d),c(d);
    rep(i,d) cin >> p[i] >> c[i];
    
    vector<int> complete(d);
    rep(i,d) complete[i] = p[i]*(i+1)+c[i];

    int ans = inf;
    rep(mask,1<<d){
        int sum_tmp = 0, ans_tmp = 0, rest_max = -1;
        rep(i,d){
            if( (mask >> i) & 1 ){
                sum_tmp += 100*(i+1) * p[i] + c[i];
                ans_tmp += p[i];
            }
            else{
                rest_max = i;
            }
        }
        if( sum_tmp < g ){
            int s = 100 * (rest_max + 1);
            int need = (g - sum_tmp + s - 1)/s;
            if(need >= p[rest_max]){
                continue;
            }
            ans_tmp += need;
        }
        ans = min(ans, ans_tmp);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll N,K;
    cin>>N>>K;
    vl dp(N,INF);
    vl h(N);
    rep(i,N) cin>>h.at(i);
    dp.at(0)=0;
    for(ll i=0;i<N;i++){
        for(ll j=0;j<K;j++){
            if(i+j+1>N-1){
                break;
            }else{
        chmin(dp.at(i+j+1),dp.at(i)+abs(h.at(i)-h.at(i+j+1)));
            }
        }
    }
    cout<<dp.at(N-1)<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
const ll INF = 1<<30;

int main(){
    ll N; cin >> N;
    map<ll,ll> mp;
    rep(i,N){
        ll a; cin >> a;
        mp[a]++;
    }
    vector<ll> v;
    for(auto it : mp){
        it.second --;
        while(it.second > 0){
            v.push_back(it.first);
            it.second -= 2;
        }
    }
    sort(v.begin(),v.end(),greater<ll>());
    if(v.size() < 2) cout << 0 << endl;
    else cout << v[0] * v[1] << endl;
}

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

vector<int> get_prime(int n) {
    vector<int> ans(n+1, 0);
    for (int i = 2; i < n+1; i++) {
        if (ans[i] == 0) {
            ans[i] = i;
            if (i*i < n) {
                for (int j = i; j <= n / i; j++) {
                    ans[i*j] = i;
                }
            }
        }
    }
    return ans;
}

int gcd(int p, int q) {
    if (p % q == 0) {
        return q;
    } else {
        return gcd(q, p % q);
    }
}

int main() {
    int n, g, a, p;
    cin >> n;
    vector<int> pl = get_prime(1000000);
    int l = pl.size();
    vector<bool> done(l, false);
    bool if_pc = true;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (i == 0) {
            g = a;
        } else {
            g = gcd(g, a);
        }
        if (if_pc) {
            while (a != 1) {
                if (done[pl[a]]) {
                    if_pc = false;
                    break;
                } else {
                    p = pl[a];
                    while (a % p == 0) {
                        a /= p;
                    }
                    done[p] = true;
                }
            }
        }
    }
    if (if_pc) {
        cout << "pairwise coprime" << endl;
    } else if (g == 1) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
    return 0;
}


Measured memory_bytes: 7164
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    //input
    ll n,k;    cin >> n >> k;
    vector<pair<int, int> >ans;
    rep(i, n){
        int a,b;    cin >> a >> b;
        ans.push_back(pair<int, int>(a, b));
    }
    //solve
    sort(ans.begin(), ans.end());
    int ptr = 0;
    while(k){
        if(ans[ptr].second >= k){
            k = 0;
        }else{
            k -= ans[ptr].second;
            ptr++;
        }
    }
    cout << ans[ptr].first << endl;
}


Measured memory_bytes: 1400
n = int(input())
l = list(map(int,input().split()))


import itertools

cnt = 0

for x in itertools.combinations(l, 3):
    i = x[0]
    j = x[1]
    k = x[2]
    if i == j or j == k or k == i: continue
    if i + j > k and j + k > i and k + i > j:
        cnt += 1

print(cnt)

Measured memory_bytes: 9136
#include <stdio.h>

int main(void)
{
	int n, i;
	int fibo[45];

	scanf("%d", &n);

	fibo[0] = 1;
	fibo[1] = 1;

	for (i = 2; i < 45; i++) {
		fibo[i] = fibo[i - 2] + fibo[i - 1];
	}

	printf("%d\n", fibo[n]);

	return 0;
}


Measured memory_bytes: 2100
n,m=map(int,input().split())
a=1
mod=1000000007
for i in range(1,n):
    a*=i
    a=a%mod
if n==m:
    a*=n
    n=a%mod
    print(2*(a**2)%mod)
elif n==m+1:
    ans=((a**2)%mod)*(n)%mod
    print(ans)
elif n==m-1:
    ans=((a**2)%mod)*(n**2*m)%mod
    print(ans)
else:
    print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll P,Q,R;
    cin >> P >> Q >> R;
    cout << min(P+Q,min(Q+R,P+R));
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#define maxn 200005
#define inf 0x3f3f3f3f
using namespace std;
typedef long int ll;
int main()
{
    int n, t, x;
    long long ans = 0;
    scanf("%d %d", &n, &t);
    if (t) return 0 & puts("-1");
    while(--n){
        scanf("%d", &x);
        if (x <= t) ans += x;
        else if (x == t + 1) ++ans;
        else return 0 & puts("-1");
        t = x;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
const int maxn=1e5+6;
int a[maxn],b[maxn],c[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		a[i]=i;
	}
	int k=1,sum=1,flag=0;
	c[1]=1;
	while(n--)
	{
		c[b[k]]=1;
		k=b[a[k]];
		sum++;
		if(k==2)
		{
			printf("%d",sum-1);
			flag=1;
			break;
		}
	}
	if(flag==0) printf("-1");
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>

using namespace std;

vector<pair<int, int> > v;


int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;

    int kuro = 0;
    int shiro = 0;

    for (int i = 0; i < N; i++) {
        if (S[i] == '.') shiro++;
    }

    int ans = shiro;
    for (int i = 0; i < N; i++) {
        if (S[i] == '#') {
            kuro++;
        } else {
            shiro--;
        }
        int temp = shiro + kuro;
        if (ans > temp) ans = temp;
    }

    cout << ans << endl;

    return 0;
}


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

int list[1000020];
int head = 1000019;
int tail = 1000019;

void insert(int x)
{
	list[head] = x;
	head--;
}

void delete(int x)
{
	int i;
	for (i = head + 1; i <= tail; i++) {
		if (list[i] == x) {
			list[i] = -1;
			if(i == tail) {
				tail--;
				while(tail == -1)
					tail--;
			}
			return;
		}
	}
}

void deleteFirst()
{
	while (list[head + 1] == -1)
		head++;
	head++;
	while (list[head + 1] == -1)
		head++;
}

void deleteLast()
{
	while (list[tail] == -1)
		tail--;
	tail--;
	while (list[tail] == -1)
		tail--;
}

int main(void)
{
	int n;
	scanf("%d", &n);
	
	while(n--) {
		char op[12];
		int key;
		scanf("%s", op);
		if (!strcmp(op, "insert")) {
			scanf("%d", &key);
			insert(key);
		} else if (!strcmp(op, "delete")) {
			scanf("%d", &key);
			delete(key);
		} else if (!strcmp(op, "deleteFirst")) {
			deleteFirst();
		} else {
			deleteLast();
		}
	}
	int i;
	for(i = head + 1; i < tail; i++) {
		if (list[i] != -1)
			printf("%d ", list[i]);
	}
	if (list[i] != -1)
		printf("%d\n", list[i]);
	return 0;
}
		
	

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)&&s.at(2)==s.at(1)){cout<<"Yes";}
  else if(s.at(2)==s.at(1)&&s.at(2)==s.at(3)){cout<<"Yes";}
  else{cout<<"No";}
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int N = Integer.parseInt(br.readLine());
        int[] arr = new int[N];
        int s1=0,s2=0;
        int ans=Integer.MAX_VALUE;
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=0;i<N;++i)
        {
            arr[i] = Integer.parseInt(st.nextToken());
            s2+=arr[i];
        }
        for(int i=0;i<N;++i)
        {
            s1+=arr[i];
            s2-=arr[i];
            ans = Math.min(ans, Math.abs(s1-s2));
        }
        bw.write(ans+"");
        bw.close();
    }

}


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

int main() {
  int N,A,B;
  cin>>N;
  vector<int> vec(N,0);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  A=B=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      A+=vec.at(i);
    }
    else{
      B+=vec.at(i);
    }
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 256
import sys
from bisect import *
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
path = [[] for _ in range(n)]
for _ in range(n-1):
    u,v = map(int,input().split())
    path[u-1].append(v-1)
    path[v-1].append(u-1)

# parent = [-1]*n
ans = [0]*n
def dfs(now,parent,LIS):
    w = bisect(LIS,a[now])
    if w > 0 and LIS[w-1] == a[now]:
        flag = -2
    elif w == len(LIS):
        flag = -1
        LIS.append(a[now])
    else:
        flag = w
        record = LIS[w]
        LIS[w] = a[now]
    ans[now] = len(LIS)
    for nxt in path[now]:
        if nxt == parent:continue
        dfs(nxt,now,LIS)
    if flag == -2:
        return
    elif flag == -1:
        LIS.pop()
    else:
        LIS[w] = record
    return
# stack = [0]
# LIS = [[] for _ in range(n)]
# while stack:
#     p = stack.pop()
#     if p == 0:
#         LIS[p] = [a[p]]
#     else:
#         parray = LIS[parent[p]].copy()
#         nxt = bisect(parray,a[p])
#         if nxt == len(parray):
#             LIS[p] = parray + [a[p]]
#         else:
#             parray[nxt] = a[p]
#             LIS[p] = parray
#     for to in path[p]:
#         if to == parent[p]:continue
#         parent[to] = p
#         stack.append(to)
dfs(0,-1,[])
print('\n'.join(str(i) for i in ans))


Measured memory_bytes: 584020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

class Main {
    static int ways;
    public static void main(String[] args) throws IOException {
        // Solution sol = new Solution();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int h = Integer.parseInt(st.nextToken());
        int w = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());

        char[][] board = new char[h][w];
        int hashes = 0;
        for (int i=0; i<h; i++) {
            String s = br.readLine();
            for (int j=0; j<w; j++) {
                board[i][j] = s.charAt(j);
                if (board[i][j]=='#') {
                    hashes++;
                }
            }
        }

        ways = 0;

        recurse(board,0,h,w,k,hashes);
        System.out.println(ways);
    }

    public static void recurse(char[][] board, int idx, int H, int W, int k, int hashes ) {
        if (idx==H+W) {
            if (hashes==k) {
                ways++;
            }
            return;
        }
        //exclude
        recurse(board, idx+1, H, W, k, hashes);
        //include
        char[][] boardcopy = new char[board.length][];
        for (int i = 0; i < board.length; i++) {
            boardcopy[i] = board[i].clone();
        }
        if(idx<H){
            for (int ll=0; ll<W; ll++) {
                if(boardcopy[idx][ll]=='#'){
                    hashes--;
                    boardcopy[idx][ll]='.';
                }
            }
        }
        else{
            for (int ll=0; ll<H; ll++) {
                if(boardcopy[ll][idx-H]=='#'){
                    hashes--;
                    boardcopy[ll][idx-H]='.';
                }
            }
        }
        recurse(boardcopy, idx+1, H, W, k, hashes);

    }

}

Measured memory_bytes: 35312
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());

      String line = in.readLine();
      int[] seq = new int[n];
      int[] ref = new int[n];
      char regex = ' ';
      boolean isContinue = true;
      for(int i=0, offset=0,next=0; isContinue; i++, offset = ++next) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        ref[i] = seq[i] = Integer.parseInt(line.substring(offset,next));
      }

      Arrays.parallelSort(ref);

      StringBuilder buf = new StringBuilder();
      for(int i=0; i<n; i++) {
        if(seq[i] < ref[(n>>1)] ) buf.append(ref[(n>>1)]).append('\n');
        else buf.append(ref[(n>>1)-1]).append('\n');
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 55852