akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;


int main(){
  while(true){
    char s[4001],t[4001];
    int l,r,ans = 0;
    static int dp[4001][4001];
    if(scanf("%s %s",s,t)==EOF) return 0;
    l = strlen(s), r = strlen(t);
    for(int i=0;i<=l;i++){
      for(int j=0;j<=r;j++){
        if(i==0||j==0) dp[i][j] = 0;
        else if(s[i-1]==t[j-1]){
          dp[i][j] = dp[i-1][j-1] + 1;
          ans = max(ans,dp[i][j]);
        }else{
          dp[i][j] = 0;
        }
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 65200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int i=1;
  while(i*2<=n){
    i*=2;
  }
  cout<<i<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void) {
	int n;
	double q, x, diff;

	while (1) {
		scanf("%d ", &n);
		if (n == -1)
			break;

		q = (double)n;
		x = q / 2.0;
		diff = q * 0.00001;
		while (1) {
			x = x - (pow(x, 3.0) - q) / (3.0 * x * x);
			if (fabs(pow(x, 3.0) - q) < diff)
				break;
		}
		printf("%.6lf\n", x);
	}
	return 0;
}

Measured memory_bytes: 716
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N;
ll A[200000];

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];

    if(A[0]>0){
        cout<<-1<<endl;
        return 0;
    }
    repn(i,N-1){
        if(A[i]>A[i-1]+1){
            cout<<-1<<endl;
            return 0;
        }
    }

    ll ans=0;
    repn(i,N-1){
        if(A[i]==A[i-1]+1){
            ans++;
        }else{
            ans+=A[i];
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 1792
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(I, LIM) for (int I = 0; I < (LIM); I++)
#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;

constexpr int MOD = 10000007;
constexpr long INF = LONG_MAX;

vector<long> divisor(long n) {
  vector<long> head, tail;
  for (long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      head.push_back(i);
      if (i * i != n)
        tail.push_back(n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return (head);
}

struct init {
  init() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // cout<<fixed<<setprecision(20);
  }
} init;

/*----------------------------*/

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

  vector<long> l(n);
  REP(i,n)cin>>l[i];

  int ans=0;

  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        vector<int> list(3);
        list[0]=l[i];
        list[1]=l[j];
        list[2]=l[k];
        sort(ALL(list));
        if(list[0] != list[1] and list[1] != list[2]){
          if(list[0]+list[1] > list[2]){
            ans++;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}


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

int main(){
	int tri[4] = {0,0,0,0},a[3];
	while(1){
		scanf("%d %d %d",&a[0],&a[1],&a[2]);
		sort(a,a + 3);
		if(a[0] + a[1] > a[2]){
			tri[0]++;
			if(a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) tri[1]++;
			else if(a[0] * a[0] + a[1] * a[1] > a[2] * a[2]) tri[2]++;
			else if(a[0] * a[0] + a[1] * a[1] < a[2] * a[2]) tri[3]++;
		}else {
			printf("%d %d %d %d\n",tri[0],tri[1],tri[2],tri[3]);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll N,K;
	cin>>N>>K;
	ll h[N];
	for(ll i=0;i<N;i++)
		cin>>h[i];
	ll ans=0;
	ll dp[N];
	dp[0]=0;
	for(ll i=1;i<N;i++)
	{
		dp[i]=1e16;
		for(ll j=1;j<=K and i-j>=0;j++)
		dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
	}
	cout<<dp[N-1];
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {

  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  while(a > 0 && c > 0) {
    c -= b;
    if(c <= 0) break;
    a -= d;
  }
  printf(a > c ? "Yes" : "No");
  puts("");
  
  return 0;
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    int i = n/111;
    if(n%111==0){
        cout << n << endl;
        return 0;
    } else if(n%111!=0){
        i++;
    }
    cout << i*111 << endl;
    
}


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

int main(){

    int N,M;
    cin >> N >> M;

    int height[N];
    int check[N];
    for(int i = 1; i <= N; i++){
        cin >> height[i];
        check[i] = 1;
    }

    int left,right;
    for(int i = 0; i < M; i++){
        cin >> left >> right;

        if(height[left] > height[right]){
            check[right] = 0;
        }else if(height[left] < height[right]){
            check[left] = 0;
        }else
        {
            check[left] = check[right] = 0;
        }
        
    }

    int count = 0;
    for(int i = 1; i <= N; i++ ){
        //cout << check[i];
        if(check[i] != 0) count++;
    }

    //cout << endl;

    cout << count << endl;

}

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

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

    int n;

    cin >> n;
    int a = (n / 1000);
    int b = (n % 1000) / 100;
    int c = (n % 100) / 10;
    int d = (n % 10) / 1;
    if ((b == c) && (a == b || c == d)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import product

A = int(input())
B = int(input())
C = int(input())
X = int(input())

n = 0
for i, j, k in product(range(A + 1), range(B + 1), range(C + 1)):
    ans = 500 * i + 100 * j + 50 * k
    if X == ans:
        n += 1
print(n)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

bool f[20][20] = {false};
ll dp[20][20] = {0};

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(a, b);
    if(!(a | b))break;
    rep(i, a)rep(j, b){
      f[i][j] = true;
      dp[i][j] = 0;
    }
    int(n);
    rep(i, n){
      int2(x, y);
      --x; --y;
      f[x][y] = false;
    }

    dp[0][0] = 1;
    rep(i, a)rep(j, b)if(f[i][j]){
      if(i - 1 >= 0)dp[i][j] += dp[i - 1][j];
      if(j - 1 >= 0)dp[i][j] += dp[i][j - 1];
    }

    pri(dp[a - 1][b - 1]);


//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    int n;
    int ans = 0,k;
    cin >> n;
    rep(i,n){
        cin >> k;
        ans += k;
    }
    PRINT(ans-n);
}


Measured memory_bytes: 256
//#include <iostream>
//#include <vector>
//#include <set>
//#include <map>
//#include <algorithm>

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 998244353;
const ll len = 2 * (int) 1e5 + 1;

ll n, m, l;
ll from, to, cost, tmp;

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

    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        a[tmp - 1]++;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    while (a.back() == 0) {
        a.pop_back();
    }

    reverse(a.begin(), a.end());
    vector<int> ps(a.size(), 0);
    ps[0] = a[0];

    for (int i = 1; i < a.size(); i++) {
        ps[i] = ps[i - 1] + a[i];
    }
    int need = n;

    for (int i = 0; i < n; i++) {
        while (true) {
            int l = 0, r = a.size() - 1, mid;
            while (l < r) {
                mid = (l + r) / 2;
                if (a[mid] < need) {
                    l = mid + 1;
                } else {
                    r = mid;
                }
            }
//            cout << need << " bin " << l << endl;
            ll sum = 0;
            if (a[r] >= need && r > 0) {
                sum += ps[r - 1];
            } else {
                if (a[r] < need && r > 0) {
                    sum += ps[r];
                }
            }
            if (a[r] >= need) {
                sum += (a.size() - r) * need;
            }
//            cout << "sum" << sum << endl;
            if (sum < (i + 1) * need) {
                need--;
            } else {
                break;
            }
        }
        cout << need << "\n";
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Y;
  cin>>N>>Y;
 
  bool flag=false;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=(N-i);j++)
      if(10000*i+5000*j+1000*(N-i-j)==Y)
      {flag=true; cout << i << " " << j << " " << (N-i-j) << endl; break;}
    if(flag)break;
   }
  if(!flag)cout<<"-1 -1 -1"<<endl;
}



Measured memory_bytes: 256
n, h = map(int, input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i], b[i] = map(int, input().split())

a.sort(reverse=True)
b.sort(reverse=True)
ans = 0
while True:
    if h <= 0:
        break
    if len(b) != 0 and b[0] > a[0]:
        c = b.pop(0)
        h -= c
        ans += 1
    else:
        ans += h // a[0]
        if h%a[0] != 0:
            ans += 1
        break

print(ans)

Measured memory_bytes: 11312
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    string a,b,c;cin>>a>>b>>c;string ans=a[a.size()-1] == b[0]&&b[b.size()-1] == c[0]?"YES":"NO";cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  cout<<fixed<<setprecision(10);
  llong num=0;
  int N;
  cin >> N;
  vector<llong> A(N+1);
  vector<llong> B(N);
  for(int i=0; i<N+1; ++i) cin >>A[i];
  for(int i=0; i<N; ++i) cin >> B[i];
  for(int i=N-1; i>=0; --i){
    if(A[i+1]>B[i]){
      num += B[i];
    } else if(B[i]>=A[i]+A[i+1]){
      num += A[i] + A[i+1];
      A[i] = 0;
    } else {
      num += B[i];
      A[i] -= B[i] - A[i+1];
    }
  }
  cout << num << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<ll>());

    priority_queue<ll> que;
    que.push(a[0]);

    ll ans = 0;
    for(ll i=1; i<n; i++){
        auto fr = que.top();
        que.pop();
        ans += fr;
        que.push(a[i]);
        que.push(a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6904
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    long A[] =new long[N];
    for(int i=0;i<N;i++){
      A[i]=sc.nextLong();}
    Arrays.sort(A);
    for(int j=1;j<N;j++){
      if(A[j]==A[j-1]){System.out.println("NO");System.exit(0);}}
    System.out.println("YES");
  }
}

Measured memory_bytes: 60676
a = int(input())
x = list(map(int, input().split()))

x.sort()
x = x[::-1]
k = []
t = x[0]
for i in range(1,a):
    if t == x[i]:
        k.append(x[i])
        t = 0
    else:t = x[i]
if len(k)>=2:
    print(k[0]*k[1])
else:print(0)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dist[1100][1100];
const int INF = 1001001001;
signed main(){
    int n,m;cin >> n >> m;
    rep(i,110)rep(j,110)dist[i][j] = INF;
    int a[m],b[m],c[m];
    rep(i,n)dist[i][i] = 0;
    rep(i,m){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;b[i]--;
        dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
    }
    rep(i,n)rep(j,n)rep(k,n)dist[j][k] = min(dist[j][k],dist[j][i] + dist[i][k]);

    int ret = 0;
    //rep(i,n)rep(j,n)trace(i,j,dist[i][j]);
    rep(edge,m){
        bool found = false;
        rep(i,n)rep(j,n){
            //i - j kの辺
            int u = a[edge],v = b[edge],d = c[edge];
            if(dist[i][u] + d +dist[v][j] == dist[i][j]){
                found = true;
                break;
            }
        }
        ret += !found;

    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 4172
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  vector<vector<int>> c(3,vector<int>(3) );
  for(int i=0;i<3;i++){
    for(int k=0;k<3;k++){
      cin>>c[i][k];
    }
  }
  int a0,a1,a2,b0,b1,b2;
  bool ans=true;
  for(int a0=0;a0<=c[0][0];a0++){
    b0=c[0][0]-a0;
    b1=c[0][1]-a0;
    b2=c[0][2]-a0;
    a1=c[1][0]-b0;
    a2=c[2][0]-b0;
    if(ans){
      if(c[1][1]!=a1+b1)ans=false;
      if(c[1][2]!=a1+b2)ans=false;
      if(c[2][1]!=a2+b1)ans=false;
      if(c[2][2]!=a2+b2)ans=false;
    }
    if(ans)break;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

int main()
{
  string a,b;
  cin>>a>>b;
  int num=0;
  for(int i = 0;i<a.length();i++){
      if(a[i]!=b[i]){
          num++;
      }
  }
  cout<<num<<endl;
  return 0; 
}

Measured memory_bytes: 3852
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int N, T;
int a[MAX];

int main() {
	cin >> N >> T;
	rep(i, N) cin >> a[i];
	int min_a = INT_MAX;
	int maxDiff = 0;
	int maxDiffCnt = 0;
	rep(i, N) {
		int diff = a[i] - min_a;
		if (diff == maxDiff) maxDiffCnt++;
		if (diff > maxDiff) {
			maxDiff = diff;
			maxDiffCnt = 1;
		}
		if (a[i] < min_a) min_a = a[i];
	}
	cout << maxDiffCnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

// #define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void)
{
  int num;
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<int> b(n);
  for (int i = 0; i < n; ++i) cin >> b[i];
  vector<int> c(n - 1);
  for (int i = 0; i < n - 1; ++i) cin >> c[i];

  num = 0;

  for (int i = 0; i < n; ++i) {
    num += b[a[i] - 1];
    if (i != n -1 && a[i] + 1 == a[i + 1]) num += c[a[i] - 1];
  }

  cout << num << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long int;
using namespace std;

int main() {
    fastio;
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
        cout << "Yay!";
    else
        cout << ":(";
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int n,k;
  cin>>n>>k;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];

  for(int i=0;i<n - k;i++){
    if(a[i]<a[i+k]){
      cout<<"Yes\n";
    }else{
      cout<<"No\n";
    }
  }

  return 0;
}


Measured memory_bytes: 4836
y,m,d=[int(i) for i in input().split('/')]
if y<2019:
    print('Heisei')
elif 2019<y:
    print('TBD')
else:
    if m<4:
        print('Heisei')
    elif 4<m:
        print('TBD')
    else:
        if d<=30:
            print('Heisei')
        else:
            print('TBD')


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

int main(int argc, char *argv[]) {
  int h,w,n,answer;
  cin >> h >> w >> n;
  int big;
  if(h>w){
    big = h;
  }else{
    big = w;
  }
  
  if(n % big == 0){
    answer = n/big;
  }else{
    answer = n/big + 1;
  }
  
  cout << answer << endl;
  
}

Measured memory_bytes: 256
def near(x, X):
    i = bisect_left(X, x)
    if i == 0: return [X[i]-x]
    elif i == len(X): return [X[i-1]-x]
    else: return [X[i]-x, X[i-1]-x]
import sys
input = sys.stdin.readline
from bisect import *
from itertools import product
A, B, Q = map(int, input().split())
S, T = [], []
for _ in range(A):
    S.append(int(input()))
for _ in range(B):
    T.append(int(input()))
for _ in range(Q):
    res = 1<<40
    x = int(input())
    for a, b in product(near(x,S), near(x,T)):
            res = min(abs(a)+abs(a-b), abs(b)+abs(b-a), res)
    print(res)

Measured memory_bytes: 80356
#include<stdio.h>

int main(void){
  int h,n,i;
  int a[100008];
  scanf("%d %d\n",&h,&n );
  for(i=0; i<n; i++){
    scanf("%d",&a[i] );
    h -= a[i];
  }
  if(h > 0){
    printf("No");
  }else{
    printf("Yes");
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	rep(i,m){
		if(n%2==0){
			puta(i+1,(i+1>((m+1)/2)?n-i-1:n-i));
		}
		else{
			puta(i+1,n-i-1);
		}
	}
}


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

using namespace std;
typedef long long ll;
typedef double db;
#define inf 0x3f3f3f3f
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main() {
	int a, b, c, i;
	cin >> a >> b >> c;
	int ans = 0;
	for (i = a; i <= b; ++i) {
		if (i % c == 0)++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
#define mp(x,y) make_pair((x),(y))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=1e5+5,inf=0x3f3f3f3f;
int n,s,t,head[N<<1],num=1;
struct edge{int to,flo,next;} e[N*10];
inline void add(int u,int v){
    e[++num]=(edge){v,1,head[u]},head[u]=num;
    e[++num]=(edge){u,0,head[v]},head[v]=num;
}

int dis[N<<1];
bool bfs(){
    queue<int> q;
    memset(dis,0,sizeof dis);
    q.push(s),dis[s]=1;
    while(!q.empty()){
	int u=q.front();q.pop();
	for(int i=head[u];i;i=e[i].next){
	    int v=e[i].to;if(dis[v]||!e[i].flo)continue;
	    dis[v]=dis[u]+1,q.push(v);
	}
    }
    return dis[t];
}
int dfs(int u,int lim){
    if(u==t||!lim)return lim;
    int flow=0;
    for(int i=head[u];i;i=e[i].next){
	int v=e[i].to;if(dis[v]!=dis[u]+1||!e[i].flo)continue;
	int f=dfs(v,min(lim,e[i].flo));
	e[i].flo-=f,e[i^1].flo+=f;
	lim-=f,flow+=f;
	if(!lim)break;
    }
    return flow;
}
int Netflow(){
    int ans=0;
    while(bfs())ans+=dfs(s,inf);
    return ans;
}

int fa[N<<1],vis[N<<1],cnt;
pii ans[N];
void serch(int u,int pa){
    cnt+=u<=n,vis[u]=1,fa[u]=pa;
    for(int i=head[u];i;i=e[i].next){
	int v=e[i].to;if(vis[v]||!e[i].flo)continue;
	serch(v,u);
    }
}

int main(){
    //freopen("in.in","r",stdin);
    n=read();s=n+n,t=s+1;
    REP(i,1,n)add(s,i);
    REP(i,1,n-1)add(n+i,t);
    REP(i,1,n-1)REP(c,1,read()){int u=read();add(u,n+i);}
    if(Netflow()<n-1)return puts("-1"),0;
    int rt=0;
    for(int i=head[s];i;i=e[i].next)if(e[i].flo){rt=e[i].to;break;}
    serch(rt,0);
    if(cnt<n)return puts("-1"),0;
    REP(i,1,n)if(i!=rt){
	int id=fa[i],p=fa[id];
	ans[id-n]=mp(p,i);
    }
    REP(i,1,n-1)printf("%d %d\n",ans[i].first,ans[i].second);
    return 0;
}


Measured memory_bytes: 22852
i = 0 # 亀の数
x,y = gets.chomp.split.map(&:to_i)
z = 0
for i in 0..x
    if (y - 2*i - 2*x) == 0
        z = 1
    end
end

if z == 1
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 14300
#include <iostream>
#include <stdio.h>
using namespace std;
int p[10000002];
int main() {
	int i,j,n;
	for (i=3;i<3163;i+=2) {
		if (p[i]==0) {for (j=i*3;j<10000001;j=j+i*2) p[j]=1;}
	}
	while(cin >> n && n>0) {
		if (n % 2==0) n--;
		for (;n>=13;n-=2) if (p[n]+p[n-2]+p[n-6]+p[n-8]==0) { cout << n << endl; break;}
	}
	return 0;
}  

Measured memory_bytes: 40220
n,m,x=map(int,input().split())
b=[list(map(int,input().split())) for _ in range(n)]
ans = 100000000
for i in range(1<<n):
    money = 0
    s=[0]*m
    for j in range(n):
        if(i>>j)&1:
            money +=b[j][0]
            for k in range(1,m+1):
                s[k-1]+=b[j][k]
    if min(s)>=x:
        ans=min(ans,money)
if ans != 100000000:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 68796
import sys 
fin = sys.stdin.readline

N, M, Q = [int(elem) for elem in fin().split()]
trains = [[int(elem) - 1 for elem in fin().split()] for _ in range(M)]
queries = [[int(elem) - 1 for elem in fin().split()] for _ in range(Q)]

map_2D = [[0] * N for _ in range(N)]
for l, r in trains:
    map_2D[l][r] += 1

cuml_1D = [[0] * N for _ in range(N)]
# vertical
for j in range(N):
    cuml_sum = 0
    for i in reversed(range(j + 1)):
        cuml_sum += map_2D[i][j]
        cuml_1D[i][j] = cuml_sum

cuml_2D = [[0] * N for _ in range(N)]
# horizontal
for i in range(N):
    cuml_sum = 0
    for j in range(N):
        cuml_sum += cuml_1D[i][j]
        cuml_2D[i][j] = cuml_sum

for p, q in queries:
    print(cuml_2D[p][q])


Measured memory_bytes: 60332
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<int>num(N + 1);
	vector<int>ans(N*N + 1);
	queue<int>mae;
	stack<int>ushiro;
	for (int i = 1; i <= N; i++) {
		cin >> num[i];
		ans[num[i]] = i;
	}
	for (int i = 1; i <= N*N; i++) {
		if (ans[i]) {
			for (int j = 1; j < ans[i]; j++) {
				mae.push(ans[i]);
			}
			for (int j = ans[i] ; j < N; j++) {
				ushiro.push(ans[i]);
			}
		}
	}
	for (int i = 1; i <= N*N; i++) {
		if (mae.empty())break;
		if (!ans[i]) {
			ans[i] = mae.front();
			mae.pop();
		}
	}
	for (int i = N*N; i >= 1; i--) {
		if (ushiro.empty())break;
		if (!ans[i]) {
			ans[i] = ushiro.top();
			ushiro.pop();
		}
	}
	for (int i = 1; i <= N; i++) {
		int order = 0;
		for (int j = 1; j <= num[i]; j++) {
			if (ans[j] == i) {
				order++;
			}
		}
		if (order != i) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for (int i = 1; i <= N*N; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3200
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int k, a, b;
  cin >> k >> a >> b;
  ll d = a / k;
  ll x = k * d;
  if (x < a) {
    x += k;
  }
  cout << (x <= b ? "OK" : "NG") << endl;

  return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

long min(long o, long t);
long max(long o, long t);


int main() {
    long n, k;
    long power[200000];
    long temp[200000 + 1];

    scanf("%ld %ld", &n, &k);

    for (long i = 0; i < n; i++){
        scanf("%ld", &power[i]);
    }

    long total = 0, preTotal = 0;
    for (long i = 0; i < k; i++) {
        for (long j = 0; j < n + 1; j++) {
            temp[j] = 0;
        }
        for (long j = 0; j < n; j++) {
            long s = max(0, j - power[j]);
            long e = min (n + 1, j + power[j] + 1);
            temp[s]++;
            temp[e]--;
        }

        long v = 0;
        for (long j = 0; j < n; j++) {
            power[j] = v + temp[j];
            v = power[j];
        }
        
        total = 0;
        for (long j = 0; j < n; j++) {
            total += power[j];
        }
        if (total == preTotal) {
            break;
        }
        preTotal = total;
    }

    for (long i = 0; i < n; i++) {
        if (i != 0) {
            printf(" ");
        }

        printf("%ld", power[i]);
    }
}

long min(long o, long t) {
    if (o < t) {
        return o;
    }
    return t;
}

long max(long o, long t) {
    if (o < t) {
        return t;
    }
    return o;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
int sum(int n) {
	int res = 0;
	while (n) {
		res += (n%10);
		n /= 10;
	}
	return res;
}
int main() {
	int n = 0;
	cin >> n;	
	int t = sum(n);
	cout << (( n % t ==0) ? "Yes" : "No");
}


Measured memory_bytes: 256
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  S = input()[:-1]

  pre = S[0]
  cnt = 1
  for i in range(1, N):
    if pre == S[i]:
      pre = S[i]
      continue
    cnt += 1
    pre = S[i]
  print(cnt)


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


Measured memory_bytes: 84920
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 300010
#define S 100000
int prime[N], snum = 325, pnum;
bool p[N];
void EulerSieve(int n) {
    for (int i = 2; i <= n; i++) {
        if (!p[i]) prime[++pnum] = i;
        for (int j = 1; j <= pnum; j++) {
            if (i * prime[j] > n) break;
            p[i * prime[j]] = true;
            if (i % prime[j] == 0) break;
        }
    }
}
ll s[N], a[N];
int n, len[N], k[N], num[N];
int id[N], ans;
bool cmp(int x, int y) { return a[x] < a[y]; }
int main() {
    EulerSieve(S);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &s[i]);
        k[i] = len[i] = 0, a[i] = 1;
        for (int j = 1; j <= snum; j++) {
            if (s[i] % prime[j]) continue;
            int m = 0;
            while (s[i] % prime[j] == 0) s[i] /= prime[j], m++;
            if (m %= 3) k[i] |= ((m & 1) << len[i]), len[i]++, a[i] *= prime[j];
        }
        if (s[i] > 1) {
            if (s[i] < S)
                k[i] |= (1 << len[i]), len[i]++, a[i] *= s[i];
            else {
                ll ss = sqrt(s[i]);
                if (ss * ss != s[i])
                    ans++, i--, n--;
                else
                    len[i]++, a[i] *= ss;
            }
        }
    }
    for (int i = 1; i <= n; i++) id[i] = i;
    sort(id + 1, id + n + 1, cmp);
    for (int l = 1, r = 1; l <= n; l = r + 1, r = l) {
        while (r < n && a[id[r]] == a[id[r + 1]]) r++;
        if (a[id[l]] == 1) {
            ans++;
            continue;
        }
        int maxn = (1 << len[id[l]]) - 1;
        for (int i = l; i <= r; i++) num[k[id[i]]]++;
        for (int i = l; i <= r; i++) {
            int x = k[id[i]], y = (maxn ^ k[id[i]]);
            if (num[x] >= num[y]) ans += num[x], num[x] = num[y] = 0;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <vector>
using namespace std;
void solve(int n){
	vector<vector<int> > t(n, vector<int>(n+1,0));
	for(int k=0; k<n; ++k)for(int c=0; c<=n; ++c)	cin >> t[k][c];
	vector<int> dp((1<<n), (1<<29));
	dp[0]=0;
	for(int i=0; i<(1<<n); ++i){
		for(int to=0; to<n; ++to)if((to&(1<<to))==0){
			int tmp=t[to][0];
			for(int use=1; use<=n; ++use)if((i&(1<<(use-1)))>0)	tmp=min(tmp, t[to][use]);
			dp[i|(1<<to)]=min(dp[i|(1<<to)], dp[i]+tmp);
		}
	}
	cout << dp[(1<<n)-1] << endl;
}
int main(){
	int n;
	while(cin >> n, n)	solve(n);
	return 0;
}

Measured memory_bytes: 1476
import numpy as np
import math
[A,B] = input().split()
# A = "1000000000000001"
# B = "9.09"
c = 0
if '.' in B:
    c = int(B.find('.'))
c = len(B)-c-1
B = B.replace(".","")
A = np.int64(A)
B = np.int64(B)
C = A*B
if c == 0 or C <=100:
    print(math.floor(C/int(10**c)))
elif c == 1:
    print(str(C)[:-1])
elif c == 2:
    print(str(C)[:-2])
# C = C/int(10**c)
# print(C)
# print(math.floor(C))
# print(9990000000000000)

Measured memory_bytes: 27120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner sc = new Scanner(System.in)) {
			String S = sc.nextLine();
			String ans  = "s";
			if (S.endsWith("s")) {
				ans = "es";
			}

           System.out.println(S.concat(ans));

		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}

Measured memory_bytes: 35652
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;

typedef pair<int,int> p;

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

int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  REP(i,h) REP(j,w) cin >> s[i][j];
  bool visited[h][w];
  fill(visited[0],visited[h],false);
  ll ans = 0;
  REP(i,h){
    REP(j,w){
      if(visited[i][j]) continue;
      queue<p> que;
      que.push(p(i,j));
      ll black_cnt = 0, white_cnt = 0;
      visited[i][j] = true;
      while(!que.empty()){
        int y = que.front().first;
        int x = que.front().second;
        //cout << y << " " << x << endl;
        bool isblack = (s[y][x]=='#') ? true : false;
        if(isblack){
          black_cnt++;
        }else{
          white_cnt++;
        }
        que.pop();
        //visited[y][x] = true;
        REP(k,4){
          int nx = x + dx[k], ny = y + dy[k];
          if(nx<0||nx>=w||ny<0||ny>=h) continue;
          if(!visited[ny][nx]&&((!isblack&&s[ny][nx]=='#')||(isblack&&s[ny][nx]=='.'))){
            visited[ny][nx] = true;
            que.push(p(ny,nx));
          }
        }
      }
      ans += black_cnt*white_cnt;
      //cout << i << " " <<  j << " " << black_cnt << " " << white_cnt << endl;;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u'|| c == 'e' || c == 'o'){
         cout << "vowel" << endl;}
    else { cout << "consonant" << endl;}
    return 0;
}
    

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

typedef long long ll;

int main() {

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

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

    ll m = 0;
    cin >> m;

    vector<ll> v(1e6 + 5, 0);
    ll n = m;
    while(n % 2 == 0) {
        n = n/2;
        v[2]++;
    }

    for(int i = 3; i < sqrt(m); i+= 2) {
        while(n % i == 0) {
            n = n /i;
            v[i]++;
        }
    }

    // for(int i = 0; i < 5; i++) {
    //     cout << v[i] << " ";
    // }
    // cout << endl;


    ll ans = 0; 
    for(int i = 0; i < v.size(); i++) {
        if(v[i] != 0) {
            int temp = 1;
            while(v[i] - temp >= 0) {
                v[i] -= temp;
                temp++;
                ans++;
            }
        }
    }
    
    if(n > 2) ans++;

    cout << ans << endl;


    
    return 0;
}

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

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

    int sum = 0;
    for(int X=K; X>=0; X--){
        for(int Y=K; Y>=0; Y--){
            int Z = S - X - Y;
            if(0 <= Z and Z <= K) sum++;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3608
# dp array
import sys
input = sys.stdin.readline
def main():
    R, G, B, N = map(int, input().split())
    r_count = N // R
    g_count = N // G
    ans = 0
    for i in range(r_count+1):
        for j in range(g_count+1):
            k = N - R * i - G * j
            if k % B == 0 and k >= 0:
                ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 40684
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int initialN = n;
		int x = 0;
		while(n % 10 != 0) {
			x += n % 10;
			n /= 10;
		}
		if(initialN % x == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		
		
	}
}



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

int main() {
	int N, M;
	cin >> N >> M;
	long long int ans = LLONG_MIN / 6;
	long long int now;
	cin >> ans;
	now = ans;
	ans--;
	for( size_t i = 1; i < M; i++ ) {
		long long int a;
		cin >> a;
		ans = max( (a - now) / 2, ans );
		now = a;
	}
	ans = max( N - now, ans );
	cout << ans << endl;
}

Measured memory_bytes: 3112
import numpy as np
[N,W]=[int(x) for x in input().split()]
dp=np.zeros([N+1,W+1],dtype=int)
for i in range(1,N+1):
  w, v=map(int,input().split())
  dp[i][:w]=dp[i-1][:w]
  dp[i][w:]=np.maximum(dp[i-1][w:],dp[i-1][:W-w+1]+v)
print(dp[N][W])

Measured memory_bytes: 106152
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int x=0,fh=1; char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') fh=-1;
	for (;isdigit(ch);ch=getchar()) x=x*10+(ch^48);
	return x*fh;
}
int a[51],b[51],c[51][1275][51],q[51],l[51],l0[51][1275]; bool f[51],fl[51],ff[51][1275];
long long pw[51]={1},ans;
int o,oo;
void dfs(int x,int len){
	if (x==o){
		l0[oo][++l[oo]]=(--len);
		For(i,1,len) c[oo][l[oo]][i]=q[i];
		return;
	}
	For(i,o+1,x) if (x%i>=o) q[len]=i,dfs(x%i,len+1);
}
int main(){
	int n=read(),cnt,L=0,mi,ma,ma2;
	For(i,1,50) pw[i]=pw[i-1]*2;
	For(i,1,n) a[i]=read();
	For(i,1,n) b[i]=read();
	For(i,1,n) if (a[i]!=b[i]) a[++L]=a[i],b[L]=b[i]; n=L;
	For(i,1,n) {oo=i,o=b[i],dfs(a[i],1); if (!l[i]) printf("-1\n"),exit(0);}
	cnt=n;
	while(cnt){
		ma=0;
		For(i,1,n) if (!f[i]){
			mi=51;
			For(j,1,l[i]) if (!ff[i][j]){
				ma2=0;
				For(k,1,l0[i][j]) if (!fl[c[i][j][k]]) ma2=max(c[i][j][k],ma2);
				if (!ma2) {f[i]=1; --cnt; break;} mi=min(mi,ma2);
			}
			if (!f[i]) ma=max(mi,ma);
		}
		if (!cnt) printf("%lld\n",ans),exit(0);
		ans+=pw[ma]; fl[ma]=1;
		For(i,1,n)
			For(j,1,l[i]) if (!ff[i][j])
				For(k,1,l0[i][j]) if (!fl[c[i][j][k]]&&c[i][j][k]>ma) {ff[i][j]=1; break;}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

vector<int> A,sorted;

int main(void) {
    int N;
    cin>>N;

    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        A.push_back(a);
        sorted.push_back(a);
    }

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

    for(int i = 0;i < N;i++) {
        if(A[i] == sorted[N-1]) {
            cout<<sorted[N-2]<<endl;
        } else {
            cout<<sorted[N-1]<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3436
#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
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)


using namespace std;

int counter(int x ){
    if ( x == 0) return 0;
    return counter( x >> 1) + (x & 1);
}


int main(){
    int a[20];
    int x[20][20];
    int y[20][20];
    int n;
    int ans = 0;
    cin >> n;
    rep(i , n){
        cin >> a[i];
        rep(j , a[i]) cin >> x[i][j] >> y[i][j];
    }
    // 1 == honest , 2 == unkind
    for ( int bits = 1 ; bits < (1 << n) ; bits++){
        bool ok = true;
        rep( i  , n){
            if ( ( bits >> ( i - 1) ) & 1){
                rep( j , a[i]){
                    if ( ((bits >> (x[i][j] - 1)) & 1 ) ^ y[i][j]) ok = false;
                }
            }
            
        }
        if ( ok) ans = max( ans , counter(bits));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612