akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int T = scanner.nextInt();
    Meal[] meals = new Meal[N + 1];
    meals[0] = new Meal(0, 0);
    for (int i = 1; i <= N; i++) meals[i] = new Meal(scanner.nextInt(), scanner.nextInt());
    Arrays.sort(meals, Comparator.comparingInt(m -> m.a));

    int[][] dp = new int[N + 1][T];
    for (int i = 1; i <= N; i++) {
      for (int j = 0; j < T; j++) {
        dp[i][j] = dp[i - 1][j];
        if (j >= meals[i].a) dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - meals[i].a] + meals[i].b);
      }
    }

    int max = 0;
    for (int i = 1; i <= N; i++) {
      max = Math.max(max, dp[i - 1][T - 1] + meals[i].b);
    }
    System.out.println(max);
  }

  private static class Meal {
    private final int a;
    private final int b;

    private Meal(int a, int b) {
      this.a = a;
      this.b = b;
    }
  }
}


Measured memory_bytes: 71232
<?php

define( 'NONE', -1 );

class AOJ1031 {
    var $L;
    var $LC;
    var $n;
    var $X;
    var $Y;

    public function init() {
        $L = &$this->L;
        $LC = &$this->LC;
        
        $L = file( '/dev/stdin' );
        $LC = count( $L );
    }

    public function input( &$offset ) {
        $L = &$this->L;
        $LC = &$this->LC;
        $n = &$this->n;
        $markup = &$this->markup;
        $X = &$this->X;
        $Y = &$this->Y;

        $n = $L[$offset];
        if ( $n == 0 ) return false;
        
        $markup = $L[$offset+1];
        $offset += 2;
        $X = array();
        $Y = array();
        for ( $i = 0; $i < $n; ++ $i, ++ $offset ) {
            $line = $L[$offset];
            $terms = split(' ', $line);
            $X[$i] = intval( $terms[0] );
            $Y[$i] = intval( $terms[1] );
        }
        return true;
    }

    public function hit_test( $x, $y, $x1, $y1, $x2, $y2 ) {
        return $x1 <= $x && $x <= $x2 && $y1 <= $y && $y <= $y2;
    }

    public function get_positions( $line, &$x1, &$y1, &$x2, &$y2 ) {
        $terms = split( ',', $line );
        $x1 = $terms[0];
        $y1 = $terms[1];
        $x2 = $terms[2];
        $y2 = $terms[3];
    }

    public function check_clicked( $root, $x, $y, &$name, &$childs ) {
        $this->get_positions( $root, $x1, $y1, $x2, $y2 );
        if ( $this->hit_test( $x, $y, $x1, $y1, $x2, $y2 ) ) {
            foreach ( $root as $child ) {
                $this->get_positions( $child, $x1, $y1, $x2, $y2 );
                if ( $this->check_clicked( $child, $x, $y, $name, $childs ) ) {
                    return true;
                }
            }
            $name = $root->getName();
            $childs = $root->count();
            return true;
        }
        $name = 'OUT OF MAIN PANEL';
        $childs = 1;
        return false;
    }

    public function solve() {
        $n = &$this->n;
        $markup = &$this->markup;
        $X = &$this->X;
        $Y = &$this->Y;

        $object = new SimpleXMLElement( $markup );
        for ( $i = 0; $i < $n; ++ $i ) {
            $name = "";
            $childs = -1;
            $this->check_clicked( $object, $X[$i], $Y[$i], $name, $childs );
            echo "$name $childs\n";
        }
    }

    public function run() {
        $L = &$this->L;
        $LC = &$this->LC;
        $this->init();
        for ( $i = 0; $i < $LC; ++ $i ) {
            while ( $this->input($i) ) {
                $this->solve();
            }
        }
    }
}

$instance = new AOJ1031;
$instance->run();

Measured memory_bytes: 10000
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

};

int inf = 1e9;
int n;

bool biparticle(int v, vvi &G, vi &color, int col = 0){
  color[v] = col;
  rep(nv,n) {
    if(G[v][nv] == inf || v == nv) continue;
    if(color[nv] == -1) {
      if(!biparticle(nv, G, color, 1-col)) return false;
    }
    else if(color[v] == color[nv]) return false;
  }

  return true;
}

int main(){
  cin >> n;
  
  vector<string> s(n); rep(i,n) cin >> s[i];
  vvi G(n,vi(n));
  rep(i,n) rep(j,n) {
    if(i == j) G[i][j] = 0;
    else if(s[i][j] == '1') G[i][j] = 1;
    else G[i][j] = inf;    
  }

  vi color(n,-1);
  bool ok = biparticle(0, G, color);

  rep(k,n) rep(i,n) rep(j,n) chmin(G[i][j], G[i][k] + G[k][j]);

  int ans = 0;
  rep(i,n) rep(j,n) if(G[i][j] != inf) chmax(ans, G[i][j]);

  cout << (ok ? ans+1 : -1) << endl;
}

Measured memory_bytes: 512
buf = input().split()
n = int(buf[0])
m = int(buf[1])

buf = input().split()
votes = [int(v) for v in buf]

numVotes = sum(votes)

ct = 0
for v in votes:
  if v >= numVotes/4.0/m:
    ct += 1
  if ct >= m:
    break
if ct >= m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    W, H, x, y = list(map(int, sys.stdin.buffer.readline().split()))
    ret = (W * H) / 2
    p = x == W/2 and y == H/2
    print(ret, 1 if p else 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split(' ')))

r, x = 0, 0
ans = 0
for l in range(0, N):
    while r < N and not (x & A[r]):
        x ^= A[r]
        r += 1
    ans += r - l
    x ^= A[l]
print(ans)

Measured memory_bytes: 24840
n, k = map(int,input().split())
p = list(map(int,input().split()))

#求める答えは入力をそれぞれ1足した数字の和を2で割ったものになる

#初項からk番目までの和
sum_1tok = 0
sum_k =[]
for i in range(k):
    sum_1tok += p[i]
sum_k.append(sum_1tok)
#print(sum_k)

sum_max= 0
#ひとつずつずらしてリストに格納
for i in range(1,n-k+1):
    sum_k.append(sum_k[i-1] + p[k+i-1] - p[i-1])

#print(sum_k)
#求める期待値に変換
ans = (max(sum_k) + k) /2
print(ans)

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


int main(){
  string s;
  int i,temp,ans=0;
  while (1){
    getline(cin,s);
    if (s=="0")break;
    for (i=0;i<s.size();i++){
      ans+=s[i]-'0';
    }
    cout<<ans<<endl;
    ans=0;
  }
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i,0,N) cin >> P[i];
    rep(i,0,N) cin >> Q[i];

    int a, b, n = 0;
    vector<int> p(N);
    rep(i,0,N) p[i] = i+1;
    do {
        if (P == p) a = n;
        if (Q == p) b = n;
        n++;
    } while (next_permutation(all(p)));
    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define NUM 102
using namespace std;

char sa[NUM], sb[NUM], sc[NUM];
int ia, ib , ic;

char *game(char ch[], int n) {
	switch (ch[n]) 
	{
	case 'a':
		game(sa, ia++); break;
	case 'b':
		game(sb, ib++); break;
	case 'c':
		game(sc, ic++); break;
	default:
		return ch; break;
	}
	
}


int main() {
	
	cin >> sa >> sb >> sc;

	char *ans = game(sa, ia);

	if (ans == sa) cout << "A\n";
	else if (ans == sb) cout << "B\n";
	else if (ans == sc)cout << "C\n";

	return 0;
}


Measured memory_bytes: 256
#coding:utf-8
#1_11_B 2015.4.20
class Dice:
    def __init__(self,ary):
        self.top = ary[0]
        self.south = ary[1]
        self.east = ary[2]
        self.west = ary[3]
        self.north = ary[4]
        self.bottom = ary[5]

    def roll_n(self):
        self.top , self.south , self.bottom , self.north = self.south , self.bottom , self.north , self.top

    def roll_e(self):
        self.top , self.west , self.bottom , self.east = self.west , self.bottom , self.east , self.top

    def roll(self):
        self.north , self.west , self.south , self.east = self.east , self.north , self.west , self.south

dice = Dice(input().split())
for i in range(int(input())):
    top,south = input().split()
    while dice.top != top or dice.south != south:
        dice.roll_n()
        if dice.top == top:
            while dice.south != south:
                dice.roll()
        elif dice.south == south:
            while dice.top != top:
                dice.roll_e()
    print(dice.east)

Measured memory_bytes: 6736
from collections import Counter

n = int(input())
data = list(map(int, input().split()))

max_ = 10 ** 6 + 1
b = [True] * (max_ + 1)
data.sort()
c = Counter(data)

ans = 0
for d in data:
    if b[d]:
        for j in range(d, max_, d):
            b[j] = False
        # 複数存在
        if c[d] == 1:
            ans += 1

print(ans)


Measured memory_bytes: 43724
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
 
#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
 
using namespace std;
 
typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const char LIST[53] = {"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"};

int main(void){
    string str;
    for(int n; cin >> n, n; cout << str << endl){
        vi ope(n);
        rep(i, n) cin >> ope[i];
        cin >> str;

        rep(i, str.size()){
            int diff = ((str[i] <= 'Z') ? str[i] - 'A':str[i] - 'a' + 26) - ope[i % n];
            str[i] = LIST[(0 <= diff) ? diff:diff + 52];
        }
    }
 
    return 0;
}

Measured memory_bytes: 1204
#include<cstdio>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int s=0;
		rep(i,n*(n-1)/2){
			int t;	scanf("%d",&t);
			s+=t;
		}
		printf("%d\n",s/(n-1));
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s[] = new String[n + 1];
		for (int i = 0; i < n; ++i)
			s[i] = sc.next();
		s[n] = "zzzzzzzzzzz";
		int m = sc.nextInt();
		String t[] = new String[m + 1];
		for (int i = 0; i < m; ++i)
			t[i] = sc.next();
		t[m] = "zzzzzzzzzzz";
		sc.close();
		int ans = 0, tmp = 0;
		Arrays.sort(s);
		Arrays.sort(t);
		int st = 0;
		for(int i = 0; i < n; ++i) {
			if(s[i].equals(s[i + 1])) ++tmp;
			else {
				++tmp;
				for(int j = st; j < m; ++j) {
					if(s[i].equals(t[j]))tmp--;
					else {
						if(s[i].compareTo(t[j]) < 0) {
							st = j - 1;
							if(st < 0)st = 0;
							break;
						}
						else st = j;
					}
				}
				ans = Math.max(ans,  tmp);
				tmp = 0;
			}
		}
		System.out.println(ans);
	}

}


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

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

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

	int kukan = 0;
	int maxKukan = 0;
	for (int i = 0; i < N; i++) {
		if (i == N - 1) {
			kukan = K - A[i]+A[0];
		}
		else {
			kukan = A[i + 1] - A[i];
		}
		maxKukan = max(maxKukan, kukan);
	}

	cout << K - maxKukan << endl;


}
	


Measured memory_bytes: 1400
MOD = (10**9) + 7


class modint():
    def __init__(self, value):
        self.value = value % MOD

    def __int__(self):
        return int(self.value)

    def __float__(self):
        return float(self.value)

    def __str__(self):
        return str(self.value)

    def __repr__(self):
        return str(self.value)

    def __add__(self, other):
        return (modint(self.value + other.value) if isinstance(other, modint)
                else modint(self.value + other))

    def __sub__(self, other):
        return (modint(self.value - other.value) if isinstance(other, modint)
                else modint(self.value - other))

    def __mul__(self, other):
        return (modint(self.value * other.value) if isinstance(other, modint)
                else modint(self.value * other))

    def __truediv__(self, other):
        return (modint(self.value * pow(other.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(self.value * pow(other, MOD - 2, MOD)))

    def __pow__(self, other):
        return (modint(pow(self.value, other.value, MOD))
                if isinstance(other, modint)
                else modint(pow(self.value, other, MOD)))

    def __eq__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __ne__(self, other):
        return (self.value == other.value if isinstance(other, modint)
                else self.value == (other % MOD))

    def __radd__(self, other):
        return (modint(other.value + self.value) if isinstance(other, modint)
                else modint(other + self.value))

    def __rsub__(self, other):
        return (modint(other.value - self.value) if isinstance(other, modint)
                else modint(other - self.value))

    def __rmul__(self, other):
        return (modint(other.value * self.value) if isinstance(other, modint)
                else modint(other * self.value))

    def __rtruediv__(self, other):
        return (modint(other.value * pow(self.value, MOD - 2, MOD))
                if isinstance(other, modint)
                else modint(other * pow(self.value, MOD - 2, MOD)))

    def __rpow__(self, other):
        return (modint(pow(other.value, self.value, MOD))
                if isinstance(other, modint)
                else modint(pow(other, self.value, MOD)))

    def modinv(self):
        return modint(pow(self.value, MOD - 2, MOD))


def main():
    n, a, b = (int(i) for i in input().split())
    MOD = 10**9 + 7
    COMB_a = modint(1)
    COMB_b = modint(1)
    for k in range(a):
        COMB_a *= n - k
    for k in range(1, a+1):
        COMB_a /= k
    for k in range(b):
        COMB_b *= n - k
    for k in range(1, b+1):
        COMB_b /= k
    ans = (pow(2, n, MOD) - 1 - COMB_a - COMB_b)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42224
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  string s;
  cin >> s;
  if( s == "RRR") cout << 3 << endl;
  else if( s == "RRS" || s == "SRR" ) cout << 2 << endl;
  else if( s == "RSR" || s == "SRS" || s == "RSS" || s == "SSR") cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int t[n],x[n],y[n];
  t[0] = x[0] = y[0] = 0;
  for (int i=1;i<=n;i++){
    cin >> t[i] >> x[i] >> y[i];
  }

  bool c=true;
  for(int i=0;i<n;i++){
    int dt,dist;
    dt = t[i+1] - t[i];
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if(dt < dist){
      c = false;
    }
    if(dt%2 != dist%2){
      c = false;
    }
  }
  if(c == true){
    cout << "Yes";
  }else{
    cout << "No";
  }
}


Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

// citiesのうち，n個の街に訪れるときの平均距離

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<pair<int, int>> cities(n);

  for (int i = 0; i < n; i++) {
    cin >> cities[i].first >> cities[i].second;
  }

  vector<int> order(n);
  iota(order.begin(), order.end(), 0);

  double ans = 0;
  int cnt = 0;
  do {
    // 平均値
    double dist = 0;
    for (int i = 0; i < n - 1; i++) {
      auto c1 = cities[order[i]], c2 = cities[order[i + 1]];
      dist += hypot(c1.first - c2.first, c1.second - c2.second);
    }

    ans += dist;
    cnt++;
  } while (next_permutation(order.begin(), order.end()));

  cout << fixed << setprecision(9) << ans / cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main() {
	std::string n;
	std::cin >> n;

	std::vector<int> v;
	for (int i = 0; i < 10; i++) {
		std::string s = n;
		std::replace(s.begin(), s.end(), '?', char('0' + i));
		long long sum = 0;
		for (int j = 0; j < 11; j++) {
			sum += (s[j] - '0') * (11 - j <= 6 ? (11 - j + 1) : (6 - j));
		}
		sum %= 11;
		if (sum <= 1) sum = 0;
		else sum = 11 - sum;
		if (sum == s[11] - '0') v.push_back(i);
	}


	if (v.size() == 1) {
		std::cout << v.front() << std::endl;
	} else {
		std::cout << "MULTIPLE" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include <string>
#include<math.h>
using namespace std;
 
int main(){
	double a,b,c,K,z;
	cin >> a >>b >> c >> K;
	z = pow(2,K);
 
	if (a <= c && b <= c)
	{
		cout << a+b+c*z << endl;
	}
	else if (a<=b && c<=b)
	{
		cout << a+c+b*z <<endl;
	}
	else if (b<=a && c<=a){
		cout << b+c+a*z << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[1010101];
//---------------------------------------------------------------------------------------------------
vector<int> primes[1010101];
int x[1010101];
void makePrimes() {
	rep(i, 0, 1010101) x[i] = i;
	rep(p, 2, 1010101) for (int y = p; y < 1010101; y += p) {
		if (x[y] % p == 0) {
			primes[y].push_back(p);
			while (x[y] % p == 0) x[y] /= p;
		}
	}
}
//---------------------------------------------------------------------------------------------------
int cnt[1010101];
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	makePrimes();

	rep(i, 0, N) fore(p, primes[A[i]]) cnt[p]++;

	bool isPairwiseCoprime = true;
	rep(i, 0, 1010101) if (1 < cnt[i]) isPairwiseCoprime = false;
	if (isPairwiseCoprime) {
		cout << "pairwise coprime" << endl;
		return;
	}

	int g = 0;
	rep(i, 0, N) g = gcd(g, A[i]);
	if (g == 1) cout << "setwise coprime" << endl;
	else cout << "not coprime" << endl;
}







Measured memory_bytes: 71348
local s = io.read()
local n = #s
local prv = s:sub(1, 1)
local nxt = ""
local from = 1
local ret = 1
local mma, mmi = math.max, math.min
for i = 2, n do
  nxt = s:sub(i, i)
  if prv ~= nxt then
    ret = mma(ret, mmi(i - 1, n + 1 - from))
    prv = nxt
    from = i
  end
end
ret = mma(ret, mmi(n, n + 1 - from))
print(ret)


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

ll n,m;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>m;
  vpll p(m);
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    p[i]={a,b};
  }
  reverse(all(p));
  UnionFind uf(n);
  vll ans(m);
  ans[0]=n*(n-1)/2;
  rep(i,m-1){
    ll a=p[i].first, b=p[i].second;
    if(uf.isSame(a,b)){
      ans[i+1]=ans[i];
    }else{
      ans[i+1]=ans[i]-uf.size(a)*uf.size(b);
      uf.connect(a,b);
    }
  }
  rrep(i,m) cout<<ans[i]<<endl;
  
}

Measured memory_bytes: 4480
#include<stdio.h>
#include<cstdlib>
#include<fstream>
#include<iostream>
#include<math.h>
#include<string>
#include<sstream>

using namespace std;

int main(){
    int A,B;
    int socket = 1;
    cin >> A;
    cin >> B;
    if(B==1){
        cout << 0 << endl;
    }
    else{
        for(int i=1; i < 21; i++){
            socket += (A - 1);
            if(socket >= B){
                cout << i << endl; 
                break;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int len = S.length();
    rep(i, len) {
        bool match = true;
        rep(j, len) {
            int k = (i + j) % len;
            if (S[j] != T[k]) match = false;
        }
        if (match) {
            cout << "Yes" << endl;
            return 0;
        }
        
    }
    cout << "No" << endl;

    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(N, vector<int>());
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    for (int j = 0; j < n; j++) {
      int m;
      cin >> m;
      v[i].push_back(m);
    }
  }

  map<int, int> m;
  for (int i = 0; i < N; i++) {
    for (int j : v[i]) m[j]++;
  }

  int ans = 0;
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    if (itr->second == N) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
using System.Diagnostics;

namespace CompetitiveProgramming
{
  class Solve
  {
    public Solve()
    {
      int N = Scanner.nextInt();
      int L = Scanner.nextInt();
      int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

      int index = -1;
      for (int i = 0; i < N - 1; i++)
      {
        if (a[i] + a[i + 1] >= L) 
        {
          index = i;
          break;
        }
      }
      if (index == -1)
      {
        Console.WriteLine("Impossible");
        return;  
      }

      Console.WriteLine("Possible");

      for (int i = 0; i < index; i++) 
      {
        Console.WriteLine(i + 1);
      }
      for (int i = N - 2; i > index; i--)
      {
        Console.WriteLine(i + 1);
      }
      Console.WriteLine(index + 1);
    }
  }

  class Program
  {
    static void Main(string[] args)
    {
      new Solve();
    }
  }

  public class Pair<T, U>
  {
    public Pair()
    {

    }
    public Pair(T first, U second)
    {
      this.first = first;
      this.second = second;
    }
    public T first { get; set; }
    public U second { get; set; }
  }

  class Scanner
  {
    private static List<string> buf = new List<string>();

    private static void next()
    {
      if (buf.Count == 0)
      {
        buf = Console.ReadLine().Split().ToList();
      }
    }

    private static string pop()
    {
      string ret = buf[0];
      buf.RemoveAt(0);
      return ret;
    }

    public static int nextInt()
    {
      next();
      return int.Parse(pop());
    }
    public static long nextLong()
    {
      next();
      return long.Parse(pop());
    }
    public static string nextString()
    {
      next();
      return pop();
    }
    public static double nextDouble()
    {
      next();
      return double.Parse(pop());
    }
  }

}

Measured memory_bytes: 18648
using System;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var exist = new int[26];
            var ans = "None";

            for(int i = 0; i < s.Length; i++)
            {
                exist[s[i] - 'a']++;
            }


            for(int i = 0; i < 26; i++)
            {
                if(exist[i] == 0)
                {
                    var a = (char)(i + 'a');
                    ans = a.ToString();
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

bool x(pair<int,int>a,pair<int,int>b){
    return a.second<b.second;
}

int main(){
    int n,m,ans=0,endtime=0;
    cin>>n>>m;
    vector<pair<int,int>>t(m);
    rep(i,m)cin>>t[i].first>>t[i].second;
    sort(t.begin(),t.end(),x);
    
    rep(i,m){
        if(endtime<=t[i].first){
        endtime=t[i].second;
        ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
def side(p1, p2, p3):
  y1,x1=p1
  y2,x2=p2
  y3,x3=p3
  return (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1)>0
while 1:
  n=input()
  if n==0:break
  D=sorted([list(input()) for i in range(n)])
  p1=D[0]
  D1=D[:]
  while True:
    c=0
    for p2 in D1:
      if p1==p2:continue
      f=[0,0]
      for p3 in D[::-1]:
        if p1==p3 or p2==p3: continue
        f[side(p1,p2,p3)]+=1
      if f[0]==0:break
    p1=p2
    D1.remove(p2)
    if p2==D[0]:break
  print len(D1)

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

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

    int ans;

    if (a + w < b) {
        ans = b - (a + w);
    }
    else if (b + w < a){
        ans = a - (b + w);
    }
    else {
        ans = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
let=input()
s=[str(c) for c in let]
n=len(s)
for i in range(n//2):
    if s[i]!=s[-i-1]:
        print("No")
        exit()
k=(n-1)//2
for j in range(k):
    if s[j]!=s[k-j-1]:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	
	int x, n, i, j, k, count = 0;
	
	while(1){
	
	scanf("%d", &n);
	scanf("%d", &x);
	
	if(x == 0 && n == 0)
		return 0;
	
	for(i = 1; i <= n; i++)
		for(j = 1; j <= n; j++)
			for (k = 1; k < n; k++)
			if(i+j+k == x && i !=j && i!=k && k != j && i > j && j > k){
				count = count + 1;
			}
		
		printf("%d\n", count);
		count = 0;
			
	}
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  sort(all(A));
  
  vector<int> B(N), C(N);
  int a = 0, b = N-1, i = 0;
  while(true) {
    C[i] = A[a];
    a++;
    i++;
    if(i == N) break;
    C[i] = A[b];
    b--;
    i++;
    if(i == N) break;
  }
  a = 0, b = N-1, i = 0;
  while(true) {
    B[i] = A[b];
    b--;
    i++;
    if(i == N) break;
    B[i] = A[a];
    a++;
    i++;
    if(i == N) break;
  }
  
  int ans = 0;
  int m = 10000000000;
  rep(i, N-1) {
    ans += abs(C[i]-C[i+1]);
    m = min(m, abs(C[i]-C[i+1]));
  }
  ans += abs(C[0]-C[N-1]);
  m = min(m, abs(C[0]-C[N-1]));
  ans -= m;
  
  int aans = 0;
  m = 10000000000;
  rep(i, N-1) {
    aans += abs(B[i]-B[i+1]);
    m = min(m, abs(B[i]-B[i+1]));
  }
  aans += abs(B[0]-B[N-1]);
  m = min(m, abs(B[0]-B[N-1]));
  aans -= m;
  
  //rep(i, N) cout << C[i];
  //cout << endl;
  cout << max(ans, aans) << endl;

    
  
}

Measured memory_bytes: 5644
// 27
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) \
  for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) \
  for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef LOCAL
#define debug(e)                             \
  cerr << "\033[48;5;196m\033[38;5;15m" << e \
       << "\033[0m";
#else
#define debug(e)
#endif
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << " " << p.se << ")";
}
// 8
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, (int)v.size()) o << setw(7) << left << v[i];
  return o << endl;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 3
void _main(int tc) {
  string s;
  cin >> s;
  int groupcnt = 0;
  for (int i = 1; i < len(s);) {
    while (s[i] == s[i - 1]) {
      i++;
    }
    i++;
    groupcnt++;
  }
  if (s[len(s) - 1] != s[len(s) - 2]) groupcnt++;

  debug(groupcnt << endl);

  cout << groupcnt - 1 << endl;

}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

struct Crop {
	string l;
	double rate;

	Crop() {}
	Crop(string _l, int p, int a, int b, int c, int d, int e, int f, int s, int m) {
		l = _l;

		int time = a + b + c + (d + e) * m;
		int income = -p + (f * s * m);
		rate = (double)income / time;
	}

	bool operator < (const Crop &c) const {
		if(rate != c.rate)
			return rate > c.rate;
		return l < c.l;
	}
};

int main() {
	int n;
	while(true) {
		cin >> n;
		if (n == 0) {
			break;
		}

		vector<Crop> crops(n);

		for (int i = 0; i < n; i++) {
			string l;
			int p, a, b, c, d, e, f, s, m;

			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;

			Crop crop(l, p, a, b, c, d, e, f, s, m);
			crops[i] = crop;
		}

		sort(crops.begin(), crops.end());

		for (int i = 0; i < n; i++) {
			cout << crops[i].l << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

ul S(ul n) {
  ul ret = 0;
  while (n > 0) {
    ret += n%10;
    n /= 10;
  }
  return ret;
}

double nsn(ul n) {
  return n * 1.0 / S(n);
}

bool check(ul n) {
  ul add = 1;
  while (add <= n) {
    if (nsn(n) > nsn(n+add)) return false;
    add *= 10;
  }
  return true;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ul k;
  cin >> k;
  ul ans = 1;
  cout << ans << endl;
  for (ul i = 1; i<k; ++i) {
    ul add = 1;
    while (true) {
      if (check(ans+add)) {
        ans += add;
        break;
      }
      add *= 10;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

/* prototype declaration */
void init();
int isPrime(int n);
int primeCounter(int n);

int flag[1000000];

/* main */
int main(int argc, const char *argv[])
{
	int n;
	init();
	while(scanf("%d",&n)!=EOF)
		printf("%d\n", primeCounter(n));	
	return 0;
}

void init()
{
	int i;
	flag[2] = 1;
	for(i=3; i<1000000; i+=2)
		if(isPrime(i)) flag[i] = 1;
}

int isPrime(int n)
{
	int i;
	if(n <= 1) return 0;
	else if(n == 2) return 1;
	else if(n%2 == 0) return 0;
	else{
		for(i=3;i*i<=n;i+=2)
			if(n%i == 0) return 0;
	}
	return 1;
}

int primeCounter(int n)
{
	int i, cnt = 0;
	for(i=1; i<=n; i++)
		if(flag[i]) cnt++;
	return cnt;
}

Measured memory_bytes: 4312
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x=0,y=0;
  cin >> n;
  int v[n+1],c[n+1];
  for(int i = 1;i<=n;i++){
    cin >> v[i];}
  for(int i = 1;i<=n;i++){
    cin >> c[i];
    if(v[i]>c[i]){x+=v[i];y+=c[i];}
  }
  cout << x-y << endl;
  return 0;
}
  


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    vector<int> dp(X + 1, 0);
    dp[0] = 1;
    FOR(i, 1, X + 1) {
        FOR(j, 100, 106) {
            if (i - j >= 0 && dp[i - j]) {
                dp[i] = 1;
                break;
            }
        }
    }
    cout << dp[X] << endl;
    return 0;
}



Measured memory_bytes: 640
K,N=map(int, input().split())
A=list(map(int, input().split()))
d=[0]*(N+1)
if A[0]!=0:
    tmp=A[0]
    A=list(map(lambda x: x-tmp, A))
for n in range(N+1):
    if n==0:
        d[n]=A[0]
    elif n==N:
        d[n]=K-A[n-1]
    else:
        d[n]=A[n]-A[n-1]
print(sum(d)-max(d))

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    vector<ll> A_S(N+1, 0);
    for (int i = 0; i < N; ++i) A_S[i+1] = A_S[i] + A[i]; 
    vector<ll> B(M);
    for (int i = 0; i < M; ++i) cin >> B[i];
    vector<ll> B_S(M+1, 0);
    for (int i = 0; i < M; ++i) B_S[i+1] = B_S[i] + B[i]; 
    ll res = 0;
    ll j = M;
    for (int i = 0; i < N+1; ++i) {
        if (A_S[i] > K) break;
        while (B_S[j] > K - A_S[i]) j -= 1;
        res = max(res, i+j);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9604
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    s = S()

    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')


if __name__ == '__main__':
    main()


Measured memory_bytes: 74464
n = gets.to_i
a = gets.split.map(&:to_i)
h = a.group_by(&:itself).map{|k,v| [k, v.count]}.to_h
total = h.values.map{|i| i*(i-1)/2}.inject(:+)

a.each{|ai|
  hi = h[ai]
  p hi==1 ? total : total - hi*(hi-1)/2 + (hi-1)*(hi-2)/2
}


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

int main(){
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k = 0;
    cin >> k;
    cout << a[k-1]; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,n;
	set <int> m;
	//vector <int> A;
	int input;
	cin>>x;
	cin>>n;
	for(int i=0;i<n;i++)
	{
	    cin>>input;
	    m.insert(input);
	}
	int ans1=x;
	int ans2=x;
	while(m.find(ans1)!=m.end()) 
	{
	    ans1++;
	}
	while(m.find(ans2)!=m.end() && (ans2>=1)) 
	{
	    ans2--;
	}
	//cout<<ans1<<ans2<<endl;
	if(abs(x-ans1)<abs(x-ans2))
	    cout<<ans1;
	 else
	    cout<<ans2;
	
	
	
	
 
}
  	

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;

    if(A > 12)
        cout << B << "\n";
    else
        cout << (A > 5 ? B/ 2 : 0) << "\n";

    return 0;
}


Measured memory_bytes: 256
n,k=map(int, input().split())
h=list(map(int, input().split()))
v=[]
dp=[0]*(n)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    for j in range(1,k+1):
        if i-j<0:
            break
        v.append(abs(h[i]-h[i-j])+dp[i-j])
    dp[i]=min(v)
    v=[]
        
        
print(dp[n-1])

Measured memory_bytes: 52448
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

void f(string s,int n,char c){
	if(n==0){
		cout<<s<<endl;
		return;
	}
	loop(i,'a',c+1)f(s+(char)i,n-1,max((ll)c,i+1));
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	f("",n,'a');
}






Measured memory_bytes: 1536
IDENTIFICATION DIVISION.
PROGRAM-ID. 140B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP  PIC X(600).
01 N    PIC 9(2).
01 TBL.
   03 A PIC 9(2) OCCURS 20.
   03 B PIC 9(2) OCCURS 20.
   03 C PIC 9(2) OCCURS 20.
01 M    PIC 9(4).
01 I    PIC 9(2).
01 P1   PIC 9(2).
01 P2   PIC 9(2).
01 OUT  PIC ZZZ9.
*>  
PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT INP.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO A(I)
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  ACCEPT INP.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO B(I)
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  ACCEPT INP.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I >= N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO C(I)
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  MOVE 0 TO M.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I >= N
    ADD B(A(I)) TO M
    IF (A(I) + 1 = A(I + 1))
      ADD C(A(I)) TO M
    END-IF
  END-PERFORM.
  ADD B(A(I)) TO M.
*>
  MOVE M TO OUT.
  DISPLAY OUT.
*>
  STOP RUN.


Measured memory_bytes: 384
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
    if (a == b) 
        return a; 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
int main(){
    
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(d==x){
        if(k%2)cout<<0;
        else cout<<d;
    }
    else if(d>x){
        if(k%2)cout<<d-x;
        else cout<<x;
    }
    else if(x>d){
        ll p = x/d;
        ll r = x%d;
        if(r==0){
            if(k>=p){
                if((k-p)%2)cout<<d;
                else cout<<0<<endl;
            }
            else cout<<x-k*d;
        }
        else{
            if(p>=k)cout<<x-k*d;
            else{
                if((k-p)%2)
                    cout<<d-x+p*d;
                else cout<<x-p*d;
            }
        }
    }
    return 0;
}






Measured memory_bytes: 3608
while True:
    number_of_input = int(raw_input())
    if number_of_input == 0:
        break
    values = [float(x) for x in raw_input().split()]
    second_moment = sum([x * x for x in values]) / number_of_input
    first_moment = sum([x for x in values]) / number_of_input
    print(second_moment - first_moment ** 2.0) ** 0.5

Measured memory_bytes: 6516
/**
*    author:  yuya1234
*    created: 24.06.2020 13:44:07
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

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

    int H, W;
    string S[50];
    bool flg = true;

    cin >> H >> W;

    REP(i, H)
    {
        cin >> S[i];
    }

    REP(i, H)
    {
        REP(j, W)
        {
            if (S[i][j] == '#')
            {
                flg = false;
                if (i < H - 1)
                {
                    if (S[i + 1][j] == '#')
                        flg = true;
                }
                if (j < W - 1)
                {
                    if (S[i][j + 1] == '#')
                        flg = true;
                }
                if (i > 0)
                {
                    if (S[i - 1][j] == '#')
                        flg = true;
                }
                if (j > 0)
                {
                    if (S[i][j - 1] == '#')
                        flg = true;
                }

                if (!flg)
                {
                    i = H;
                    j = W;
                    break;
                }
            }
        }
    }

    if (flg)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<bitset>
using namespace std;

int main()
{
    int H,W,k,ans=0;
    cin>>H>>W>>k;
    vector <vector <char>> c(H,vector <char>(W));
    for(int i=0;i<H;i++) for(int k=0;k<W;k++) cin>>c[i][k];
    
    for(int bith=0;bith<(1<<H);++bith) for(int bitw=0;bitw<(1<<W);++bitw)
    {
        int count=0;
        for(int h=0;h<H;++h) for(int w=0;w<W;++w)
        {
            if((bith>>h)&1) continue;
            if((bitw>>w)&1) continue;
            if(c[h][w]=='#') count++;
        }
        if(count==k) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3620
using System;
using System.Linq;

class PG{
    static void Main(string[] args){
        int[] nums=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int W,H,x,y,r;
        W=nums[0];
        H=nums[1];
        x=nums[2];
        y=nums[3];
        r=nums[4];
        
        if((r<=x&&r<=y)&&(x<=W-r&&y<=H-r)){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 18428