akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}


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

void solve() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N+1);
    vector<int> w(N+1);
    for (int i = 0; i < N; ++i) {
        cin >> v[i+1] >> w[i+1];
    }
    int dp[N+1][W+1];
    for (int i = 0; i <= W; ++i) dp[0][i] = 0;
    for (int i = 1; i <= N; ++i) {
        int vi = v[i];
        int wi = w[i];
        for (int j = 0; j <= W; ++j) {
            if (j == 0) dp[i][j] = 0;
            if (wi <= j) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wi] + vi);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[N][W] << endl;
}

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



Measured memory_bytes: 7028
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main(void) {
	int s, w;
	cin >> s >> w;

	if (w >= s)
		cout << "unsafe" << endl;
	else
		cout << "safe" << endl;


	
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,H[101010];

ll i, j, k,ans;
int main(){
    scanf("%lld",&N);
    j = -1;
    k = 1e15;
    fornum(i,0,N){
        ll h = 0;
        scanf("%lld", &h);
        if(k<h){
            j = 0;
        }else{
            j++;
        }
        k = h;
        if(j>ans)
            ans = j;
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
    int x=0,f=1;char ch =getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int K;
main(){
    K=read();
    printf("%lld\n",(K+1>>1)*(K>>1));
    return 0;
}

Measured memory_bytes: 256
while True:
  n, x = map(int, input().split())
  if n==0 and x==0:
    break
  ans = 0
  for i in range(1, n-1):
      for j in range(i+1, n):
          for k in range(j+1, n+1):
              if i+j+k==x:
                  ans+=1
  print(ans)


Measured memory_bytes: 5596
#include <iostream>
#include <cmath>
#include <cctype>
#include <vector>
using namespace std;

#define sq(c) ((c)*(c))

vector<double> col8[8];

vector<double> col16to10( string str ) {
  string s;
  
  str = str.substr(1, 6);
  vector<double> col(3);
  for(int i=0; i<3; i++) {
    s = str.substr(i*2, 2);
    if(isalpha(s[1]))	col[i] = s[1]-'a' + 10;
    else col[i] = s[1]-'0';
    
    if(isalpha(s[0]))	col[i] += ( s[0]-'a' + 10 ) * 16;
    else col[i] += ( s[0]-'0' ) * 16;
  }

  return col;
}

double calc( vector<double> col, int i ) {
  return sqrt( sq(col[0]-col8[i][0]) + sq(col[1]-col8[i][1]) + sq(col[2]-col8[i][2]) );
}

int main() {
  string str;
  
  col8[0] = col16to10("#000000");
  col8[1] = col16to10("#0000ff");
  col8[2] = col16to10("#00ff00");
  col8[3] = col16to10("#00ffff");
  col8[4] = col16to10("#ff0000");
  col8[5] = col16to10("#ff00ff");
  col8[6] = col16to10("#ffff00");
  col8[7] = col16to10("#ffffff");
  
  while(getline(cin, str)) {
    if( str == "0" ) break;
    
    vector<double> col(3);
    col = col16to10( str );
    
    double mn = 1<<20;
    int num = 0;
    for(int i=0; i<8; i++) {
      double temp = mn;
      mn = min( mn, calc(col, i) );
      if( mn < temp ) num = i;
    }
    
    switch( num ) {
    case 0: cout << "black"; break;
    case 1: cout << "blue";  break;
    case 2: cout << "lime";  break;
    case 3: cout << "aqua";  break;
    case 4: cout << "red";   break;
    case 5: cout << "fuchsia"; break;
    case 6: cout << "yellow"; break;
    case 7: cout << "white"; break;
    }
    cout << endl;
  }
  
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    double X[1000], Y[1000];
    for(int i=0; i<N; i++) cin >> X[i] >> Y[i];

    double ans = 0;
    for(int i=0; i<N; i++) for(int j=0; j<i; j++){
        double x = X[i]-X[j], y = Y[i]-Y[j];
        double res = sqrt(x*x + y*y);
        ans += res*2/N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


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

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

ll dfs(const vvi &e, int n, int x, int p) {
    ll r = 0;
    for (int y : e.at(x)) {
        if (y != p) {
            r += dfs(e, n, y, x);

            if (y < x) {
                r += 1ll * (x - y) * (y + 1);
            } else {
                r += 1ll * (y - x) * (n - y);
            }
        }
    }

    return r;
}

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

    int n;
    cin >> n;
    vvi e(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        e.at(u).push_back(v);
        e.at(v).push_back(u);
    }

    cout << dfs(e, n, 0, -1) + n << endl;

    return 0;
}


Measured memory_bytes: 29708
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;
int N,M,v[3000],to[3000][2];
bool done[3000][3000];
vector<int> rG[3000][2];
int main(){
	cin>>N>>M;
	rep(i,N) cin>>v[i]>>to[i][0]>>to[i][1];
	rep(i,N) rG[to[i][0]][0].pb(i),rG[to[i][1]][1].pb(i);
	queue<P> que;
	rep(i,N) rep(j,N) if(v[i]!=v[j]) que.push(P(i,j)),done[i][j]=1;
	while(!que.empty()){
		P p=que.front();que.pop();
		int u=p.fs,v=p.sc;
		rep(k,2){
			for(int a:rG[u][k]) for(int b:rG[v][k]){
				if(!done[a][b]){
					que.push(P(a,b));
					done[a][b]=1;
				}
			}
		}
	}
	int c[3000]={};
	rep(i,N){
		rep(j,N) if(!done[i][j]) c[i]++;
	}
	rep(i,M){
		int a;
		cin>>a;
		cout<<c[a]<<endl;
	}
}

Measured memory_bytes: 48736
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
  ll x, ans;
  cin >> x;

  ans =	ceil((sqrt(1 + 8 * x) - 1) / 2);

  cout << (ll)ans << endl;

  return 0;
}

Measured memory_bytes: 256
N=int(input())
p=list(map(int,input().split()))
cnt = 0
ans = 0
for i in range(1,len(p)+1):
    if i == p[i-1]:
        cnt += 1
    elif cnt == 1:
        ans += 1
        cnt = 0
    if cnt == 2:
        ans += 1
        cnt = 0
if cnt == 1:
    ans += 1
print(ans)

Measured memory_bytes: 20460
#include <climits>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int answer = INT_MAX;
  for (int i = 1; i < N; ++i) {
    int A = i;
    int B = N - A;
    int sum = 0;
    while (A) {
      sum += A % 10;
      A /= 10;
    }
    while (B) {
      sum += B % 10;
      B /= 10;
    }
    answer = min(answer, sum);
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<char> S(4);
  for (int i=0;i<4;i++){
    cin >> S.at(i);
  }
  int s=1;
  for (int i=0;i<3;i++){
    if (S.at(i)==S.at(i+1)){
      s*=0;
    }
    else{
      s*=1;
    }
  }
  if (s==1){
    cout << "Good" << endl;
  }
  else{
    cout << "Bad" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	s = '.' + s;
	int ans = n;
	for(int i = 2; i <= n; i++){
		if(s[i] != s[i-1]){
			int x = max(i-1,n-i+1);
			ans = min(ans,x);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
Flag = False
base = 0
height = 0
ans = 0
for i in range(N - 1):
    if Flag:
        Flag = False
        continue
    if A[i] == A[i + 1] and base == 0:
        base = A[i]
        Flag = True
    elif A[i] == A[i + 1]:
        height = A[i]
        Flag = True
    area = base * height
    if area > ans:
        ans = area
print(ans)

Measured memory_bytes: 14636
fn main(){
  loop {
    let nm: Vec<usize> = read_vec();
    let n = nm[0];
    let m = nm[1];

    if n == 0 && m == 0 { break; }

    let mut st: Vec<char> = vec!['#';n];
    
    for _ in 0 .. m {
      let a: String = read();
      
      if a == "A".to_string() { countrya(n, &mut st); }
      else if a == "B".to_string() { countryb(n, &mut st); }
      else if a == "C".to_string() { countryc(n, &mut st); }
      else { countryd(n, &mut st); }
    }
      
    println! ("{}", st.iter().collect::<String>());
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn countrya(n: usize, st: &mut Vec<char>){
  for i in 0 .. n {
    if st[i] == '#' {
      st[i] = 'A';
      break;
    }
  }
}

fn countryb(n: usize, st: &mut Vec<char>){
  if n == 1 { st[0] = 'B'; }
  else {
    let mut f: bool = true;
  
    for i in (0 .. n).rev() {
      if i == n - 1 {
        if st[i] == '#' && st[i-1] != 'A' {st[i] = 'B'; f = false; break;}
      }
      else if i == 0 {
        if st[i] == '#' && st[i+1] != 'A' {st[i] = 'B'; f = false; break;}
      }
      else {
        if st[i] == '#' && st[i+1] != 'A' && st[i-1] != 'A' {st[i] = 'B'; f = false; break;}
      }
    }
    if f {
      for i in 0 .. n {
        if st[i] == '#' {
          st[i] = 'B';
          break;
        }
      }
    }
  }
}

fn countryc(n: usize, st: &mut Vec<char>){
  if n == 1 { st[0] = 'C'; }
  else {
    let mut f: bool = true;
    
    for i in 0 .. n {
      if st[i] != '#' {
        if i < n - 1 && st[i+1] == '#' {st[i+1] = 'C'; f = false; break;}
        if i > 0 && st[i-1] == '#' {st[i-1] = 'C'; f = false; break;}
      }
    }
    if f {
      st[n/2] = 'C';
    }
  }
}

fn countryd(n: usize, st: &mut Vec<char>){
  let mut d: Vec<usize> = vec![1000;n];

  for i in 0 .. n {
    if st[i] != '#' {
      d[i] = 0;
      let mut j: usize = 1;
      while i >= j && st[i-j] == '#' && d[i-j] > j {
        d[i-j] = j;
        j += 1;
      }
      j = 1;
      while i+j < n && st[i+j] == '#' {
        d[i+j] = j;
        j += 1;
      }
    }
  }
  
  let mut md: usize = 0;
  let mut mi: usize = 0;

  for i in 0 .. n {
    if d[i] > md {
      md = d[i];
      mi = i;
    }
  }

  st[mi] = 'D';
}



Measured memory_bytes: 5040
import * as fs from "fs";

const input = fs
  .readFileSync("/dev/stdin", "utf8")
  .split("")
  .map(Number);

let sum = input.reduce((a,c) => {
	return a + c;
});

let ans = sum % 9 == 0 ? "Yes" : "No"; 

console.log(ans);

Measured memory_bytes: 35256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

/*std::mt19937 mt{ std::random_device{}() };

std::uniform_int_distribution<int> dist(1, 6);
dist(mt);

while(1){
	val;
	cout << val << endl;
	sol1 = solver1();
	sol2 = solver2();
	if(sol1==sol2){
	cout << "OK" << endl;
	}else{
	cout << "NG" << endl;
	cout << sol1 << endl;
	cout << sol2 << endl;
	break;
	}
}
*/

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);
  string s,t;
  cin >> s >> t;
  int ans = t.size();
  rep(i,s.size()-t.size()+1){
	  int a = t.size();
	  rep(j,t.size()){
		  if(s[i+j] == t[j]){
			  a--;
		  }
	  }
	  ans = min(a,ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>

int main()
{
   int a,b;
   scanf("%d%d",&a,&b);
   if(a+b==15){
    printf("+");

   }
   else if(a*b==15){
    printf("*");

   }
   else{
    printf("x");
   }


    return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    char c;
    in(c);
    char d = c + 1;
    out(d);
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    table = [
        [1 for _ in range(N)] for _ in range(N)
    ]
    if N%2 == 0:
        for i in range(N//2):
            table[i][N-i-1] = table[N-i-1][i] = 0
    else:
        for i in range(N//2):
            table[i][N-i-2] = table[N-i-2][i] = 0
    size = 0
    answer = []
    for i in range(N):
        for j in range(i+1, N):
            if table[i][j]:
                answer.append((i+1, j+1))
                size += 1
    print(size)
    for a in answer:
        print(*a)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 68900
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

int main() {
	ll k, x; cin >> k >> x;

	cout << ((k * 500 >= x) ? "Yes" : "No") << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std; 
typedef long long ll;

int main(){
    ll a,b;
    char op;
    cin >> a >> op >> b;
    if(op == '+'){
	cout << a + b << endl;
    }else{
	cout << a - b << endl;
    }
}


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

int main() {
  string s;
  cin >> s;
  bool cond = false;
  if(s[0] == '7') cond = true; 
  if (s[1] == '7') cond = true;
  if (s[2] == '7') cond = true;
  cout << (cond ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
	int a,b,d,r;
	double f;
	
	cin>>a>>b;
	f=static_cast<double>(a)/static_cast<double>(b);
	cout<<a/b<<" "<<a%b<<" "<<fixed<<f<<"\n";
}

Measured memory_bytes: 1244
import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();;
        int N = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        int notcon = 101;
        int notcon2 = 101;
        for(int i = 0;i < N;i++){
            list.add(sc.nextInt());
        }
        int Forbidden = X;
        for(int i = 0;i < 100;i++){
            if(!list.contains(Forbidden)){
                //int notcon = X;
                notcon = Forbidden;
                //System.out.println(notcon + "j");
                //System.out.println(notcon);
                break;
            }
            Forbidden++;
        }
        int Forbidden2 = X - 1;
        for(int i = 0;i < 100;i++){
            if(!list.contains(Forbidden2)){
                notcon2 = Forbidden2;
                //System.out.println(notcon2 + "g");
                break;
            }
            Forbidden2--;
        }
        if(list == null || list.size() == 0){
            System.out.println(X);
        }else if(Math.abs(notcon - X) < Math.abs(notcon2 - X)){
            System.out.println(notcon);
        }else if(Math.abs(notcon - X) > Math.abs(notcon2 - X)){
            System.out.println(notcon2);
        }else if(notcon < notcon2){
            System.out.println(notcon);
        }else if(notcon2 < notcon){
            System.out.println(notcon2);
        }
    }
}


Measured memory_bytes: 36124
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
long long n,m,d,k;
double ans,z;
int main(){
	cin>>n>>m>>d;
	ans=2*(n-d)*(m-1);
	z=(n*n);
	z=1/z;
	ans*=z;
	if(d==0) {
/*		z=n;
		z=1/z;
		ans=z*(m-1);*/
		ans/=2;
	}
	printf("%.10lf",ans);
	return 0;
}

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

int main()
{
    char a[3][3];
    int i, j;

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

    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
        {
            if(i == j)
            {
                cout<<a[i][j];
            }
        }
    }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define ll long long
using namespace std;
const int N=300000;
pii a[N];
int n,nd,b[N],ls[N],rs[N];
map<int,int> mp[N];
void dfs(int l,int r,int v){
	if (mp[l].find(r)==mp[l].end()){
		mp[l][r]=++nd;
		a[nd]=pii(l,r);
	}
	if (v>=n) return;
	dfs(l,l+r,v+1);
	dfs(l+r,r,v+1);
	ls[mp[l][r]]=mp[l][l+r];
	rs[mp[l][r]]=mp[l+r][r];
}
ll f[20][20][200000];
ll F(int l,int r,int S){
	if (l+1==r) return 0;
	if (f[l][r][S]<(1ll<<59)) return f[l][r][S];
	For(m,l+1,r-1) f[l][r][S]=min(f[l][r][S],F(l,m,ls[S])+F(m,r,rs[S])+1ll*a[ls[S]].se*b[m]);
	return f[l][r][S];
}
int main(){
	scanf("%d",&n);
	dfs(1,1,2);
	For(i,1,n) scanf("%d",&b[i]);
	memset(f,30,sizeof(f));
	printf("%lld ",F(1,n,mp[1][1])+b[1]+b[n]);
}

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

using namespace std;


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

	int a_index = 0;
	int z_index = 0;
	string a2z = "";
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'A') {
			a_index = i;
			break;
		}
	}
	for (int i = str.size() - 1; i > 0; i--) {
		if (str[i] == 'Z') {
			z_index = i;
			break;
		}
	}

	cout << z_index - a_index + 1 << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int dp[11][11];

struct S {
	int a;
	int b;
	int c;
	int d;
};

int solve(vector<int>& as, vector<S> ss, int m, int k,int i) {
	if (i == as.size()) {
		int ans = 0;
		FOR_LT(l, 0, ss.size()) {
			S& s = ss[l];
			if (as[s.b - 1] - as[s.a - 1] == s.c) ans += s.d;
		}
		return ans;
	}

	int ans = 0;
	FOR_LE(n, k, m) {
		as[i] = n;
		ans = max(ans, solve(as, ss, m, n, i + 1));
	}

	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, m, q; cin >> n >> m >> q;

	vector<S> ss(q); for (auto& s : ss) {
		cin >> s.a >> s.b >> s.c >> s.d;
	}

	vector<int> as(n);
	cout << solve(as, ss, m, 1, 0) << endl;
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t a, b, x;
  cin >> a >> b >> x;
  
  int64_t res;
  if(a != 0)
  	res = b/x - (a - 1LL)/x;
  else
    res = b/x + 1;
  
  cout << res << endl;
}

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

using namespace std;

const int M = 1e9+7;
string l;
long long dp[110000][2];

int main() {
  cin >> l;
  int len = l.length();
  
  dp[0][0] = 1;
  for (int i = 0; i < len; i++) {
    if (l[i] == '0') {
      dp[i+1][0] += dp[i][0];
    } else {
      dp[i+1][0] += dp[i][0] * 2;
      dp[i+1][1] += dp[i][0];
    }
    dp[i+1][1] += dp[i][1] * 3;
    dp[i+1][0] %= M;
    dp[i+1][1] %= M;
  }
  
  cout << (dp[len][0] + dp[len][1]) % M << endl;
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cinttypes>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const int INF = 1e9;
const double EPS = 1e-9;

typedef pair<int, int> P;
inline P operator+(const P& p1, const P& p2) {
  return P(p1.first + p2.first, p1.second + p2.second);
}

int main(){
  int N, M;
  cin >> N >> M;
  int A = 1;
  for (int i = 0; i < M; i++) {
    A *= 2;
  }

  int ans = ((N - M) * 100 + 1900 * M) * A;
  cout << ans << endl;

  return 0;
}

/*
/*/

Measured memory_bytes: 256
<?php
function sumEle($arr)
{
    $sum=0;
    for($i=0;$i<sizeof($arr);$i++)
        $sum+=$arr[$i];
    return $sum;
}

fscanf(STDIN,"%d",$n);
$d = explode(" ",rtrim(fgets(STDIN)));
fscanf(STDIN,"%d",$m);
$t = explode(" ",rtrim(fgets(STDIN)));
sort($d);
sort($t);
$dkey=0;
$tkey=0;

while($dkey<$n&&$tkey<$m)
{
    if($t[$tkey]==$d[$dkey])
        $tkey++;
    elseif($t[$tkey]<$d[$dkey])
        $dkey=$n-1;
    $dkey++;
}

if($tkey==$m)
    echo "YES";
else
    echo "NO";

Measured memory_bytes: 77524
(defvar *n* (read))
(defvar *m* (read))
(defvar *x* (read))
(defvar *y* (read))

(defun set-lst (n)
  (let ((lst (list nil)))
    (dotimes (x n)
        (push (read) lst))
    (cdr (reverse lst))))

(defvar *lst-x* (sort (set-lst *n*) #'>))
(defvar *lst-y* (sort (set-lst *m*) #'<))

(defun calc (x y z)
  (cond ((and (< x z) (>= y z) (< *x* z) (>= *y* z))
         t)
        ((> z *y*)
         nil)
        (t (calc x y (1+ z)))))

(defun main ()
  (if (calc (nth 0 *lst-x*) (nth 0 *lst-y*) (1+ *x*))
      (princ "No War")
      (princ "War")))

(main)

Measured memory_bytes: 12648
x,k,d=input().split()
k=int(k)
x=int(x)
d=int(d)
x=int(abs(x))
if((k*d)<=x):
    print(x-(k*d))
else:
    k-=int(x/d)
    x%=d
    if(k%2):
        print(d-x)
    else:
        print(x)

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

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    vector<pair<ll, ll>> str;
    REP(i, h){
        cin >> s.at(i);
        REP(j, w){
            if(s.at(i).at(j) == '#'){
                str.emplace_back(i, j);
            }
        }
    }

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

    vector<vector<ll>> ans(h, vector<ll>(w, 0));

    ll xmin = 0;
    REP(i, str.size()){
        ll x = str.at(i).first;
        ll y = str.at(i).second;

        if(i > 0 && str.at(i - 1).first != x){
            xmin = str.at(i - 1).first + 1;
        }

        ll ymin = 0;
        if(i > 0 && str.at(i - 1).first == x){
            ymin = y;
        }
        ll ymax = w - 1;
        if(i + 1 < str.size() && str.at(i + 1).first == x){
            ymax = str.at(i + 1).second - 1;
        }

        for(ll u = xmin; u <= x; ++u){
            for(ll v = ymin; v <= ymax; ++v){
                ans.at(u).at(v) = i + 1;
            }
        }
    }

    for(ll j = 0; j < w; ++j){
        for(ll i = str.back().first; i + 1 < h; ++i){
            ans.at(i + 1).at(j) = ans.at(i).at(j);
        }
    }

    REP(i, h){
        REP(j, w){
            cout << ans.at(i).at(j);
            if(j + 1 < w){
                cout << ' ';
            }
        }
        cout << endl;
    }

    // Failed to predict input format
    return 0;
}


Measured memory_bytes: 3076
from collections import deque

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

while True:
	a = list(a)
	a.sort()
	a = deque(a)
	while True:
		A = a.popleft()
		if A != 0:
			a.appendleft(A)
			break
	for i in range(1,len(a)):
		a[i] %= a[0]
	if sum(a) - a[0] == 0:
		print(a[0])
		break


Measured memory_bytes: 14636
#include<iostream>
#include<vector>

using namespace std;

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

bool valid(vector<int> v) {
  rep (i, v.size() - 1) {
    if (v[i + 1] - v[i] != v[1] - v[0]) return false;
  }
  return true;
}

int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;
    vector<int> v;
    rep (i, n + 1) {
      int a;
      cin >> a;
      v.push_back(a);
    }
    rep (i, n + 1) {
      vector<int> vv;
      rep (j, n + 1) if (i != j) vv.push_back(v[j]);
      if (valid(vv)) {
	cout << v[i] << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1220
n = gets.to_i
n.times{
  a = gets.split.map(&:to_i)
  b = 0
  c = 0
  flag = true
  a.each{|i|
    if b > i && c > i
      flag = false
      break
    elsif b > i
      c = i
    else
      b = i
    end
  }
  if flag
    puts "YES"
  else
    puts "NO"
  end
}

Measured memory_bytes: 8552
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
 
const long INF = (1l << 30);
const long LINF = (1l << 60);
 
std::map<long, long> mp;
 
long n, m;
long h[1505], w[1505];
 
int main(){
    long count = 0;
    while(1){
		mp.clear();
        scanf("%ld %ld", &n, &m);
        if(n == 0){
            return 0;
        }
        count++;
        for(int i = 1; i <= n; i++){
            long a;
            scanf("%ld", &a);
            h[i] = h[i-1] + a;
        }
        for(int i = 1; i <= m; i++){
            long a;
            scanf("%ld", &a);
            w[i] = w[i-1] + a;
        }
        for(int i = 0; i <= n; i++){
            for(int j = i+1; j <= n; j++){
				mp[h[j] - h[i]]++;
            }
        }
        long ans = 0;
        for(int i = 0; i <= m; i++){
            for(int j = i+1; j <= m; j++){
                ans += mp[w[j] - w[i]];
            }
        }
        printf("%ld\n", ans);
    }
    //printf("  %ld\n", count);
    return 0;
}



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

namespace ABC124c
{
    class Program
    {
        static void Main(string[] args)
        {
            List<char> s = new List<char>(Console.ReadLine());

            int count = 0;

            for(int i = 0; i < s.Count-1; i++)
            {
                if(s[i] == s[i + 1])
                {
                    count++;
                    if(s[i+1] == '0')
                    {
                        s[i + 1] = '1';

                    }
                    else
                    {
                        s[i + 1] = '0';
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11872
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,i;
cin>>n;
lli a[n],l;
cin>>l;
for(i=0;i<n;i++){
    cin>>a[i];
    
}
int val=0;
int nonbreak=0;
   for(i=0;i<n-1;i++){
       if((a[i]+a[i+1])>=l){
           val=1;
           nonbreak=i+1;
           break;
           
           
       }
   }
   if(val==0) {cout<<"Impossible\n";}
   else{
       cout<<"Possible\n";
       for(i=1;i<nonbreak;i++){
           cout<<i<<"\n";
       }
       for(i=n-1;i>=nonbreak;i--){cout<<i<<"\n";}
       
   }
   
   
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <cstring>
#define MAX_N 1000 + 16
 
using namespace std;
 
int N, H, W;
int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];
int fld[2 * MAX_N][2 * MAX_N], // ??????????????¨?????£??¨??????(i, j)??????????????????????????????
dx[4] = { 1, -1, 0, 0 }, dy[4] = { 0, 0, 1, -1 };
 
// ????????????????°?????????????????????????????¬¬????§?????????????????????±???????§???????
int compress(int *x1, int *x2, int w)
{
	vector<int>xs;
 
	for (int i = 0; i < N; ++i)
	{
		int tx1 = x1[i], tx2 = x2[i];
		if (1 <= tx1 && tx1 < w) xs.push_back(tx1);
		if (1 <= tx2 && tx2 < w) xs.push_back(tx2);
	}
	xs.push_back(0);
	xs.push_back(w);
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	for (int i = 0; i < N; ++i)
	{
		x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
		x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
	}
	return xs.size() - 1;
}
 
int bfs()
{
	int ans = 0;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (fld[i][j]) continue;
			++ans;
			queue<pair<int, int> >que;
			que.push(make_pair(j, i));
			while (!que.empty())
			{
				int nx = que.front().first, ny = que.front().second;
				que.pop();
 
				for (int i = 0; i < 4; ++i)
				{
					int tx = nx + dx[i], ty = ny + dy[i];
					if (tx < 0 || W < tx || ty < 0 || H< ty || fld[ty][tx] > 0) continue;
					que.push(make_pair(tx, ty));
					fld[ty][tx] = 1;
				}
			}
		}
	}
	return ans;
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	while (cin >> W >> H, W | H)
	{
		cin >> N;
		for (int i = 0; i < N; ++i)
		{
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		}
 
		memset(fld, 0, sizeof(fld));
 
		W = compress(X1, X2, W);
		H = compress(Y1, Y2, H);
 
		// imos-???
		for (int i = 0; i < N; i++)
		{
			fld[Y1[i]][X1[i]]++;
			fld[Y1[i]][X2[i]]--;
			fld[Y2[i]][X1[i]]--;
			fld[Y2[i]][X2[i]]++;
		}
		// ?¨?????´??§?
		for (int i = 0; i < H; i++)
		{
			for (int j = 1; j < W; j++)
			{
				fld[i][j] += fld[i][j - 1];
			}
		}
		// ???????´??§?
		for (int i = 1; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				fld[i][j] += fld[i - 1][j];
			}
		}// ?´??§??????????fld??????0??¨?????¨????????????
		cout << bfs() << endl;
	}
	return 0;
}
///////////////////////////End Sub//////////////////////////////////

Measured memory_bytes: 18900
using System;
using System.Collections.Generic;
using System.Linq;

namespace Test01
{
    class Program
    {
        
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            bool nice = true;
            for(int i = 0; i < S.Length; i++)
            {
                if((i + 1) % 2 == 0)
                {
                    if (S[i] == 'R') nice = false;
                }
                else
                {
                    if (S[i] == 'L') nice = false;
                }
            }

            if (nice) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N, M, X;

    cin >> N >> M >> X;

    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    REP(i, N){
       cin >> C[i];

       REP(j, M){
           cin >> A[i][j];
       }
    }

    ll ans = INT_MAX;
    REP(i, (1<<N)){
        vector<ll> score(M);
        ll cost=0;
        REP(j, N){
            if(i & (1<<j)){
               cost+= C[j];
               REP(k, M){
                    score[k] += A[j][k];
               }
            }
        }

        bool ok = true;
        REP(k, M){
           if( score[k] < X ){
              ok = false;
              break;
           }
        }

        if( ok ){
           ans = min(ans, cost);
        }
    }

    cout << (ans == INT_MAX ? -1 : ans) << endl;

}


Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if(A >= 10 || B >= 10) {
        cout << "-1" << endl;
    } else {
        cout << A * B << endl;
    }

    return 0;
}


Measured memory_bytes: 3640
main = do
  li <- getLine
  let [w, h, x, y] = map read $ words li
  let (a1,a2) = compute w h x y
  putStrLn $ unwords [show a1, show a2]

compute :: Int -> Int -> Int -> Int -> (Float, Int)
compute w h x y = (area, flag)
  where
    area = fromIntegral (w*h) / 2
    flag = if x * 2 == w && y * 2 == h then 1 else 0


Measured memory_bytes: 508
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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 main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,U,V; cin>>N>>U>>V; U--; V--;
  vector<vector<ll>> graph(N,vector<ll>(0));
  vector<ll> deg(N,0);
  
  rep(i,N-1){ 
    ll a,b; cin>>a>>b; a--; b--;
    //cout<<a<<" "<<b<<endl;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
    deg[a]++;
    deg[b]++;
  }
  
  vector<ll> leaves(0); rep(i,N) if(deg[i]==1) leaves.push_back(i);
  vector<ll> LU(N,-1),LV(N,-1);
  queue<ll> que; que.push(U); LU[U]=0;
  while(!que.empty()){
    ll v=que.front(); que.pop();
    for(auto nv:graph.at(v)){
      if(LU[nv]>-1) continue;
      LU[nv]=LU[v]+1;
      que.push(nv);
    }
  }
  que.push(V); LV[V]=0;
  while(!que.empty()){
    ll v=que.front(); que.pop();
    for(auto nv:graph.at(v)){
      if(LV[nv]>-1) continue;
      LV[nv]=LV[v]+1;
      que.push(nv);
    }
  }
  
  ll ans=0;
  for(auto leaf:leaves){
    if(LV[leaf]+1<=LU[leaf]) continue;
    chmax(ans,LV[leaf]-1);
  }
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 12172
#include <stdio.h>
#include <stdbool.h>

int x1, x2, x3, x4, x5;

int main() {
    scanf("%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5);
    printf("%d\n", x1 ^ x2 ^ x3 ^ x4 ^ x5 ^ 1 ^ 2 ^ 3 ^ 4 ^ 5);
}

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

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l[i];
	sort(all(l));
	int ans = 0;
	for(int i = 0; i < n-2; i++){
		for(int j = i+1; j < n-1; j++){
			int mx = l[i] + l[j];
			int mn = l[j] - l[i];
			int mx_n = lower_bound(l.begin()+j+1, l.end(), mx) - l.begin();
			int mn_n = upper_bound(l.begin()+j+1, l.end(), mn) - l.begin();
			ans += mx_n - mn_n;
			// cout << i << " " << j << " " << mx_n << " " << mn_n << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define FOR(i,s,e) for(int i = s; i < e; i++)
#define all(x) (x).begin(),(x).end()
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair

typedef vector<int>       VI;
typedef pair<int, int> pii;
typedef long long ll;


int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    string week[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    int c = 7;
    char Q[5];
    scanf("%3s",Q);
    string q = Q;
    for (string w : week){
        if(w==q){
            printf("%d",c);
            return 0;
        }
        else{
            c--;
        }
    }
    // freopen("out.txt", "w", stdout);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF (2e9)
#define EPS (1e-7)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b && a > c && b < c) {
        cout << "Yes" << endl;
    } else if (a < b && a < c && b > c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

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

    rep(i, X+1) {
        if (Y == i * 2 + (X - i) * 4) {
            cout << "Yes" << endl;
            exit(0);
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 3624
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e8
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int> 
#define N (1<<7)

const int maxn=45;
int n,ma,mb,ans=INF;
int a[maxn],b[maxn],c[maxn];
int dp[2][405][405];

int main()
{
	scanf("%d%d%d",&n,&ma,&mb);
	REP(i,n)scanf("%d%d%d",&a[i],&b[i],&c[i]);
	for(int cnt=1;cnt<=min(400/ma,400/mb);cnt++)
	{
		int x=ma*cnt,y=mb*cnt;
		for(int p=0;p<2;p++)for(int i=0;i<=x;i++)for(int j=0;j<=y;j++)dp[p][i][j]=INF;
		dp[0][0][0]=0;
		for(int p=1;p<=n;p++)
		for(int i=0;i<=x;i++)for(int j=0;j<=y;j++)
		{
			dp[p&1][i][j]=dp[(p-1)&1][i][j];
			if(i>=a[p]&&j>=b[p])dp[p&1][i][j]=min(dp[(p-1)&1][i-a[p]][j-b[p]]+c[p],
			dp[p&1][i][j]);
		}
		ans=min(ans,dp[n&1][x][y]);
	}
	if(ans==INF)printf("-1");
	else printf("%d",ans);
	return 0;
}
/*
40 2 3
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
10 10 100
*/

Measured memory_bytes: 1536
MOD = 10 ** 9 + 7
n = int(input())

"""
dp = [-1] * (n + 1)
dp[0] = 1
def cnt(num):
    ans = 0
    if num < 0:
        return 1
    if dp[num] != -1:
        return dp[num]
    if num == 1:
        dp[num] = n
        return n
      
    for i in range(n):
        if i == 0:
            ans += cnt(num - 1)
            ans %= MOD
        else:
            if num - 2 - i < 0:
                ans += 1
            else:
                ans += cnt(num - 2 - i)
            ans += n - 1
            ans %= MOD
    dp[num] = ans
    return ans

dp[0] = 1
print(cnt(n))
"""

dq = [0] * (n + 1)
sum_ = [0] * (n + 1)
dq[0] = 1
sum_[0] = 1
for i in range(n):
    if i == 0:
        dq[i + 1] = n
        sum_[i + 1] = sum_[i] + dq[i + 1]
        continue
    """
    for j in range(n):
        if j == 0:
            dq[i + 1] += dq[i]
        else:
            if i - 1 - j < 0:
                dq[i + 1] += 1
            else:
                dq[i + 1] += dq[i - 1 - j]
            dq[i + 1] += n - 1
    """
    dq[i + 1] += dq[i]
    dq[i + 1] += (n - 1) * (n - 1)
    dq[i + 1] += sum_[i - 2]
    dq[i + 1] += abs(i - n)
    dq[i + 1] %= MOD
    sum_[i + 1] = sum_[i] + dq[i + 1]
    sum_[i + 1] %= MOD

print(dq[-1])


Measured memory_bytes: 56044