akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
  int i,j,num,count=0,key;
  int pri[10000];
  double sqrtNum;
  scanf("%d",&num);
  if(num<1 || num>10000) exit(1);
  for(i=0; i < num; i++)
    {
      scanf("%d",&pri[i]);
      if(pri[i] < 2 || pri[i] > 10e8)
	exit(1);
    }
 
  for(i = 0; i < num; i++ )
    {
      key=0;
      if(pri[i]<2) key = 1;
      else if (pri[i] == 2) key =0;
      else if (pri[i]%2== 0) key =1;
      else
	{
	  sqrtNum = sqrt(pri[i]);
	  for(j =3; j <= sqrtNum; j += 2)
	    {
	      if(pri[i]%j==0)key = 1;
	    }
	}
      if(key == 0) count++;
    }
  printf("%d\n",count);

  return 0;
 
}
  




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

using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;int sum=0;
    for(int i=n;i<=m;i+=1){
        if(i%k==0){
            sum++;
        }
    }
    cout<<sum<<endl;









    return 0;
}




Measured memory_bytes: 3648
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
// #define int unsigned long long int
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int mul1 = 1003, mul2 = 5, mul3 = 8;
const int MOD3 = 179424673, MOD2 = 982451653, MOD1 = 1190494759;
const ld EPS = 1e-9;
 
#include <bits/extc++.h>
using namespace __gnu_pbds;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=10*xx+ch-'0';ch=getchar();}
    return xx*ff;
}
 
ull hasher(ull a, ull b) {
    return 14831553208299411291ull * (a ^ 16184882973064831860ull) + b;
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n;
const int LIM = 2e5+5;
string s[LIM];
gp_hash_table<ull, int> m;
 
int main(){
    fastio;
 
    cin>>n;
 
    ll ans = -n;
 
    forn(i,n){
        cin>>s[i];
        reverse(s[i].begin(), s[i].end()); 
        
        ull h1 = 0;
        forn(j,s[i].length()){
            h1 = hasher(h1, s[i][j]);
        }
        ++m[h1];
    }


    forn(i,n) {
        int num[26] = {0};
        forn(j,s[i].length()){
            ++num[s[i][j]-'a'];
        }

        ull h1 = 0;
        forn(j,s[i].length()){
            forn(k,26){
                if (num[k]) {
                    ull n1 = hasher(h1, k+'a');
                    
                    auto it = m.find(n1);
                    if (it != m.end())
                        ans += (*it).second;
                }
            }
            h1 = hasher(h1, s[i][j]);
            --num[s[i][j]-'a'];
        }
    }
 
    cout<<ans<<ln;
    return 0;
}


Measured memory_bytes: 28012
#include <bits/stdc++.h>
using namespace std;
int h,w,k;
string s;
int res;
int a[10][10];
int num1[10],num2[10];
int num;
bool xuanze1[10],xuanze2[10];


void dfs(int hang,int lie){
	//cout<<hang<<" "<<lie<<endl;
	if(hang<h){
		xuanze1[hang]=true;
		dfs(hang+1,lie);
		xuanze1[hang]=false;
		dfs(hang+1,lie);
	}
	else if(lie<w){
		xuanze2[lie]=true;
		dfs(hang,lie+1);
		xuanze2[lie]=false;
		dfs(hang,lie+1);
	} else{
		int b[10][10];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				b[i][j]=a[i][j];
			}
		}
		for(int i=0;i<h;i++)
			if(xuanze1[i])
				for(int j=0;j<w;j++)
					b[i][j]=0;
		for(int i=0;i<w;i++)
			if(xuanze2[i])
				for(int j=0;j<h;j++)
					b[j][i]=0;
		int ans=0;
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				if(b[i][j]==1){
					++ans;
				//	cout<<"1"<<endl;
				}
		if(ans==k)++res;
	}
	
}


int main(){
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		cin>>s;
		for(int j=0;j<w;j++){
			if(s[j]=='.')a[i][j]=0;
			else {
				a[i][j]=1;
				num++;
				num1[i]++;
			}
		}
	}
	for(int i=0;i<w;i++){
		for(int j=0;j<h;j++){
			if(a[j][i]==1)num2[i]++;
		}
	}
	dfs(0,0);
	cout<<res;
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

    public static long x,y;
    public static void main(String [] args) {

        Scanner sc = new Scanner(System.in);

        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();

        long maxx = Math.max(a * c, a * d);
        long maxy = Math.max(b * c, b * d);
        long ans = Math.max(maxx, maxy);

        System.out.println(ans);

    }

}


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

int main(){
  long long n,k;
  cin >> n >> k;
  long ans;
  if(n > k){
    ans = min(n%k,abs(n%k - k));
  }
  else{
    ans = min(n,abs(n - k));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-08-24 12:05:01
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 3e3 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 924844033; // 998244353; // 1e9 + 9;

ll n , k , dp[MAXN][MAXN] , dp2[MAXN] , fact[MAXN];
vector<int> vec;

int main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	fact[0] = 1;
	for(int i = 1 ; i < MAXN ; i++)	fact[i] = fact[i - 1] * i % MOD;
	for(int i = 0 ; i < MAXN ; i++){
		dp[i][0] = 1;
		dp[i][1] = i;
		for(int j = 2 ; j <= i ; j++){
			dp[i][j] = dp[i - 1][j] + dp[i - 2][j - 1];
			if(dp[i][j] >= MOD)	dp[i][j] -= MOD;
		}
	}
	cin >> n >> k;
	for(int i = 0 ; i < k ; i++){
		vec.push_back((n - i - 1) / k);
		vec.push_back((n - i - 1) / k);
	}
	dp2[0] = 1;
	for(int i : vec){
		for(int j = n ; j >= 0 ; j--){
			for(int k = 1 ; k <= i && k <= j ; k++){
				dp2[j] = (dp2[j] + dp2[j - k] * dp[i][k]) % MOD;
			}
	//		cout << j << sep << dp2[j] << endl;
		}
//		cout << "============" << endl;
	}
	ll ans = 0;
	for(int i = 0 ; i <= n ; i++){
		if(i % 2 == 0)	ans += dp2[i] * fact[n - i] % MOD;
		if(i % 2 == 1)	ans -= dp2[i] * fact[n - i] % MOD;
	}
	cout << (ans % MOD + MOD) % MOD;
	

    return 0;
}
/*

*/


Measured memory_bytes: 50076
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
	//code
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}

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


Measured memory_bytes: 3580
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())

d = {}
for i in range(n):
    s = stdin.readline().rstrip()

    if s in d:
        d[s] += 1
    else:
        d[s] = 1

d = sorted(d.items(), key=lambda x:x[1], reverse=True)

m = d[0][1]
a = []
i = 0
for i in range(len(d)):
    if d[i][1] == m:
        a.append(d[i][0])
    else:
        break

a.sort()

for aa in a:
    print(aa)

Measured memory_bytes: 47984
#include<stdio.h>
#include<math.h>
int main() 
{
	int n,ans,max,min;
	int A[100];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
		if(i==0){
			max = A[i];
			min = A[i];
		}
		else {
			if (max < A[i]) {
				max = A[i];
			}
			if (min > A[i]) {
				min = A[i];
			}
		}
	}
	ans = abs(max - min);
	printf("%d\n", ans);

	return 0;
}

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

int main(){
	long long X, Y;
	cin >> X >> Y;
	if((X-Y) % 3 == 0){
		if(X == Y) cout << "Brown" << endl;
		else cout << "Alice" << endl;
	}else{
		if(abs(X-Y) == 1) cout << "Brown" << endl;
		else cout << "Alice" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <map>
#include <vector>
//#include <utility>
//#include <numeric>
//#include <cmath>
using __int64=long long;


__int64 gcd(__int64 a,__int64 b){
  __int64 r=a%b;
  while(r!=0){
   //std::cout<<a<<" "<<b<<" "<<r<<std::endl;
   a=b;
   b=r;
   r=a%b;
  }
  return b;
}


 __int64 pow(__int64 a,__int64 b, __int64 d){
  if(b==1){
   return a%d;
  }else if(b==0){
   return 1;
  }else{
   __int64 pre=a;
   a=a%d;
   a=(a*a)%d;
   if(b%2==0){
    return pow(a,b/2,d);
   }else{
    return (pow(a,b/2,d)*pre)%d;
   }
  }
 }

/*
 long long pow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
 }

 __int64 pow3(__int64 a,__int64 b, __int64 d){
  if(b==0){
   return 1;
  }else{
   __int64 res=1;
   for(int i=0;i<b;i++){
    res*=a;
    res=res%d;
   }
   return res;
  }
 }
*/


int main(){
/*
int main(int argc, char* argv[]){

    if(argc != 2){
        std::cerr << "�����̐����Ԉ���Ă��܂��D" << std::endl;
        std::cerr << "./extraction input.txt" << std::endl;
        return 1;
    }

    // C++�̃t�@�C�����͂̂��߂̏���
    std::ifstream ifs(argv[1], std::ios::in);
    // �t�@�C�����J���̂Ɏ��s�����Ƃ��̏���
    if(!ifs){
        std::cerr << "Error: file not opened." << std::endl;
        return 1;
    }
*/

 int N;
 std::cin>>N;
 //ifs>>N;
 std::map<std::pair<__int64,__int64>,std::pair<__int64,__int64>> mp;
 __int64 d=1000000007;

 //std::cout<<pow(2,3,d)<<" "<<pow2(2,3,d)<<" "<<pow3(2,3,d)<<std::endl;

 __int64 a,b;

 __int64 zero=0;
 for(int i=0;i<N;i++){
  std::cin>>a>>b;
  //ifs>>a>>b;

  if(a==0&&b==0){
   zero++;
  }else if(a==0){
   mp[{0,1}].first++;
  }else if(b==0){
   mp[{0,1}].second++;
  }else{
   if(a<0&&b<0){
    __int64 g=gcd(-a,-b);
    mp[{(-a/g),(-b/g)}].first++;
   }else if(a<0){
    __int64 g=gcd(-a,b);
    mp[{(b/g),(-a/g)}].second++;
   }else if(b<0){
    __int64 g=gcd(a,-b);
    mp[{(-b/g),(a/g)}].second++;
   }else{
    __int64 g=gcd(a,b);
    mp[{(a/g),(b/g)}].first++;
   }
  }

 }

 //std::cout<<zero<<std::endl;
 //auto p=mp[{0,1}];
 //std::cout<<"(<"<<0<<","<<1<<">"<<","<<"<"<<p.first<<"," <<p.second <<">)"<<std::endl;

/*
 for (auto const& p : mp){
    std::cout<<"(<"<<p.first.first<<","<<p.first.second<<">"<<","<<"<"<<p.second.first<<"," <<p.second.second <<">)"<<std::endl; 
 }
*/


 __int64 ans=1;
 __int64 al=0;
 __int64 be=0;
 __int64 ga=0;
 __int64 num1=0;
 __int64 num2=0;
 for(auto p:mp){
  al=p.second.first;
  be=p.second.second;
/*
  if(al<0 || be<0){
   std::cout<<a<<" "<<b<<std::endl;
  }
*/

  ga=1;
  ga+=pow(2,al,d)-1;
  ga=ga%d;
  ga+=pow(2,be,d)-1;
  ga=ga%d;
/*
  num1=pow(2,al,d);
  num2=pow2(2,al,d);
  if(num1!=num2){
   std::cout<<"al="<<al<<" "<<"2^al%d="<<num1<<" "<<num2<<std::endl;
  }
  num1=pow(2,be,d);
  num2=pow2(2,be,d);
  if(num1!=num2){
   std::cout<<"be="<<be<<" "<<"2^be%d="<<num1<<" "<<num2<<std::endl;
  }
*/

/*
  if(ga<=0){
   std::cout<<ga<<std::endl;
  }
*/

  ans*=ga;
  ans=ans%d;
 }
 
 ans+=zero;
 ans=ans%d;
 ans--;
 if(ans<0){
  ans+=d;
 }
 std::cout<<ans<<std::endl;

}

Measured memory_bytes: 19220
// AOJ Volume 0 Problem 0041

#include <stdio.h>
#include <string.h>

int n[4], n2[4], m[4];
char op[3] = {'+', '-', '*'};

int cal(int a, int b, int op)
{
	int result;
	
	if (op == 0){
		result = m[a] + m[b];
	}
	else if (op == 1){
		result = m[a] - m[b];
	}
	else if (op == 2){
		result = m[a] * m[b];
	}

	return (result);
}


// (((a * b) * c) * d)
int ex1(int op1, int op2, int op3)
{
	memcpy(m, n2, sizeof(m));
	
	m[0] = cal(0, 1, op1);
	m[0] = cal(0, 2, op2);
	m[0] = cal(0, 3, op3);

	if (m[0] == 10){
		printf("(((%d %c %d) %c %d) %c %d)\n",
					n2[0], op[op1], n2[1], op[op2], n2[2], op[op3], n2[3]);
		return (1);
	}
	return (0);
}

// ((a * b) * (c * d))
int ex2(int op1, int op2, int op3)
{
	memcpy(m, n2, sizeof(m));

//	printf("<%d %d %d %d %d %d %d>", m[0], op1, m[1], op2, m[2], op3, m[3]);

	m[0] = cal(0, 1, op1);
	
//	printf("(%d ", m[0]);
		
	m[2] = cal(2, 3, op3);
//	printf("%d ", m[2]);
	m[0] = cal(0, 2, op2);

//	printf("(%d)", m[0]);
	
	
	if (m[0] == 10){
		
		printf("((%d %c %d) %c (%d %c %d))\n",
					n2[0], op[op1], n2[1], op[op2], n2[2], op[op3], n2[3]);
		return (1);
	}
	return (0);
}

// ((a * (b * c)) * d)
int ex3(int op1, int op2, int op3)
{
	memcpy(m, n2, sizeof(m));

	m[1] = cal(1, 2, op2);
	m[0] = cal(0, 1, op1);
	m[0] = cal(0, 3, op3);

	if (m[0] == 10){
		printf("((%d %c (%d %c %d)) %c %d)\n",
					n2[0], op[op1], n2[1], op[op2], n2[2], op[op3], n2[3]);
		return (1);
	}
	return (0);
}

// (a * ((b * c) * d))
int ex4(int op1, int op2, int op3)
{
	memcpy(m, n2, sizeof(m));

	m[1] = cal(1, 2, op2);
	m[1] = cal(1, 3, op3);
	m[0] = cal(0, 1, op1);

	if (m[0] == 10){
		printf("(%d %c ((%d %c %d) %c %d))\n",
					n2[0], op[op1], n2[1], op[op2], n2[2], op[op3], n2[3]);
		return (1);
	}
	return (0);
}

// (a * (b * (c * d)))
int ex5(int op1, int op2, int op3)
{
	memcpy(m, n2, sizeof(m));

	m[2] = cal(2, 3, op3);
	m[1] = cal(1, 2, op2);
	m[0] = cal(0, 1, op1);

	if (m[0] == 10){
		printf("(%d %c (%d %c (%d %c %d)))\n",
					n2[0], op[op1], n2[1], op[op2], n2[2], op[op3], n2[3]);
		return (1);
	}
	return (0);
}

int exp(void)
{
	int op1, op2, op3;
	int flag;

	flag = 0;
	
	for (op1 = 0; op1 <= 2; op1++){
		for (op2 = 0; op2 <= 2; op2++){
			for (op3 = 0; op3 <= 2; op3++){
				if (ex1(op1, op2, op3) == 1){
					return (1);
				}
				if (ex2(op1, op2, op3) == 1){
					return (1);
				}
				if (ex3(op1, op2, op3) == 1){
					return (1);
				}
				if (ex4(op1, op2, op3) == 1){
					return (1);
				}
				if (ex5(op1, op2, op3) == 1){
					return (1);
				}
			}
		}
	}
	return (flag);
}

int main(void)
{
	int flag;
	int i, j, k;
	
	while (1){
		scanf("%d%d%d%d", &n[0], &n[1], &n[2], &n[3]);
		if (n[0] == 0 && n[1] == 0 && n[2] == 0 && n[3] == 0){
			break;
		}
		
		flag = 0;
		for (i = 0; i <= 3; i++){
			for (j = 0; j <= 3; j++){
				for (k = 0; k <= 3; k++){
					if (i != j && i != k && j != k){
						n2[0] = n[i];
						n2[1] = n[j];
						n2[2] = n[k];
						n2[3] = n[6 - i - j - k];
						flag += exp();
						if (flag != 0){
							goto end;
						}
					}
				}
			}
		}
end:;
		if (flag == 0){
			printf("0\n");
		}
	}
	return (0);
}

Measured memory_bytes: 0
c = 3.times.map{gets.split.map(&:to_i)}
ans = true
3.times do |i|
  c[i][1] -= c[i][0]
  c[i][2] -= c[i][0]
end
for i in 1..2
  ans = false if c[0][i] != c[1][i] || c[0][i] != c[2][i]
end
puts ans ? "Yes" : "No"

Measured memory_bytes: 1788
#include <cstdio>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define INF 0x3f3f3f3f
#define mp std::make_pair
#define fi first
#define se second

typedef std::pair<int, std::pair<int, int> > pip;

const int MAXN = 2e5 + 1;

int n, a[MAXN], pos[MAXN];

__gnu_pbds::priority_queue<pip, std::greater<pip> > q;

int f[2][MAXN][30];

namespace ST_Table {
	int Log[MAXN], bin[30];
	
	void Prework() {
		Log[0] = -1;
		for (int i = 1; i <= n; ++i)
			Log[i] = Log[i >> 1] + 1;
		bin[0] = 1;
		for (int i = 1; i <= 20; ++i)
			bin[i] = bin[i - 1] << 1;

		for (int k = 0; k <= 1; ++k)
			for (int j = 1; j <= Log[n]; ++j)
				for (int i = 1; i <= n - bin[j] + 1; ++i)
					f[k][i][j] = std::min(f[k][i][j - 1], f[k][i + bin[j - 1]][j - 1]); 
	}

	inline int Qmin(int op, int l, int r) {
		int k = Log[r - l + 1];
		return std::min(f[op][l][k], f[op][r - bin[k] + 1][k]);
	}

} using namespace ST_Table;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		pos[a[i]] = i;
		f[i & 1][i][0] = a[i];
		f[i & 1 ^ 1][i][0] = INF;
	}

	Prework();
	q.push(mp(Qmin(1, 1, n), mp(1, n)));

	while (q.size()) {
		pip	Now = q.top();
		q.pop();
		int x = Now.fi, L = Now.se.fi, R = Now.se.se;
		int p1 = pos[x], p2 = pos[Qmin(pos[x] & 1 ^ 1, pos[x] + 1, R)];
		printf("%d %d ", a[p1], a[p2]);

		if (L < p1)
			q.push(mp(Qmin(L & 1, L, p1 - 1), mp(L, p1 - 1)));
		if (p1 < p2 - 1) 
			q.push(mp(Qmin(p1 + 1 & 1, p1 + 1, p2 - 1), mp(p1 + 1, p2 - 1)));
		if (p2 < R)
			q.push(mp(Qmin(p2 + 1 & 1, p2 + 1, R), mp(p2 + 1, R)));
	}

	return 0;
}

Measured memory_bytes: 52608
N,Y = [int(i) for i in input().split()]

Y = Y / 1000

flag = False
for i in range(N+1):
    for j in range(N+1-i):
        k = N - i - j
        if i * 10 + j * 5 + k == Y:
            print(i,j,k)
            flag = True
            break
    if flag:
        break

if flag == False:
    print(-1,-1,-1)


Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b >= 0 && (c - b - a) * (c - b - a) - 4*a*b > 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}  

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

int main() {
    int n;
    cin >> n;
    vector<int> t(n), x(n), y(n);
    rep(i, n) {
        cin >> t.at(i) >> x.at(i) >> y.at(i);
    }
    bool can = true;
    rep(i, n) {
        int dist, time;
        if (i > 0) {
            dist = abs(x.at(i) - x.at(i-1)) + abs(y.at(i) - y.at(i-1));
            time = t.at(i) - t.at(i-1);
        }
        else{
            dist = abs(x.at(i)) + abs(y.at(i));
            time = t.at(i);
        }
        
        if (dist > time || (time - dist) % 2 == 1) {
            can = false;
            break;
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main () {
  std::string s, t;
  std::cin >> s >> t;
  int result = 0;
  for (int i = 0; i < static_cast<int>(s.size()); ++i) {
      if (s[i] != t[i]) ++result;
  }
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 3916
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(L[int(input())-1])


Measured memory_bytes: 2940
#include<stdio.h>

int main ()
{
    int x,y,z,ttl;
    scanf("%d%d",&x,&y);
    if(y%2==0){
    z=y/2;
    ttl=x+z;
    printf("%d\n",ttl);}
    else 
    printf("%d\n",y);
  
    return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=100050;
vector<int> E[N];
bool use[N];
int disc[N],tid;
vector<pair<int,int>> ans;
void DFS(int u, int p)
{
	disc[u]=++tid;
	vector<int> go;
	for(int v:E[u])
	{
		if(!disc[v])
		{
			DFS(v,u);
			if(!use[v]) go.pb(v);
		}
		else if(disc[v]>disc[u]) go.pb(v);
	}
	if(go.size()&1) go.pb(p),use[u]=1;
	for(int i=0;i<go.size();i++) ans.pb({u,go[i]});
}
int main()
{
	int n,m,u,v;
	scanf("%i %i",&n,&m);
	while(m--) scanf("%i %i",&u,&v),E[u].pb(v),E[v].pb(u);
	DFS(1,0);
	if(use[1]) printf("-1\n");
	else
	{
		for(auto p:ans) printf("%i %i\n",p.first,p.second);
	}
	return 0;
}

Measured memory_bytes: 19188
#include<bits/stdc++.h>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define all(v) v.begin(), v.end()
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	ll n;
	cin>>n;
	string ans;
	while(n!=0){
		n--;
		ans+= n%26 + 'a';
		n/=26;
	}
	reverse(all(ans));
	cout<<ans<<endl;
}

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

int main(void) {
    int X,Y,Z; cin >> X >> Y >> Z;
    int i = 1;
    int result;
    while (Y * i + Z * (i + 1) <= X) {
        result = i;
        i++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
/*
PROG: apc001a
LANG: C++11
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

long long readi()
{
	long long input = 0;
	bool negative = false;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
int sgn(long long x)
{
	if (x < 0) 
	{
		return -1;
	}
	if (x > 0) 
	{
		return 1;
	}
	return 0;
}
long long randomize(long long mod)
{
	return ((1 << 30) * rand() + (1 << 15) * rand() + rand()) % mod;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second

const long double PI = 4.0 * atan(1.0);
const long double EPS = 1e-20;

#define SINF 10007
#define CO 1000007
#define INF 1000000007
#define BIG 1000000931
#define LARGE 1696969696967ll
#define GIANT 2564008813937411ll
#define LLINF 2696969696969696969ll

long long normalize(long long x, long long mod = INF)
{
	return (((x % mod) + mod) % mod);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int X, Y;

int32_t main()
{
	ios_base::sync_with_stdio(0); 
	srand(time(0));
	//	cout << fixed << setprecision(12);	
	//	cerr << fixed << setprecision(12);
	if (fopen("apc001a.in", "r"))
	{	
		freopen ("apc001a.in", "r", stdin);
		freopen ("apc001a.out", "w", stdout);
	}
	cin >> X >> Y;
	if (X % Y == 0)
	{
		cout << "-1\n";
		return 0;
	}
	cout << X << '\n';
	return 0;
	//	cerr << "time elapsed = " << (clock() / (CLOCKS_PER_SEC / 1000)) << " ms" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>
#include <map>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint ans=1;
  map<int,int> prime;
  FOR(i,2,N+1){
    int temp=i;
    FOR(j,2,i+1){
      while(temp%j==0){
        temp/=j;
        prime[j]++;
      }
    }
  }
  for(auto i=prime.begin();i!=prime.end();i++){
    // cout<<i->first<<" "<<i->second<<endl;
    ans*=i->second+1;
    ans%=1000*1000*1000+7;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Solve s= new Solve();
		s.solve();
	}

}
class Solve{
	 Scanner sc = new Scanner(System.in) ;
	 void solve() {
		
		 int N =sc.nextInt();
		 int D =sc.nextInt();
		 int judge_sum =0;
		 int res = 0;
		 
		while(judge_sum<N) {
			res++;
			judge_sum+=2*D+1;
		}
		 
		 System.out.println(res);
	 }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};

int main(){
    ll n,m; cin >> n >> m;
    vector<pair<ll,ll>> p;
    for(ll i = 1;i * i < m;i++){
        if(m % i == 0){
            p.push_back(make_pair(i,m / i));
        }
    }
    ll ans = 1;
    for(ll i=0;i<p.size();i++){
        if(p[i].second >= n){
            ans = max(ans,p[i].first);
        }
    }
    for(ll i=0;i<p.size();i++){
        if(p[i].first >= n){
            ans = max(ans,p[i].second);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=1e5+5;
int n,i,j,l,r,a[N];
int main()
{
//	freopen("candy.in","r",stdin);
//	freopen("candy.out","w",stdout);
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	rep(i,1,n)
	if (i==n+1 || a[i]<i) break; i--;
	r=a[i]+1-i;
	if (r%2==0) printf("First\n");
	else {
		for (j=i;j<=n && a[j]>=i;j++);
		l=j-i;
		if (l%2==0) printf("First\n");
		else printf("Second\n");
	}
	return 0;
}

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


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

    int A,B;
    int ans;
    cin >> A >> B;
    ans = (A+B-3)/(A-1);
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b, x = map(int, readline().split())

    if a == 0:
        ans = b // x + 1
    else:
        ans = b // x - (a - 1) // x

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif

int main(){
  fastIO();
  ll ans=0,n,m,k;
  cin>>n>>m>>k;
  vector<ll>a(n+1);
  vector<ll>b(m+1);
  for(int i=1;i<=n;i++){
    cin>>a[i];
    a[i]+=a[i-1];
  }
  for(int i=1;i<=m;i++){
    cin>>b[i];
    b[i]+=b[i-1];
  }
  ll pos=m;
  for(int i=0;i<=n;i++){
    while(a[i]+b[pos]>k&&pos>0)pos--;
    if(a[i]+b[pos]>k)continue;
    ans=max(ans,i+pos);
  }
  cout<<ans<<endl;
  return 0;
}


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

/*
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
*/

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<string>> mesh(H, vector<string>(W));

    for (int i=0; i<H; i++)
    {
        string r;
        cin >> r;
        for (int j=0; j<W; j++)
        {
            mesh[i][j] = r[j];
        }
    }
    //cout << mesh << endl;

    int H_bit_max = pow(2, H);
    int W_bit_max = pow(2, W);

    int answer = 0;
    for (int i=0; i<H_bit_max; i++)
    {
        for (int j=0; j<W_bit_max; j++)
        {
            int black = 0;

            for (int p=0; p<H; p++)
            {
                for (int q=0; q<W; q++)
                {
                    if (mesh[p][q]=="#" && (i & (1<<p)) && (j & (1<<q))) black++;
                }
            }
            //cout << black << endl;
            if (black==K)
            {
                answer++;
            }
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 4116
#include <cmath>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
  
   int a[3];
  
   for(int i = 0;i<3;i++){
     
     cin >> a[i];
     
  }
  sort(a, a + 3); 
  

cout <<a[0]<< " "<<a[1]<< " "<<a[2] <<endl;


 
}


Measured memory_bytes: 3140
#include "bits/stdc++.h"
using namespace std;

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 2e5+1;
double arr[N];

int main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
    fastio;cin.tie(0);cout.tie(0);
    double n , e = 0 , ge = 0  ;
    int k ;
    cin >> n >> k ;
    for(int i = 1 ; i <= n ; ++i)
        cin >> arr[i];
    int cnt = 0 ;
    for(int i = 1 ; i <= n ; ++i)
    {
        if(cnt < k)
        {
            e += ((arr[i]+1)/2) ;
            ++cnt;
        }
        if(cnt == k)
        {
            ge = max(e , ge);
            e -= ((arr[i-k + 1] + 1)/2);
            --cnt;
        }
    }
    cout << fixed << setprecision(12) << ge ;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int h, w;
vector<vector<int>> v;

vector<int> tmp;

void dfs(int ite, int cnt){
    if(cnt > h/2)return;
    if(ite == h && cnt == h/2){
        // ネクパ
        int f[h] = {};
        rep(i,cnt){
            f[tmp[i]] = 1;
        }
        vector<int> a;
        rep(i,h){
            if(f[i] == 0)a.push_back(i);
        }
        do {
            int flag = 1;
            rep(i,cnt){
                if(tmp[i] > a[i]){
                    flag = 0;
                    break;
                }
            }
            if(flag){
                vector<int> vv;
                rep(i,h/2)vv.push_back(tmp[i]);
                if(h % 2 == 1)vv.push_back(a[h/2]);
                rep(i,h/2)vv.push_back(a[h/2-1-i]);
                v.push_back(vv);
            }
        } while( next_permutation(a.begin(), a.end()) );     // 次の順列を生成
    }

    if(ite == h)return;

    dfs(ite+1,cnt);
    tmp.push_back(ite);
    dfs(ite+1,cnt+1);
    tmp.erase(tmp.end()-1);
}

void v_init(){
    dfs(0,0);
}

int main() {
    cin >> h >> w;
    string s[h];
    rep(i,h) cin >> s[i];

    v_init();

    rep(_,v.size()){
        char c[h][w];
        rep(i,h){
            rep(j,w){
                c[i][j] = s[v[_][i]][j];
            }
        }
        string t[w];
        rep(j,w){
            rep(i,h)t[j] += c[i][j];
        }
        int use[w] = {};
        int odd = 0;
        int ng = 0;

        rep(j,w){
            if(use[j] == 1)continue;
            use[j] = 1;
            string tt = t[j];
            reverse(tt.begin(), tt.end());
            int ok = 0;
            rep(k,w){
                if(use[k] == 0 && t[k] == tt){
                    ok = 1;
                    use[k] = 1;
                    break;
                }
            }
            if(ok == 0){
                if(tt == t[j]){
                    odd++;
                    if(w % 2 == 0 || odd > 1){
                        ng = 1;
                    }
                }else{
                    ng = 1;
                }
            }
            if(ng)break;
        }

        if(ng)continue;
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;
    return 0;
}




Measured memory_bytes: 4264
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	string odd,even;
	cin >> odd >> even;
	int oddsize=odd.length(),evensize=even.length();
	if(oddsize==evensize){
		for(int i=0; i<oddsize; i++){
			cout << odd[i] << even[i];
		}
	}else {
		for(int i=0; i<evensize; i++){
			cout << odd[i] << even[i];
		}
		cout << odd[evensize];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
D = {}
for c1 in "ACGT":
    for c2 in "ACGT":
        for c3 in "ACGT":
            D[c1+c2+c3] = [0] * 101
            D[c1+c2+c3][3] = 1
D["AGC"][3]=0
D["ACG"][3]=0
D["GAC"][3]=0

for i in range(4,101):
    for k in D:
        for c in "ACGT":
            D[k[1:]+c][i] += D[k][i-1]
            D[k[1:]+c][i] %= 10**9+7
    D["AGC"][i] = 0
    D["GAC"][i] = 0
    D["ACG"][i] = 0
    D["GGC"][i] -= D["AGG"][i-1]
    D["GGC"][i] %= 10**9+7
    D["GTC"][i] -= D["AGT"][i-1]
    D["GTC"][i] %= 10**9+7
    D["TGC"][i] -= D["ATG"][i-1]
    D["TGC"][i] %= 10**9+7

ans = 0
for k in D:
    ans += D[k][N]
    ans %= 10**9+7
print(ans)


Measured memory_bytes: 3188
a_index, a_v = map(int, input().split())
b_index, b_v = map(int, input().split())
t = int(input())
 
d = abs(b_index - a_index)
d_v = a_v - b_v
 
if d == 0 :
  print("YES")
elif d_v > 0 and d / d_v <= t :
  print("YES")
else :
  print("NO")

Measured memory_bytes: 9124
<?php
//error_reporting(0);
//$S = trim(fgets(STDIN));
list($N,$M,$Q) = explode(" ",trim(fgets(STDIN)));
//$A = explode(" ",trim(fgets(STDIN)));
for($i=0;$i<$M;$i++) {
  list($L[],$R[]) = explode(" ",trim(fgets(STDIN)));
}
for($i=0;$i<$Q;$i++) {
  list($p[],$q[]) = explode(" ",trim(fgets(STDIN)));
}
$sum = buildSumTable();

for($i=0;$i<$Q;$i++) {
   printf("%d\n",getSumRange($p[$i],$q[$i],$sum));
}

function buildSumTable() {
  global $N,$M,$Q,$L,$R,$p,$q;
  $sumline = array_fill(0,$N+1,array_fill(0,$N+1,0));
  for($i=0;$i<$M;$i++) {
    $sum[$L[$i]][$R[$i]]++;
  }
  for($i=1;$i<=$N;$i++) {
    for($j=1;$j<=$N;$j++) {
      $sum[$i][$j]+=$sum[$i-1][$j];
      $sum[$i][$j]+=$sum[$i][$j-1];
      $sum[$i][$j]-=$sum[$i-1][$j-1];
    }
  }
  return $sum;
}
function getSumRange($L,$R,$sum) {
  return $sum[$R][$R] - $sum[$R][$L-1] - $sum[$L-1][$R] + $sum[$L-1][$L-1];
}


Measured memory_bytes: 148084
X,K,D=map(int,input().split())
if X-K*D>0:
    print(X-K*D)
elif X+K*D<0:
    print(abs(X+K*D))
else:
    if K%2==1:
        X=abs(X)
        X-=D
        M=X//(2*D)
        print(min(abs(X-2*D*M),abs(X-2*D*(M+1))))
    else:
        X=abs(X)
        M=X//(2*D)
        print(min(abs(X-2*D*M),abs(X-2*D*(M+1))))

Measured memory_bytes: 61908
from operator import mul
from functools import reduce
import bisect

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N=int(input())
L=input()
L=L.split()
L=[int(item) for item in L]
L.sort()
ans=cmb(N,3)
ans2=0
for i in reversed(range(2,N)):
    for j in reversed(range(1,i)):
        a=bisect.bisect_right(L,L[i]-L[j])
#        print('{0}:{1}'.format(a,j))
#        print(a)
        if(a<j):
            ans2+=(j-a)
    

print(ans2)


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

using namespace std;

int N;
char c[4000];
int a[4000];
int dp[2001][2001];
int cntw[4000][2002]; //cntw[i][j]:i番目まででj以上のWの数
int cntb[4000][2002]; //cntw[i][j]:i番目まででj以上のBの数
int W[2001];
int B[2001];

int main(){
    cin >> N;
    for(int i = 0; i < 2*N; i++) {
        cin >> c[i] >> a[i];
        if(c[i] == 'W') W[a[i]] = i;
        if(c[i] == 'B') B[a[i]] = i;
    }

    for(int i = 0; i < 2*N; i++) {
        int w[2001], b[2001];
        for(int j = 0; j <= N; j++){
            w[j] = 0;
            b[j] = 0;
        }
        for(int j = 0; j <= i; j++){
            if(c[j] == 'W') w[a[j]] = 1;
            if(c[j] == 'B') b[a[j]] = 1;
        }
        cntb[i][N+1] = 0;
        cntw[i][N+1] = 0;
        cntb[i][N] = b[N];
        cntw[i][N] = w[N];
        for(int j = N-1; j >= 0; j--){
            cntb[i][j] = cntb[i][j+1] + b[j];
            cntw[i][j] = cntw[i][j+1] + w[j];
        }
    }

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            if(i == 0 && j == 0) dp[i][j] = 0;
            else if(i == 0){
                dp[i][j] = dp[i][j-1]+cntb[B[j]][j+1]+cntw[B[j]][i+1];
            }else if(j == 0){
                dp[i][j] = dp[i-1][j]+cntb[W[i]][j+1]+cntw[W[i]][i+1];
            }else{
                dp[i][j] = min(dp[i-1][j]+cntb[W[i]][j+1]+cntw[W[i]][i+1], dp[i][j-1]+cntb[B[j]][j+1]+cntw[B[j]][i+1]);
            }
        }
    }
    cout << dp[N][N] << endl;
}

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

using namespace std;

int main(void) {

    int N;
    cin >> N;

    long long A[N], B[N], C[N];

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

    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);

    long long ans = 0;
    for(int i = 0; i < N; i++){
        long long upper = lower_bound(A, A+N, B[i]) - A;
        long long lower = upper_bound(C, C+N, B[i]) - C;
        ans += upper * (N - lower);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define reprs(i, m, n) for(int i = n; i >= m; i--)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pl;
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}


int main(){

  int N,A,B;
  cin >> N>>A>>B;

  cout << min(N*A,B) <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll N, K;
vector<ll> a;
vector<vector<ll>> dp;
vector<ll> Inv;

int main() {
    init_combination();
    cin >> N >> K;
    a.resize(K);
    for(int i = 0; i < K; i++) cin >> a[i];
    Inv.resize(K);
    for(int i = 0; i < K; i++) {
        Inv[i] = beki(combination(N, a[i]), mod - 2);
    }
    dp.resize(K + 1);
    dp[0].resize(N + 1);
    dp[0][0] = 1;
    for(int i = 0; i < K; i++) {
        dp[i+1].resize(N + 1);
        for(ll before = 0; before <= N; before++) {
            for(ll delta = 0; delta <= a[i]; delta++) {
                if(before + delta > N) break;
                ll factor = dp[i][before] * combination(N - delta, a[i] - delta) % mod;
                factor *= Inv[i];
                factor %= mod;
                factor *= combination(N - before, delta);
                factor %= mod;
                dp[i+1][before+delta] += factor;
                dp[i+1][before+delta] %= mod;
            }
        }
    }
    /*
    for(int k = 0; k <= K; k++) {
        cerr << "------" << k << "-----" << endl;
        for(int i = 0; i <= N; i++) {
            cerr << dp[k][i] << " ";
        }
        cerr << endl;
    }
    */
    ll ans = dp[K][N];
    for(int i = 0; i < K; i++) {
        ans *= combination(N, a[i]);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 234752
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		char[] val = scn.nextLine().trim().toCharArray();
		String out = "";
		for (char v : val) {
			out = out + "" + (v == '1' ? '9' : '1');
		}
		System.out.println(out);
	}
}

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

int main() {
  vector<int> A = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  int K; cin >> K; K--;
  cout << A.at(K) << endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


typedef long long ll;
typedef pair<ll,ll> P;

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


int main()
{
	REP(i,55)REP(j,55)mp[i][j] = '.';
	int h,w;cin >> h >> w;
	REP(i,h)REP(j,w)cin >> mp[i+1][j+1];
	
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			if(mp[i][j] == '#'){
				bool flag = false;
				REP(k,4){
					if(mp[i+dy[k]][j+dx[k]] == '#')flag = true;
				}
				if(!flag){
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys

class UFT: #Union-find tree class
    def __init__(self, N): 
        self.tree = [int(i) for i in range(N)] 
        self.rank = [0 for i in range(N)]

    def find(self, a):
        if self.tree[a] == a: return a
        else:
            self.tree[a] = self.find(self.tree[a])
            return self.tree[a]

    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b: return
        if self.rank[a] < self.rank[b]: self.tree[a] = b
        else:
            self.tree[b] = a
            if self.rank[a] == self.rank[b]: self.rank[a] += 1

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    parent = UFT(N)
    P = [int(p) - 1 for p in input().split()]
    for i in range(M):
        x, y = map(int, input().split())
        parent.unite(x-1, y-1)
    for i in range(N):
        parent.find(i)
        count = 0
    for i, p in enumerate(P):
        if parent.find(p) == parent.find(i): count += 1
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 18544
#include<iostream>
int main() {
	long long int n;
	std::cin >> n;
	long long int ans;
	if (n % 2)ans = 0;
	else {
		ans = 0;
		n /= 10;
		while (n != 0) {
			ans += n;
			n /= 5;
		}

	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n, a, b, sum = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    int d5 = i / 10000;
    int n4 = i % 10000;
    int d4 = n4 / 1000;
    int n3 = n4 % 1000;
    int d3 = n3 / 100;
    int n2 = n3 % 100;
    int d2 = n2 / 10;
    int d1 = n2 % 10;
    int dsum = d5 + d4 + d3 + d2 + d1;
    if (dsum >= a && dsum <= b) {
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}
	for (int i = 1; i < 3; i++) {
		int diff = c[i][0] - c[0][0];
		for (int j = 1; j < 3; j++) {
			if(c[i][j] - c[0][j] != diff){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  string a, b;
  cin >> a >> b;
  REP(i, a.size()-b.size()+1){
    bool match = true;
    REP(j, b.size()){
      if(a[i+j]!=b[j]) { match = false; break; }
    }
    if(match) cout << i << endl;
  }
  return 0;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t a,v,b,w,t; cin>>a>>v>>b>>w>>t;
	int64_t diff=abs(a-b);
	int64_t diff2=v-w;
	if(diff2>0&&diff2*t>=diff)cout<<"YES\n"s;
	else cout<<"NO\n"s;
}

Measured memory_bytes: 3652