akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  if(n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a = in();
    int b = in();
    cout << a + b << endl;
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
n = int(input())
a = [0]
a.extend(list(map(int,input().split())))
plan = 0
for i in range(n):
    plan += abs(a[i] - a[i+1])
plan += abs(a[n])
for i in range(1,n+1):
    if i == 1:
        ans = plan - abs(a[0]-a[1]) - abs(a[1]-a[2]) + abs(a[0]-a[2])
    elif i == n:
        ans = plan - abs(a[n-1]-a[n]) -abs(a[n]) + abs(a[n-1])
    else:
        ans = plan - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i-1]-a[i+1])
    print(ans)

Measured memory_bytes: 14048
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <stack>

#define rep(i, n) for(int i=0;i<n;i++)
#define IOS() ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define INT_MINI -987654321
#define INT_MAXI 987654321
#define ABS(X) ((X) < 0 ? -(X) : (X))


using namespace std;

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 n, m;
int a[300], a_l;

void input() {

    cin >> n >> m;

    int ev = 2, od = 1;
    a_l = 0;
    while(n > 0 || m > 0){

        if(m > 0){
            a[a_l++] = od;
            od += 2;
            m--;
        }

        if(n > 0){
            a[a_l++] = ev;
            ev += 2;
            n--;
        }
    }
}

void process() {

    int count = 0;

    for(int i=0;i<a_l;i++) {
        for(int j=i+1;j<a_l;j++) {
            if((a[i] + a[j]) % 2 == 0) {
                count++;
            }
        }
    }

    cout << count;

}

int main() {

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    input();
    process();

    return 0;
}

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

A.sort(reverse=True)

Sum = 0

for i in range(N-1):
    if i == 0:
        Sum += A[i]
    else:
        Sum += A[(i+1)//2]
        #print(A[(i+1)//2])

print(Sum)

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

int main() {
    string S;
    cin >> S;
    int p=0, c=0;
    
    while(p < S.size()-1) {
        if(S.at(p) != S.at(p+1)) {
            if(p < S.size()-2)
                S = S.substr(0,p)+S.substr(p+2);
            else
                S = S.substr(0,p+1);
            if(p!=0 && S.at(p)!=S.at(p-1))
                --p;
            c += 2;
        } else
            ++p;
        }
  
  cout << c << endl;
}

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

#define dump(x) cout << (x) << endl
#define Int int64_t
#define fi first
#define se second

Int mod = 1e9 + 7;
Int INF = 1e18;

int main() {
    Int n;
    cin >> n;
    vector<Int> l(n);
    for (Int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    Int res = 0;
    for (Int i = 0; i < n - 2; i++) {
        for (Int j = i + 1; j < n - 1; j++) {
            Int add = lower_bound(l.begin() + j + 1, l.end(), l[i] + l[j]) - l.begin();
            res += add - 1 - j;
        }
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S1 = str(input())
S2 = str(input())
mod = 10 ** 9 + 7

queue = [0, 1, 2]
ans = 1
p = 0
for i in range(N):
  if p <= 1:
    if S1[i] == S2[i]:
      if i == 0:
        ans *= 3
      else:
        if p == 0:
          ans *= 2
        else:
          ans = ans
      p = 0
    else:
      if i == 0:
        ans *= 6
      else:
        if p == 0:
          ans *= 2
        else:
          ans *= 3 
      p = 2
  else:
    p -= 1
  ans = ans % mod  
      
print(ans)      
      
    
  





Measured memory_bytes: 9140
n,m=gets.split(" ").map(&:to_i)
h = Array.new(n+1).map{Array.new(m+1,0)} 

for i in 1..n

a= gets.split.map(&:to_i)
    for j in 1..m
    h[i-1][j-1] = a[j-1]
    h[i-1][m] += a[j-1]
    h[n][j-1] += a[j-1]
    h[n][m] += a[j-1]
    end
end
for i in 0..n
    for j in 0..m
      print " " unless j == 0
      print h[i][j]
    end
    print "\n"
  end



Measured memory_bytes: 7044
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    N = II()
    a = input()
    b = input()
    c = input()
    ans = 0
    for i in range(N):
        C = Counter([a[i], b[i], c[i]]).most_common(1)[0][1]
        if C == 1: ans += 2
        elif C == 2: ans += 1
    return ans


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


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

int N;
const int MAX_N = 1.0e5 + 100;
int A[MAX_N];

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

    int ans = 1;
    bool down = false;
    bool up = false;
    for (int i = 0; i < N-1; i++) {
        if (A[i] < A[i+1]) {
            if (down) {
                down = false;
                up = false;
                ans++;
            }
            else {
                up = true;
            }
        }
        else if (A[i] > A[i+1]) {
            if (up) {
                down = false;
                up = false;
                ans++;
            }
            else {
                down = true;
            }
        }
    }
    
    cout << ans << endl;

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

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

    ll n;
    cin >> n;

    vector<ll> a(n);
    REP(i,n)cin >> a[i];
    sort(All(a));
    reverse(All(a));

    ll sum=0;
    for(int i = 1; i<n;i++){
        sum+=a[i/2];
    }
    cout << sum << endl;

}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<double> vd;
typedef vector<vd> vvd;

struct P {
    int src;
    int dst;
    double cost;

    bool operator >(const P& p) const {
        return cost > p.cost;
    }
};

int main() {
    int n;
    while (cin >> n, n) {
        vd x(n), y(n), z(n), r(n);
        REP(i, n) cin >> x[i] >> y[i] >> z[i] >> r[i];

        vvd E(n, vd(n));
        REP(i, n) FOR(j, i+1, n) {
            double xx = (x[i] - x[j]);
            double yy = (y[i] - y[j]);
            double zz = (z[i] - z[j]);
            double v = sqrt(xx*xx + yy*yy + zz*zz) - r[i] - r[j];
            E[i][j] = E[j][i] = v > 0 ? v : 0;
        }

        double ans = 0;
        vb visited(n);
        priority_queue<P, vector<P>, greater<P>> que;
        que.push({0, 0, E[0][0]});
        while (!que.empty()) {
            P p = que.top(); que.pop();
            if (visited[p.dst]) continue;
            ans += E[p.src][p.dst];
            visited[p.dst] = true;
            REP(i, n) {
                if (visited[p.dst]) {
                    que.push({p.dst, i, E[p.dst][i]});
                }
            }
        }
        printf("%.03f\n", ans);
    }
}

Measured memory_bytes: 3424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    --a;
    --b;
    --c;
    --d;
    string s;
    cin >> s;
    vector<bool> x(n);
    rep(i,0,n) x[i]=s[i]=='#';

    bool ok = true, one = false;
    rep(i,b,d) {
        if(x[i]) {
            if(one) ok = false;
            else one = true;
        }
        else one = false;
    }
    rep(i,a,c) {
        if(x[i]) {
            if(one) ok = false;
            else one = true;
        }
        else one = false;
    }
    if(ok) {
        if(c>d) {
            bool found = false;
            rep(i,b,d+1) {
                if(!x[i-1]&&!x[i]&&!x[i+1]) {
                    found = true;
                }
            }
            if(!found) ok = false;
        }
    }
    
    if(ok) cout << "Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
  	int a = 0, b = 0, i;
            string s;
            cin >> s;
            for (i == 0; i < s.size(); i++) {
            	if (s[i] == 'A')
                  	a++;
              else
                b++;
            }
            if (a == 3 or b == 3)
              	cout << "No\n";
           	else
              cout << "Yes\n";
	return 0;           
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

    int h, w;

    int i, j;

    while(1){

        scanf("%d %d ", &h, &w);

        if(h==0&&w==0)break;

        for(i=0;i<h;i++){

            for(j=0;j<w;j++){

                if(i==0||i==h-1||j==0||j==w-1){

                    printf("#");

                }else{

                    printf(".");

                }

            }

            printf("\n");

        }

        printf("\n");

    }





    return 0;

}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2; typedef pair<int, P2> P3;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

char s[100][100];

int main(){
	for(int i = 0; i < 50; i++)
		for(int j = 0; j < 100; j++)
			s[i][j] = '#';
	for(int i = 50; i < 100; i++)
		for(int j = 0; j < 100; j++)
			s[i][j] = '.';
	int a, b; cin >> a >> b; a--; b--;
	
	for(int i = 1; i < 50; i += 2){
		for(int j = 1; j < 100; j += 2){
			if(!a) break; a--;
			s[i][j] = '.';
		}
	}
	
	for(int i = 51; i < 100; i += 2){
		for(int j = 1; j < 100; j += 2){
			if(!b) break; b--;
			s[i][j] = '#';
		}
	}
	
	cout << 100 << " " << 100 << endl;
	for(int i = 0; i < 100; i++){
		for(int j = 0; j < 100; j++){
			cout << s[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int S[M][2];
    REP(i,M){
        cin >> S[i][0] >> S[i][1];
    }
    int T[N] = {};
    int U[N] = {};
    REP(i,M){
        if(S[i][0]==1){
            T[S[i][1]-1] = 1;
        }else if(S[i][1]==N){
            U[S[i][0]-1] = 1;
        }
    }
    REP(i,N){
        if(T[i]*U[i]==1){
            cout << "POSSIBLE" << endl;
            exit(0);
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(void) {
 int a,b,c;
 scanf("%d",&a);
 for(b=1;b<=a;b++){
   c=b;
   if(c%3==0){
     printf(" %d",b);}
   else if(c%10==3){
     printf(" %d",b);}
   else{
     while(c!=0){
     c/=10;
     if(c%10==3){
     printf(" %d",b);
     break;
    }
   }
  }
 }
 printf("\n");
  return 0;
}


Measured memory_bytes: 2104
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    use std::cmp;

    input! {
        N: usize,
        H: [i64; N],
    }

    let mut dp = vec![std::i64::MAX / 10; N];
    dp[0] = 0;

    for i in 0..N {
        for d in 1..3 {
            let j = i + d;

            if j >= N { continue; }
            dp[j] = cmp::min(dp[j], dp[i] + (H[i] - H[j]).abs())
        }
    };

    println!("{}", dp[N - 1]);
}

Measured memory_bytes: 6396
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int h, w;
  cin >> h >> w;
  vector<string> v(h+2, string(w+2, '.'));
  FOR(i, 1, h+1) {
    cin >> v[i];
    v[i] = '.' + v[i] + '.';
  }

  vector<pair<double,int>> eve;
  REP(i, h+1) REP(j, w+1) {
    // (h-i, j+1) の偏角
    double ang = atan2(h-i, j);
    if(v[i][j] == '#' && v[i+1][j] == '.' && v[i][j+1] == '.' && v[i+1][j+1] == '.') {
      eve.PB({ang, 1});
    }
    if(v[i][j] == '.' && v[i+1][j] == '#' && v[i][j+1] == '#' && v[i+1][j+1] == '#') {
      eve.PB({ang, 1});
    }
    if(v[i][j] == '.' && v[i+1][j] == '.' && v[i][j+1] == '.' && v[i+1][j+1] == '#') {
      eve.PB({ang, -1});
    }
    if(v[i][j] == '#' && v[i+1][j] == '#' && v[i][j+1] == '#' && v[i+1][j+1] == '.') {
      eve.PB({ang, -1});
    }
  }

  sort(ALL(eve));
  int num = 1, ans = 2;
  for(auto i: eve) {
    num += i.second;
    chmax(ans, num);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 5936
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int n,r;
  cin >> n >> r;
  if(n < 10){
    r += (10-n)*100;
  }
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  math2do
 *    created: 04.09.2020 18:17:57 IST
**/

#include <bits/stdc++.h>

using namespace std;

const int mod = (int) (1e9 + 7);

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector <vector <char> > mat(n, vector <char>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mat[i][j];
    } 
  } 
  if (mat[0][0] == '#') {
    cout << 0 << endl;
    return 0;
  } 
  vector <vector <int> > dp(n, vector <int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == '#') {
	dp[i][j] = 0;
	continue;
      } else {
	if (i == 0 && j == 0) {
	  dp[0][0] = 1;
	} else if (i == 0) {
	  dp[i][j] = dp[i][j - 1];
	} else if (j == 0) {
	  dp[i][j] = dp[i - 1][j];
	} else {
	  add(dp[i][j], dp[i - 1][j]);
	  add(dp[i][j], dp[i][j - 1]);
	}
      } 
    } 
  } 
  
  cout << dp[n - 1][m - 1] << endl;
  return 0;
}


Measured memory_bytes: 8152
# ABC061C - Big Array
import sys
input = sys.stdin.readline

def main():
    n, k = list(map(int, input().rstrip().split()))
    arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])
    cur, cnt = 0, 0
    for i, j in arr:
        cnt += j
        if cnt >= k:
            print(i)
            break


if __name__ == "__main__":
    main()

Measured memory_bytes: 28640
import sys, itertools
range = xrange
input = raw_input

orda = ord('a')

A = [ord(c) - orda for c in input()]
B = [ord(c) - orda for c in input()]
C = [ord(c) - orda for c in input()]

A = [-1 if a == - 34 else a for a in A]
B = [-1 if a == - 34 else a for a in B]
C = [-1 if a == - 34 else a for a in C]

An = len(A)
Bn = len(B)
Cn = len(C)

 
ABhit = []
AChit = []
BChit = []

big = 4010
for i in range(-big,big):
#for i in range(-Bn, An + 1):
    for j in range(max(0, i), min(An, Bn + i)):
        if A[j] != -1 and B[j - i] != -1 and A[j] != B[j - i]:
            break
    else:
        ABhit.append(i)

for i in range(-big,big):
#for i in range(-Cn, An + 1):
    for j in range(max(0, i), min(An, Cn + i)):
        if A[j] != -1 and C[j - i] != -1 and A[j] != C[j - i]:
            break
    else:
        AChit.append(i)

for i in range(-big,big):
#for i in range(-Cn, Bn + 1):
    for j in range(max(0, i), min(Bn, Cn + i)):
        if B[j] != -1 and C[j - i] != -1 and B[j] != C[j - i]:
            break
    else:
        BChit.append(i)

best = An + Bn + Cn
for i in ABhit:
    ind1 = 0
    ind2 = 0
    # AChit[ind1] - BChit[ind2] = i
    while ind1 < len(AChit) and ind2 < len(BChit):
        if AChit[ind1] - BChit[ind2] < i:
            ind1 += 1
        elif AChit[ind1] - BChit[ind2] > i:
            ind2 += 1
        else:
            j = AChit[ind1]
            best = min(best, max(An, Bn + i, Cn + j) - min(0,i,j))
            ind1 += 1

#print ABhit
#print AChit
#print BChit
print best


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

using namespace std;
using ll = long long;

ll dp[301];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n, avail; cin >> n >> avail;
    fill(dp + 1, dp + n + 1, 1e9 * 305);
    
    vector<ll> block(n + 1);
    
    for (int i = 1; i <= n; ++i)
        cin >> block[i];
    
    for (int j = 1; j <= n - avail; ++j)
    {
        for (int k = n; k >= j; --k)
        {
            dp[k] = 1e9 * 305;
            
            for (int s = j - 1; s < k; ++s)
                dp[k] = min(dp[k], dp[s] + max(0ll, block[k] - block[s]));
        }
    }
    
    ll res(1e9 * 305);
    for (int x = n - avail; x <= n; ++x)
        res = min(res, dp[x]);
    
    cout << res;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    int ret = 0;
    vector<int> cnt3;
    vector<int> cnt2(1000001);
    vector<bool> cnt(1000001);
    for(int i = 0;i < N;i++) {
        if(cnt2.at(vec.at(i)) == 0 && cnt.at(vec.at(i)) == false) {
            for(int j = vec.at(i) + vec.at(i);j < 1000001;j += vec.at(i)) {
                cnt.at(j) = true;
            }
        }
        cnt2.at(vec.at(i))++;
    }
    for(int i = 0;i < N;i++) {
        if(cnt2.at(vec.at(i)) == 1 && cnt.at(vec.at(i)) == false) {
            ret++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 8008
#include <bits/stdc++.h>
using i64 = long long;

double dp[303][303][303];
int n;

void calc(int i, int j, int k)
{
    if (dp[i][j][k] >= 0)
        return;
    if (i)
        calc(i - 1, j, k);
    if (j)
        calc(i + 1, j - 1, k);
    if (k)
        calc(i, j + 1, k - 1);

    dp[i][j][k] = (i ? dp[i - 1][j][k] * i : 0) +
                  (j ? dp[i + 1][j - 1][k] * j : 0) +
                  (k ? dp[i][j + 1][k - 1] * k : 0) +
                  n;
    dp[i][j][k] *= 1.0 / (i + j + k);
}

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

    memset(dp, -1, sizeof dp);
    dp[0][0][0] = 0.0;
    calc(cnt[1], cnt[2], cnt[3]);
    printf("%.10lf\n", dp[cnt[1]][cnt[2]][cnt[3]]);

    return 0;
}


Measured memory_bytes: 217600
#include<bits/stdc++.h>
using namespace std;
int yeee(int n){
    int df = 0;
    while(n > 0){
        df += n%10;
        n /= 10;
    }
    return df;
}
int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int total = 0;
    for(int i = 1;i <= N;i++){
        int df = yeee(i); 
        if(df >= A && df <= B){
            total += i;
        }   
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int n;
    cin>>n;
    string a1;
    set<string> s1;
    for(int i=0;i<n;i++)
    {
        cin>>a1;
        s1.insert(a1);
    }
    cout<<s1.size();
    return 0;
}


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

using namespace std;

#ifdef LOCAL 
  #include "..\debug.hpp"
#else
  #define debug(...) 630;
#endif

const int mod = 1e9+7;
 
struct Mint {
  long long x; Mint() : x(0) {}
  Mint(long long _x) : x ((_x%mod + mod)%mod) {}
  Mint& fix() { x = (x%mod + mod)%mod; return *this; }
  Mint& operator += (const Mint& other) { if ((x += other.x) >= mod) { x-= mod; } return *this;}
  Mint& operator -= (const Mint& other) { if ((x += mod-other.x) >= mod) { x -= mod; } return *this; }
  Mint& operator *= (const Mint& other) { (x*=other.x)%=mod; return *this; }
  Mint operator + (const Mint& other) const { return Mint(*this) += other; }
  Mint operator - (const Mint& other) const { return Mint(*this) -= other; }
  Mint operator * (const Mint& other) const { return Mint(*this) *= other; }
  Mint operator - () const { return Mint(0) - *this; }
  Mint operator ++ (int) { Mint result(*this); *this += 1; return result; }
  Mint operator -- (int) { Mint result(*this); *this -= 1; return result; }
  bool operator < (const Mint& other) const { return x < other.x; }
  bool operator == (const Mint& other) const { return x == other.x;} 
};
ostream& operator << (ostream& out, const Mint& val) { return out << val.x; }
istream& operator >> (istream& in, Mint& val ) { in >> val.x; return in;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<Mint> dp(k + 1);
  vector<int> a(n);
  for (auto& x : a) cin >> x; 
  dp[0] = 1;
  for (int j = 0; j < n; j++) {
    vector<Mint> p = dp;
    for (int i = 1; i <= k; i++) {
      p[i] += p[i - 1];
    }
    for (int i = 1; i <= k; i++) {
      dp[i] = p[i];
      if ( i - a[j] -1 >= 0) {
        dp[i] -= p[i - a[j] - 1];
      }
    }
  }
  cout << dp[k] << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep_r(i, n) for (ll i = n-1; i >= 0; i--)
using namespace std;

int main(){
  int n, m, q;
  cin >> n >> m >> q;
  vector<ll> a(q);
  vector<ll> b(q);
  vector<ll> c(q);
  vector<ll> d(q);
  rep(i, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  vector<ll> aa(n, 1);
  ll ans = 0;
  ll temp;
  while(1){
    temp = 0;
    rep(i, q){
      if (aa[b[i]] - aa[a[i]] == c[i]){
        temp += d[i];
      }
    }
    if (temp > ans)
      ans = temp;
    bool flag = true;
    rep(i, n){
      if (aa[i] != m){
        flag = false;
        break;
      }
    }
    if (flag)
      break;
    aa[n-1]++;
    rep_r(i, n){
      if (aa[i] == m+1){
        aa[i-1]++;
        aa[i] = 1;
      }
    }
    rep(i, n-1){
      if (aa[i] > aa[i+1]){
        aa[i+1] = aa[i];
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3572
N = int(input())
a = list(map(int,list(input())))
a = list(map(lambda x:x-1,a))
x = 0
for i,n in enumerate(a):
  if n%2==0:
    continue
  else:
    if ((N-1)^i)&i==0:
      x+=1

if x%2!=0:
  print(1)
  
elif 1 in a:
  print(0)

else:
  a = [x//2 for x in a]
  x = 0
  for i,n in enumerate(a):
    if n%2==0:
      continue
    else:
      if((N-1)&i)==i:
        x+=1
  if x%2!=0:
    print(2)
  else:
    print(0)

Measured memory_bytes: 22740
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)

using namespace std;

int main(void) {
	int dish[5];

    REP(i, 0, 5) scanf("%d", &dish[i]);

    int min = 10;
    int idx = -1;
    REP(i, 0, 5) {
    	int x = dish[i] % 10;
    	if ( x >= 1 && x < min ) {
    		min = x;
    		idx = i;
    	}
    }

    int ans = 0;

    if ( idx == -1 ) REP(i, 0, 5) ans += dish[i];
    else {
    	REP(i, 0, 5) {
    		if ( i == idx ) ans += dish[i];
    		else ans += ((dish[i] + 10 - 1) / 10) * 10;
    	}
    }
    
    printf("%d\n", ans);

	return 0;
}


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

int coin[2] = {5, 500};

int main(void) {
    long long int money;
    long long int c[2] = {0};
    cin >> money;

    for (int i = 1; i >= 0; i--) {
        if (money / coin[i] > 0) {
            int d = money / coin[i];
            money %= coin[i];
            c[i] = d;
        }
    }

    cout << c[1] * 1000 + c[0] * 5 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D){
    cout << "Left" << endl;
  }
  else if(A + B == C + D){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

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

int main()
{
	string name;
	cin >> name;
	if (name == "Sunny"){
		cout << "Cloudy" << endl;
	}
	else if (name == "Cloudy"){
		cout << "Rainy" << endl;
	}
	else{
		cout << "Sunny" << endl;
	}
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define MAX 123456*2
int main (){
    bool pr[MAX];
    int a;
    for(int i=0;i<MAX;i++) pr[i]=true;
    pr[0]=false;
    pr[1]=false;
     
    for(int i=0;i*i<MAX;i++){
        if(pr[i]){
            for(int j=i*i;j<=MAX;j=j+i){
                pr[j]=false;
            }
        }
    }
    while(cin>>a,a){
        int ans=0;
        for(int i=a+1;i<=2*a;i++){
            if(pr[i])ans++;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3336
N = int(input())
A = []
B = []
S = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    S.append((i, a + b))
ans = 0
S.sort(key=lambda x: x[1], reverse=True)
for i in range(N):
    if i % 2 == 0:
        ans += A[S[i][0]]
    else:
        ans -= B[S[i][0]]

print(ans)


Measured memory_bytes: 26300
# -*- coding: utf-8 -*-

import math


def is_prime(x):
    # Primality Test
    if x == 2:
        return True

    if x <= 1 or x % 2 == 0:
        return False

    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i += 2
    return True


def to_int(v):
    return int(v)


if __name__ == '__main__':
    l = to_int(input())
    seq = [to_int(input()) for i in range(l)]
    cnt = 0

    for v in seq:
        if is_prime(v):
            cnt += 1
    print(cnt)

Measured memory_bytes: 8020
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main (){
    int n,x;
    int ans = 0;
    cin  >> n >> x ;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    } 
    sort(a.begin(),a.end());
    for (int i = 0; x > 0 && i< n; i++, ans ++ )
    {
       x -= a[i]; 
       if((x<0||i==n-1) && x !=0)ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int A[]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;
int main(){
	scanf("%d",&n);
	printf("%d",A[n]);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    
    int i = 0;
    int x=1;
    int y=1;
    int j;
    

    while(x != 0 && y != 0){
        
        scanf("%d",&x);
        scanf("%d",&y);
        
        for(i=0;i<x;i++){
            for(j=0;j<y;j++){
                printf("#");
            }
            if(x != 0 && y != 0){
            printf("\n");
            }
        }
        if(x != 0 && y != 0)
        printf("\n");
    }
    return 0;
}

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

vector<vector<pair<int, int>>> G;
vector<int> ans;
int INF = 1000000000;

void dfs(int current, int parent, int color) {
  for (auto nx : G.at(current)) {
    if (nx.first == parent) continue;
    if (nx.second % 2 == 0) ans.at(nx.first) = color;
    else ans.at(nx.first) = (color + 1) % 2;
    dfs(nx.first, current, ans.at(nx.first));
  }
}

int main() {
  int N; cin >> N;
  G.resize(N);
  ans.assign(N, INF);
  ans.at(0) = 0;
  for (int i = 0; i < N-1; i++) {
    int u, v, w; cin >> u >> v >> w;
    u--; v--;
    G.at(u).push_back(make_pair(v, w));
    G.at(v).push_back(make_pair(u, w));
  }
  dfs(0, -1, 0);
  for (int i = 0; i < N; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 8960
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int64_t> vs(n);
    int neg_count = 0;
    for (auto& v : vs)
    {
        cin >> v;
        if (v < 0)
        {
            neg_count++;
        }
        v = abs(v);
    }
    sort(vs.begin(), vs.end());
    if (neg_count % 2 == 1)
    {
        vs[0] *= -1;
    }
    int64_t ans = 0;
    for (auto& v : vs)
    {
        ans += v;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N, T = map(int, input().split())
A = list(map(int, input().split()))
min_A = 1000000001
max_diff = 0
ans = 0
for i in A:
    min_A = min(min_A, i)
    if i - min_A == max_diff:
        ans += 1
    if i - min_A > max_diff:
        max_diff = i - min_A
        ans = 1
print(ans)


Measured memory_bytes: 14292
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char S[11000];
char T[11000];
vector<vector<long long> >dp;
int main(){
	init_C(210000);
	scanf("%s%s",S,T);
	int A=0;
	int B=0;
	int C=0;
	for(int i=0;S[i];i++){
		if(S[i]=='1'&&T[i]=='0')B++;
		if(S[i]=='0'&&T[i]=='1')A++;
		if(S[i]=='1'&&T[i]=='1')C++;
	}
	dp=vector<vector<long long> >(A+C+1,vector<long long>(B+1));
	dp[0][0]=1;
	for(int i=0;i<A+C;i++){
		for(int j=0;j<B;j++){
			if(!dp[i][j])continue;
			dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j]*(B-j)%mod*(B-j))%mod;
			dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(B-j)%mod*(C-(i-j)))%mod;
			
		}
	}
	long long ret=0;
	for(int i=B;i<=B+C;i++){
		ret=(ret+fact[B+C-i]*fact[B+C-i]%mod*dp[i][B]%mod*Comb(B+C,B+C-i))%mod;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 205824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll p[1002];

int main()
{
    ll n,k,i,l,cnt,ans,j,a,b,pos;
    cin>>n;
    for(i=1; i<=n; i++)scanf("%lld",&p[i]);
    ans=0;
    sort(p+1,p+n+1);
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            if(p[i]==p[j])continue;
            for(k=j+1;k<=n;k++)
            {
                if(p[j]==p[k])continue;
                if(p[i]+p[j]>p[k])ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3780
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
const int mo = 1E9 + 7;
long long f[200005];
long long d(int x)
{
	long long p = mo - 2;
	long long t, sum, ans = 1;
	while (p > 0)
	{
		sum = x; t = 1;
		while (t * 2 < p)
		{
			sum = (sum * sum) % mo;
			t *= 2;
		}
		ans = (ans * sum) % mo;
		p -= t;
	}
	return ans;
}
int main()
{
	long long n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	long long t, g = n;
	long long ans = 1, sum;
	while (g > 0)
	{
		sum = 2; t = 1;
		while (t * 2 <= g)
		{
			sum = (sum * sum) % mo;
			t *= 2;
		}
		ans = (ans * sum) % mo;
		g -= t;
	}
	ans = (ans - 1 + mo) % mo;
	f[1] = 1;
	for (int i = 2; i <= min(b, n - a); i++)
		f[i] = d(i);
	sum = 1;
	for (int i = 1; i <= min(a, n - a); i++)
		sum = (sum * (n - i + 1)) % mo;
	for (int i = 1; i <= min(a, n - a); i++)
		sum = (sum * f[i]) % mo;
	ans = ((ans - sum) % mo + mo) % mo;
	sum = 1;
	for (int i = 1; i <= min(b, n - b); i++)
		sum = (sum * (n - i + 1)) % mo;
	for (int i = 1; i <= min(b, n - b); i++)
		sum = (sum * f[i]) % mo;
	ans = ((ans - sum) % mo + mo) % mo;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3.4.3
import numpy as np
from scipy.sparse.csgraph import floyd_warshall, csgraph_from_dense
from itertools import*
from collections import*

h, w = map(int, input().split())
G = [list(map(int, input().split())) for _ in [0]*10]

m = floyd_warshall(csgraph_from_dense(G))

d = list(chain.from_iterable(list(map(int, input().split())) for _ in [0]*h))
C = Counter(d)
s = 0
for i in range(10):
    s += m[i][1] * C.get(i, 0)
print(int(s))

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

#define int long long

main(){
	int n,m;
	int a,b;

	cin>>n>>m;
	int arr[100010]={0};
	for(int i=0;i<m;i++){
		cin>>a>>b;
		arr[a]++;arr[b]++;
	}
	int f=0;
	for(int i=1;i<=n;i++){
		if(arr[i]%2)f++;
	}
	if(f)cout<<"NO"<<endl;
	else cout<<"YES"<<endl;

	return(0);
}

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

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long
#define vi vector<int>

bool isMonth(int n)
{
    return (1 <= n && n <=12);
}

int main(){
    LL s;
    LL y, m;
    bool iy, im;

    cin >> s ;
    y = s/100;
    m = s- y*100;
    iy = isMonth(y);
    im = isMonth(m);

    if(iy && im){
        cout << "AMBIGUOUS";
    }
    else if (iy){
        cout << "MMYY";
    }
    else if(im){
        cout << "YYMM";
    }
    else{
        cout << "NA";
    }
    cout << endl;

    return 0;
}


    
  
  

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n,q,opt,t,x;
	cin >> n;
	vector<int> a[n];
	cin >> q;
	while (q--)
	{
		cin >> opt;
		if (opt == 0)
		{
			cin >> t >> x;
			a[t].push_back(x);
		}
		if (opt == 1)
		{
			cin >> t;
			if (a[t].size()>0)
			{
				cout << a[t][0];
				for (int i=1; i<a[t].size(); i++)
					cout << ' ' << a[t][i];
			}
			cout << endl;
		}
		if (opt == 2)
		{
			cin >> t;
			a[t].clear();
		}
	}
	return 0;
}


Measured memory_bytes: 5920
# coding: utf-8
# Your code here!

w = input()

# print(w)

dic = {}
for i in range(len(w)):
    # print(w[i])
    
    key = w[i]
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1

# print(dic)

flag = True
for val in list(dic.values()):
    # print(val % 2)
    if val % 2 != 0:
        flag = False

# print(flag)
if flag:
    print('Yes')
else:
    print('No')


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

struct card{ char a; int b; };
int n;
card a[200010],b[200010];

int partition(int p,int r){
  for(int i = p; i < r; i++){
    if(a[i].b <= a[r].b) swap(a[p++],a[i]);
  }
  swap(a[p],a[r]);
  return p;
}

void quicksort(int p,int r){
  if(p >= r) return;
  int q = partition(p,r);
  quicksort(p,q-1);
  quicksort(q+1,r);
}

const int INF = 1e9+10;
card L[300010],R[300010];

void merge(int l,int m,int r){
  int n1 = m-l;
  int n2 = r-m;
  for(int i = 0; i < n1; i++) L[i] = b[l+i];
  for(int i = 0; i < n2; i++) R[i] = b[m+i];
  L[n1] = R[n2] = {'D',INF};
  int i = 0,j = 0;
  for(int k = l; k < r; k++){
    if(L[i].b <= R[j].b) b[k] = L[i++];
    else {
      b[k] = R[j++];
    }
  }
}

void mergesort(int l,int r){
  if(l+1 == r) return;
  int m = (l+r)/2;
  mergesort(l,m);
  mergesort(m,r);
  merge(l,m,r);
}

signed main(){

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i].a >> a[i].b;
    b[i].a = a[i].a;
    b[i].b = a[i].b;
  }

  quicksort(0,n-1);
  mergesort(0,n);

  int f = 1;
  for(int i = 0; i < n; i++){
    if(a[i].a != b[i].a || a[i].b != b[i].b) f = 0;
  }

  cout << (f ? "Stable" : "Not stable") << endl;
  for(int i = 0; i < n; i++){
    cout << a[i].a << " " << a[i].b << endl;
  }



  return 0;
}



Measured memory_bytes: 5388
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

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

  for(long i=1; i<=3500; i++){
    for(long j=1; j<=3500; j++){
      long a = 4*i*j - n*i - n*j;
      long b = n*i*j;
      if(a>0 && b%a==0){
        cout << i << " " << j << " " << b/a << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
N=int(input())
cnt={1:0,2:0,4:0}
for a in map(int,input().split()):
    if a%4==0:cnt[4]+=1
    elif a%2==0:cnt[2]+=1
    else:cnt[1]+=1

if cnt[1]>0:
    cnt[1]-=1
    bef=1
elif cnt[2]>0:
    cnt[2]-=1
    bef=2
else:
    cnt[4]-=1
    bef=4

flag=True
for i in range(N-1):
    if bef==1:
        if cnt[4]==0:
            flag=False
            break
        cnt[4]-=1
        bef=4
    elif bef==4:
        if cnt[1]>0:
            cnt[1]-=1
            bef=1
        elif cnt[2]>0:
            cnt[2]-=1
            bef=2
        else:
            cnt[4]-=1
            bef=4
    elif bef==2:
        if cnt[2]>0:
            cnt[2]-=1
            bef=2
        else:
            if cnt[4]==0:
                flag=False
                break
            cnt[4]-=1
            bef=4
if flag:print('Yes')
else:print('No')

Measured memory_bytes: 11480