akhauriyash/Code-Regression huggingface dataset:
my $N = <STDIN>;
my @A;
push (@A, 0);
foreach my $v (split(/ /,<STDIN>)){
        chomp($v);
        push (@A, $v);
}
push (@A, 0);
my @t;
my $total = 0;
my $j = -1;
foreach my $v (@A) {
        $j++;
        next if ($j == 0);
        my $tmp = abs($A[$j] - $A[$j-1]);
        $total += $tmp;
        push(@t, $tmp);
}
foreach my $i (0..$N-1){
        print $total - (@t[$i]+@t[$i+1]) + abs($A[$i]-$A[$i+2])."\n";
}

Measured memory_bytes: 20140
n = int(input())
lst_p = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]


ans = 'Yes'
for i in range(n):
    t = lst_p[i+1][0] - lst_p[i][0]
    x = abs(lst_p[i+1][1] - lst_p[i][1])
    y = abs(lst_p[i+1][2] - lst_p[i][2])
    if t >= x + y and (x+y)%2 == t%2:
        continue
    else:
        ans = 'No'
        break


print(ans)

Measured memory_bytes: 28068
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var: ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
    }
    let min = std::cmp::min(std::cmp::min(a + b, b + c), c + a);
    println!("{}", min);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	
	int n,x,fx=0;
	cin>>n;
	x=n;
	while(n>0){
		fx+=n%10;
		n/=10;
	}
//	cout<<fx<<" "<<x<<endl;
	if(x%fx==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	
	
	return 0;
}


















































Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision; // int64_tは9*10^18まで

#define MAX_N 51

// Union-Find木(蟻本p84)
int par[MAX_N];  // 親
int rk[MAX_N]; // 木の深さ

void init(int n) { // n要素で初期化
  for (int i = 0; i < n; i++) {
    par[i] = i;
  }
}

int find(int x) { // 木の根を求める
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) { // xとyの属する集合を併合
  x = find(x);
  y = find(y);
  if (x == y)
    return;

  if (rk[x] < rk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rk[x] == rk[y])
      rk[x]++;
  }
}

bool same(int x, int y) { // xとyが同じ集合に属するか否か
  return find(x) == find(y);
}

int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m], res=0;
  for (int i=0; i < m; i++)
    cin >> a[i] >> b[i];

  for(int i=0; i<m; i++){
    init(n+1);
    for(int j=0; j<m; j++){
      if(i==j) continue;
      unite(a[j], b[j]);
    }
    if(!same(a[i], b[i])) res++;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 3616
H, W = map(int, input().split())
ans = 1<<60

# 3等分できたら差は0になる
if H%3==0 or W%3==0:
  print(0)
else:
  for h in range(1, H): # チョコを横置きに縦幅を探索
    A = h*W
    B = (H-h) * -(-W//2) # 切り上げ
    C = (H-h) * (W//2) # 切り捨て
    ans = min(ans, max(A,B,C) - min(A,B,C))
    
  for w in range(1, W): # チョコを縦置きに縦幅を探索
    A = w*H
    B = (W-w) * -(-H//2) # 切り上げ
    C = (W-w) * (H//2) # 切り捨て
    ans = min(ans, max(A,B,C) - min(A,B,C))
  print(min(ans, H, W))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
using namespace std;
typedef long long ll;

const ll MAX = 200000;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
  // 前処理
  COMinit();
  ll h,w,a,b;cin >> h >> w >> a >> b;
  ll ans=0;//cout << ans << endl;
  ll m=min(a,b);
  for(int i=1;i<=w-b;i++){
    //cout << 1 << endl;
    ll ans_sub=COM(h-a+b+i-2,b+i-1)*COM(w-b+a-i-1,a-1)%MOD;
    ans+=ans_sub;
    ans%=MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

string s[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        mp[s[i]]++;
    }
    int mx = 0;
    for(int i = 0; i < n; i++){
        mx = max(mx, mp[s[i]]);
    }
    set<string>st;
    for(int i = 0; i < n; i++) if(mp[s[i]] == mx) st.insert(s[i]);
    for(auto i: st) cout << i << '\n';


    return 0;
}


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

int main() {
  double a,b,h,m;
    cin >>a>> b>>h>>m;
    
    static const double pi = 3.141592653589793;
    
    double c;
    c = 30*h+m/2-6*m;
  
    cout << fixed << setprecision(12);
    cout <<sqrt(a*a+b*b -2*a*b*cos(pi/(180/c)));
}

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

s1 = list(input())
s2 = list(input())

kind = 0
next_step = 0
# 0なら前が縦、1なら前が横
pre = 0
step = 0
for _ in range(n):
  if next_step > n-1:
    break
  w1 = s1[next_step]
  w2 = s2[next_step]
  if next_step > 0:
    if w1 == w2:
      next_step += 1
      if pre == 0:
        kind *= 2
      else:
        kind *= 1
      pre = 0
    else:
      next_step += 2
      if pre == 0:
        kind *= 2
      else:
        kind *= 3
      pre = 1
  else:
    if w1 == w2:
      kind += 3
      next_step += 1
      pre = 0
    else:
      kind += 6
      next_step += 2
      pre = 1

mod = 1000000007
print(kind%mod)
    
    

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
using namespace std;

int D[303][303][155];
char S[303]; int K;

int main()
{
	scanf("%s %d", S+1,&K);
	int N = 0;
	while (S[N + 1]) N++;
	if (2 * K > N) {
		printf("%d\n" , N);
		return 0;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = N; j > i; j--) {
			for (int k = 0; k <= K; k++) {
				D[i][j][k] = max(D[i - 1][j][k], D[i][j + 1][k]);
				if (S[i] == S[j]) D[i][j][k] = max(D[i][j][k], D[i - 1][j + 1][k] + 2);
				else {
					if (k) D[i][j][k] = max(D[i][j][k], D[i - 1][j + 1][k-1] + 2);
				}
			}
		}
	}

	int ans = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = N; j > i; j--) {
			for (int k = 0; k <= K; k++) {
				int d = D[i][j][k];
				if (i + 1 < j) d++;
				ans = max(ans, d);
			}
		}
	}

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

	return 0;
}

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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

const int MAX=2e5+9;
int n, m, k;
ll pref1[MAX], pref2[MAX];

int BSFind(int rest) {
    int low=0, high=m, res=0;

    while (low<=high) {
        int mid=((low+high)/2);

        if (pref2[mid]<=rest) {
            res=mid;
            low=mid+1;
        }
        else {
            high=mid-1;
        }
    }

    return res;
}

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

int  d,t,s;
cin>>d>>t>>s;

if(s*t>=d)
    cout<<"Yes\n";
else
cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3632
function Main(input) {
	input = input.split("\n");


    const num = Number(input[0]);

    if (input[1].length > num) {
         console.log(input[1].substr( 0, num ) + '...');
    } else {
        console.log(input[1]);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29620
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int A,B,Q;
    cin>>A>>B>>Q;
    long long ans;
    long long s[100010],t[100010],x[100010];
    s[0]=t[0]=-pow(10,15);s[A+1]=t[B+1]=pow(10,15);
    for(int i=1;i<=A;++i)cin>>s[i];
    for(int i=1;i<=B;++i)cin>>t[i];
    for(int i=1;i<=Q;++i){
        cin>>x[i];

        auto itr_s0=lower_bound(s,s+A+2,x[i]);
        auto itr_t0=lower_bound(t,t+B+2,x[i]);
        auto itr_s1=itr_s0;
        auto itr_t1=itr_t0;
        --itr_s0;--itr_t0;
        
        if(*itr_s1<=*itr_t1&&*itr_t0<=*itr_s0)
            ans=min(*itr_t1-x[i],x[i]-*itr_t0);
        else if(*itr_s0<=*itr_t0&&*itr_t1<=*itr_s1)
            ans=min(*itr_s1-x[i],x[i]-*itr_s0);
        else ans=min(min(*itr_s1,*itr_t1)-max(*itr_s0,*itr_t0)+min(min(*itr_s1,*itr_t1)-x[i],x[i]-max(*itr_s0,*itr_t0)),
                 min(max(*itr_s1,*itr_t1)-x[i],x[i]-min(*itr_s0,*itr_t0)));
        
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e7 + 7;
const int MX = 998244353;
const LL INF = 1LL * MX * MX;

int n;
int rv[N];
int sil[N];

int fast(int a, int b){
	int ret = 1;
	while(b){
		if(b & 1)
			ret = (1LL * ret * a) % MX;
		
		b >>= 1;
		a = (1LL * a * a) % MX;
	}
	
	return ret;
}

inline int newton(int a, int b){
	return (((1LL * sil[a] * rv[b]) % MX) * rv[a - b]) % MX;
}

int main(){
	scanf("%d", &n);
	sil[0] = 1;
	for(int i = 1; i <= n; ++i)
		sil[i] = 1LL * i * sil[i - 1] % MX;
	
	rv[n] = fast(sil[n], MX - 2);
	for(int i = n; i >= 1; --i)
		rv[i - 1] = 1LL * i * rv[i] % MX;
	
	int cur = 1, ans = 0;
	for(int i = n; i + i > n; --i){
		ans = (ans + 1LL * cur * newton(n, i)) % MX;
		cur = (cur + cur) % MX;
	}

	ans = (ans + ans) % MX;
	ans = (fast(3, n) + MX - ans) % MX;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 78336
#include<cstdio>
int I,O,T,J,L,S,Z,now,ans;
int main()
{
	scanf("%d%d%d%d%d%d%d",&I,&O,&T,&J,&L,&S,&Z);
	now=(I&1)+(J&1)+(L&1);
	if(now>=2&&I&&J&&L)
	{
		--I,--J,--L;
		ans+=3;
	}return printf("%lld\n",(long long)ans+O+I/2*2+J/2*2+L/2*2),0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    double res = 0.0;
    REP(i, N){
    	double x;
    	string s;
    	cin >> x >> s;
    	if(s=="JPY"){
    		res += x;
    	}else{
    		res += x* 380000.0;
    	}
    }
    printf("%.10f\n", res);
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n, k;
  cin >> n >> k;
  string ar;
  cin >> ar;
  ar[k - 1] = tolower(ar[k - 1]);
  cout << ar << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

string func(string a, string b){
	if(a.size() < b.size()) return func(b, a);
	rep(i, b.size()) a[i] = (a[i] - '0' ^ b[i] - '0') + '0';
	int z = 0;
	rep(i, a.size()) if(a[i] != '0') break; else z++;
	if(z == a.size()) return b;
	return func(b, a.substr(z));
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n;
	string x; cin >> n >> x;
	vector<string> a(n);
	rep(i, n) cin >> a[i];
	
	string s = a[0];
	for(int i = 1; i < n; i++) s = func(s, a[i]);
	dbg(s);
	
	const int mod = 998244353;
	ll ans = 0, pw[5000];
	pw[0] = 1; rep(i, 4999) pw[i + 1] = pw[i] * 2 % mod;
	
	string y(x.size(), '0');
	rep(i, (int)x.size() - (int)s.size() + 1){
		if(x[i] == '1') ans += pw[(int)x.size() - (int)s.size() - i];
		if(x[i] != y[i]){
			rep(j, s.size()) y[i + j] = (y[i + j] - '0' ^ s[j] - '0') + '0';
		}
	}
	//dbg(y);
	
	if(x >= y) ans++;
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 22060
//2019.7.18 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define eps 1e-10
#define RG register
#define db long double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
inline LL Read() {
    RG LL s=0;
    res ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG __int128 x){
//    if(x>10)write(x/10);
//    putchar(x%10+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace MAIN{
    int n,a[18+10];
    LL dfs(res l,res r,RG LL L,RG LL R){
        if(r-l==1)return 0;
        RG LL ret=INF;
        for(res i=l+1;i<=r-1;i++)
            ret=min(ret,dfs(l,i,L,L+R)+dfs(i,r,L+R,R)+(L+R)*a[i]);
        return ret;
    }
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)a[i]=read();
        printf("%lld\n",a[1]+a[n]+dfs(1,n,1,1));
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("route.in","r",stdin);
//    freopen("route.out","w",stdout);
    MAIN::MAIN();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
const int MAXN = 200000;
long long cnt[MAXN + 5];
int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	for(int i=1;i<=N;i++)
		cnt[i%K]++;
	long long ans = 0;
	for(int i=0;i<K;i++)
		if( (2*i)%K == 0 ) ans += cnt[i]*cnt[i]*cnt[i];
	printf("%lld\n", ans);
}

Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a,Ma=0,Mi=10e9+1;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		Ma=max(Ma,a);
		Mi=min(Mi,a);
	}
	printf("%d",Ma-Mi);
} 

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

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

const long long MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  bool l=true,r=true;
  
  if(n/100 > 12 || n/100 == 0) l=false;
  if(n%100 > 12 || n%100 == 0) r=false;
  
  if(l & r) cout << "AMBIGUOUS" << endl;
  else if(l) cout << "MMYY" << endl;
  else if(r) cout << "YYMM" << endl;
  else cout << "NA" << endl;
}


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

int main() {
  int N, l , r , S;
  cin >> N;
  S = 0;

 for(int i = 0; i < N; i++){
   cin >> l >> r;
   S =S + r - l + 1;

 }
  cout << S << endl;
   
}

Measured memory_bytes: 3596
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    long long a, b, c, k;
    while (cin >> a >> b >> c >> k) {
        if (k < 10) {
            for (int i = 0; i < k; ++i) {
                long long d, e, f;
                d = b + c;
                e = a + c;
                f = a + b;
                a = d;
                b = e;
                c = f;
            }
        } else {
            for (int i = 0; i < (k % 2 ? 11 : 10); ++i) {
                long long d, e, f;
                d = b + c;
                e = a + c;
                f = a + b;
                a = d;
                b = e;
                c = f;
            }
        }
        cout << a - b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

const double kEps = 1e-10;

int dcmp(double x) {
  if (fabs(x) < kEps) return 0;
  return x < 0 ? -1 : 1;
}

struct Vector {
  double x, y;
  Vector() {}
  Vector(double x, double y): x(x), y(y) {}
  // Vector(const Point & p1, const Point & p2): x(p2.x - p1.x), y(p2.y - p1.y) {}
  Vector(const Vector & v);

  double Norm() const { return hypot(x, y); }
  double NormSquared() const { return x * x + y * y; }
  Vector Normalize() const {
    return *this / this->Norm();
  }
  Vector operator-() const {
    return Vector(-x, -y);
  }
  Vector operator+(const Vector & rhs) const {
    return Vector(x + rhs.x, y + rhs.y);
  }
  Vector operator-(const Vector & rhs) const {
    return *this + (-rhs);
  }
  Vector operator*(const double rhs) const {
    return Vector(rhs * x, rhs * y);
  }
  Vector operator/(const double rhs) const {
    return *this * (1.0 / rhs);
  }
  double Dot(const Vector & rhs) const {
    return x * rhs.x + y * rhs.y;
  }
  double Cross(const Vector & rhs) const {
    return x * rhs.y - y * rhs.x;
  }
  bool operator==(const Vector & rhs) const {
    return dcmp(x - rhs.x) == 0 && dcmp(y - rhs.y) == 0;
  }
  bool operator<(const Vector & rhs) const {
    return dcmp(x - rhs.x) < 0 || (dcmp(x - rhs.x) == 0 && dcmp(y - rhs.y) < 0);
  }
};

struct Point {
  Point() {}
  Point(double x, double y): x(x), y(y) {}
  Point(const Point & p);

  double x, y;

  Point operator-() {
    return Point(-x, -y);
  }
  Point operator+(const Vector & rhs) const {
    return Point(x + rhs.x, y + rhs.y);
  }
  Point operator-(const Vector & rhs) const {
    return *this + (-rhs);
  }
  bool operator==(const Point & rhs) const {
    return dcmp(x - rhs.x) == 0 && dcmp(y - rhs.y) == 0;
  }
  bool operator<(const Point & rhs) const {
    return dcmp(x - rhs.x) < 0 || (dcmp(x - rhs.x) == 0 && dcmp(y - rhs.y) < 0);
  }
};

struct Line {
  Line() {}
  Line(const Point & p1, const Point & p2): p1(p1), p2(p2) {}
  Line(double x1, double y1, double x2, double y2): p1(x1, y1), p2(x2, y2) {}
  Line(const Line & l);

  Point p1, p2;
};

ostream & operator<<(ostream & os, const Point & p) {
  os << p.x << " " << p.y;
  return os;
}

ostream & operator<<(ostream & os, const Vector & v) {
  os << v.x << " " << v.y;
  return os;
}

Point Projection(const Point & p, const Line & l) {
  Vector v0(p.x - l.p1.x, p.y - l.p1.y);
  Vector v(l.p2.x - l.p1.x, l.p2.y - l.p1.y);
  auto perpendicular = v * (v.Dot(v0) / v.NormSquared()) - v0;
  return p + perpendicular;
}

int main(int argc, char const *argv[]) {
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  Line l(x1, y1, x2, y2);

  int q;
  cin >> q;
  for (unsigned i = 0; i < q; ++i) {
    double x0, y0;
    cin >> x0 >> y0;
    Point p(x0, y0);
    cout << fixed << setprecision(10) << Projection(p, l) << endl;
  }
  return 0;
}

Measured memory_bytes: 3284
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>
#include<cassert>

using namespace std;
#define MAX 20

class State{
public:
  char T[MAX][MAX], w, h, cost;
  State(){}
  State(int w, int h):w(w), h(h){ cost = 0;}

  bool operator < ( const State &s ) const{
    for ( int i = 0; i < h; i++ ){
      for ( int j = 0; j < w; j++ ){
	if ( T[i][j] == s.T[i][j] ) continue;
	return T[i][j] < s.T[i][j];
      }
    }
    return false;
  }

  bool solved(){
    char t = T[0][0];
    for ( int i = 0; i < h; i++ ){
      for ( int j = 0; j < w; j++ ){
	if ( T[i][j] != t ) return false;
      }
    }
    return true;
  }
};

void dfs( State &u, int y, int x, char s, char t ){
  u.T[y][x] = t;
  static const int dy[4] = {0, -1, 0, 1};
  static const int dx[4] = {1, 0, -1, 0};
  int ny, nx;
  for ( int r = 0; r < 4; r++ ){
    ny = y + dy[r];
    nx = x + dx[r];
    if ( ny < 0 || nx < 0 || u.h <= ny || u.w <= nx){
	continue;
      }
      if ( u.T[ny][nx] == s ) dfs(u, ny, nx, s, t);
  }
}

int bfs(State init){
  queue<State> Q;
  map<State, bool> V;
  
  init.cost = 0;
  V[init] = true;
  Q.push(init);

  string tb = "RGB";

  State u, v;
  while(!Q.empty() ){
    u = Q.front(); Q.pop();
    if ( u.solved() ) return u.cost;

    for ( int r = 0; r < 3; r++ ){
      v = u;
      if ( v.T[0][0] == tb[r] ) continue;
      dfs(v, 0, 0, v.T[0][0], tb[r] );
      if ( !V[v] ){
	v.cost = u.cost + 1;
	V[v] = true;
	Q.push(v);
      }
    }
  }

  return -1;
}

main(){
  int w, h;

  while(1){
    cin >> w >> h;
    if ( w== 0 && h == 0 ) break;
        assert( 2 <= w && w <= 10 );
        assert( 2 <= h && h <= 10 );
    State init = State(w, h);
    for ( int i = 0; i < h; i++ ){
      for ( int j = 0; j < w; j++ ){
	cin >> init.T[i][j];
      }
    }
    cout << bfs(init) << endl;
  }
}

Measured memory_bytes: 3844
#include <stdio.h>
int main () {
	int data[5],i,ave;
	int sum = 0;
	for (i = 0; i < 5; i++) {
		scanf("%d",&data[i]);
	}
	for (i = 0; i < 5; i++) {
		if(data[i] < 40) {
			data[i] = 40;
		}
		sum = sum + data[i];
	}
	ave = sum / 5;
	printf("%d\n",ave);
}

Measured memory_bytes: 1028
def main():

    a, b  = map(int, input().split())

    if a > b:
        a, b = b, a
    def gcd(a, b):
        if a == 0:
            return b
        else:
            return gcd(b % a, a)

    g = gcd(a, b)
    return a * b // g



if __name__ == '__main__':
    print(main())

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

using namespace std;

const int N = 2e5+7;

int n, k;
int a[N], s[N];
long long res;
map<int, int> cnt;

int main()
{
    cin >> n >> k;
    ++cnt[0];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        --a[i];
        a[i] %= k;
        s[i] = (s[i-1]+a[i])%k;
        // cout << s[i] << endl;///////
        if (i-k >= 0) --cnt[s[i-k]];
        res += cnt[s[i]];
        ++cnt[s[i]];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>

int main()
{
	int a,b,c;
	scanf ("%d %d %d",&a,&b,&c);

	long long ans = 0;
	if (b >= c) ans = b + c;
	else{
		ans += b * 2;
		c -= b;
		if (c > a) ans += a + 1;
		else ans += c;
	}
	printf ("%lld\n",ans);

	return 0;
}

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

#define mx 1000
#define mod 1000007
#define ll long long

using namespace std;

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);

    int n,total=0;
    cin>>n;

    int side[n+5];

    for(int i=0;i<n;i++)
      cin>>side[i],total+=side[i];

    sort(side,side+n);
    total-=side[n-1];
    
    string ans=side[n-1]<total ? "Yes" :"No";
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    int k = min(s.size(), t.size());
    while(k > 0){
        bool check = true;
        for(int i = 1; i <= k; i++){
            if(s[s.size() - i] != t[k - i]){
                check = false;
            }
        }
        if(check){
            break;
        }
        k--;
    }
    cout << s.size() + t.size() - k << endl;



        return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var cnt = 0L
    var cntXXA = 0L
    var cntBXX = 0L
    var cntBXA = 0L
    repeat(n) {
        val s = readLine()!!
        cnt += s.split("AB").size - 1
        if (s.first() == 'B' && s.last() == 'A') {
            cntBXA++
        } else if (s.first() == 'B') {
            cntBXX++
        } else if (s.last() == 'A') {
            cntXXA++
        }
    }
    if (0 < cntBXA) {
        cnt += cntBXA - 1
        if (0 < cntXXA) {
            cnt++
            cntXXA--
        }
        if (0 < cntBXX) {
            cnt++
            cntBXX--
        }
    }
    cnt += Math.min(cntXXA, cntBXX)
    println(cnt)
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int w,h;

bool solve(){
  // input
  vector<vi> mp(h,vi(w,-1));
  REP(i,h){
    string s;
    cin>>s;
    REP(j,w){
      if(s[j]=='.')mp[i][j] = -1;
      else mp[i][j] = s[j]-'0';
    }
  }

  // identify
  int cnt = 0;
  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};
  REP(i,h)REP(j,w){
    if(mp[i][j]==-1 || mp[i][j]>9)continue;
    int befid = mp[i][j];
    int nexid = 10 + cnt++;
    queue<pii> Q;
    Q.push(make_pair(i,j));
    while(!Q.empty()){
      pii P = Q.front(); Q.pop();
      int y = P.first;
      int x = P.second;
      REP(dd,4){
        int ny = y+dy[dd];
        int nx = x+dx[dd];
        if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
        if(mp[ny][nx]!=befid)continue;
        mp[ny][nx] = nexid;
        Q.push(make_pair(ny,nx));
      }
    }
  }

  vector<vi> bumpu(cnt,vi(w));
  vi left(cnt),right(cnt);
  REP(i,h)REP(j,w){
    if(mp[i][j]==-1)continue;
    int id = mp[i][j];
    int bid = id-10;

    queue<pii> Q;
    Q.push(make_pair(i,j));
    left[bid] = w;
    right[bid] = -1;
    ++bumpu[bid][j];
    mp[i][j] = -1;
    int toid = -1;
    while(!Q.empty()){
      pii P = Q.front(); Q.pop();
      int y = P.first;
      int x = P.second;
      REP(dd,4){
        int ny = y+dy[dd];
        int nx = x+dx[dd];
        if(ny<0 || nx<0 || nx>=w)continue;
        if(ny>=h){
          // down
          left[bid] = min(left[bid],nx);
          right[bid] = max(right[bid],nx);
          continue;
        }
        if(mp[ny][nx]==-1)continue;
        if(mp[ny][nx]!=id){
          if(dd==1){
            // down
            left[bid] = min(left[bid],nx);
            right[bid] = max(right[bid],nx);
            toid = mp[ny][nx]-10;
          }
          continue;
        }
        assert(mp[ny][nx] == id);
        ++bumpu[bid][nx];
        mp[ny][nx] = -1;
        Q.push(make_pair(ny,nx));
      }
    }
    double g = 0.0;
    double cnt = 0.0;
    REP(t,w){
      g += (0.5+t)*(double)bumpu[bid][t];
      cnt += (double)bumpu[bid][t];
    }
    g /= cnt;
    if(!(left[bid]<g && g<right[bid]+1))return false;
    if(toid == -1)continue;
    REP(t,w) bumpu[toid][t] += bumpu[bid][t];
  }

  // ok
  return true;
}

int main(){
  while(true){
    cin>>w>>h;
    if(w==0 && h==0)break;
    cout<<(solve()?"STABLE":"UNSTABLE")<<endl;
  }
  return 0;
}

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

#define fr first
#define sc second

using namespace std;

const int N = 1e5 + 7;
const int inf = 1e9 + 7;

int a[N];

main()
{
    int n;

    cin >> n;

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

    sort(a + 1, a + n + 1);

    int al = a[n], ar;

    pair<double, int>cur;

    cur = {inf, inf};

    for (int i = 1; i <= n; i++)
    {
        if (abs((a[i] * 1.0) - (al / 2.0)) * 1.0 < cur.fr)
        {
            cur.fr = abs((a[i] * 1.0) - (al / 2.0)) * 1.0;
            cur.sc = i;
        }
    }

    ar = a[cur.sc];

    cout << al << " " << ar << endl;
}




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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_H = 105;
const int MAX_W = 10;

int H, W, K;
int dp[MAX_H][MAX_W];

int ww[MAX_W];

int calcW(int w) {
  if(ww[w] != -1) {
    return ww[w];
  }
  if(w <= 1) {
    return ww[w] = 1;
  } else {
    return ww[w] = (calcW(w-1) + calcW(w-2)) % MOD;
  }
}

signed main()
{
  memset(ww, -1, sizeof(ww));
  cin >> H >> W >> K;
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;

  REP(h,H) {
    REP(w,W) {
      dp[h+1][w] += (((dp[h][w] * calcW(w) ) % MOD) * calcW(W-w-1) ) % MOD;
      dp[h+1][w] %= MOD;
      //左
      if(w-1 >= 0) {
        dp[h+1][w-1] += (((dp[h][w] * calcW(w-1) ) % MOD) * calcW(W-w-1) ) % MOD;
        dp[h+1][w-1] %= MOD;
      }
      //右
      if(w+1 < W) {
        dp[h+1][w+1] += (((dp[h][w] * calcW(w) ) % MOD) * calcW(W-w-2) ) % MOD;
        dp[h+1][w+1] %= MOD;
      }
    }
  }

  cout << dp[H][K-1] << endl;

  return 0;
}

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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mp             make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));


int main()
{
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC\n";
    else
        cout<<"ABC\n";
}



Measured memory_bytes: 3624
/*  -*- coding: utf-8 -*-
 *
 * 2856.cc: Window
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

pii ps[MAX_N];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    int xi;
    scanf("%d", &xi);

    ps[i].first = w * i + ((! (i & 1)) ? xi : -xi);
    ps[i].second = ps[i].first + w;
  }
  sort(ps, ps + n);

  int sum = 0, rp = 0;
  for (int i = 0; i < n; i++) {
    int &li = ps[i].first, &ri = ps[i].second;

    if (rp < li) sum += li - rp;
    if (rp < ri) rp = ri;
  }
  if (rp < n * w) sum += n * w - rp;

  printf("%d\n", sum * h);
  return 0;
}



Measured memory_bytes: 3212
#include <iostream>
#include <math.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int N;
	long long int ans = 0;
	cin >> N;
	vector<int>L(2 * N);
	for (int i = 0; i < 2*N; i++)cin >> L[i];
	sort(L.begin(), L.end());
	for (int i = 0; i < 2*N; i+=2)
	{
		ans += L[i];
	}
	cout << ans;
}


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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; ++i) {
    cin >> d[i];
  }

  sort(d.begin(), d.end());
  d.erase(unique(d.begin(), d.end()), d.end());

  cout << d.size();
}

Measured memory_bytes: 256
let puts st = print_string st; print_string "\n";;
let puti num = print_int num; print_string "\n";;
let getSL () = Str.split (Str.regexp " ") (read_line ());;
let getLI () = List.map int_of_string (getSL ());;
let getI () = int_of_string (read_line ());;
let rep n f =
    let rec repimpl i n = if i < n then (f i; repimpl (i+1) n) else () in repimpl 0 n;;
let rep_from from until f =
    let rec repimpl i n = if i < n then (f i; repimpl (i+1) n) else () in repimpl from until;;

let len = getI ();;
let arr = 
    let arr = Array.make len "" in
    rep len (fun i -> arr.(i) <- read_line ());
    arr;;

module SetSt = Set.Make(String);;
let st = ref SetSt.empty

let solve () =
    rep len (fun i -> st := SetSt.add arr.(i) !st);
    if SetSt.cardinal !st = len then begin
        let res = ref true in
        rep (len-1) (fun i ->
            res := !res && (Str.last_chars arr.(i) 1) = (Str.first_chars arr.(i+1) 1);
            (* puts @@ arr.(i) ^ arr.(i+1) *)
        );
        puts @@ if !res then "Yes" else "No";
    end else puts "No";;

solve ();;


Measured memory_bytes: 384
#include <stdio.h>

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

    int sec = in % 60;
    int min = ((in - sec) % 3600) / 60;
    int hour = (in - sec - min * 60) / 3600;
    printf("%d:%d:%d\n", hour, min, sec);

    return 0;
}

Measured memory_bytes: 592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		String line;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line = br.readLine()) != null) {
			if (line.equals("0 0")) {
				break;
			}

			String[] arr = line.split(" ");
			int n = Integer.parseInt(arr[0]);
			int x = Integer.parseInt(arr[1]);

			int ans = 0;
			for (int i = 1; i <= n - 2; i++) {
				for (int j = i + 1; j <= n - 1; j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i + j + k == x) {
							ans++;
						}
					}
				}
			}
			
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 24640
a, b = map(int, input().split())
num_tap = 0
output = 0
if b == 1:
  print(0)
else:
  for i in range(30):
    output += 1
    if i == 0:
      num_tap += a
    else:
      num_tap += a-1
    if num_tap >= b:
      break
  print(output)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<bool> vb;

const int MAXN = 1e5;
const int INF = INT_MAX;

int num[MAXN][3], accum[MAXN][3]={0};

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

    int N; cin >> N;

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

    for(int i=0; i<3; i++){
        accum[0][i] = num[0][i];
    }

    for(int i=1; i<N; i++){
        for(int j=0; j<3; j++){
            if(j){
                accum[i][j] = max(accum[i][j], accum[i-1][j-1]+num[i][j]);
            }else{
                accum[i][j] = max(accum[i][j], accum[i-1][j+2]+num[i][j]);
            }
            if(j+1<3){
                accum[i][j] = max(accum[i][j], accum[i-1][j+1]+num[i][j]);
            }else{
                accum[i][j] = max(accum[i][j], accum[i-1][j-2]+num[i][j]);
            }
        }
    }

    cout << max(max(accum[N-1][0],accum[N-1][1]),accum[N-1][2]) << '\n';

    return 0;
}



Measured memory_bytes: 2560
#include <cstdio>
#define rg register int
#define rep(a, b, c) for(rg a=b; a<=c; ++a)

int n, l;

inline int read() {
	int x=0; char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x;
}

int main() {
	n=read(), l=read();
	int lst, nw;
	bool flg=0;
	lst=read();
	rep(i, 2, n) {
		nw=read();
		if(lst+nw>=l) {
			flg=1; lst=i-1; break;
		}
		lst=nw;
	}
	if(!flg) {
		puts("Impossible");
		return 0;
	}
	puts("Possible");
	rep(i, 1, lst-1) printf("%d\n", i);
	for(rg i=n-1; i>lst; --i) printf("%d\n", i);
	printf("%d", lst);
	return 0;
}


Measured memory_bytes: 768
N = int(input())
S = [int(input()) for _ in range(N)]
S = sorted(S)
grade = sum(S)
if grade % 10 != 0:
    print(grade)
    exit()
for s in S:
    tmp = grade - s
    if tmp % 10 != 0:
        print(tmp)
        exit()
print(0)

Measured memory_bytes: 2940
// 2019.cpp : This file contains the 'main' function. Program execution begins and ends there.
//JANUARY: {1521, 1644} -> {1614, 1644} -> {1643, 1644} ->

#include <bits/stdc++.h>
using namespace std;


#define int long long
#define all(a) a.begin(), a.end()
#define need_for_speed ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const int INF = 1e18;
int dp[26][26];
string s[26];


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

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

	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		if (i - 1 >= 0) {
			dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		}
		if (i - 2 >= 0) {
			dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}
	cout << dp[n - 1];
}




Measured memory_bytes: 1792
a = input()
b = input()
c = input()

# 文字のマッチング(?はワイルドカード)
def match(a, b):
    return a=="?" or b=="?" or a==b

ab = [True] * 100000 # Aに対して(i-50000)個左にスライドした位置にBを置けるか？
ac = [True] * 100000 # Aに対して(i-50000)個左にスライドした位置にCを置けるか？
bc = [True] * 100000 # Bに対して(i-50000)個左にスライドした位置にCを置けるか？

def check(a, b, ab):
    for i in range(len(a)):
        for j in range(len(b)):
            if not match(a[i], b[j]):
                ab[i-j+50000] = False

check(a, b, ab)
check(a, c, ac)
check(b, c, bc)

len_max = 2000
len_a = len(a)
len_b = len(b)
len_c = len(c)

ans = len_a + len_b + len_c

# i = BをAに対していくつスライドして置くか
for i in range(-2 * len_max, 2 * len_max + 1):
    # j = CをAに対していくつスライドして置くか
    for j in range(-2 * len_max, 2 * len_max + 1):
        if ab[i+50000] and ac[j+50000] and bc[j-i+50000]:
            ans = min(ans, max(len_a, len_b+i, len_c+j) - min(0, i, j))

print(ans)


Measured memory_bytes: 53192
#include <iostream>

int main(){
   int A, B;
   std::cin >> A >> B;

   for(int i=1; i<=1000; ++i){
      int tax_A = i * 0.08;
      int tax_B = i * 0.10;
      if(tax_A == A && tax_B == B) {
	 std::cout << i << std::endl;
	 return 0;
      }
   }
   std::cout << -1 << std::endl;
   return 0;
}


Measured memory_bytes: 256
n=int(input())
alist=list(map(int,input().split()))
MOD=10**9+7
nijo=0
for i in range(n):
    nijo+=(alist[i]**2)
gokei=sum(alist)

ans=(gokei**2-nijo)
ans=ans//2
ans=ans%MOD
print(ans)

Measured memory_bytes: 31608
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair
    {
        public long x, y;
        public Pair(long x, long y) { this.x = x; this.y = y; }
        public long Max() { return Math.Max(x, y); }
        public long Min() { return Math.Min(x, y); }
    }
    public static void Solve()
    {
        string S = NextString();
        S += "oooooooooooooooooooo";
        Console.WriteLine((S.Take(15).Count(v => v == 'o') > 7) ? "YES" : "NO");
    }
    private static int LowerBound(long[] list, long n)
    {
        int a = 0, b = list.Count();
        if (list[b - 1] <= n) return b - 1;
        else if (list[a] > n) return -1;
        while (b - a != 1)
        {
            int x = (a + b) / 2;
            if (list[x] <= n) a = x;
            else b = x;
        }
        return a;
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n, a, b;
int fcnt, scnt, tcnt;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> a >> b;
	vector<int> p(n);
	for (int i = 0; i < n; ++i)
	{
		int x;
		cin >> x;
		if (x <= a)
			++fcnt;
		if (x > a && x <= b)
			++scnt;
		if (x > b)
			++tcnt;
	}
	cout << min(fcnt, min(scnt, tcnt)) << endl;
	return 0;
}


Measured memory_bytes: 256
//                               //
    // author : samars_diary //
    // 16-09-2020 │ 18:03:57 //
//                               //

#include <iostream>
using namespace std;

void solve(){
    long long int a;
    cin>>a;
    if(a==1){
        cout<<0;
    }else{
        cout<<1;
    }
}

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

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int t = 1;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3660
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int A[10];
int dp[10][10];
int main()
{
  string str;
  while(cin>>str){
    for(int i = 0;i <str.size();i++){
      dp[9][i] =str[i]-'0';
    }
    for(int i = 8;i >=0;i--){
      for(int j = 0;j <=i;j++){
	dp[i][j] =(dp[i+1][j]+dp[i+1][j+1])%10;
      }
    }
    cout <<dp[0][0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180