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

s_left = [0]
s_right = [sum(a)]
for i in range(n):
    s_left.append(s_left[-1] + a[i])
    s_right.append(s_right[-1] - a[i])

df = []
for i in range(1, len(s_left) - 1):
    df.append(abs(s_left[i] - s_right[i]))

print(min(df))


Measured memory_bytes: 37484
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ");cout<<endl;
#define pdd(a,n,m)for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define mp make_pair
#define pb push_back
#define ll long long
#define int ll
//#define __int64 lng long
#define P pair<int,int>
#define PP pair<P,int>

int k;
int cnt;
vector<int>r;
queue<int>bfs;

signed main(){
  cin>>k;
  rep(i,9){
    bfs.push(i+1);
    r.pb(i+1);
    cnt++;
  }

  while(!bfs.empty()){
    if(cnt>k)
      break;
      int now=bfs.front();
      bfs.pop();

      int last=now%10;
      if(last>0){
        bfs.push(now*10+last-1);
        r.pb(now*10+last-1);
        cnt++;
      }
      bfs.push(now*10+last);
       r.pb(now*10+last);
      if(last<9){
        bfs.push(now*10+last+1);
        r.pb(now*10+last+1);
      }
  }
  sort(r.begin(),r.end());
  cout<<r[k-1]<<endl;
  return 0;
}


Measured memory_bytes: 7500
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
using ll = long long int;

int main(){
    int n;
    vector<int> A;
    cin >> n;
    A.resize(n);
    for(int i = 0; i < n; i++)cin >> A[i];

    sort(A.begin(), A.end(), greater<int>());

    ll ans = 0;
    int num = 0;
    int res = 1;
    for(int i = 0; i < n-1; i++){
        if (res == 0){
            num++;
            res = 2;
        }
        ans += A[num];
        res--;
    }
    cout << ans << endl;
    return 0;
}

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

int main(void){

    int n, x;
    cin >> n >> x;
    
    vector<int> L(n);
    for(int i=0; i<n; i++) cin >> L[i];
    
    int count = 1;
    int D = 0;
    
    for(int i=0; i<n; i++) {
        D += L[i];
        if(D<=x) count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    double[] x, y;
    int i, j;
    double sum, ax, ay, bx, by;

    for(j = 1;;){
      n = sc.nextInt();
      if(n == 0)break;
      x = new double[n];
      y = new double[n];

      for(i = 0;i < n;i++){
        x[i] = sc.nextDouble();
        y[i] = sc.nextDouble();
      }

      sum = 0.0;
      for(i = 0;i < n - 2;i++){
        ax = x[i + 1] - x[0];
        ay = y[i + 1] - y[0];
        bx = x[i + 2] - x[0];
        by = y[i + 2] - y[0];
        sum += (ax * by - ay * bx) / 2.0;
      }

      System.out.printf("%d %.1f%n", j++, -sum);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 23404
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int N;
  cin >> N;
  for (auto i = 0; i <= N; ++i) {
    int sum = i * (i+1) / 2;
    if (sum >= N) {
      int n = sum - N;
      for (auto j = 1; j <= i; ++j) {
        if (j != n) {
          cout << j << endl;
        }
      }
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b,cnt=0,x,i=1,flag=0,y;
  cin>>a>>b;
  y=b;
  while (b!=0) {
    b/=10;
    cnt+=1;
  }
  x=a*pow(10,cnt)+y;
  while (x>=i*i) {
    if (i*i==x) {
      cout<<"Yes"<<endl;
      flag+=1;
      break;
    }
    i+=1;
  }
  if (flag==0) {
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdint>
#include <utility>
#include <tuple>
#include <map>    
#include <queue> 
#include <set>  
#include <stack> 
#include <deque>  
#include <unordered_map> 
#include <unordered_set> 
#include <bitset>

using namespace std;

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

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

	int ans = 0;
	int count = 0;
	for (int i = 0; i < N - 1; i++) {
		int dif = H.at(i) - H.at(i + 1);
		if (dif >= 0) {
			count++;
		}
		if (ans < count) {
			ans = count;
		}
		if(dif < 0) {
			count = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <list>
#include <cmath>
#include <fstream>
#include <queue>
#include <sstream>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
	int a,b;
	while(cin >> a >> b)
	{
		int n = a + b;
		int count = 0;
		while(n)
		{
			n /= 10;
			count ++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define N 8
#define YES 1
#define NO 0

int X[N],Y[N],L_U[2*N - 1],R_U[2*N - 1];

char Board[N][N];

void print(){
  int i,j;
  for(i = 0 ; i < N; i++){
    for(j = 0; j < N; j++){
      if(Board[i][j] == 'Q' && X[i] != j)return;
    }
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(X[i] == j) Board[i][j] = 'Q';
    }
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      printf("%c",Board[i][j]);
    }
    printf("\n");
  }
}

void Solve(int i){
  int j;
  if(i == N) {
    print();
    return;
  }
  for(j = 0; j < N; j++){
    if(Y[j] == NO || L_U[i + j] == NO || R_U[i - j +  N - 1] == NO) continue;
    X[i] = j;
    Y[j] = L_U[i + j] = R_U[i - j + N - 1] = NO;
    Solve(i + 1);
    X[i] = Y[j] = L_U[i + j] = R_U[i - j + N - 1] = YES;
  }

}

int main()
{
  int n,i,j,r,c;
  /*Initialize*/
  for(i = 0; i < N; i++) {
    X[i] = YES;
    Y[i] = YES;
  }
  for(i = 0; i < 2*N-1; i++) {
    L_U[i] = YES;
    R_U[i] = YES;
  }
  for(i = 0; i < N;i++){
    for(j = 0; j < N; j++){
      Board[i][j] = '.';
    }
  }
  /*main*/    
  scanf("%d",&n);
  for(i = 0; i < n;i++){
    scanf("%d%d",&r,&c);
    Board[r][c] = 'Q';
  }
  Solve(0);

  return 0;
}



Measured memory_bytes: 2112
#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() {
    string a, b; cin >> a >> b;
    int n = a.size();
    int m = b.size();
    rep(i, n) {
        if(i!=n-1) cout << a[i] << b[i];
        else {
            if(n==m) cout << a[i] << b[i];
            else cout << a[i];
        }
    }puts("");
}


Measured memory_bytes: 256
//ABC 048-A
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;


int main() {
	long long a, b, x, ans;
	cin >> a >> b >> x;

	if (a%x == 0) ans = b / x - a / x + 1;
	else ans = b/x - a/x;

	cout << ans << endl;

}


Measured memory_bytes: 384
#
# abc177 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """cabacc
abc"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """codeforces
atcoder"""
        output = """6"""
        self.assertIO(input, output)


def resolve():
    S = input()
    T = input()

    ans = float("inf")
    for i in range(len(S)-len(T)+1):
        tmp = 0
        for j in range(len(T)):
            if T[j] != S[i+j]:
                tmp += 1
        ans = min(ans, tmp)

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

using namespace std;

constexpr int MaxN = 100000 + 10;
constexpr int MaxD = 10 + 10;
int n, m, q;
vector<int> E[MaxN];
int C[MaxN];
int dp[MaxN][MaxD + 10];

void MaxAssign(int &a, int b) {
    a = max(a, b);
}

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

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }

    cin >> q;
    memset(dp, -1, sizeof(dp));

    for (int i = 0; i < q; i++) {
        int v, d, c;
        cin >> v >> d >> c;
        v--;
        C[i] = c;

        dp[v][d] = i;
    }

    for (int dist = MaxD; dist > 0; dist--) {
        for (int no = 0; no < n; no++) {
            if (dp[no][dist] >= 0) {
                for (auto& to : E[no]) {
                    MaxAssign(dp[to][dist - 1], dp[no][dist]);
                }
                MaxAssign(dp[no][dist - 1], dp[no][dist]);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        int ans = dp[i][0] >= 0 ? C[dp[i][0]] : 0;
        cout << ans << endl;
    }
}


Measured memory_bytes: 18552
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int bitCount[13] = { 0, };

vector<int> make(int bit)
{
	if (bit == 12)
	{
		if (bitCount[bit] == 1)
			return vector<int> { 1 << 12 };
		else
			return vector<int> { 0 };
	}

	auto next = make(bit + 1);

	if (bitCount[bit] == 0)
		return next;

	if (bitCount[bit] == 1)
	{
		//둘 중에 하나 선택 가능
		vector<int> res;

		for (auto& ni : next)
		{
			res.push_back(ni | (1 << bit));
			res.push_back(ni | (1 << (24 - bit)));
		}

		return res;
	}
	else
	{
		// s != 0 이 되려면 항상 두 개를 서로 다른 위치에 배치해줘야 함
		for (auto& ni : next)
		{
			ni |= (1 << bit);
			ni |= (1 << (24 - bit));
		}

		return next;
	}
}

int main()
{
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		int d;
		scanf("%d", &d);
		bitCount[d]++;
	}

	if (bitCount[0] >= 1 || bitCount[12] >= 2)
	{
		printf("0\n");
		return 0;
	}

	for (int i = 1; i < 12; i++)
	{
		if (bitCount[i] >= 3)
		{
			printf("0\n");
			return 0;
		}
	}

	//0..12 까지 존재하는 숫자들 가지고 가능한 시간 배열 생성
	auto cases = make(1);

	int s = 0;

	for (auto& c : cases)
	{
		vector<int> p = { 0, };

		for (int i = 1; i < 24; i++)
		{
			if ((c & (1 << i)) != 0)
				p.push_back(i);
		}

		p.push_back(24);

		int g = 24;

		for (int i = 0; i < p.size() - 1; i++)
			g = min(g, p[i + 1] - p[i]);
		
		if (g == 24)
			continue;

		s = max(g, s);
	}

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

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<map>
#include<cstring>

int n;
int a[12], prv[12];
std::map<int, int> cnt, tmp;
int ans;

int main()
{
	while( std::cin >> n, n )
	{
		ans = 0;
		memset( a, 0, sizeof( a ) );
		memset( prv, 0, sizeof( prv ) );
		cnt.clear();
		tmp.clear();

		for( int i = 0; i != n; ++i )
		{
			std::cin >> a[i];
			++cnt[a[i]];
		}

		while( true )
		{
			std::copy( a, a + 12, prv );

			for( int i = 0; i != n; ++i )
			{
				a[i] = cnt[a[i]];
				++tmp[a[i]];
			}

			if( std::equal( a, a + 12, prv ) )
				break;

			++ans;

			cnt = tmp;
			tmp.clear();
		}

		std::cout << ans << std::endl;
		for( int i = 0; i != n; ++i )
			std::cout << a[i] << ( i == n - 1 ? '\n' : ' ' );
	}

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
int main(void)
{
	long double a,b;
	cin>>a>>b;
	long double ans=a*b;
	cout<<(ll)ans<<endl;
}

Measured memory_bytes: 3780
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
H = INT()
W = INT()

print((N-H+1)*(N-W+1))


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

typedef long long ll;

const int N = 1e5 + 20;
ll dp[N][3];

int main()
{
	int n;
	cin >> n;
	ll a, b, c;
	cin >> a >> b >> c;
	dp[0][0] = a; dp[0][1] = b; dp[0][2] = c;
	for (int i = 1; i < n; i++)
	{
		cin >> a >> b >> c;
		dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]);
	}
	cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
}


Measured memory_bytes: 5932
def main():
  n = int(input())
  m = list(input_list())
  d = int(input())
  t = list(input_list())
  if n < d:
    print('NO')
    exit()
  mc = collections.Counter(m)
  tc = collections.Counter(t)
  for key, count in tc.items():
    if mc[key] < count:
      print('NO')
      exit()
  print('YES')
  
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

Measured memory_bytes: 58788
using System;

class program{
	static void Main(string[] args){
      string[] input = Console.ReadLine().Split(' ');
      int a = int.Parse(input[0]);
      int b = int.Parse(input[1]);
      int c = int.Parse(input[2]);
      int x=0;
      
      if(a==5||a==7){
        if(b==5||b==7){
          if(c==5||c==7){
            if((a+b+c)==17){
              x = 1;
            }
          }
        }
      }
      
      if(x==1){
        Console.WriteLine("YES");
      }else{
        Console.WriteLine("NO");
      }
    }
}

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


int main()
{
    ll n, c;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    rep(i, 0, n)
        cin >> x[i] >> v[i];

    vector<ll> cumsum(n + 1), cumsum_rev(n + 1);
    cumsum[0] = cumsum_rev[0] = 0;
    rep(i, 0, n)
    {
        cumsum[i + 1] = cumsum[i] + v[i];
        cumsum_rev[i + 1] = cumsum_rev[i] + v[n - i - 1];
    }

    vector<ll> back(n + 1), back_rev(n + 1);
    back[0] = back_rev[0] = 0;
    rep(i, 0, n) 
    {
        back[i + 1] = max(back[i], cumsum[i + 1] - x[i] * 2);
        back_rev[i + 1] = max(back_rev[i], cumsum_rev[i + 1] - (c - x[n - i - 1]) * 2);
    }

    ll ans;
    ans = max(cumsum[n] - x[n - 1], cumsum_rev[n] - (c - x[0]));
    ans = max(0LL, ans);
    rep(i, 0, n - 1)
    {
        ll cand1 = cumsum[i + 1] + back_rev[n - i - 1] - x[i];
        ll cand2 = cumsum_rev[i + 1] + back[n - i - 1] - (c - x[n - 1 - i]);
        ans = max(ans, cand1);
        ans = max(ans, cand2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int a[100001],f[100001];
int main()
{
        int n,k,i,j;
        scanf("%d %d",&n,&k);
        for(i=1;i<=n;i++)
                scanf("%d",&a[i]);
        for(i=2;i<=n;i++)
        {
                f[i]=INT_MAX;
                for(j=1;j<=min(k,i-1);j++)
                {
                        f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
                }
        }
        printf("%d",f[n]);
        return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int main(){
  ll N;
  cin>>N;
  vector<ll> b(N),ruiseki(N+1,0);
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  vector<ll> a(b);
  
  //plus minus
  ll ans=0;
  if(a[0]<=0) {
    ans+=(-a[0]+1);
    a[0]=1;
  }
  ll pos=a[0];
  for(int i=1;i<N;i++){
    if(i%2==1){ //minus
      if(pos+a[i]>=0){
        ans+=pos+a[i]+1;
        a[i]=-pos-1;
      }
    }else{ //plus
      if(pos+a[i]<=0){
        ans+=-(pos+a[i])+1;
        a[i]=-pos+1;
      }
    }
    pos+=a[i];
  }

  //minus plus
  ll ans2=0;
  if(b[0]>=0) {
    ans2+=b[0]+1;
    b[0]=-1;
  }
  pos=b[0];
  for(int i=1;i<N;i++){
    if(i%2==0){ //minus
      if(pos+b[i]>=0){
        ans2+=pos+b[i]+1;
        b[i]=-pos-1;
      }
    }else{ //plus
      if(pos+b[i]<=0){
        ans2+=-(pos+b[i])+1;
        b[i]=-pos+1;
      }
    }
    pos+=b[i];
  }

  cout<<min(ans,ans2)<<endl;
  return 0;
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int n, m, x;
vector<int> a;
/**********************************************/

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

    cin >> n >> m >> x;
    a.resize(m);
    REP(i, m) cin >> a[i];

    int cnt = 0;
    REP(i, m){
        if(a[i] > x) continue;
        cnt++;
    }
    cout << min(cnt, m-cnt) << endl;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(n int) int {
        sum := 0
        for i := 1; i <= n; i++ {
                if i%3 != 0 && i%5 != 0 {
                        sum += i
                }
        }
        return sum
}

func main() {
        var n int
        fmt.Scan(&n)
        fmt.Println(solution(n))
}

Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    int n, k, b;
    bitset<18> T;
    cin >> n;
    cin >> k;
    rep(i, k)
    {
        cin >> b;
        T.set(b);
    }
    
    rep(i, pow(2, n))
    {
        bitset<18> bit(i);
        if ((bit & T) == T)
        {
            cout << i << ":";
            rep(j, 18)
            {
                if (bit.test(j)) cout << " " << j;
            }
            cout << endl;
        }
    }
}



Measured memory_bytes: 3272
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
r = [[0]*w for _ in range(h)]
for i in range(h):
    flg = False
    for j in range(w):
        if s[i][j]=='.':
            if not flg:
                tmp = 0
                begin = j
                flg = True
            tmp += 1
        if flg and s[i][j]=='#':
            for k in range(begin, j):
                r[i][k] = tmp
            flg = False
    if flg:
        for k in range(begin, w):
            r[i][k] = tmp
c = [[0]*w for _ in range(h)]
for i in range(w):
    flg = False
    for j in range(h):
        if s[j][i]=='.':
            if not flg:
                tmp = 0
                begin = j
                flg = True
            tmp += 1
        if flg and s[j][i]=='#':
            for k in range(begin, j):
                c[k][i] = tmp
            flg = False
    if flg:
        for k in range(begin, h):
            c[k][i] = tmp
ans = 0
for row1, row2 in zip(r, c):
    for e1, e2 in zip(row1, row2):
        if ans<e1+e2-1:
            ans = e1+e2-1
print(ans)

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

using namespace std;

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int res = 0;

    for(int a = 0; a <= A; ++a) {
        for(int b = 0; b <= B; ++b) {
            for(int c = 0; c<= C; ++c) {
                int total = 500*a + 100*b + 50*c;
                if(total == X) ++res;
            }
        }
    }

    cout << res <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
vector<int> h, memo;

// int dp(int n) {
//     if (memo[n] != -1) {
//         return memo[n];
//     }
//     if (n == 0) {
//         return 0;
//     }
//     if (n == 1) {
//         return abs(h[1] - h[0]);
//     }
//     memo[n] = min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
//     return min(dp(n - 1) + abs(h[n] - h[n - 1]), dp(n - 2) + abs(h[n] - h[n - 2]));
// }

signed main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    for (int i = 0; i < 1000; i++) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        long res = 0;
        boolean[] seen = new boolean[n];
        int[] A = new int[n];
        for(int i = 0; i < n; i++) {
            A[i] = Integer.parseInt(sc.next())-1;
        }
        int next = A[0];
        List<Integer> list = new ArrayList<>();
        list.add(0);
        int idx = -1;
        seen[0] = true;
        while(true) {
            if(seen[next]) {
                idx = next;
                break;
            }
            seen[next] = true;
            list.add(next);
            next = A[next];
        }

        int c = 0;
        next = A[idx];
        while(true) {
            c++;
            if(next == idx) break;
            next = A[next];
        }

        if(k < list.size()) {
        	res = list.get((int)k) + 1;
        } else {
        	res = list.get((int)((k - list.size() + c) % c + list.size() - c)) + 1;
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 61256
#include <cstdio>

int num[300000];

void prime(){
	num[0] = 0;
	num[1] = 0;
	for(int i = 2; i < 300000; i++) num[i] = 1;
	for(int i = 2; i < 1000; i++){
		if(!num[i]) continue;
		for(int j = 2*i; j < 300000; j += i){
			num[j] = 0;
		}
	}
}

int main(){
	prime();
	for(int i = 1; i < 300000; i++) num[i] += num[i-1];
	int n;
	while(scanf("%d",&n),n) printf("%d\n", num[2*n]-num[n]);
}

Measured memory_bytes: 2200
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = scan.nextInt();
        int b = scan.nextInt();
        int answer = a + b;
        if (10 <= answer) {
            System.out.println("error");
        } else {
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 21844
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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; }

 


void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> P(n);
    rep(i,n) cin >> P[i];
    int ans = 0;
    int nowmin = n*2;
    for (int i = 0; i < n; i++) {
        if(nowmin >= P[i]) {
            ans++;
            nowmin = P[i];
        }
    }
    
    cout << ans << endl;
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int a[80000];
map<int, int> cnt;
int main() {
	string s;
	while (cin >> s, s != "0") {
		cnt.clear();
		a[0] = s[0] - '0';
		for (int i = 1; i < s.size(); i++) a[i] = (a[i - 1] * 10 + (s[i] - '0')) % 11;
		for (int i = 1; i < s.size(); i += 2) (a[i] *= 10) %= 11;
		int ans = 0;
		for (int i = 0; i < s.size(); i++) {
			ans += cnt[a[i]];
			if (a[i] == 0) ans++;
			if (i+1<s.size() && s[i + 1] != '0') cnt[a[i]]++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3592
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,X,Y=get_i
k=array(N,0)
1.upto(N-1).each do|i|
    (i+1).upto(N).each do|j|
        if (j-i)>(X-i).abs+(Y-j).abs+1
            k[(X-i).abs+(Y-j).abs+1]+=1
        else
            k[(j-i)]+=1
        end
    end
end

k.shift
k.each do|k_|
    puts k_
end

Measured memory_bytes: 1916
f = true;
e = false;

while (s = gets) && !e do
  if f then
    f = false;
  else
    puts;
  end
  a = s.split(" ").map(&:to_i);
  a[0].times{|i|
    if i == 0 || i == a[0] - 1 then
      puts "#" * a[1];
    else
      puts "#" + "." * (a[1] - 2) + "#";
    end
  }
end

Measured memory_bytes: 8880
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n+1];
        for (int i = 1; i < n; i++) {
            int a = sc.nextInt();
            array[a]++;
        }
        for (int i = 1; i <= n; i++) {
            System.out.println(array[i]);
        }
    }
}


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

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

string a,b,c;
int main()
{

    cin>>a>>b>>c;
    a[0]-=32;
    b[0]-=32;
    c[0]-=32;
    cout<<a[0]<<b[0]<<c[0];
}




Measured memory_bytes: 256
unittest
{
	assert( [ "6 4", "-10 8 2 1 2 6" ].parse.expand.solve == 14 );
	assert( [ "6 4", "-6 -100 50 -2 -5 -3" ].parse.expand.solve == 44 );
	assert( [ "6 3", "-6 -100 50 -2 -5 -3" ].parse.expand.solve == 0 );
	
	assert( [ "6 8", "-10 8 2 1 2 -6" ].parse.expand.solve == 13 );		// 追加ケース
}


import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto vs = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], vs );
}

auto solve( long k, long[] vs )
{
	// 左からk個までの累積和を計算、マイナス値を集計
	auto lts = new long[]( 1 + min( k, vs.length ) );
	for( auto i = 1L; i < lts.length; i++ ) lts[ i ] = lts[ i - 1 ] + vs[ i - 1 ];
	
	// 右からk個までの累積和を計算
	auto rts = new long[]( 1 + min( k, vs.length ) );
	for( auto i = 1L; i < rts.length; i++ ) rts[ i ] = rts[ i - 1 ] + vs[ $ - i ];
	
	// 左と右の累積和を組み合わせて最大値を取得
	auto ans = 0L;
	long[] lms;
	foreach( li, lt; lts )
	{
		// 左側のマイナスの宝石を収集
		if( 0 < li && vs[ li - 1 ] < 0 ) lms ~= vs[ li - 1 ];
		
		long[] rms;
		foreach( ri, rt; rts )
		{
			if( k < li + ri || vs.length < li + ri ) break;
			
			// 右側のマイナスの宝石を収集
			if( 0 < ri && vs[ $ - ri ] < 0 ) rms ~= vs[ $ - ri ];
			
			// 操作回数がまだ残っている場合はマイナスの宝石を捨てる
			auto dt = ( lms ~ rms ).sort().take( k - li - ri ).sum;
			
			ans = max( ans, lt + rt - dt );
		}
	}
	return ans;
}


Measured memory_bytes: 764
N,M = [int(i) for i in input().split()]

#N = 13 #奇数
#M = 3 #偶数

#2個選んで総和が偶数
# 奇数、奇数＝偶数、偶数、偶数＝偶数

print(int((N * (N-1)/2) + (M *(M-1)/2)))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int n, x;
    cin >> n >> x;
    
    int now = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        int d;
        cin >> d;
        if (now <= x) ans++;
        now += d;
    }
    ans += (now <= x);
    
    cout << ans << '\n';
    
    return 0;
}


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

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

  int i;
  int min = L, max = L + N - 1;

  int sum = 0;
  for (i=0;i<N;i++){
    sum += L + i;
  }

  if (min>0){
    cout << sum-min << endl;
  }else if (max<0){
    cout << sum-max << endl;
  }else {
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
S = list(input())
FF = ''
RR = ''
J = [0] * 2

for st in S[0],S[1]:
	FF += st

for st in S[2],S[3]:
	RR += st

if 1 <= int(FF) <= 12:
	J[0] = 1
else:
	J[0] = 0

if 1 <= int(RR) <= 12:
	J[1] = 1
else:
	J[1] = 0

if J[0] == 0 and J[1] == 0:
	print('NA')
elif J[0] == 0 and J[1] == 1:
	print('YYMM')
elif J[0] == 1 and J[1] == 0:
	print('MMYY')
else:
	print('AMBIGUOUS')

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

int getLength(char a[]);

int main(void){
    int i,len,sum=0;
    char num[15];
    gets(num);
    len=getLength(num);
    for(i=0;i<len;i++){
        sum+=num[i]-'0';    
    }
    if(atoi(num)%sum){
        puts("No");
        return 0;
    }else{
        puts("Yes");
        return 0;
    }
    
    return 0;
}
    
int getLength(char a[]){
    int i=0;
    while(a[i]){
        i++;
    }
    return i;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define rep(i,j,k) for(int i=j;i<k;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1LL;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

main(){
    fastio;
    int n;
    cin >> n;
    vector<vector<int>> dp(n,vector<int>(3));
    vector<vector<int>> c(n,vector<int>(3));
    for(auto &x : c)
        for(int &y : x)
            cin >> y;
    dp[0][0] = c[0][0];
    dp[0][1] = c[0][1];
    dp[0][2] = c[0][2];
    for(int i=1;i<n;i++){
        dp[i][0] = c[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = c[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i][2] + max(dp[i-1][1],dp[i-1][0]);
    }
    cout << *max_element(td(dp[n-1])) << endl;
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;


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



int main() {

  cout<<fixed<<setprecision(10);

  ll n;cin>>n;

  ll taro, hanako;
  taro = hanako = 0;

  rep(i,n){
    string s1,s2;
    cin>>s1>>s2;
    if(s1 > s2){
      taro+= 3;
    }else if(s1 < s2){
      hanako += 3;
    }else{
      taro += 1;
      hanako += 1;
    }
  }

  cout<<taro<<" "<<hanako<<endl;
}




//






Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s, S="";
  int l;
  
  cin >> s;
  l = s.length()-1;
  l = l / 2;
  
  for (int i = 0; i < l+1; i++) {
    S = S + s[i*2];
  }
 
  cout << S << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int ans = 1;
		while (ans * 2 <= n)
			ans *= 2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#!/usr/bin/env python3
from itertools import accumulate

s = input()
l = s.split('BC')[:-1]
l = l[::-1]

ans = 0
i = 0

while i < len(l):
    anum = []
    flag = True
    while flag and i < len(l):
        M = len(l[i])
        tmp = 0
        for j in range(M):
            if l[i][M-j-1] == 'A':
                tmp += 1
            else:
                flag = False
                break
        anum.append(tmp)
        if flag:
            i += 1
    ans += sum(accumulate(anum[::-1]))
    i += 1
print(ans)


Measured memory_bytes: 11272
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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



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


long double a,b,c;
cin >> a >> b >> c;

 long double eps = 1.0E-14;

 if(sqrt(a) + sqrt(b) + eps < sqrt(c)){
cout << "Yes" << endl;
 } else {
cout<<"No\n";
 }



   
 


}



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

using ll = long long;
using pii = pair<int, int>;

template <typename T> constexpr T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;
template <> constexpr double inf<double> = 1e18;

template<typename T>
std::vector<T> table(int n, T v) { return std::vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return std::vector<decltype(val)>(n, std::move(val));
}


ll solve(ll n) {
    const auto s = to_string(n);
    const int m = s.size();
    // [pos][i - 3][i - 2][i - 1][already ok][strictly less]
    auto dp = table<ll>(m + 1, 10, 10, 10, 2, 2, 0LL);
    dp[0][0][0][0][0][0] = 1;
    for(int i = 0; i < m; ++i) {
        for(int i3 = 0; i3 <= 9; ++i3) for(int i2 = 0; i2 <= 9; ++i2) for(int i1 = 0; i1 <= 9; ++i1) {
            for(int aok = 0; aok <= 1; ++aok) {
                for(int le = 0; le <= 1; ++le) {
                    const int lim = le ? 9 : s[i] - '0';
                    for(int add = 0; add <= lim; ++add) {
                        int nok = aok || (i3 == 5 && i2 == 1 && add == 3);
                        int nle = le || s[i] - '0' > add;
                        dp[i + 1][i2][i1][add][nok][nle] += dp[i][i3][i2][i1][aok][le];
                    }
                }
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i <= 9; ++i) {
        for(int j = 0; j <= 9; ++j) {
            for(int k = 0; k <= 9; ++k) {
                ans += dp[m][i][j][k][1][0] + dp[m][i][j][k][1][1];
            }
        }
    }
    return ans;
}

int main() {
    ll N;
    cin >> N;
    cout << solve(N) << endl;
}


Measured memory_bytes: 6344
// #include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<iostream>
#define pb emplace_back
#define LOCAL
  
using namespace std;
  
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
typedef long long ll;
typedef pair<int,int> Pii;
 
template <typename T>inline void read(T& t){
    char c=getchar();t=0;
    int f=1;
    while(!isdigit(c)){
       if(c=='-')f=-1;
        c=getchar();
    }
    while(isdigit(c))t=t*10+c-48,c=getchar();
    t=f*t;
}
  
template <typename T,typename... Args> inline void read(T& t,Args&... args){
    read(t);read(args...);
}
  
int main(){
    int t=1;
    // read(t);
    while(t--){
        ll n,x,t;
        read(n,x,t);
        ll tmp=n%x==0?n/x:n/x+1;
        printf("%lld\n",tmp*t);
    }
    return 0;
}

Measured memory_bytes: 3228
import numpy as np

N = int(input())
A = [0] + list(map(int, input().split()))

A = np.array(A, dtype = np.int64)
A = np.cumsum(A)

dp = np.zeros((N, N), dtype = np.int64)

for j in range(1, N):
    for i in range(N - j):
        # print (dp[i, i:i + j], dp[i + 1:i + j + 1, i + j])
        tmp = min(dp[i, i:i + j] + dp[i + 1:i + j + 1, i + j])
        dp[i, i + j] = tmp + A[i + j + 1] - A[i]

print (dp[0, N - 1])

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

int main() {
  int n, m = 2000000000;
  cin >> n;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    m = min(m, a+b);
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;

int n, cnt = 0, odd_cnt = 0;

signed main() {

	cin >> n;

	for(int i = 1; i <= n; i++){
		int temp = i, cnt = 0;
		while(temp > 0){
			cnt++;
			temp /= 10;
		}
		if(cnt % 2 == 1) odd_cnt++;
	}

	cout << odd_cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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 rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3 = x2 - y2 + y1;
  int y3 = y2 - x1 + x2;
  int x4 = x3 - y3 + y2;
  int y4 = y3 - x2 + x3;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()
flag = 0
count = 0
for i in range(len(S)+1):
    for j in range(i+1, len(S)+1):
        flag = 1
        tmp = S[i:j]
        for k in range(len(tmp)):
            if tmp[k] == 'A' or tmp[k] == 'C' or tmp[k] == 'G' or tmp[k] == 'T':
                flag = 0
            else:
                flag = 1
                break
        if (flag == 0) and len(tmp) > count:
            count = len(tmp)

print(count)

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

int main()
{
ll n ;
cin >> n ;
string s ;
cin >> s ;
rep(i,1000){
  ll a=i/100;
  ll b=(i%100)/10;
  ll c=(i%10);
  ll cnt=0;
  rep(i,n){
    if(s[i]-'0'==c&&cnt==2)cnt++;
    if(s[i]-'0'==b&&cnt==1)cnt++;
    if(s[i]-'0'==a&&cnt==0)cnt++;
  }
  if(cnt==3)ans++;
}

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>

using namespace std;

int main(){
   string s;
   int K;
   cin >> s >> K;
   int size = s.size();
   for(int i = 0 ; i < size; i++){
      if( K > 0 && s[i]!='a'&& s[i]+K > 'z' ){
         K-='z'-s[i]+1;
         s[i]='a';
      }
   }
   if(K>0){
      K%=26;
      s[size-1]+=K;
   }
   cout << s << endl;
}


Measured memory_bytes: 512
using AtCoderBeginnerContest139.Questions;
using AtCoderBeginnerContest139.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest139.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine();
            var t = inputStream.ReadLine();

            var count = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == t[i])
                {
                    count++;
                }
            }
            yield return count;
        }
    }
}


namespace AtCoderBeginnerContest139
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest139.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest139.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

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

  if(N.at(0)=='9' || N.at(1)=='9'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
return 0;  
}

Measured memory_bytes: 256