akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    ll a, b, c, d;
    sf(a);sf(b);sf(c);sf(d);
    ll ans1 = b / c - (a - 1) / c;
    prln(ans1);
    ll ans2 = b / d - (a - 1) / d;
    prln(ans2);
    ll tt = c * d / __gcd(c, d);
    prln(tt);
    ll ans3 = b / (tt) - (a - 1) / (tt);
    prln(ans3);
    ll ret = ans1 + ans2 - ans3;
    ll ret1 = b - a + 1 - ret;
    cout << ret1 << endl;


    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = list(input().split())
seq = []


for i in range(n):
    m = -1
    for j in range(len(s)):
        if int(s[j]) == j+1:
            m = j
    if m != -1:
        s = s[:m]+s[m+1:]
        seq.append(m+1)

# print(s)
# print(seq)

if len(s) == 0:
    for i in range(1,n+1):
        print(seq[-i])
else:
    print("-1")

Measured memory_bytes: 3064
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int ans = 0;
    REP(i, A + 1)
    REP(j, B + 1) REP(k, C + 1) if (X == i * 500 + j * 100 + k * 50) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::cmp::min;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let mut a = vec![];
    let mut b = vec![];
    let mut is_same = true;
    let mut mb = 1i64 << 60;
    let mut s = 0;
    for i in 0..n {
        a.push(scan.read::<i64>());
        b.push(scan.read::<i64>());
        if a[i] != b[i] {
            is_same = false;
        }
        if a[i] > b[i] {
            mb = min(mb, b[i]);
        }
        s += a[i];
    }
    if is_same {
        println!("{}", 0);
        return;
    }
    println!("{}", s - mb);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,l,r) for(int i=l; i<(int)(r); i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define swap(a,b) {ll tp=a;a=b;b=tp;}
const ll MOD = 1000000007;

int main(){
    int n,m;scanf("%d%d",&n,&m);
    int a[55],b[55],c[55],d[55];
    rep(i,n) scanf("%d%d",a+i,b+i);
    rep(i,m) scanf("%d%d",c+i,d+i);
    
    rep(i,n){
        int ans=MOD,ansj=0;
        rep(j,m){
            int tmp=abs(c[j]-a[i])+abs(d[j]-b[i]);
            if(ans>tmp){
                ans = tmp;
                ansj = j+1;
            }
        }
        printf("%d\n",ansj);
    }
}

Measured memory_bytes: 1716
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

#define ff first
#define ss second

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

const int maxn = 1e5 + 7;
const int inf = 2e9 + 7;
const ll infl = 1e18 + 7;
const long double eps = 1e-9;
const ll mod = 1e9 + 7;

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // _DEBUG

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

	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<vector<ll>> dp(n, vector<ll>(n, 0));
	bool f = true;
	if (n % 2 == 0) f = false;
	for (int j = 1; j <= n; j++) {
		for (int i = 0; i < n; i++) {
			if (i + j - 1 >= n) break;
			if (f) {
				if (j == 1) dp[i][i] = a[i];
				else if (j % 2 == 1) {
					dp[i][i + j - 1] = max(dp[i][i + j - 2] + a[i + j - 1], dp[i + 1][i + j - 1] + a[i]);
				}
				else {
					dp[i][i + j - 1] = min(dp[i][i + j - 2] - a[i + j - 1], dp[i + 1][i + j - 1] - a[i]);
				}
			}
			else {
				if (j == 1) dp[i][i] = -a[i];
				else if (j % 2 == 1) {
					dp[i][i + j - 1] = min(dp[i][i + j - 2] - a[i + j - 1], dp[i + 1][i + j - 1] - a[i]);
				}
				else {
					dp[i][i + j - 1] = max(dp[i][i + j - 2] + a[i + j - 1], dp[i + 1][i + j - 1] + a[i]);
				}
			}
		}
	}
	cout << dp[0][n - 1];
	return 0;
}


Measured memory_bytes: 70784
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int c = 0;
        int max = 0;
        for (char ch : scanner.next().toCharArray()) {
            if (ch == 'I') {
                max = Math.max(max, ++c);
            } else {
                c--;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

template<typename T>
struct SegTree {
	T init_val;
	int n;
	vector<T> dat;
	
	SegTree() {}
	SegTree(int _n, T init_val) {
		init(_n, init_val);
	}
	
	void init(int _n, T iniv) {
		init_val = iniv;
		n = 1;
		while (n < _n) n *= 2;
		dat.resize(n * 2 - 1, init_val);
	}
	
	void update(int k, T x) {
		k += n - 1;
		chmax(dat[k], x);
		while (k > 0) {
			k = (k - 1) / 2;
			chmax(dat[k], max(dat[k * 2 + 1], dat[k * 2 + 2]));
		}
	}
	
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return max( query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r) );
	}
	
	T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

int N, M;
int A[5000], B[5000][200];
ll d[5000], imos[5001][5001];
SegTree<pii> st[2000];

// 2点(x1,y1),(x2, y2)を囲む長方形領域にaddを加算
void imos_add(int x1, int y1, int x2, int y2, ll add) {
	if (x1 > x2) swap(x1, x2);
	if (y1 > y2) swap(y1, y2);
	
	
	imos[y1][x1] += add;
	imos[y1][x2 + 1] -= add;
	imos[y2 + 1][x1] -= add;
	imos[y2 + 1][x2 + 1] += add;
}

void imos_calc() {
	REP(i, N) FOR(j, 1, N) imos[i][j] += imos[i][j - 1];
	REP(j, N) FOR(i, 1, N) imos[i][j] += imos[i - 1][j];
}


void solve(int x, int l, int r) { // [l,r]
	pii now = st[x].query(l, r + 1);
	int num = now.fi, m = now.se;
	
	imos_add(m, m, r, l, num);
	
	if (l != m) solve(x, l, m - 1);
	if (r != m) solve(x, m + 1, r);
}

int main() {
	cin >> N >> M;
	REP(i, N - 1) scanf("%d", &A[i]);
	REP(i, N) REP(j, M) scanf("%d", &B[i][j]);
	
	REP(i, N - 1) d[i + 1] = d[i] + A[i];
	
	REP(i, M) st[i] = SegTree<pii>(N, pii(-1, 0));
	REP(j, M) REP(i, N) st[j].update(i, pii(B[i][j], i));
	
	REP(i, M) solve(i, 0, N - 1);
	imos_calc();
	
	ll ans = 0;
	REP(i, N) FOR(j, i, N) chmax(ans, imos[i][j] - d[j] + d[i]);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 226048
n=int(input())
s=input()
e=s.count('E')
w=0
ans=e+w
p=0
for i in s:
  if p==1:
    w+=1
    p=0
  if i=='E':
    e-=1
  else:
    p=1
  ans=min(ans,e+w)
print(ans)

Measured memory_bytes: 3700
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,t=map(int,readline().split())
    li=[list(map(int,readline().split())) for _ in range(n)]
    li.sort()
    a=[0]*n
    b=[0]*n
    for i in range(n):
        a[i],b[i]=li[i][0],li[i][1]

    #ナップサックDP
    inf=-10**9
    dp=[[inf]*(t+1) for _ in range(n+1)]
    dp[0][0]=0
    for i in range(n):
        for j in range(t+1):
            #i番目を食べる
            if j!=t:
                dp[i+1][min(t,j+a[i])]=max(dp[i+1][min(t,j+a[i])],dp[i][j]+b[i])
            
            #i番目を食べない
            dp[i+1][j]=max(dp[i+1][j],dp[i][j])

    print(max(dp[n]))

if __name__=="__main__":
    main()

Measured memory_bytes: 115292
#include <bits/stdc++.h>
#define ll long long
#define p pair<int, int>
using namespace std;

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> sub(n);
    for (int i = 0; i < n - 1; i++) sub[i] = a[i + 1] - a[i];
    sub[n - 1] = k - a[n - 1] + a[0];
    sort(sub.begin(), sub.end());
    int sum = 0;
    for (int i = 0; i < n - 1; i++) sum += sub[i];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s, table[4] = { "KIH","B","R" };

int main() {
	cin >> s;
	rep(i, (1 << 4)) {
		string t;
		rep(j, 4) {
			if (i&(1 << j))t += "A";
			if (j != 3)t += table[j];
		}
		if (s == t) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import sys


def exhaustive(lst, size):
    result = []
    for i in range(0, 1 << size):
        total = 0
        for j in range(0, size):
            if (i & 0x01) == 1:
                total += lst[j]
            i = i >> 1
        result.append(total)
    return result


if __name__ == "__main__":
    lst = [val.split() for val in sys.stdin.read().splitlines()]
    n, data, m, targets = [[int(n) for n in inner_lst] for inner_lst in lst]
    result = exhaustive(data, int(n[0]))
    print("\n".join(["yes" if x in result else "no" for x in targets]))

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

using mat = vector<vint>;

bool check(mat table) {
  rep(i, 4) rep(j, 4) {
    if(table[i][j] > 0) return false;
  }
  return true;
}

bool blowup(mat &table) {
  static const int dy[] = {0, 1, 0, -1};
  static const int dx[] = {1, 0, -1, 0};
  auto in = [&](int y, int x) {
    return 0<=y&&y<4&&0<=x&&x<4;
  };
  queue<Ti> que;
  bool update = true;
  while(update) {
    update = false;
    rep(i, 4) rep(j, 4) {
      if(table[i][j] >= 5) {
	table[i][j] = 0;
	rep(k, 4) que.emplace(k, i, j);
	update = true;
      }
    }
    if(!update) break;
    while(!que.empty()) {
      int d, y, x; tie(d, y, x) = que.front(); que.pop();
      int ny = y+dy[d], nx = x+dx[d];
      if(!in(ny, nx)) continue;
      if(table[ny][nx] > 0) ++table[ny][nx];
      else que.emplace(d, ny, nx);
    }
  }
  return check(table);
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  mat input(4, vint(4));
  rep(i, 4) rep(j, 4) cin >> input[i][j];
  if(check(input)) {
    cout << 0 << endl;
    return 0;
  }
  set<mat> st;
  queue<pair<int, mat> > que;
  que.emplace(0, input);
  st.insert(input);
  while(!que.empty()) {
    auto p = que.front(); que.pop();
    mat table = p.second;
    int mx = 0;
    rep(i, 4) rep(j, 4) chmax(mx, table[i][j]);
    if(p.first > mx) continue;
    if(p.first == 5) continue;
    rep(i, 4) rep(j, 4) {
      if(table[i][j] == 0) {
	table[i][j] = 1;
	if(!st.count(table)) {
	  que.emplace(p.first+1, table);
	  st.insert(table);
	}
	table[i][j] = 0;
      } else {
	mat cpytable = table;
	++cpytable[i][j];
	if(cpytable[i][j] >= 5) {
	  if(blowup(cpytable)) {
	    cout << p.first+1 << endl;
	    return 0;
	  }
	}
	if(!st.count(cpytable)) {
	  que.emplace(p.first+1, cpytable);
	  st.insert(cpytable);
	}
      }
    }
  }
  cout << -1 << endl;

  return 0;
}

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

using namespace std;

#define pb push_back
#define popb pop_back
#define pf push_front
#define popf pop_front
#define nl "\n"
#define sp " "
#define hashset unordered_set

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef set<int> si;
typedef set<char> sc;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
    */
    int n; cin >> n;
    if (400 <= n && n <= 599) cout << 8;
    if (600 <= n && n <= 799) cout << 7;
    if (800 <= n && n <= 999) cout << 6;
    if (1000 <= n && n <= 1199) cout << 5;
    if (1200 <= n && n <= 1399) cout << 4;
    if (1400 <= n && n <= 1599) cout << 3;
    if (1600 <= n && n <= 1799) cout << 2;
    if (1800 <= n && n <= 1999) cout << 1;
}


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

using namespace std;
typedef long long ll;

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

    for (int i = X - K + 1 ; i < X + K - 1; i++) {
        cout << i << " ";
    }
    cout << X + K - 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int H, W;
	cin >> H >> W;
	rep(i, H)rep(j, W) {
		string S;
		cin >> S;
		if (S == "snuke") {
			cout << char('A' + j) << i + 1 << endl;
		}
	}



}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
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;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, a; cin >> n >> a;
  ll maxa = a;
  vll x(n);
  REP(i, n) {
    cin >> x[i];
    chmax(maxa, x[i]);
  }
  V<vvll> dp(n+1, vvll(n+1, vll(n*maxa+1, 0)));
  dp[0][0][0] = 1;
  rep(i, 1, n+1) REP(j, n+1) REP(k, n*maxa+1) {
    dp[i][j][k] = dp[i-1][j][k];
    if (j>=1 && k >= x[i-1]) dp[i][j][k] += dp[i-1][j-1][k-x[i-1]];
  }
  ll ans = 0;
  rep(k, 1, n+1) ans += dp[n][k][k*a];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 52224
import java.util.Scanner;

/**
 * B - Judge Status Summary
 *
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        int n = sc.nextInt();   // 提出数
        // 結果
        int totalAcCnt = 0;
        int totalWaCnt = 0;
        int totalTleCnt = 0;
        int totalReCnt = 0;
        for( int i = 0; i < n; i++ ) {
            String s = sc.next();
            if( s.equals( "AC" ) ) ++totalAcCnt;
            else if( s.equals( "WA" ) ) ++ totalWaCnt;
            else if( s.equals( "TLE" ) ) ++ totalTleCnt;
            else ++totalReCnt;
        }

        StringBuffer sb = new StringBuffer();
        sb.append( "AC x " ).append( totalAcCnt );
        sb.append( "\nWA x " ).append( totalWaCnt );
        sb.append( "\nTLE x " ).append( totalTleCnt );
        sb.append( "\nRE x " ).append( totalReCnt );

        System.out.println( sb.toString() );

        sc.close();
    }
}

Measured memory_bytes: 58444
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-10;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}

ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}

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

int main() {
	IOS();
	ll n;
	cin >> n;
	double ans = 0;
	for (int i = 0; i < n; i++) {
		double x;
		string s;
		cin >> x >> s;
		if (s[0] == 'J') {
			ans += x;
		} else {
			ans += x * 38e4;
		}
	}
	dumpf(ans, 6);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

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

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    Rep (i, N) {
        cin >> A[i];
    }
    Rep (i, N) {
        cin >> B[i];
    }
    Rep (i, N) cin >> C[i];

    sort(A.begin(), A.end()); sort(B.begin(), B.end()); sort(C.begin(), C.end());

    ll ans = 0;
    for (auto b : B) {
        ll a = lower_bound(A.begin(), A.end(), b) - A.begin();
        ll c = C.end() - upper_bound(C.begin(), C.end(), b);
        ans += a * c;
    }

    cout << ans << endl;
}

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

//Spiral Pattern
public class Main {

	static char[][] s;
	static int n;
	static int[][] move = {{-1,0},{0,1},{1,0},{0,-1}};
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		boolean f = true;
		while(t--!=0){
			if(!f)System.out.println();
			f = false;
			n = sc.nextInt();
			s = new char[n][n];
			for(int i=0;i<n;i++)Arrays.fill(s[i], ' ');
			int i = n;
			int j = 0;
			int k = 0;
			while(true){
				int ni = i+move[k][0];
				int nj = j+move[k][1];
				if(0<=ni&&ni<n&&0<=nj&&nj<n&&c(ni,nj)){
					s[ni][nj] = '#';
					i = ni;
					j = nj;
				}
				else{
					k = (k+1)%4;
					ni = i+move[k][0];
					nj = j+move[k][1];
					if(0<=ni&&ni<n&&0<=nj&&nj<n&&c(ni,nj)){
						s[ni][nj] = '#';
						i = ni;
						j = nj;
					}
					else break;
				}
			}
			for(int x=0;x<n;x++)System.out.println(new String(s[x]));
		}
	}
	
	static boolean c(int i, int j){
		int c = 0;
		for(int k=0;k<4;k++){
			int ni = i+move[k][0];
			int nj = j+move[k][1];
			if(0<=ni&&ni<n&&0<=nj&&nj<n&&s[ni][nj]=='#')c++;
		}
		return c<=1;
	}
}

Measured memory_bytes: 27280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <tuple>
using namespace std;

int main(void) {
  int N; cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> h(N);

  tuple<int, int, int> G = make_tuple(-1, -1, -1);
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] >= 1)
      G = make_tuple(x[i], y[i], h[i]);
  }

  vector<tuple<int, int, int>> V;
  for (int Cx = 0; Cx <= 100; Cx++) {
    for (int Cy = 0; Cy <= 100; Cy++) {
      long long V = get<2>(G) + abs(get<0>(G) - Cx) + abs(get<1>(G) - Cy);
      V = max(V, 0LL);
      bool flag = true;
      for (int i = 0; i < N; i++) {
        long long VV = V - abs(x[i] - Cx) - abs(y[i] - Cy);
        VV = max(VV, 0LL);
        if (h[i] != VV)
          flag = false;
      }
      if (flag) {
        cout << Cx << " " << Cy << " " << V << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ul;

const int iinf = 1 << 29;
const long long linf = 1l << 61;

int main(int argc, char* argv[])
{
	int X, Y, Z;
	scanf("%d %d %d", &X, &Y, &Z);
	printf("%d", (X - Z) / (Y + Z));

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[35];
int main()
{
	int n,m;
	cin>>n>>m;
	int k[n+2];
	for(int i=1;i<=n;i++)
		{
			cin>>k[i];
			for(int j=1;j<=k[i];j++)
			{
				int x;
				cin>>x;
				a[x]+=1;
			}
		}
	int ans=0;
	for(int i=1;i<=m;i++)
	{
		if(a[i]==n)	ans++;
	}
	cout<<ans;
	return 0;
 } 	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <utility>
#include <tuple>

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

using namespace std;

struct PairHash{

    /**
     * @brief generate hash for std::pair
     *
     * @param p std::pair variable
     *
     * @return generated hash
     */
    template<class T1, class T2>
        inline size_t operator()(const std::pair<T1, T2> & p) const{
            unsigned int lhs = std::hash<T1>()(p.first);
            unsigned int rhs = std::hash<T2>()(p.second);
            return lhs^(rhs+0x9e3779b9+(lhs<<6)+(lhs>>2));
        }
};

int main(int argc, char const* argv[])
{
    size_t N,M,X;
    cin >> N;
    cin >> M;
    cin >> X;
    vector<size_t> C(N);
    unordered_map<pair<size_t, size_t>, size_t, PairHash> A;
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> A[make_pair(i,j)];
        }
    }

    size_t result = INT64_MAX;
    for(size_t c=0; c<(1 << N); c++){
        size_t money_count = 0;
        vector<size_t> skill(M);
        rep(i,N){
            if((c & (1 << i)) != 0){
                money_count += C[i];
                rep(j,M){
                    skill[j] += A[make_pair(i, j)];
                }
            }
        }
        //check
        bool flag = true;
        rep(j,M){
            if(skill[j] < X){
                flag = false;
            }
        }

        if(flag){
            result = std::min(result, money_count);
        }
    }

    if(result != INT64_MAX){
        cout << result << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<long long> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	vector<vector<int> > V(N);
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--, B--;
		V[A].push_back(B);
		V[B].push_back(A);
	}
	int ANS = 0;
	for (int i = 0; i < N; i++) {
		bool check = true;
		for (int j : V[i]) {
			if (H[j] >= H[i]) check = false;
		}
		if (check) ANS++;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 9068
import numpy as np
N,K=map(int,input().split())
a = np.array([int(x) for x in input().split()])
val=sum(a[:K])
max_val=val
for i in range(N-K):
  val+=a[K+i]
  val-=a[i]
  max_val=max(val,max_val)
print(max_val/2+K*0.5)

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int a,b,c;cin>>a>>b>>c;
  int ans=a+b+c;
  cout << (ans>21?"bust":"win") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>

using namespace std;
int main() {
	char c;
	while (cin >> c) {
		for (int i = 0; i < 3; i++) {
			c--;
			if (c < 'A') c = 'Z';
		}
		cout << c;
	}
	cout << endl;
	return 0;
}

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

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
mint f2(int n, int k) {
  return comb(n+k-1,k-1);
}
mint f(int n, int k) {
  if (n < k) return 0;
  if (n == 0 && k == 0) return 1;
  if (k < 1) return 0;
  return f2(n-k,k);
}

int main() {
  init();
  int n, k;
  cin >> n >> k;

  for (int i = 1; i <= k; i++) {
    mint blue = f(k,i);
    mint red = 0;
    {
      red += f(n-k,i-1);
      red += f(n-k,i);
      red += f(n-k,i);
      red += f(n-k,i+1);
    }
    mint ans = blue*red;
    printf("%lld\n", ans.x);
  }
  return 0;
}


Measured memory_bytes: 125568
N, L = map(int, input().split())

T = [L+i-1 for i in range(1, N+1)]

if all([i > 0 for i in T]):
    print(sum(T)-min(T))
elif any([i==0 for i in T]):
    print(sum(T))
else:
    print(sum(T)-max(T))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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 long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin >> n;
    ll x[n],y[n],h[n];
    for (ll i=0;i<n;i++){
        cin >> x[i] >> y[i] >> h[i];
    }
    
    for (ll i=0;i<=100;i++){
        for (ll j=0;j<=100;j++){
            ll flag[n],ans=1;
            bool z[n];
            for (ll k=0;k<n;k++){
                flag[k]=h[k]+abs(x[k]-i)+abs(y[k]-j);
                if (h[k]!=0){
                    z[k]=true;
                    ans=flag[k];
                }else{
                    z[k]=false;
                }
            }
            bool f=true;
            for (ll k=0;k<n;k++){
                if (z[k] and ans!=flag[k]){
                    f=false;
                    break;
                }
                if(!z[k] and ans>flag[k]){
                    f=false;
                    break;
                }
            }
            if (f){
                cout << i << " " << j << " " << ans << endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
h,w=map(int,input().split())
s=[input() for _ in range(h)]
ans=[""]*h
for i in range(h):
    for j in range(w):
        num=0
        if s[i][j]=="#":
            ans[i]+="#"
        else:
            if i!=0 and j!=0 and s[i-1][j-1]=="#":
                num+=1
            if i!=0 and s[i-1][j]=="#":
                num+=1
            if i!=0 and j!=w-1 and s[i-1][j+1]=="#":
                num+=1
            if j!=0 and s[i][j-1]=="#":
                num+=1
            if j!=w-1 and s[i][j+1]=="#":
                num+=1
            if i!=h-1 and j!=0 and s[i+1][j-1]=="#":
                num+=1
            if i!=h-1 and s[i+1][j]=="#":
                num+=1
            if i!=h-1 and j!=w-1 and s[i+1][j+1]=="#":
                num+=1
            ans[i]+=str(num)
for i in range(h):
    print(ans[i])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
	ll n,a,b,c;
	cin >> a >> b;
	if((a+b)%2==0){
		cout << (a+b)/2 << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
}

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

int main(){
    ll n, k;
    ll mini=0;
    ll minas=0;
    cin >> n >> k;
    mini = n%k;
    minas = abs(mini-k);
    if(mini < minas)
        cout << mini << endl;
    else
        cout << minas << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>

using ::std::cin;
using ::std::cout;
using ::std::endl;
using ::std::vector;

using LL = long long;

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

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

  LL sum = 0;
  for (int i = 0; i < n; i++) {
    sum += ds[i];
  }

  LL subSum = 0;
  for (int i = 1; i <= n - 2; i += 2) {
    subSum += 2 * ds[i];
  }

  // cout << sum << " " << subSum << endl;

  vector<LL> xs(n);
  xs[0] = sum - subSum;
  for (int i = 1; i < n; i++) {
    xs[i] = (ds[i - 1] - xs[i - 1] / 2) * 2;
  }

  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << xs[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2944
# Problem D - Line++

# input
N, X, Y = map(int, input().split())

# initialization
INF = N
kyori_graph = [[INF]*N for i in range(N)]
kosu_list = [0]*(N-1)
for i in range(N):
    for j in range(i+1, N):
        if j==i+1:
            kyori_graph[i][j] = 1
        else:
            kyori_graph[i][j] = INF
kyori_graph[X-1][Y-1] = 1

# graph search
for i in range(N):
    for j in range(i+1, N):
        # グラフの更新
        kyori_graph[i][j] = min(abs(j-i), abs(X-1-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))

# 個数の数え上げ
for i in range(N):
    for j in range(i+1, N):
        kyori = kyori_graph[i][j]
        kosu_list[kyori-1] += 1

# output
for k in kosu_list:
    print(k)


Measured memory_bytes: 79836
import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

import scala.annotation.tailrec

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val input = new Scanner(in)

    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val Array(n, x) = input.nextLine().split(" ").map(_.toInt)
      val xs          = input.nextLine().split(" ").map(_.toInt)

      if (n <= 1) {
        output.println(Math.abs(xs.head - x))
      } else {
        val diffs = (x :: xs.toList).sorted
          .sliding(2)
          .map {
            case List(n, m) =>
              Math.abs(n - m)
          }
          .toSeq
        println(diffs.reduce(gcd))
      }
    }

    @tailrec
    final def gcd(m: Int, n: Int): Int = {
      val (x, y) = if (m > n) (m, n) else (n, m)
      if (y != 0) gcd(y, x % y)
      else x
    }

  }

}


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

typedef long long int llint;

struct restaurant{
	int no;
	int point;
};

int main(){
	int N;
	vector<string> cities;
	map<string,vector<restaurant>> guidebook;
	cin >> N;
	for(int i=0;i<N;i++){
		string S;
		int P;
		cin >> S >> P;
		restaurant R;
		R.no=i+1;
		R.point=P;
		if(guidebook.count(S)==0){
			cities.push_back(S);
		}
		guidebook[S].push_back(R);
	}
	sort(cities.begin(),cities.end());
	for(const auto& city : cities){
		vector<restaurant>& rests=guidebook[city];
		sort(rests.rbegin(),rests.rend(),
			[](const restaurant& l,const restaurant& r){
				return l.point<r.point;
			});
		for(const auto& r : rests){
			cout << r.no << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
N,M = [int(x) for x in input().split(' ')]

ans_l = [0 for _ in range(N)]

ng = False

for _ in range(M):
    s, c = [int(x) for x in input().split(' ')]
    if s == 1 and c == 0 and N != 1:
        ng = True

    if ans_l[s-1] == 0 or ans_l[s-1] == c:
        ans_l[s-1] = c
    else:
        ng = True

if ans_l[0] == 0 and N != 1:
    ans_l[0] = 1

if ng:
    print(-1)
else:
    ans_l = [str(x) for x in ans_l]
    print(int(''.join(ans_l)))

Measured memory_bytes: 3064
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    P = []
    M = []
    for _ in range(N):
        x, y = map(int, input().split())
        P.append(x + y)
        M.append(x - y)
    P.sort()
    M.sort()
    ans = max(P[-1] - P[0], M[-1] - M[0])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25676
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
          	int dw = sum_w - weight[i];
            if (dw >= 0) {
                chmax(dp[i+1][sum_w], dp[i][dw] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 79360
def long_angle(h, m):
  return m * 6

def short_angle(h, m):
  return 30 * h + 0.5 * m

def diff_angle(la, sa):
  max_a, min_a = max(la, sa), min(la, sa)
  dff = max_a - min_a
  if dff >= 180:
    return 360 - dff
  else:
    return dff


def put_mess(dff):
  if dff < 30:
    print("alert")
  elif dff < 90:
    print("warning")
  else:
    print("safe")

n = int(input())
for _ in range(n):
  h, m = list(map(int, input().split(":")))
  dff = diff_angle(long_angle(h, m), short_angle(h, m))
  put_mess(dff)



Measured memory_bytes: 5616
#include<iostream>
#include<cstdio>
using namespace std;
int n,ans,del,x;
int main() {
	scanf("%d",&n);
	ans=1; del=1;
	for (int i=1;i<=n;i++) {
		scanf("%d",&x);
		ans*=3;
		if (x%2==0) del*=2;
	}
	printf("%d\n",ans-del);
	return 0;
}

Measured memory_bytes: 256
// testcplusplus.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <math.h>

using namespace std;



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

	cout << pow(n, 3);
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
int main(void){
    int i,n,y,p,b[51]={},t[51]={},r[51]={};
    double max,a[51]={};
    
    while(1){
        scanf("%d",&n);
        if(n==0)break;
        
        scanf("%d",&y);
        for(i=1;i<=n;i++){
            scanf("%d %d %d",&b[i],&r[i],&t[i]);
            switch(t[i]){
                case 1 :a[i]=1+(double)y*(double)r[i]/100;break;
                case 2 :a[i]=pow(1+(double)r[i]/100,(double)y);break;
            }
        }
        
        max=0;
        for(i=1;i<=n;i++){
            if(max<a[i]){
                max=a[i];
                p=b[i];
            }
        }
        
        printf("%d\n",p);
    }
    return 0;
}

Measured memory_bytes: 692
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int s=sc.nextInt();
		long[][] dp=new long[n][50*(n-1)+1];
		for(int i=0; i<n; i++){
			Arrays.fill(dp[i],Long.MAX_VALUE);
		}
		ArrayList<State>[] list=new ArrayList[n];
		for(int i=0; i<n; i++){
			list[i]=new ArrayList<>();
		}
		for(int i=0; i<m; i++){
			int u=sc.nextInt()-1;
			int v=sc.nextInt()-1;
			int a=sc.nextInt();
			long b=sc.nextLong();
			list[u].add(new State(v,a,b));
			list[v].add(new State(u,a,b));
		}
		int[][] cd=new int[n][2];
		for(int i=0; i<n; i++){
			cd[i][0]=sc.nextInt();
			cd[i][1]=sc.nextInt();
		}
		PriorityQueue<State> q=new PriorityQueue<>((x,y)->((x.time-y.time<0)?-1:1));
		if(s>50*(n-1)){
			s=50*(n-1);
		}
		q.add(new State(0,s,0));
		while(!q.isEmpty()){
			State ss=q.poll();
			if(dp[ss.to][ss.money]==Long.MAX_VALUE){
				dp[ss.to][ss.money]=ss.time;
			}else{
				continue;
			}
			if(ss.money+cd[ss.to][0]<=50*(n-1)){
				q.add(new State(ss.to,ss.money+cd[ss.to][0],ss.time+cd[ss.to][1]));
			}
			for(State i:list[ss.to]){
				if(ss.money-i.money>=0 && dp[i.to][ss.money-i.money]==Long.MAX_VALUE){
					q.add(new State(i.to,ss.money-i.money,ss.time+i.time));
				}
			}
		}
		for(int i=1; i<n; i++){
			long ans=Long.MAX_VALUE;
			for(int j=0; j<=50*(n-1); j++){
				ans=Math.min(ans,dp[i][j]);
			}
			System.out.println(ans);
		}
	}
	static class State{
		int to,money;
		long time;
		State(int to,int money,long time){
			this.to=to;
			this.money=money;
			this.time=time;
		}
	}
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    int A[4];
    for(int i = 0; i <4; i++) A[i] = int(s[i] - '0');

    for(int i = 0; i < (1<<3); i++){
        int sum = A[0];
        for(int j = 0; j < 3; j++){
            if(i&(1<<j)) sum+=A[j+1];
            else sum-=A[j+1];
        }
        if(sum == 7){
            cout << A[0];
            for(int j = 0; j < 3; j++){
                if(i&(1<<j)) cout << "+";
                else cout << "-";
                cout << A[j+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200009],xsum[200009],sum[200009],ll=1;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
		xsum[i]=xsum[i-1]^a[i];
	}
	long long ans=0;
	int l=n;
	for(int i=1;i<=n;i++)
	{
		if(sum[i]!=xsum[i])
		{
			l=i-1;
			break;
		}
	}
	ans=ll*l*(l+1)/2;
	for(int i=2;i<=n;i++)
	{
		if(l==n)break;
		int j;
		for(j=max(i+1,l+1);j<=n;j++)
		{
			if(sum[j]-sum[i-1]!=(xsum[j]^xsum[i-1]))
			{
				j--;
				break;
			}
		}
		j=min(j,n);
		ans+=ll*(j-i+2)*(j-i+1)/2;
		//cout<<ans<<" "<<l<<"  "<<i<<" "<<j<<"      ";
		if(i<=l)ans-=ll*(l-i+2)*(l-i+1)/2;
		l=j;
		//cout<<ans<<" "<<l<<"  "<<i<<" "<<j<<endl;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

#define ll long long

struct Point {
	int x;
	int y;
};

double dist(Point a) {
	return sqrt(pow(a.x, 2) + pow(a.y, 2));
}


void solve() {

	int n, D;
	cin >> n >> D;
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		Point p;
		cin >> p.x >> p.y;
		double d = dist(p);
		if(d <= D) {
			cnt++;
		}
	}
	cout << cnt << "\n";

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--) 
		solve();

	return 0;
}

Measured memory_bytes: 3684
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int a, b, k;
    cin >> a >> b >> k;
    set<int> s;
    for(int i = a; i <= min(a + k - 1, b); i++){
        s.in(i);
    }
    for(int i = b; i >= max(b - k + 1, a); i--){
        s.in(i);
    }
    for(auto x : s) cout << x << " ";
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct
{
    int b;
    int c;
}food;


int main (void){
    int n = 0;
    int a[20] = {0};
    food meal[20];
    int h =0;

    scanf("%d",&n);

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

    for (int i = 0; i < n-1; i++)
    {
        scanf("%d",&meal[i].c);
    }

    for (int i = 0; i < n; i++)
    {
        h+=meal[a[i]-1].b;

        if (a[i+1]==(a[i]+1))
        {
            h+=meal[a[i]-1].c;
        }
        
    }
    
    printf("%d",h);

    return 0;

}

Measured memory_bytes: 128
# -*- coding : utf-8 -*-
N, T = map(int, input().split(" "))

c = [int(1001)]

for i in range(0, N):
    tmp, t = map(int, input().split(" "))
    if t <= T:
        c.append(tmp)

tmp = min(c)
if tmp == 1001:
    print("TLE")
else:
    print(tmp)

Measured memory_bytes: 3060