akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}



using namespace std;
int main(){
    int n,sum=0;
    cin >> n;
    vector<int> vec(n+2),rui(n+2);
    vec[0] = 0;
    FOR(i,1,n+1){
        cin >> vec[i];
    }
    

    vec[n+1] = 0;

    
    rui[0] = vec[0];
    FOR(i,1,n+2){
        rui[i]= rui[i-1] + abs(vec[i-1]- vec[i]);
        
    }
    
    
    
    FOR(i,1,n+1){
        int sa,r,h;
        sa = abs(vec[i-1] - vec[i]) + abs(vec[i]-vec[i+1]);
        r = abs(vec[i-1] - vec[i+1]);
        h = sa -r;

        cout << rui[n+1] - h <<endl;

    }

    
}

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

int main(){
  ll a,b,c,d;
  std::cin >> a >> b>> c>>d;

  ll ans=b*c;
  ans=max(ans,b*d);

  ans=max(ans,a*d);
  ans=max(ans,a*c);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
  int A,B,m;
  cin >> A >> B >> m;
  int a[A],b[B];
  int mina=999999;
  int minb=999999;

  int xyc[m][3];

  for (int i = 0; i < A; i++)
  {
    cin >> a[i];
    if (a[i] < mina)
    {
      mina=a[i];
    }
  }
  
  for (int i = 0; i < B; i++)
  {
    cin >> b[i];
    if (b[i] < minb)
    {
      minb=b[i];
    }
  }

  for (int i = 0; i < m; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> xyc[i][j];
    }
  }

  int minsum=mina+minb;
  
  // yes
  for (int i = 0; i < m; i++)
  {
    int sum = a[xyc[i][0]-1] + b[xyc[i][1]-1] - xyc[i][2];
    if (sum<minsum)
    {
      minsum=sum;
    } 
  }

  cout << minsum << "\n";

  return 0;
}

Measured memory_bytes: 2176
INF = float('inf')
N = int(input())
a = [0]+[int(x) for x in input().split()]
for i in range(N):
    a[i+1] += a[i]
dp = [[INF] * N for i in range(N)]
for i in range(N):
    dp[i][i] = 0
for k in range(1, N):
    for i in range(N-k):
        for j in range(k):
            dp[i][i+k] = min(dp[i][i+k], dp[i][i+j]+dp[i+j+1][i+k]+a[i+k+1]-a[i])
print(dp[0][N-1])

Measured memory_bytes: 46928
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			int[] s = new int[n];
			double e = 0.0, v = 0.0;
			for (int i = 0; i < n; i++) {
				s[i] = sc.nextInt();
				e += s[i];
				v += s[i] * s[i];
			}
			e /= n;
			v = v / n - e * e;
			System.out.println(Math.sqrt(v));
		}
	}
}



Measured memory_bytes: 31164
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;  

int main()
{
  fastio;
  int red,green,blue;
  int k;
	cin>>red>>green>>blue;
	cin>>k;
	bool flag=true;
	int count=0;
	while(!(green>red&&blue>green))
	{
		if(green<=red)
		{
			green*=2;
			count++;
		}
		if(blue<=green)
		{
			blue*=2;
			count++;
		}
		if(count>k)break;
	}

	if(green>red&&blue>green&&count<=k)
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

}

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

int main()
{
	int n;
	cin>>n;
	int f=0;
	while(n>0)
	{
		int z=n%10;
		if(z==7)
		{
			f=1;
			cout<<"Yes"<<endl;
			break;
		}
		n=n/10; 
	}
	if(f==0)
	{
		cout<<"No"<<endl;
	}

}

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

int main() {
  int n;
  cin >> n;
  int taro=0,hanako=0;
  for (int i=0; i<n; i++) {
      string a,b;
      cin >> a >> b;
      if (a>b) taro+=3;
      else if (a==b) {
          taro++; hanako++;
      }
      else hanako+=3;
  }
  cout << taro << " " << hanako << endl;
}


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

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

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func contains(target string, list []string) bool {
	for _, r := range list {
		if target == r {
			return true
		}
	}
	return false
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func Ave(s []int) int {
	val := 0
	for _, i := range s {
		val += i
	}
	return int(val / len(s))
}
func cal(i int) (sum int) {
	for i != 0 {
		sum += i % 10
		i /= 10
	}
	return
}
func max(a []int) (idx int, val int) {
	max := a[0]
	idx = 0
	for j, i := range a {
		if max < i {
			max = i
			idx = j
		}
	}
	return idx, max
}

func draw(i int, a []int) (l []int) {
	// p = a[i]
	for j := i; j < len(a); j++ {
		if j != len(a)-1 {
			a[j] = a[j+1]
		} else if j == len(a)-1 {
			a = a[:len(a)-1]
		}
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer([]byte{}, math.MaxInt64)
	// a := make([][]int, 3)
	// for i := 0; i < 3; i++ {
	// 	a[i] = make([]int, 3)
	// }
	// for i := 0; i < 3; i++ {
	// 	for j := 0; j < 3; j++ {
	// 		a[i][j] = nextInt()
	// 	}
	// }

	n := nextInt()

	var out int
	var ans int

	if n == 1 {
		ans = 1
	}

	for i := 2; i <= n; i++ {
		if i%2 == 0 {
			cnt := 0
			for j := i; j%2 == 0; {
				j = j / 2
				cnt++
			}
			if cnt > out {
				out = cnt
				ans = i
			}

		}

	}

	fmt.Println(ans)

}


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

void print(int numbers[], int n) {
  for (int i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << numbers[i];
  }
  cout << endl;
}

int * insertion_sort(int numbers[], int n) {
  for (int i = 1; i < n; i++) {
    int v = numbers[i];
    int j = i - 1;
    while (0 <= j && v < numbers[j]) {
      numbers[j+1] = numbers[j];
      j--;
    }
    numbers[j+1] = v;

    print(numbers, n);
  }

  return numbers;
}

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

  int cards[n] = {0};

  for (int i = 0; i < n; i++)
    cin >> cards[i];

  print(cards, n);
  insertion_sort(cards, n);

  return 0;
}



Measured memory_bytes: 3088
A = int(input())
B = int(input())
C = int(input())
x = int(input())

count = 0
if x % 50 != 0:
    print(0)
else:
    for c in range(C+1):
        for b in range(B+1):
            for a in range(A+1):
                if c*50 + b*100 + a*500 == x:
                    count += 1
    print(count)

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int h, w;
string c[50];
int d[50][50];
int kita[50][50];

int main() {
    std::ios::sync_with_stdio(false);
    cin >> h >> w;
    inc(i, 0, h){
        cin >> c[i];
    }

    int sum = 0;
    inc(i, 0, h){
        inc(j, 0, w){
            if(c[i][j] == '#'){
                sum++;
            }
            d[i][j] = INF;
        }
    }

    mset(kita, 0);

    queue<pair<pair<int, int>, int>> q;
    q.push({{0, 0}, 0});
    while(!q.empty()){
        auto n = q.front();
        q.pop();
        int i = n.fi.fi;
        int j = n.fi.se;
        int dist = n.se;

        if(kita[i][j]){
            continue;
        }

        kita[i][j] = 1;
        if(d[i][j] < dist) continue;
        d[i][j] = dist;

        inc(k, 0, 4){
            int ni = i + di[k];
            int nj = j + dj[k];
            if(ni >= 0 && ni < h && nj >= 0 && nj < w){
                if(c[ni][nj] == '#') continue;
                if(d[ni][nj] < dist+1) continue;
                q.push({{ni, nj}, dist+1});
            }
        }
    }

    if(d[h-1][w-1] == INF){
        cout << -1 << endl;
        return 0;
    }

    cout << h*w - d[h-1][w-1] - sum -1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int a, b, r, g, l;
	int a1, b1;
	
	while(scanf("%d %d", &a, &b) != EOF){
		a1 = a;
		b1 = b;
		do{
			r = a % b;
		
			if(r == 0){
				g = b;
			}else {
				a = b;
				b = r;
			}
		}while(r != 0);
	
		l = g * (a1 / g) * (b1 / g);
	
		printf("%d %d\n", g, l);
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  string s;
  cin >> s;
  int a, z;
  int ssize = s.size();
  for(int i = 0; i < ssize; i++){
    if(s.at(i) == 'A'){
      a = i;
      break;
    }
  }
  for(int i = ssize - 1; i >= 0 ; i--){
    if(s.at(i) == 'Z'){
      z = i;
      break;
    }
  }
  cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vint A(Q);
    unordered_map<int, int> correct_num;
    rep(i, Q) {
        cin >> A[i];
        correct_num[A[i]]++;
    }

    REP(i, 1, N + 1) {
        if (K - (Q - correct_num[i]) <= 0) {
            cout << "No" << endl;
        }
        else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
    
    int n; 
    cin >> n;
    int a[n],b[n];

    for(int i=0;i<n;i++)
    {
      cin>>a[i]>>b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    ll x,y;
    if (n% 2 == 1)
     {
        x=a[n/2];
        y=b[n/2];
    } 
    else {
        x =a[n/2 - 1] + a[n/2];
        y= b[n/2 - 1] + b[n/2];
    }
 
    cout <<y-x+1<<endl;
  
 
  return 0;
}

	

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

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

  int tmp = b - a;
  int tmp2 = 0;
  for (int i = 0; i < tmp; i++) {
    tmp2 += i;
  }
  int ans = tmp2 - a;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct UnionFind {
  vector<int> data;
  UnionFind(int N) : data(N, -1) { }
  inline bool uni(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[x] > data[y]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) {
    return root(x) == root(y);
  }
  inline int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  inline int size(int x) {
    return -data[root(x)];
  }
};

struct edge{
  int src, dst, cost;
  edge(int s, int d, int c) : src(s), dst(d), cost(c) {}
  edge() {}
  bool operator< (const edge& e) const {
    return cost < e.cost;
  }
};

int main(){
  int N;
  cin>>N;
  vector<edge> v(N - 1);
  REP(i, N - 1){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    v[i] = edge(a, b, c);
  }
  UnionFind uf(N);
  sort(v.begin(), v.end());
  ll ans = 0;
  REP(i, N - 1){
    ans += (ll)uf.size(v[i].src) * uf.size(v[i].dst) * v[i].cost;
    uf.uni(v[i].src, v[i].dst);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4172
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;

int main()
{
	ll n,m;
	cin>>n>>m;
	if(n<m)
	cout<<"1";
	else
	{
		if(n%m==0)
		cout<<n/m;
		else
		cout<<(n/m)+1;
	}
}

Measured memory_bytes: 256
import copy

def Warshall_Floyd(edges,N):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        edges[i][j]=min(edges[i][j],edges[i][k]+edges[k][j])
  return edges

n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
g=[[float('inf')]*n for _ in range(n)]
for i in range(n):
  for j in range(n):
    g[i][j]=arr[i][j]
d=Warshall_Floyd(copy.deepcopy(g),n)
ans=0
for a in range(n):
  for b in range(n):
    if a>=b:
      continue
    w=g[a][b]
    if d[a][b]<w:
      print(-1)
      exit()
    else:
      tmp=10**10
      for k in range(n):
        if k==a or k==b:
          continue
        tmp=min(tmp,d[a][k]+d[k][b])
      if w==tmp:
        continue
      else:
        ans+=w
else:
  print(ans)

Measured memory_bytes: 60380
#include<iostream>
using namespace std;
int a,b,c,d;

    int main()
    {
        while(cin>>a>>b>>c>>d)
        {
            int ans=0;
            for(int i=0;i<=100;i++)
            {
                if((i>=a && i<=b) && (i>=c && i<=d))ans++;
            }
            printf("%d\n",ans-1>=0?ans-1:0);
        }
        return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,m,out,matrix[100][100],vector[100];
    scanf("%d %d",&n,&m);
    for(int i = 0;i<n;i++){
        for(int j = 0;j < m;j++){
            scanf("%d",&matrix[i][j]);
        }
    }
    for(int i = 0;i < m;i++) scanf("%d",&vector[i]);
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            out += matrix[i][j]*vector[j];
        }
        printf("%d\n",out);
        out = 0;
    }
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int ans = 0 ;
  int m = 10;  
  for(int i = 0;i<5;i++){
    int t ;    
    cin >> t;
    if( t % 10 == 0){
      ans += t;
    }
    else{
      ans += ((t/10)+1) *10;
      m = min(m,t % 10);
    }
  }
  if( m == 10 ){
    cout << ans ;
  }
  else {
    cout << ans + m - 10;
  }
    
}

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

    long long a,b,c,d,e,f,g,h,i,j,k,l,m,n,t,x,y,z;
    cin>>a>>b;
    if(a<=9&&b<=9)
        cout<<a*b<<endl;
    else cout<<"-1"<<endl;






}


Measured memory_bytes: 3636
n=int(input())

if(n<=111):
  print(111)
elif(111<n and n<=222):
  print(222)
elif(222<n and n<=333):
  print(333)
elif(333<n and n<=444):
  print(444)
elif(444<n and n<=555):
  print(555)
elif(555<n and n<=666):
  print(666)
elif(666<n and n<=777):
  print(777)
elif(777<n and n<=888):
  print(888)
elif(888<n and n<=999):
  print(999)  




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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	rep(i,3){
	if(s[i]=='1') ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from math import gcd as gcd
import numpy as np
N = int(input())
A = list(map(int,input().split()))

A = [0] + A + [0]

fromleft = np.array([0]*N)
fromright = np.array([0]*N)

for i in range(1,N):
    fromleft[i] = gcd(A[i],fromleft[i-1])
    fromright[-(i+1)] = gcd(A[-(i+1)],fromright[-i])

#print(fromleft)
#print(fromright)

ansgcd = [0]*N

for i in range(N):
    ansgcd[i] = gcd(fromright[i], fromleft[i])

print(max(ansgcd))

Measured memory_bytes: 38552
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
int h,w;
int main(){
    int n;
    std::cin >> n;
    string s;
    std::cin >> s;
    string t=s;
    int ans=0;
    rep(i,n+1){
        int c=0;
        rep(j,n){
            if(s[j]==t[j])c++;
            else{
                ans=max(ans,min(c,i));
                c=0;
            }
        }
        ans=max(ans,min(c,i));
        t.insert(t.begin(),'0');
    }
    std::cout << ans << std::endl;
        
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <fstream>

#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cctype>

#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
        os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

string const resstr[] = {"Impossible","Possible","No","Yes"};

const int MAX_V = 100;

int cost[MAX_V][MAX_V];

int V;

void bm(){
    rep(k,V)rep(i,V)rep(j,V){
        cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
    }

    // rep(i,V)rep(j,V){
    //     // printf("%d -> %d %d\n", i,j, cost[i][j]);
    // }
}

int main(){
    rep(i,100)rep(j,100){
        cost[i][j]=1<<29;
    }
    rep(i,100) cost[i][i]=0;

    int E;
    cin >> V >> E;
    rep(i,E){
        int a,b,c,d;
        scanf("%d,%d,%d,%d",&a,&b,&c,&d);
        a--,b--;
        cost[a][b]=c, cost[b][a]=d;
    }

    bm();
    int x1,x2,y1,y2; 
    scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
    x1--, x2--;

    int dis = cost[x1][x2] + cost[x2][x1];
    // cout << cost[x1][x2] << " " <<  cost[x2][x1] << endl;
    cout << y1 - y2 - dis << endl;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define inf             1e18
#define no_of_test(x)        int x; cin>>x; while(x--)
const int mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//	no_of_test(x)
	{
       	int a,b;
		   cin>>a>>b;
		   if(a%b==0)
		   {
			   cout<<a/b<<'\n';
		   }
		   else
		   {
			   {
				   cout<<(a/b)+1<<'\n';
			   }
		   }
		   
	}
	return 0;
}

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

typedef long long ll;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a[i];
    }
    ll cur1=0, cur2=0;
    ll a1=0, a2=0;
    for (int i=0; i<n; ++i) {
        cur1+=a[i];
        cur2+=a[i];
        if (i%2==0) {
            if (cur1>=0) {
                a1+=cur1+1;
                cur1=-1;
            }
            if (cur2<=0) {
                a2+=-cur2+1;
                cur2=1;
            }
        } else {
            if (cur1<=0) {
                a1+=-cur1+1;
                cur1=1;
            }
            if (cur2>=0) {
                a2+=cur2+1;
                cur2=-1;
            }
        }
    }
    cout << min(a1, a2);
    return 0;
}

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

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

  int lb=0;
  int rw=0;

  for(int i = 0; i < n; i++)
  {
      if(s[i]=='.'){
          rw++;
      }
  }

  int ans=lb+rw;
  for(int i = 0; i < n; i++)
  {
      if(s[i]=='.'){
          rw--;
      }
      else{
          lb++;
      }
      ans=min(ans,lb+rw);
  }
  cout << ans << endl;  
}


Measured memory_bytes: 640
function Main(input){
   input = input;
  
  	var num = String(input);
    var j = 1;
  	var judge = 0;
  	var array = num.split('');
  
  		for(var i=0;i<3;i++){
			if(array[i] == array[j]){
        		judge++;
        	}
          	else{
    			j++;
            }
		}
  
  	if(judge == 0){
      console.log('Good');
    }
    else{
      console.log('Bad');
    }
}
 Main(require("fs").readFileSync("/dev/stdin","utf-8"));

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int mod_pow(Int x, Int a, Int m = MOD){
    if(a == 0)return 1;
    if(a % 2 == 1)return x * mod_pow(x, a - 1, m) % m;
    Int res = mod_pow(x, a / 2, m);
    return res * res % m;
}

Int inv(Int x, Int m = MOD){
    return mod_pow(x, m-2, m);
}


int main(){
    Int n, m;
    cin >> n >> m;
    cout << mod_pow(n, m, 1000000007) << endl;
    return 0;
}


Measured memory_bytes: 3092
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
map< pair<int,int>,int > mp;
LL ans[10];
int main(void){
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    int i,k;
    int dx[9]={-2,-2,-2,-1,-1,-1,0,0,0};
    int dy[9]={-2,-1,0,-2,-1,0,-2,-1,0};
    ans[0]=(LL)(h-2)*(w-2);
    for(i=0;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		x--; y--;
		for(k=0;k<9;k++){
			int nx=x+dx[k],ny=y+dy[k];
			if(nx<0 || nx>=h-2 || ny<0 || ny>=w-2) continue;
			//printf(" %d %d\n",nx,ny);
			pair<int,int> now=MP(nx,ny);
			if(mp.find(now)==mp.end()){
				ans[0]--;
				mp[now]=1;
				ans[1]++;
			}else{
				ans[mp[now]]--;
				mp[now]++;
				ans[mp[now]]++;
			}
		}
		/*for(k=0;k<10;k++)
			printf("%d ",ans[k]);
		printf("\n");*/
	}
	for(i=0;i<10;i++)
		printf("%lld\n",ans[i]);
    return 0;
}


Measured memory_bytes: 56448
n = int(input())
A = list(map(int,input().split()))
q = int(input())
M = list(map(int,input().split()))

flag = [0]*(2000+1)
for status in range(2**n):
    tmp = 0
    for mask in range(n):
        if status&(1<<mask):
            tmp += A[mask]
    flag[tmp] = True

for m in M:
    print('yes' if flag[m] else 'no')


Measured memory_bytes: 5636
#include "math.h"
#include <algorithm>
#include <set>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int ans = 1e4;
    rep(i, 26)
    {
        char tar = char('a' + i);
        string t = s;
        bool flag = false;
        rep(j, n)
        {
            if (s[j] == tar) {
                flag = true;
            }
        }
        if (!flag) {
            continue;
        }
        int cnt = 0;
        while (true) {
            string h = t;
            string l = "";
            set<char> se;
            rep(j, t.size())
            {
                se.insert(t[j]);
            }
            if (se.size() == 1) {
                break;
            }
            rep(j, (int)h.size() - 1)
            {
                if (h[j] == tar || h[j + 1] == tar) {
                    l += tar;
                } else {
                    l += "*";
                }
            }
            t = l;
            cnt++;
        }
        ans = min(cnt, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;



int main()
{   IOS;
cout.precision(30);
    ll n;
    cin >> n ;
    vector <ll> L;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin >> x;
        L.push_back(x);
    }
    sort(L.begin(),L.end());
    cout << L[(n/2)]-L[(n/2)-1];



    return 0;
}


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

int main()
{
    int N,K;
    cin >> N >> K;

    vector<int> A(N);

    for (int i = 0; i < N;i++){
        cin >> A.at(i);
    }

    int count=0;

    for (int i = 0; i < N;i++){
        if(A.at(i)>=K){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[1000],t[10000];
    int i,j,n;
    scanf("%s%s",s,t);
    n=strlen(s);
    for(i=0;i<n;i++)
    {
        if(t[i]==s[0] && t[(i+1)%n]==s[1])
        break;
    }
    for(j=0;j<n;j++)
    {
        if(s[j]==t[i%n])
        i++;
        else
        break;
    }
    if(j==n)
    printf("Yes");
    else
    printf("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a, b) memset(a, (b), sizeof(a))
#define fore(i,a) for(int i=0;i<a;i++)
#define fore1(i,j,a) for(int i=j;i<a;i++)
#define print(ar) for(int i=0;i<ar.size();i++)cout<<ar[i]<<" ";
#define END cout<<'\n'
const double pi=acos(-1.0);
 
typedef pair<int, int> PII;
 
typedef vector<long long> VI;
 
typedef vector<string> VS;
 
typedef vector<PII> VII;
 
typedef vector<VI> VVI;
 
typedef map<int,int> MPII;
 
typedef set<int> SETI;
 
typedef multiset<int> MSETI;
 
typedef long int li;
 
typedef unsigned long int uli;
 
typedef long long int ll;
 
typedef unsigned long long int  ull;
ll fastexp (ll a, ll b, ll n) {
  ll res = 1;
  while (b) {
      if (b & 1) res = res*a%n;
      a = a*a%n;
      b >>= 1;
  }
  return res;
}
void fast(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void CountTriangles(vector<int> A) 
{ 
    print(A);
    int n = A.size(); 
  
    sort(A.begin(), A.end()); 
  
    int count = 0; 
  
    for (int i = n - 1; i >= 1; i--) { 
        int l = 0, r = i - 1; 
        while (l < r) { 
            if (A[l] + A[r] > A[i]) { 
  
                count += r - l; 
  
                // checking for more possible solutions 
                r--; 
            } 
            else
  
                // if not possible check for 
                // higher values of arr[l] 
                l++; 
        } 
    } 
    cout << count <<endl; 
} 
int main()
 {  fast();
	int t, n, k;
    //cin >> t;
    t=1;
	while(t--) {
    ll x,k,d;
    cin>>x>>k>>d;
    if(x<0){
        x=x*-1;
    }
    if((x/d)<k){
        ll a;
        if((k-x/d)%2==0)
         a=x-(x/d)*d;
        else 
        a=abs(x-(x/d+1)*d);
        cout<<a<<endl;
    }
    else {
        cout<<min(abs(x-(d)*k),x)<<endl;
    }
      
     }}
       

	  


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    long long N, K; cin >> N >> K;
    cout << min(N % K, K - (N % K)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    cout << "ABC";
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h> //rand() 0~RAND_MAX2147483647
#include <math.h>
#include <time.h>   //srand((unsigned int)time(NULL));
#include <unistd.h> //sleep
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
#include <numeric>
#include <iterator>
#include <list>

using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
#define FORREVeq(i,max,min) for(int i=(max);i>=(min);i--)
const int MOD=1e9+7;
const int MOD2=998244353;

const int INF=2000000001;
const ll INFll=2e18;
//const int MAX_V=10000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INFll || MOD2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){cin>>array[i];}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){cin>>arrayA[i]>>arrayB[i];}
#define br printf("\n");
#define OutputAndReturn0(x) {cout<<(x)<<endl;return 0;}
#define elif else if

#define issame(a,b,c,d) ((a)==(b) and (b)==(c) and (c)==(d))
#define isdiff3(a,b,c) ((a)!=(b) and (b)!=(c) and (c)!=(a))
#define isdiff4(a,b,c,d) ((a)!=(b) and (b)!=(c) and (c)!=(a) and (d)!=(a) and (d)!=(b) and (d)!=(c))
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
inline ll  gcd(ll a,ll b){ if(b==0)return a;else return gcd(b,a%b);}//最大公約数 なお一方が0なら答えは他方になるので番兵は０で良い また、負の数もOK -4%3=-1となるため
inline ll  lcm(ll a,ll b){return a*b/gcd(a,b);}//MODやオーバーフローには注意！



//Eと名のつくのはデバッグ用！
int EintN(ll array[],const int num){
    for(int i=0;i<num;i++){cerr<<array[i]<<" ";}
    br;
    return 0;
}
int EintNN(const int heighth,const int width,int array[heighth][width]){
    FOR(i, 0, heighth){
        FOR(k, 0, width){
            {cerr<<array[i][k]<<" ";}
        }
        br;
    }
    br;
    return 0;
}
int Eint(string str,const ll num){
    cerr<<str<<" is "<<num<<" now."<<endl;
    return 0;
}


int Ap(){
    int a;a=0;
    string s;
    cin>>a>>s;
    if(a>=3200){OutputAndReturn0(s);}
    OutputAndReturn0("red");
    return 0;
}

ll Bp(){
    ll ans;ans=0;
    int n;
    cin>>n;
    double a[n];
    
    double revsum=0;
    FOR(i, 0, n){
        cin>>a[i];
        revsum+=1/a[i];
    }
    printf("%lf\n",1/revsum);
    return 0;
}

int Cp(){
    int ans;ans=0;
    
    return 0;
}

int Dp(){
    long long int N=0;
    
    OutputAndReturn0(N);
    return 0;
}

signed main(){
    //test();
    //Ap();
    Bp();
    //Cp();
    //Dp();
    return 0;
}


Measured memory_bytes: 888
#include<iostream>

using namespace std;

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

	if (b >= a && a> 0) {
		cout << "Positive" << endl;
	}
	else if (a <= b && b < 0) {
		if ((b - a + 1) % 2 == 0) {
			cout << "Positive" << endl;
		}
		else if((b - a + 1) % 2 != 0){
			cout << "Negative" << endl;
		}
	}
	else if(a <= 0 && 0 <=b ){
			cout << "Zero" << endl;
	}

	return 0;
}

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

typedef vector<int > vi;
typedef vector<vi> vii;

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

vector<int> G[maxn];
int n;
int power[maxn];
int dep[maxn];
int freq[maxn];

void add(int &a, int b){
    a += b;
    if(a >= mod){
        a -= mod;
    }
}

int mul(int a, int b){
    long long c = 1LL * a * b;
    if(c >= mod)
        c %= mod;
    return c;
}

void merge(vii &a, vii b){
    int len1 = a.size();
    int len2 = b.size();
    for(int i = 0;i < len2;i++){
        vi tmp = {0, 0, 0};
        for(int x = 0;x <= 2;x++){
            for(int y = 0;y <= 2;y++){
                int z = min(x + y, 2);
                int val = mul(a[len1 - 1 - i][x], b[len2 - 1 - i][y]);
                add(tmp[z], val);
            }
        }
        a[len1 - 1 - i] = tmp;
    }
}

void recalc(vii &a, int len1){
    int len = a.size();
    for(int i = 0;i < len1;i++){
        add(a[len - 1 - i][0], a[len - 1 - i][2]);
        a[len - 1 - i][2] = 0;
    }
}

vii dfs(int u, int depth){
    dep[u] = depth;
    vii tmp;
    int ma = 0;
    for(auto v : G[u]){
        vii ret = dfs(v, depth + 1);
        if(tmp.size() < ret.size())
           swap(ret, tmp); 
        ma = max(ma, (int)min(ret.size(), tmp.size()));
        merge(tmp, ret);
    }
    if(tmp.size())
        recalc(tmp, ma);
    tmp.push_back({1, 1, 0});
    return tmp;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    power[0] = 1;
    for(int i = 1;i <= n;i++){
        power[i] = power[i - 1] * 2 % mod;
    }
    for(int i = 1;i <= n;i++){
        int p;
        cin >> p;
        G[p].push_back(i);
    }
    vii dp = dfs(0, 0);
    for(int i = 0;i <= n;i++){
        freq[dep[i]]++;
    }
    int ans = 0;
    for(int i = 0;i < dp.size();i++){
        int tmp = 1LL * power[n + 1 - freq[dp.size() - 1 - i]] * dp[i][1] % mod;
        add(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 56620
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 1010;
const ll INF = 1e17;
ll dp[N][N][8];

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

    VVL x(n, VL(3));
    REP(i,n) REP(j,3) cin >> x[i][j];

    REP(i,n+1) REP(j,m+1) REP(k,8) dp[i][j][k] = -INF;
    REP(k,8) dp[0][0][k] = 0;

    REP(i,n) REP(j,m+1) REP(k,8){
        if (dp[i][j][k] == -INF) continue;
        dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);
        ll tmp = dp[i][j][k];
        REP(p,3){
            if ((k >> p) & 1){
                tmp += x[i][p];
            }else{
                tmp -= x[i][p];
            }
        }
        dp[i+1][j+1][k] = max(dp[i+1][j+1][k], tmp);
    }
    ll ans = -INF;
    REP(k,8) ans = max(ans, dp[n][m][k]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 63744
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()

lint dp[2010][2];
lint a[2010];
lint n, z, w;

lint f(lint i, lint turn){
  if(dp[i][turn] != -1) return dp[i][turn];
  lint curVal = w;
  lint ret;
  if(i != 0) curVal = a[i - 1];
  
  if(turn == 0){
    // maximize
    ret = 0;
    srep(ni, i + 1, n){
      ret = max(ret, f(ni, 1));
    }
    ret = max(ret, (lint)abs(curVal - a[n - 1]));

  }else{
    // minimize
    ret = INF;
    srep(ni, i + 1, n){
      ret = min(ret, f(ni, 0));
    }
    ret = min(ret, (lint)abs(curVal - a[n - 1]));
  }

  dp[i][turn] = ret;
  return ret;
}

int main(){
  
  cin >> n >> z >> w;
  rep(i, n) cin >> a[i];
  rep(i, n + 1)
    rep(j, 2) dp[i][j] = -1;



  cout << f(0, 0) << endl; 
  return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if (a+b+c)%2 != 0 {
		fmt.Println("No")
		return
	}
	h := (a + b + c) / 2
	if a == h || b == h || c == h {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=1 ; i<=(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

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

  int a,b, ans;
  a = x/500;
  x-= a*500;
  b = x/5;
  ans = a*1000 + b*5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i;
    double a,sum,seq[10]={0};
    while(scanf("%lf",&a)!=EOF){
        sum=0;
        for(i=0;i<10;i++){
            if(i==0) seq[i]=a;
            else if(i%2==0){
                seq[i]=seq[i-1]/3;
            }
            else{
                seq[i]=seq[i-1]*2;
            }
        }
        for(i=0;i<10;i++){
            sum+=seq[i];
        }
        printf("%0.8f\n",sum);
    }
    return 0;
}

Measured memory_bytes: 652
import collections
num=collections.deque([])

for i in range(int(input())):
	com=input().split()
	if com[0]=='insert':
		num.appendleft(com[1])
	elif com[0]=='delete':
		try:
			num.remove(com[1])
		except ValueError:
			pass
	elif com[0]=='deleteFirst':
		num.popleft()
	elif com[0]=='deleteLast':
		num.pop()
print(' '.join(num))
		


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N-1);
  vector<int> b(N);
  for (int i=0; i<N-1; i++) {
    cin >> a[i];
  }
  
  for (int j=0; j<N-1; j++) {
    b[a[j]-1] ++;
  }
  
  for (int l=0; l<N; l++) {
    cout << b[l] << endl;
  }
}


Measured memory_bytes: 4844
#include <iostream>

#define max(a,b) ((a)>(b)?(a):(b))

using namespace std;

int main(){
  int N,M;
  cin >> N>>M;
  int H[100001],MAX[100001] = {0};
  for(int i=1; i<=N; i++){
   cin >> H[i];
  }
  for(int i=1; i<=M; i++){
   int A,B;
    cin >>A>>B;
    MAX[A] = max(MAX[A],H[B]);
    MAX[B] = max(MAX[B],H[A]);
  }
  int count =0;
  for(int i=1; i<=N; i++){
    if(H[i]>MAX[i])
      count++;
  }
  cout << count <<endl;
 return 0; 
}


Measured memory_bytes: 4384
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

const int mod = 1000000007;

vector<int> v[100000];
ll dp[2][100000] = {};
bool vis[2][100000] = {};

int dfs(int p, int x, int c){
    if(dp[c][x])   return dp[c][x];
    dp[c][x] = 1;
    for(int child : v[x]){
        if(child == p)   continue;   // 1でもよい
        ll tmp = dfs(x, child, 0);
        if(c == 0){
            tmp += dfs(x, child, 1);
            tmp %= mod;
        }
        dp[c][x] *= tmp;
        dp[c][x] %= mod;            
    }
    return dp[c][x];
}

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n-1; i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    cout << (dfs(-1,0,0)+dfs(-1,0,1))%mod << endl;
    return 0;
}

Measured memory_bytes: 15616
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

ll l[51], p[51];

ll rec(int N, ll X) {
    if (X <= 0) return 0;
    if (X >= l[N]) return p[N];

    ll ret = 0;
    ret += rec(N - 1, X - 1);
    if (X > l[N - 1] + 1) ++ret;
    ret += rec(N - 1, X - l[N - 1] - 2);

    return ret;
}

int main() {
    l[0] = 1, p[0] = 1;
    for (int i = 1; i <= 50; ++i) {
        l[i] = l[i - 1] * 2 + 3;
        p[i] = p[i - 1] * 2 + 1;
    }

    ll N, X;
    cin >> N >> X;

    cout << rec(N, X) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count = 0
total = 0
minimum = 1000000000
for n in range(N):
    if A[n] > 0:
        total += A[n]
        minimum = min(minimum, A[n])
    else:
        total += -A[n]
        minimum = min(minimum, -A[n])
        count += 1
if count%2 == 0:
    print(total)
else:
    print(total-2*minimum)

Measured memory_bytes: 15020