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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e3, mod = 924844033;
int n, m, k, o, x = 1, fac[nsz + 5], dp[2][nsz + 5][2], f[nsz + 5], ans;

void inline upd(int &a, int b) {
    (a += b) && (a >= mod) && (a -= mod);
    (a < 0) && (a += mod);
}

int main() {
    scanf("%d%d", &n, &k);
    fac[0] = f[0] = 1;
    cont (i, n) {
        fac[i] = (num) fac[i - 1] * i % mod;
    }
    cont (s, k) {
        int len = (n - s) / k + 1;
        memset(dp[o], 0, sizeof(dp[o]));
        dp[o][0][0] = 1;
        cont (i, len - 1) {
            loop (j, i) {
                upd(dp[x][j][0], dp[o][j][0]);
                upd(dp[x][j + 1][1], dp[o][j][0]);
                upd(dp[x][j][0], dp[o][j][1]);
            }
            swap(o, x);
            memset(dp[x], 0, sizeof(dp[x]));
        }
        m += len;
        cont (_, 2)  for (int i = m; i >= 0; --i) {
            cont (j, min(len, i)) {
                upd(f[i], (num) f[i - j] * (dp[o][j][0] + dp[o][j][1]) % mod);
            }
        }
    }
    circ (i, 0, n) {
        upd(ans, (num) (i & 1 ? -1 : 1) * fac[n - i] * f[i] % mod);
    }
    printf("%d\n", ans);
}

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

const int mod = 1e9 + 7;

template <int mod>
struct ModInt {
  int x;

  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inv() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
};

using modint = ModInt<mod>;

signed main() {
  int N, M;
  cin >> N >> M;
  vector<modint> S(N), T(M);
  for (int i = 0; i < N; i++) cin >> S[i];
  for (int i = 0; i < M; i++) cin >> T[i];

  static modint dp[2020][2020], sum[2020][2020];
  dp[0][0] = 1;

  for (int i = 0; i <= N; i++) sum[i][0] = 1;
  for (int i = 0; i <= M; i++) sum[0][i] = 1;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (S[i] == T[j]) {
        dp[i + 1][j + 1] = sum[i][j];
      } else {
        dp[i + 1][j + 1] = 0;
      }

      sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + dp[i + 1][j + 1];
    }
  }

  cout << sum[N][M] << endl;
  return 0;
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;
vector<int> a;

int main(void) {
    cin >> N;
    a.assign(N, 0);

    vector<int> col(8 + 1);

    rep(i, N) {
        cin >> a[i];

        int c = min(a[i] / 400, 8);

        col[c]++;
    }

    int ans_max = 0;
    int ans_min = 0;
    int rest = 0;
    rep(i, 8) {
        if (col[i] > 0) ans_max++;
        else rest++;
    }

    ans_min = ans_max;
    if (rest == 8 && col[8] > 0) ans_min++;
    ans_max += col[8];

    cout << ans_min << ' ' << ans_max << endl;


    return 0;
}

Measured memory_bytes: 256
n = gets.strip.to_i
ac = 0
wa = 0
tl = 0
re = 0
n.times do |i|
  s = gets.strip
  case s
  when "AC"
    ac += 1
  when "WA"
    wa += 1
  when "TLE"
    tl += 1
  when "RE"
    re += 1
  end
end
puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tl}"
puts "RE x #{re}"


Measured memory_bytes: 14340
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

vector<int> graph[100000] = {};

int memo_aoki[100000] = {};
int memo_taka[100000] = {};
bool visited[100000] = {};


int main(void) {

	int N, u, v;
	cin >> N >> u >> v;

	u--; v--;

	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	//aoki memo
	{
		queue<pair<int, int>> q;
		q.push({ v,0 });

		while (!q.empty()) {
			pair<int, int> p = q.front();
			q.pop();

			if (!visited[p.first]) {
				visited[p.first] = true;

				memo_aoki[p.first] = p.second;

				for (int i = 0; i < graph[p.first].size(); i++) {
					q.push({ graph[p.first][i],p.second + 1});
				}
			}
		}
	}
	//takahashi memo
	{
		for (int i = 0; i < N; i++) {
			visited[i] = false;
		}
		queue<pair<int, int>> q;
		q.push({ u,0 });

		while (!q.empty()) {
			pair<int, int> p = q.front();
			q.pop();

			if (!visited[p.first]) {
				visited[p.first] = true;

				memo_taka[p.first] = p.second;

				for (int i = 0; i < graph[p.first].size(); i++) {
					q.push({ graph[p.first][i],p.second + 1 });
				}
			}
		}
	}
	//answer
	{
		int answer = 0;

		for (int i = 0; i < N; i++) {
			if (memo_taka[i] <= memo_aoki[i] && graph[i].size() != 1) {
				CHMAX(answer,memo_aoki[i]);
			}
		}

		COUT(answer);
	}



	return 0;
}

Measured memory_bytes: 6936
#include<iostream>
using namespace std;
void Insert(int);
void Increase(int,int);
int Extract(void);
void maxheapify(int i);
int H[1000000];
int n=0;
int main(){
    int key,n=0;
    char ch[7];
    
    while(1){
        cin>>ch;
        if(ch[0]=='i'){
            cin>>key;
            Insert(key);
        }
        else if(ch[0]=='e' && ch[1]=='x'){
            cout<<Extract()<<endl;
        }else{
            break;
        }
    }
    for(int i=0;i<n;i++){
        cout<<H[i]<<endl;
    }
    return 0;
}
void Insert(int key)
{
    n=n+1;
    H[n]=-1;
    Increase(n,key);
}
void Increase(int i,int key){
    int tmp;
    H[i]=key;
    while(i>1 && H[i/2]<H[i]){
        tmp=H[i];
        H[i]=H[i/2];
        H[i/2]=tmp;
        i=i/2;
    }
}

int Extract(){
    int max=H[1];
    H[1]=H[n];
    n--;
    maxheapify(1);
    return max;
}
void maxheapify(int i)
{
  int r,l,largest,tmp;
  l=i*2;
  r=i*2+1;

  if(l<=n&& H[l]>H[i])largest=l;
  else largest=i;

  if(r<=n && H[r]>H[largest])largest=r;

  if(largest!=i){
    tmp=H[i];
    H[i]=H[largest];
    H[largest]=tmp;
  
  maxheapify(largest);
  }
}



Measured memory_bytes: 6980
main = do
    input <- getContents
    let (_:xss) = map words $ lines input :: [[String]]
    mapM_ putStrLn (map ans xss)

ans (x:y:z:_)
    | a*a == b*b + c*c = "YES"
    | b*b == c*c + a*a = "YES"
    | c*c == a*a + b*b = "YES"
    | otherwise = "NO"
    where a = read x
          b = read y
          c = read z

Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int l,r,ans; cin>>l>>r; ans=2020;
  
  if(l/2019 == r/2019){
    for(int k=l;k<r;k++){
      for(int j=k+1;j<r+1;j++){
       if(((k%2019)*(j%2019))%2019<ans){ans=((k%2019)*(j%2019))%2019;}
      }
    }
      cout<<ans<<endl;
  }
  
  else{
      cout<<0<<endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    string s; cin >> s;
    if (s == "#") return;
    int y, m, d; cin >> y >> m >> d;
    if ((y == 31 && m >= 5) || y >= 32) s = "?", y -= 30;
    cout << s << " " << y << " " << m << " " << d << '\n';
  }
}



Measured memory_bytes: 3116
N = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    d[i] = d[i] + 1 if i in d else 1
ans = 0
for i in d:
    if i < d[i]:
        ans += d[i]-i
    if i > d[i]:
        ans += d[i]
print(ans)



Measured memory_bytes: 90624
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <string.h>

using namespace std;

int64_t a[100010]={0};


int main()
{
    int64_t n,i,b,c,s=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>b;
        s+=b;
        a[b]++;
    }
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>b>>c;
        a[c]+=a[b];
        s+=(c-b)*a[b];
        a[b]=0;
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 4332
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
bool road[17][17];
int memo[17][17];
int A,B,N;
int func(int y,int x){
    if(y<1||x<1)return 0;
    if(memo[y][x]!=0)return memo[y][x];
    if(road[y][x]){
        memo[y][x]=0;
        return memo[y][x];
    }
    memo[y][x]=func(y-1,x)+func(y,x-1);
    return memo[y][x];
}
int main(){
    while(cin>>A>>B,A||B){
        cin>>N;
        fill(road[0],road[0]+17*17,false);
        fill(memo[0],memo[0]+17*17,0);
        for(int i=0;i<N;i++){
            int x,y;
            cin>>x>>y;
            road[y][x]=true;
        }
        memo[1][1]=1;
        cout<<func(B,A)<<endl;
    }
    /*for(int i=0;i<B;i++){
        for(int j=0;j<A;j++){
            cout<<memo[i][j]<<" ";
        }
        cout<<endl;
    }*/
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int main(void){
    int n;
    
    cin >> n;
    
    for(int i=1; i <= n; i++){
        if(i%3 == 0)
            cout << " " << i;
        else{
            for(int x=i; x; x /= 10){
                if(x%10 == 3){
                    cout << " " << i;
                    break;
                }
            }
        }
        
    }
    
    cout << endl;
    return 0;
}



Measured memory_bytes: 3092
/*
गिरते हैं शहसवार ही मैदान-ए-जंग में ।
वो तिफ़्ल क्या गिरे जो घुटनों के बल चले ।।
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)   sort(v.rbegin(),v.rend())
#define R(v)    reverse(v.begin(),v.end())
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define T       int tc;cin>>tc;while(tc--)
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)      for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define sz(v)       (int)(v.size())
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define N 400005


void Weapons19(){
    //
    int a,b,c,d;cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){cout<<"Yes";return;}
        a-=d;
        if(a<=0){cout<<"No";return;}
    }

















}

int32_t main(){

    /*
    त्यक्तवाधर्मं च लोभं च
    मोहंचो द्यमास्थिता।
    युद्ध्यध्वमनहंकारा
    यतो धर्मस्ततो जयः।।
    */

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);

 

    Weapons19();
    
}


Measured memory_bytes: 3652
fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}



fn main() {
    let line = getline();

    let vec: Vec<&str> = line.split_whitespace().collect();
    let a:i32  = vec[0].parse().unwrap_or(0);
    let b:i32  = vec[1].parse().unwrap_or(0);
    let mut k:i32  = vec[2].parse().unwrap_or(0);

    let mut ans:i32 = 0;
    for x in (1..std::cmp::min(a,b)+1).rev() {
        if a%x == 0 && b%x == 0{
            k-=1;
            if k==0{
                ans=x;
                break;
            }
        }
    }

    println!("{}", ans);
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> A(1);
int D[5001][5001];
bool D2[5001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, K, ans=0;
	cin>>N>>K;
	for(int i=0;i<N;i++) {
		int a;
		cin>>a;
		if(a<K) A.push_back(a);
	}
	ans=N=A.size(); ans--;
	D[0][0]=D2[0]=1;
	for(int i=1;i<N;i++) {
		for(int j=K;j>=0;j--) {
			D[i][j]=D[i-1][j];
			if(j>=A[i] && D[i-1][j-A[i]]) D[i][j]=1;
		}
	}
	for(int i=N-1;i>0;i--) {
		for(int j=1;j<=K;j++) D[i-1][j]+=D[i-1][j-1];
		for(int j=0;j<K;j++) if(D2[j] && D[i-1][K-1-j]>(K-1-A[i]-j>=0 ? D[i-1][K-1-A[i]-j]:0)) {
			ans--;
			break;
		}
		for(int j=K-A[i];j>=0;j--) D2[j+A[i]]|=D2[j];
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 101396
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

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

// デバッグを消し忘れるな！！！

int main() {
    ll n, k; cin >> n >> k;
    Vl a(n+2); 
    Rep(i, 1, n) cin >> a[i];

    // k >= n のときは全部nになる
    if(k >= n){
        rep(i, 0, n){
            if(i) cout << " ";
            cout << n;
        }
        coel;
        return 0;
    }

    // // 愚直にやったら計算量O(n*k) (n*k >= 10^10)
    Vl d(n+2, 0);
    Vl e;
    do{
        e = a;
        rep(i, 0, n+2) d[i] = 0;
        Rep(i, 1, n){
            if(a[i] == 0){continue;}
            ll l = max(1LL, i-a[i]), r = min(n, i+a[i]);
            d[l]++; d[r+1]--;
        }
        Rep(i, 2, n){
            d[i] += d[i-1];
        }
        Rep(i, 1, n) if(a[i] == 0) d[i]++;    
        a = d;
        k--;
    }while(k != 0 && e != a);

    Rep(i, 1, n) cout << d[i] << " ";
    coel;


    return 0;
}


Measured memory_bytes: 7944
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define pob pop_back
#define sw swap
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
LL a,b,c;
cin >> a >> b >>c; 
if(b-a==c-b){
cout << "YES";
}else{
    cout<<"NO";
}
 return 0;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long h,n;cin >> h >> n;
    int arr[n];
    for(int i = 0;i < n;i++)
    {
        cin >> arr[i];
        h -= arr[i];
    }
    if(h <= 0)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
using namespace std;
int main(void){
    int p[3],ju[2];
    rep(i,0,3)cin>>p[i];
    rep(i,0,2)cin>>ju[i];
    
    int ans=100000000;
    rep(i,0,3)rep(j,0,2)ans=min(ans,p[i]+ju[j]);
    cout<<ans-50<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3092
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n; cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i - 1]) ans++;
  }
  cout << ans << endl;
}

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

double nb(int n) {
	double d = 1.;
	for (int i = 1; i <= n; ++i){
		d *= (double)i;
	}
	return d;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	vector<int> v;
	rep(i, n)
		v.push_back(i);
	sort(v.begin(), v.end());

	// for (auto u : v)
	// 	cout << u << endl;

	double sum = 0;		
	do {
		rep(k, n - 1) {
			int i = v[k], j = v[k + 1];
			int dd = pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2);
			sum += sqrt(double(dd));
		}
    }while(next_permutation(v.begin(), v.end()));
    // cout << sum / nb(n) << endl;
    printf("%.9f\n", sum / nb(n));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
struct T
{
    double num;
    int index;
}a[200];
int n;
double S=0;
double ans=1000000;
int ind=0;
double abs(double a)
{
    if (a>0) return a;
    return -a;
} 
int main()
{
    cin>>n;

    for (int i=0; i<n; ++i)
    {
        a[i].index=i;
        cin>>a[i].num;
        S+=a[i].num;
    }
    S/=n;
    for (int i=0; i<n; ++i)
    {
        if (abs(a[i].num-S)<ans-0.000001) 
        {
            ans = (abs(a[i].num-S));
            ind = a[i].index;
        }
    }
    cout<<ind<<endl;
    return 0;
}


Measured memory_bytes: 256
open System

let Puts = Console.WriteLine : 'a -> unit
let Reads () = Console.ReadLine().Split()
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])

let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)


// main code

let (n, k) = ReadDouble() |> FuncDouble int int
k * pown (k-1) (n-1) |> Puts


Measured memory_bytes: 11220
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  if(a>b){
    printf("0\n");
    return;
  } else if(n==1){
    printf("%d\n",a==b?1:0);
    return;
  }
  int64 min=(int64)a*(n-1)+b;
  int64 max=(int64)b*(n-1)+a;
  printf("%lld\n",max-min+1);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
        cin >>s;
        if(s == "MON")
        {
                cout << "6"<< endl;
        }
        else if(s == "TUE")
        {
                cout << "5" << endl;
        }
        else if(s == "WED")
        {
                cout << "4" << endl;
        }
        else if(s == "THU")
        {
                cout << "3" << endl;
        }
        else if(s == "FRI")
        {
                cout << "2" << endl;
        }
        else if(s == "SAT")
        {
                cout << "1" << endl;
        }
        else if(s == "SUN")
        {
                cout << "7" << endl;
        }
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
C = N // (A+B)

if N <= A+B:
  print(min(A, N))
elif N % (A+B) < A:
  print(A*C + N%(A+B))
else:
  print(A*(C+1))

Measured memory_bytes: 5148
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int n; cin >> n;
    ll k; cin >> k;
    vector<int> a(n);
    vector<vector<int>> next(61,vector<int>(n));
    rep(i,n){
        cin >> a[i];
        a[i]--;
        next[0][i] = a[i];
    }
    rep(i,60)rep(j,n){
        next[i+1][j] = next[i][next[i][j]];
    }
    int now = 0;
    rep(i,61){
        if(k>>i&1){
            now = next[i][now];
        }
    }
    cout << now+1 << endl;

}


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

ans = 0
for i in range(N):
  if A[i] <= B[i]:
    ans += A[i]
    B[i] -= A[i]
  else:
    ans += B[i]
    B[i] = 0
  if B[i] > 0:
    if A[i+1] > B[i]:
      A[i+1] -= B[i]
      ans += B[i]
    else:
      ans += A[i+1]
      A[i+1] = 0
print(ans)

Measured memory_bytes: 18376
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $d_root = [];
  $d_node = [];
  for ($i=1; $i<=$n-1; $i++) {
    list($u, $v, $w) = explode(" ", trim(fgets(STDIN)));
    if(!isset($d_node[$u])) $d_node[$u]=[];
    if(!isset($d_node[$v])) $d_node[$v]=[];
    $d_node[$u][$v] = $w;
    $d_node[$v][$u] = $w;
  }

  $queue = [1];
  $d_root[1] = 0;
  while(count($queue) > 0){
    $node = array_pop($queue);
    foreach($d_node[$node] as $next_node => $distance){
      // 既に見つかっているもの
      if(isset($d_root[$next_node])){
        continue;
      }
      $d_root[$next_node] = $d_root[$node] + $distance;
      $queue[] = $next_node;
    }
  }

  for($i=1;$i<=$n;$i++){
     echo ($d_root[$i]%2).PHP_EOL;
  }



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

int main()
{
    int64_t N, K;
    cin >> N >> K;
    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (N%K < K - N%K) cout << N%K << endl;
    else cout << K - N%K << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();	
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		int value = 0;
		while (k > 0) {
			if (a!=0) {
				a--;
				k--; 
				value+=1;
			} else if (b != 0) {
				b--; k--; ;
			} else if (c != 0) {
				c--; k--; value-=1;
			} else {
				break;
			}
		}

		System.out.println(value);
	}
}


Measured memory_bytes: 35792
import itertools

N, = (int(x) for x in input().split())

ncount = 0
for n_s in range(3, 10):
    for s_tuple in itertools.product("357", repeat=n_s):
        found = {"3":False, "5":False, "7":False}
        num = 0
        for s in s_tuple:
            num *= 10
            num += int(s)
            found[s] = True
        if False in found.values():
            continue
        if num <= N:
            ncount += 1

print(ncount)


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 1000010
const int MOD = 1000000007;

vector<int> primes;
vector<bool> isPrime(maxn, true);
int pre[maxn];

void sieve(int n = maxn - 10) {
    isPrime[0] = isPrime[1] = false;
    for (int i = 3; i * i <= n; i += 2)
        if (isPrime[i])
            for (int j = i * i; j <= n; j += 2 * i)
                isPrime[j] = false;
    primes.push_back(2);
    for (int i = 3; i <= n; i += 2)
        if (isPrime[i])primes.push_back(i);
}

void solve() {
    int n;
    cin >> n;

    cout << pre[n - 1] << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    sieve();
    for (int i = 1; i <= maxn - 10; i++) {
        int cur = i, val = 1;
        for (auto x: primes) {
            if (x * x > cur)break;
            int ct = 0;
            while (cur % x == 0)cur /= x, ct++;
            val *= (ct + 1);
        }
        if (cur > 1)val *= 2;
        pre[i] = val + pre[i - 1];
    }
    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 12020
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, p;
	ll l = 0, r = 0, ans;
	cin >> num;
	vector<int> a(num << 1);
	vector<pair<int, int>> d(num << 1);
	priority_queue<int> que;
	for (i = 0; i < (num << 1); i++) {
		scanf("%d", &a[i]);
		d[i] = make_pair(a[i], i);
	}
	sort(d.begin(), d.end(), greater<pair<int, int>>());
	for (i = 0; i < num; i++) {
		l += d[i].first;
		scanf("%d", &p);
		que.push(p);
		r += p;
	}
	p = num - 1;
	ans = l - r;
	for (i = (num << 1) - 1; i >= num; i--) {
		que.push(a[i]);
		r -= que.top();
		r += a[i];
		que.pop();
		if (d[p].first <= a[i]) {
			l -= a[i];
			p++;
			while (d[p].second >= i)
				p++;
			l += d[p].first;
		}
		ans = max(ans, l - r);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3196
char m[9][10],s[9];
main(i,j){
	for(i=0;;){
		if(scanf("%s",&s)==-1)return 0;
		for(j=0;j<8;j++)s[j]-=48;
		memcpy(m[i++]+1,s,8);
		if(i==8){
			for(i=0;i<8;i++)for(j=1;j<9;j++)if(m[i][j])goto z;
			printf("%d %d %d\n",i,j,m[0][4]);
			z:if(m[i+1][j]&&m[i][j+1]&&m[i+1][j+1])puts("A");
			else if(m[i][j+1]&&m[i+1][j-1]&&m[i+1][j])puts("G");
			else if(m[i][j+1]&&m[i+1][j+1]&&m[i+1][j+2])puts("E");
			else if(m[i+1][j]&&m[i+1][j-1]&&m[i+2][j-1])puts("D");
			else if(m[i+1][j]&&m[i+1][j+1]&&m[i+2][j+1])puts("F");
			else puts(m[i+1][j]?"B":"C");
			memset(m,0,sizeof(m));i=0;
		}
	}
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se secondO
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		vi d(n+1);
		rep(i,0,n) cin>>d[i];
		d[n]=1e8;
		int cnt=1;
		bool f=false;
		rep(i,1,n+1){
			if(d[i]==d[i-1]+1) cnt++;
			else{
				if(f) cout<<" ";
				if(cnt==1){
					cout<<d[i-1];
				}else{
					cout<<d[i-cnt]<<"-"<<d[i-1];
				}
				f=true;
				cnt=1;
			}
		}
		cout<<endl;
	}
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define EPS (double)(1e-7)

int n;
double x[50], y[50];

double dist(double x1, double y1, double x2, double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

double find(){
	double cx=0.0, cy=0.0, tx=0.0, ty=0.0;
	double mvrate=1.0, maxdist;
	bool flg=false;
	while(!flg){
		for(int p=0; p<100; p++){
			int k;
			maxdist=0.0;
			for(int i=0; i<n; i++){
				double d=dist(cx, cy, x[i], y[i]);
				if(maxdist<d){
					maxdist=d;
					k=i;
				}
			}
			cx+=(x[k]-cx)*mvrate;
			cy+=(y[k]-cy)*mvrate;
			if(dist(tx, ty, cx, cy)<EPS){
				flg=true;
				break;
			}
			tx=cx;
			ty=cy;
		}
		mvrate/=2.0;
	}
	return maxdist;
}

int main(){
	cin >> n;
	for(int i=0; i<n; i++) cin >> x[i] >> y[i];
	printf("%.9f\n", find());
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

const ll MOD=1e9+7;
signed main(){
    fastio
    ll n,K;cin>>n>>K;
    ll ans=0;
    for(ll k=K;k<=n+1;k++){
        ll l=(k*(k-1))/2;
        ll r=k*(2*(n)+1-k)/2;
        // cout<<r<<" "<<l<<"\n";
        ans+=(r-l+1);ans%=MOD;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3652
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }

  bool same(int x, int y)
  {
      return find(x) == find(y);
  }
};

int main()
{
    LL N, M;
    cin >> N >> M;
    cout << (100 * (N - M) + 1900 * M) * static_cast<LL>(pow(2.0, M)) << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
par=[-1]*n
def find(x):
  if par[x]<0:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return False
  else:
    if par[x]>par[y]:
      x,y=y,x
    par[x]+=par[y]
    par[y]=x
    return True
def same(x,y):
  return find(x)==find(y)
def size(x):
  return -par[find(x)]
for i in range(m):
  x,y,z=map(int,input().split())
  unite(x-1,y-1)
par.sort()
print(bisect.bisect_left(par,0))

Measured memory_bytes: 5908
//緑を塗る = 赤と青を塗る, と言い換えてよい。
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2) return (a * powmod(a, n - 1, mod)) % mod;
	return powmod((a * a) % mod, n / 2, mod);
}

int mod = 998244353;	//素数
int fact[500000];
int factInv[500000];

void init() {
	int i;
	fact[0] = 1;
	for (i = 1; i < 500000; i++) fact[i] = (fact[i - 1] * i) % mod;
	factInv[0] = 1;
	for (i = 1; i < 500000; i++) factInv[i] = powmod(fact[i], mod - 2, mod);
}

int comb(int n, int k) {
	if (k > n) return 0;
	return fact[n] * factInv[k] % mod * factInv[n - k] % mod;
}

int n, a, b, k;

signed main() {
	cin >> n >> a >> b >> k;
	init();
	
	int r, blue;
	int ans = 0;
	for (r = 0; r <= n; r++) {
		if (k < r * a || (k - r * a) % b != 0) continue;
		blue = (k - r * a) / b;
		ans += comb(n, r) * comb(n, blue) % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8192
n,y= map(int, input().split())
x=[]
for i in range(0,n+1):
    for j in range(0,n+1-i):
        k=n-i-j
        if y==10000*i+5000*j+1000*k:
            x.append(i)
            x.append(j)
            x.append(k)
if not x:
    print('-1 -1 -1')
else:
    print(x[0],x[1],x[2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    string s;
    cin>>s;
    cout<<(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi"?"Yes":"No")<<endl;
}


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

using namespace std;

const int MAX_N=2005;

int dp[MAX_N][MAX_N];

vector< pair<int, int> > complete_array;
vector< vector<int> > pos;
vector<int> rechts_kleiner_zelfde_soort;
vector< vector<int> > rechts_kleiner_andere_soort;
vector< vector<bool> > aanwezig;

int n;

int calc(int num0, int num1)
{
    if(dp[num0][num1] != -1) return dp[num0][num1];
    if(num0==n && num1==n) return dp[num0][num1]=0;
    int targ_pos=num0+num1;
    int ans=0;
    if(num0==n)
    {
        int his_pos=pos[1][num1]+rechts_kleiner_zelfde_soort[pos[1][num1]]+rechts_kleiner_andere_soort[pos[1][num1]][num0];
        return dp[num0][num1]=his_pos-targ_pos+calc(num0, num1+1);
    }
    else if(num1==n)
    {
        int his_pos=pos[0][num0]+rechts_kleiner_zelfde_soort[pos[0][num0]]+rechts_kleiner_andere_soort[pos[0][num0]][num1];
        return dp[num0][num1]=his_pos-targ_pos+calc(num0+1, num1);
    }
    else
    {
        int his_pos=pos[1][num1]+rechts_kleiner_zelfde_soort[pos[1][num1]]+rechts_kleiner_andere_soort[pos[1][num1]][num0];
        ans=his_pos-targ_pos+calc(num0, num1+1);
        his_pos=pos[0][num0]+rechts_kleiner_zelfde_soort[pos[0][num0]]+rechts_kleiner_andere_soort[pos[0][num0]][num1];
        ans=min(ans, his_pos-targ_pos+calc(num0+1, num1));
        return dp[num0][num1]=ans;
    }
}

int main()
{
    //freopen("inp.in", "r", stdin);
    for(int i=0; i<MAX_N; i++)
    {
        for(int j=0; j<MAX_N; j++)
        {
            dp[i][j]=-1;
        }
    }
    scanf("%d", &n);
    complete_array.assign(2*n, make_pair(-1, -1));
    vector<int> emp(n);
    pos.assign(2,emp);
    for(int i=0; i<2*n; i++)
    {
        char ch;
        int num;
        scanf(" %c %d", &ch, &num);
        num--;
        int id=0;
        if(ch=='B') id=1;
        complete_array[i]=make_pair(id, num);
        pos[id][num]=i;
    }
    rechts_kleiner_zelfde_soort.assign(2*n,0);
    vector<int> emp2(n+5, 0);
    rechts_kleiner_andere_soort.assign(2*n, emp2);
    vector<bool> emp3(n, false);
    aanwezig.assign(2, emp3);
    for(int i=2*n-1; i>=0; i--)
    {
        for(int j=i+1; j<2*n; j++)
        {
            if(complete_array[j].first==complete_array[i].first && complete_array[j].second<complete_array[i].second)
            {
                rechts_kleiner_zelfde_soort[i]++;
            }
        }
        int teller=0;
        for(int j=0; j<n; j++)
        {
            if(aanwezig[1-complete_array[i].first][j]) teller++;
            rechts_kleiner_andere_soort[i][j+1]=teller;
        }
        aanwezig[complete_array[i].first][complete_array[i].second]=true;
    }
    printf("%d\n", calc(0, 0));
    return 0;
}


Measured memory_bytes: 47744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	int N,M;
	cin>>N>>M;
	char num[3]={'a','a','a'};
	for( int i=0; i<M; i++ )
	{
		int s,c;
		cin>>s>>c;
		s--;
		char ch = '0'+c;
		if( ( num[s]!='a' && ch!=num[s] ) || s>=N )
		{
			cout << -1 << endl;
			return 0;
		}
		num[s] = '0'+c;
	}
	for( int i=0; i<N; i++ )
	{
		char ch = num[i];
		if( 'a'==ch )
		{
			if(i==0 && N>1)
				ch = '1';
			else
				ch = '0';
		}
		if( i==0 && N>1 && '0'==ch )
		{
			cout << -1 << endl;
			return 0;
		}
		cout << ch;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(len(S)):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Measured memory_bytes: 9236
/*
 * @Author: Kaizyn
 * @Date: 2020-04-27 23:13:30
 * @LastEditTime: 2020-04-27 23:27:19
 */
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+7;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

string s;
long long dp[2][2019];

inline void solve()
{
    cin >> s;
    int n = s.size();
    long long res = 0;
    dp[0][s[0]-'0'] = 1;
    for (int i = 1; i < n; ++i) {
        memset(dp[i&1], 0, sizeof dp[i&1]);
        for (int j = 0; j < 2019; ++j) {
            dp[i&1][(j*10+s[i]-'0')%2019] += dp[~i&1][j];
        }
        ++dp[i&1][s[i]-'0'];
        #ifdef DEBUG
        if (dp[i&1][0]) cout << i << endl;
        #endif
        res += dp[i&1][0];
    }
    cout << res << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3824
import sys
input = sys.stdin.readline
s = list(input())
t = list(input())

snum = [(0,0)] #snum[j]-snum[i-1]:i-j文字目に含まれる(A,B)の数
for i in range(len(s)):
    if s[i] == 'A':
        snum.append((snum[-1][0]+1,snum[-1][1]))
    else:
        snum.append((snum[-1][0],snum[-1][1]+1))

tnum = [(0,0)]
for i in range(len(t)):
    if t[i] == 'A':
        tnum.append((tnum[-1][0]+1,tnum[-1][1]))
    else:
        tnum.append((tnum[-1][0],tnum[-1][1]+1))

q = int(input())
for i in range(q):
    a,b,c,d = map(int,input().split())
    sa = snum[b][0]-snum[a-1][0]
    sb = snum[b][1]-snum[a-1][1]
    ta = tnum[d][0]-tnum[c-1][0]
    tb = tnum[d][1]-tnum[c-1][1]
    
    #全てbにする
    b1 = sb+sa*2
    b2 = tb+ta*2
    if abs(b2-b1)%3==0:
        print('YES')
        continue
    
    
    print('NO')


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

using namespace std;

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

    vector<string> S(n);

    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        S.at(i) = s;

    }

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

    long cnt = 1,ans=0;
    for(int i=1; i<n; i++){
        if(S.at(i) == S.at(i-1) ){
            cnt++;
            if(i == n-1){
                ans += cnt*(cnt-1)/2 ;
                cnt = 1;
            }
        }else{
            ans += cnt*(cnt-1)/2 ;
            cnt = 1;
        }        
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
const int Maxn=2e5+5;
const int Maxa=1e6+5;
int a[Maxn];
int mp[Maxa],cnt[Maxa];
int main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
//	rep(i,n)cout<<a[i]<<' ';cout<<endl;
	rep(i,n){
		cnt[a[i]]++;
		mp[a[i]]++;
	}
	rep(i,n){
		if(cnt[a[i]]==1){
			mp[a[i]]=0;
		}
	}
	int ans=n;
	rep(i,n){
		for(int j=1;j*j<=a[i];j++){
			if(a[i]%j==0){
				int x=j,y=a[i]/j;
				if(mp[x]||mp[y]){
					ans--;
//					cout<<i<<endl;
					break;
				}
			}
		}
		mp[a[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12176
s=input()
res=[]
for x in set(s):
    t=s
    while(len(set(t))>1):
        y=""
        for i in range(len(t)-1):
            if t[i]==x:
                y+=x
            elif t[i+1]==x:
                y+=x
            else:
                y+=t[i]
        t=y
    res.append(len(t))
print(len(s)-max(res))

Measured memory_bytes: 41580
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main() {
    string s;
    cin >> s;
    if(s[0]=='9'||s[1]=='9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
 


Measured memory_bytes: 256
import sys

array = list(map(int, input().strip().split(' ')))

A = array[0]
B = array[1]
K = array[2]

#print(A)
#print(B)
#print(K)

if A < 1:
    sys.exit()
if A > 10**9:
    sys.exit()

#print("Aok")


if B < 1:
    sys.exit()
if B > 10**9:
    sys.exit()

#print("Bok")


if K < 1:
    sys.exit()
if K > 100:
    sys.exit()


#print("Kok")

#print(K)

#i = 0

kaisu = 0 

for i in range(K):

    #print("i",i)

    kaisu = kaisu + 1
    
    if kaisu % 2 ==1:

        if A % 2 == 1:
        #kisu
        #print("A kisu")
            A = A - 1

        work_a = int(A / 2)
    
        A = A - work_a

        B = B + work_a

        
    elif kaisu % 2 ==0:
    
        if B % 2 == 1:
            #kisu
            #print("B kisu")
            B = B - 1
     
        work_b = int(B / 2)

        #print("work_b",work_b)

    
        A = A + work_b

        B = B - work_b
    
            #print("roop_e")
    

print(A,end='')
print(' ',end='')
print(B,end='')



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000

int main() {
  vector<bool> isPrime(MAX, true);
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i * i < MAX; i++) {
    if (isPrime[i]) {
      for (int j = 2; i * j < MAX; j++) {
        isPrime[i * j] = false;
      }
    }
  }
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i <= n; i++) {
      if (isPrime[i]) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)

signed main(){
    int N;
    string S;

    cin>>N>>S;

    if(N>=S.size()) cout<<S<<endl;
    else{
        for(int i=0;i<N;i++){
            cout<<S[i];
        }
        cout<<"..."<<endl;
    }
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    vector<ll> a(n);rep(i,n) {cin>>a[i];}
    ll z_cur = 0;
    ll res = 0;
    if(a[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    repr(i, 1, n) {
        if (a[i] == 0) {
            z_cur = i;
        }else if(i - z_cur < a[i] || a[i-1] + 1 < a[i]) {
            cout << -1 << endl;
            return 0;
        }else if(a[i] == a[i-1] + 1) {
            res++;
        }else {
            res += a[i];
        }
    }
    cout << res <<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int findThefn(int n){
    int count=0;

    for(int i=1;i<=int(sqrt(n));i++){
        for(int j=1;j<=n-i*i;j++){
            if(i*i+j*j+i*j > n)
                break;
            for(int k=1;k<=n-(i*i+j*j+i*j);k++){
                if(i*i+j*j+k*k+i*j+i*k+k*j > n){
                    break;
                }
                if(i*i+j*j+k*k+i*j+i*k+k*j == n){
                    count++;
                }
            }
        }
    }

    return count;
}
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cout<<findThefn(i)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3092