akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
	
	int n,k,x,y,cost = 0;
	
	scanf("%d\n%d\n%d\n%d",&n,&k,&x,&y);
	
	if(n > k){
		cost = (k * x) + ((n - k) * y); 
	}else{
		cost = n * x;
	}
	
	printf("%d\n",cost);
	
	return 0;
	
}

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

int main() {
    vector<char> cal(10);
    for (int i = 0; i < 10;i++) {
        cin >> cal.at(i);
    }
    if (cal.at(3)=='7') {
        cal.at(3) = '8';
        for (int i = 0; i < 10;i++) {
            cout << cal.at(i);
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h=sc.nextInt();
        int w=sc.nextInt();
        int n=sc.nextInt();
        System.out.println(Math.min((n-1)/h+1, (n-1)/w+1));
 
    }



}

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

int main() {
  string a, b;
  cin >> a >> b;

  if (a == b)
  {
    cout << "H" << "\n";
  } else if ((a == "H" && b == "D") || (a == "D" && b == "H"))
  {
    cout << "D" << "\n";
  } else
  {
    cout << "H" << "\n";
  }

  return 0;
}

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

int main() {
    string s;cin>>s;
    s.replace(4,1,"0");
    s.replace(7,1,"0");
    if(s<="2019004030")cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
	return 0;
}

Measured memory_bytes: 3552
#include <iostream>
#include <math.h>

using namespace std;


int main() {
    int answer = 0;
    string s, t;
    cin >> s >> t;

    for (int i = 0; i<3; i++) {
        if (s[i] == t[i]) {
            answer++;
        }

    }

    cout << answer;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int a[3][3];
    int sum=0;
    int ch=0;
    REP(i,3)
    {
        REP(j,3)
        {
            cin>>a[i][j];
            sum+=a[i][j];
            if(i==j)ch+=a[i][j];
        }
    }
    if(sum==(3*ch))cout<<"Yes";
    else cout<<"No";
  }  
  return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
CA = [list(map(int,input().split())) for i in range(N)]

cost = 1200001
for i in range(2**N):
    skill = [0]*M
    cost_ = 0
    for j in range(N):
        if i>>j & 1:
            cost_+=CA[j][0] #金額
            for k in range(M):
                skill[k] += CA[j][k+1]
    if all([l>=X for l in skill]):
        cost = min(cost_, cost)

if cost == 1200001:
    print(-1)
else:
    print(cost)

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <algorithm>

void print(std::string str, int a, int b) {
	std::cout << str.substr(a, b - a + 1) << "\n";
}

std::string reverse(std::string& str, int a, int b) {



	std::string top, bot, reverse;
	top = str.substr(0, a);
	bot = str.substr(b+1);
	reverse = str.substr(a, b - a + 1);
	std::reverse(reverse.begin(), reverse.end());
	return top + reverse + bot;
}

std::string replace(std::string str, int a, int b, std::string p) {
	std::string top, bot;
	top = str.substr(0, a);
	bot = str.substr(b+1);
	return top + p + bot;
}


int main()
{
	std::string str, command, p;
	int q, a ,b;
	std::cin >> str >> q;

	for (int i = 0; i < q; i++) {
		std::cin >> command >> a >> b;
		if (command == "print")
			print(str, a, b);
		else if (command == "reverse")
			str = reverse(str, a, b);
		else if (command == "replace") {
			std::cin >> p;
			str = replace(str, a, b, p);
		}
	}
    return 0;
}




Measured memory_bytes: 3252
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

ll rec(ll h) {
    if (h == 1) return 1;

    return 1LL + 2LL * rec(h / 2);
}

int main() {
    fastio();

    ll h;
    cin >> h;

    cout << rec(h) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static int[] parent;//union-find用
	static int[] rank;//union-find用

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean[] red = new boolean[N];
		int redNum = 0;

		String C = sc.next();
		for(int i = 0;i<N ; i++) {
			if('R'== C.charAt(i)) {
				red[i] = true;
				redNum++;
			}
		}

		int leftRed = 0;
		int rightRed = 0;
		int leftWhite = 0;
		int rightWhite = 0;

		for(int i = 0;i<N ; i++) {
			if(i<redNum && red[i]) {
				leftRed++;
			}
			if(i<redNum && !red[i]) {
				leftWhite++;
			}
			if(i>=redNum && red[i]) {
				rightRed++;
			}
			if(i>=redNum && !red[i]) {
				rightWhite++;
			}
		}

		ans = 0;
		ans += Integer.min(leftWhite, rightRed);
		ans+= leftWhite - ans;


		System.out.println(ans);
	}

	//素数判定
	public static boolean isPrime(long num) {
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

		double sqrtNum = Math.sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2)
		{
			if (num % i == 0)
			{
				// 素数ではない
				return false;
			}
		}

		// 素数である
		return true;
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}

	//Union-Find用の配列を要素数nで初期化
	static void ufInit(int n){
		parent = new int[n];
		rank = new int[n];
	}

	//Union-Findの要素の最上位の親（グループ名）を返す
	static int ufFind(int a) {
		if(parent[a]==a) {
			return a;
		}else {
			return ufFind(parent[a]);
		}
	}

	//Union-Find木を連結する
	static void ufUnite(int a, int b) {
		a = parent[a];
		b = parent[b];

		if(a==b) {
			return;
		}
		if(rank[a] > rank[b]){
			parent[b]=a;
		}else {
			parent[a]=b;
			if(rank[a]==rank[b]) {
				rank[b]++;
			}
		}
	}

	static boolean ufSame(int a, int b) {
		return ufFind(a)==ufFind(b);
	}
}


Measured memory_bytes: 40824
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n, k;
long long a[16];
long long ans = 1e18 * 2;
int main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, 1 << n) {
		int c = 0;
		rep(j, n)if (i&(1 << j))c++;
		if (c != k)continue;
		long long cnt = 0;
		long long mem = 0;
		rep(j, n) {
			if (i&(1 << j)) {
				cnt += max((long long)0, mem - a[j] + 1);
				mem++;
			}
			mem = max(mem, a[j]);
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	getchar();getchar();
}

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

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

    int N, T;
    cin >> N >> T;
    int c[100] = {}, t[100] = {};
    int c_tmp, t_tmp;

    for (int i = 0; i < N; ++i) {
        cin >> c_tmp >> t_tmp;
        c[i] = t_tmp <= T ? c_tmp : 1001;
    }
    sort(c, c + N);

    if (c[0] < 1001) {
        cout << c[0] << '\n';
    } else {
        cout << "TLE" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  char S;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == 'Y'){
      cout << "Four" << endl;
      break;
    }else{
      if(i == (N - 1)){
        cout << "Three" << endl;
      }else{
        continue;
      }
    }
  }
}

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

int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    string t = "";
    for(int i = 0; i < s.size()/2; i++) t += s[i];
    bool flag = true;
    for(int i = s.size()/2; i < s.size(); i++)
    {
        if(s[i] != t[i-s.size()/2]) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
sum=0
if a==b:
  for i in range(a):
   	sum+=a*pow(10,i)
  print(sum)
elif a<b:
  for i in range(b):
   	sum+=a*pow(10,i)
  print(sum)
elif b<a:
  for i in range(a):
   	sum+=b*pow(10,i)
  print(sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N 10
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
char str[N][N];
int main(int argc, char const *argv[]) {
  int n = read(), m = read();
  for (int i = 1; i <= n; ++ i) {
    scanf("%s", str[i] + 1);
  }
  for (int i = 1; i <= n; ++ i) {
    for (int j = 1; j <= m; ++ j) {
      if (str[i][j] == '#') {
        if (str[i-1][j] == '#' && str[i][j-1] == '#' ||
            str[i+1][j] == '#' && str[i][j+1] == '#') {
          return puts("Impossible"), 0;
        }
      }
    }
  }
  puts("Possible");
  return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define MOD (int)1e9+7;

using ll = long long;
using namespace std;

int main() {
    int N;
    ll ans = 0;
    cin >> N;
    vector<int> X(N);
    rep(i, N) 
        cin >> X[i];
    
    vector<int> Y(N);
    Y = X;
    sort(Y.begin(), Y.end());
    int midl = Y[N/2-1];
    int midr = Y[N/2];

    if(midl == midr) {
        rep(i, N) {
            cout << midl << "\n";
        }
    } else {
        rep(i, N) {
            if(X[i] <= midl) cout << midr << "\n";
            else cout << midl << "\n";
        }
    }
    
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>

int main()
{
	int input_a, input_b;
	int d, r;
	double f;

	std::cin >> input_a >> input_b;

	d = input_a / input_b;
	r = input_a % input_b;
	f = (double)input_a / (double)input_b;

	std::cout << d << " " << r << " " 
		<< std::fixed << std::setprecision(5) << f << std::endl;

	return 0;
}


Measured memory_bytes: 3264
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(std::string s){
  char x = s[0];
  char y = s[1];
  if(x==y) {
    std::cout << 1 << " "<<2 << std::endl;
    return;
  }
  for(ll i=2; i<s.size(); i++) {
    if(s[i]==x) {
      std::cout << (i-2)+1 <<" "<<i+1 << std::endl;
      return;
    } else if(s[i]==y) {
      std::cout << (i-1)+1 <<" "<<i+1<< std::endl;
      return;
    }
    x = s[i-1];
    y = s[i];
  }
  std::cout << -1 << " " << -1 << std::endl;
}

int main(){
  std::string s;
  std::cin >> s;
  solve(s);
  return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> used;
	multiset<int> ret;
	rep(i,1<<n){
		int s;
		cin>>s;
		ret.insert(s);
	}
	auto itr=ret.end();
	itr--;
	used.push_back(*itr);
	ret.erase(itr);
	rep(i,n){
		vector<int> nused(used);
		for(auto v:used){
			if(ret.empty()) break;
			auto itr=ret.lower_bound(v);
			if(itr==ret.begin()){
				cout<<"No"<<endl;
				return 0;
			}
			itr--;
			nused.push_back(*itr);
			ret.erase(itr);
		}
		swap(used,nused);
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 14196
#include <iostream>
#define MAX 15

using namespace std;
int main(){
  int dataset, i, j, k, x, y, gx, gy, p;
  cin >> dataset;

  for (i = 0; i < dataset; ++i){
    bool vert[MAX+1][MAX+1];
    bool hori[MAX+1][MAX+1]; 
    int ways[MAX+1][MAX+1];

    for (j = 0; j <= MAX; ++j){
      for (k = 0; k <= MAX; ++k){
        vert[j][k] = true;
        hori[j][k] = true;
        ways[j][k] = 0;    
      } 
    }
    cin >> gx >> gy >> p;
  
    for (j = 0; j < p; ++j){
      int x1, y1, x2, y2;
      cin >> x1 >> y1 >> x2 >> y2;
      if(x1==x2){
        if(y2 > y1){
          vert[x2][y2] = false;
        }else{
          vert[x2][y1] = false;          
        }
      }else{
        if(x2 > x1){
          hori[x2][y2] = false;
        }else{
          hori[x1][y2] = false;          
        }
      }
    }


    for (x = 0; x <= gx; ++x){
      for (y = 0; y <= gy; ++y){
        if(x == 0 && y == 0){
          ways[x][y] = 1;
        }else if(x == 0){
          if(vert[x][y]){
            ways[x][y] = ways[x][y-1];
          }else{
            ways[x][y] = 0;
          }
        }else if(y == 0){
          if(hori[x][y]){
            ways[x][y] = ways[x-1][y];
          }else{
            ways[x][y] = 0;
          }
        }else{
          if(!hori[x][y] && !vert[x][y]){
            ways[x][y] = 0;
          }else if(!hori[x][y]){
            ways[x][y] = ways[x][y-1];
          }else if(!vert[x][y]){
            ways[x][y] = ways[x-1][y];
          }else{
            ways[x][y] = ways[x-1][y] + ways[x][y-1];
          }
        }
      } 
    }

    if(ways[gx][gy] == 0){
      cout << "Miserable Hokusai!" << endl;
    }else{
      cout <<ways[gx][gy] << endl;
    }
  }
}

Measured memory_bytes: 1160
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class UnionFindTree{

private:
  // indexツづ個青板づ個親ツノツーツド
  vector<int> par;
  // indexツづーツ債ェツづつキツづゥツ姪伉づ個δ可δ督ク
  vector<int> rank;
  // ツ姪伉づ個催妥・ツ値
  int treeSize;
  
public:
  UnionFindTree(int initTreeSize = 1000){
     // ツ暗クツ青板づ与ツつヲツづァツづェツつスツ値ツづーツ催妥・ツ格ツ納ツ青板づつキツづゥUnionFindTreeツづ個催ャツ青ャ
    treeSize = initTreeSize;
    init();
  }
  
  
  void init(){
    
    for(int i = 0; i < treeSize; i++){
      par.push_back(i);
      rank.push_back(0);
    }
    
  }

  // ツ与ツつヲツづァツづェツつスツ青板つェツ格ツ納ツつウツづェツづつ「ツづゥツ姪伉づ個δ仰ーツトツづーツ探ツ催オ
  int find(int x){
    
    if(par[x] == x){
      return x;
    }
    else{
      return par[x] = find(par[x]);
    }
    
  }
  
  void unite(int x,int y){
    
    x = find(x);
    y = find(y);
    
    if(x == y)
      return;
    
    if(rank[x] < rank[y]){
      par[x] = y;
    }
    else{
      par[y] = x;
      if(rank[y] == rank[x]){
	rank[x]++;
      }
    }
    
  }
  
  bool same(int x,int y){
    return find(x) == find(y);
  }

};



int fib[1001];

int main(){

	int V,d;
	while(cin>>V>>d){
		int cnt=1;
		fib[0]=1;
		fib[1]=2;
		for(int i = 2; i < 1001; i++)
			fib[i]=(fib[i-1]+fib[i-2])%1001;
		sort(fib+1,fib+V+1);
		//UnionFindTree uft(1001);
		int prv=fib[1];
		for(int i = 2; i <= V; i++){
			if(abs(prv-fib[i])>=d){
				cnt++;
			}
			prv=fib[i];
		}
		cout<<cnt<<endl;
	}

	return 0;
}

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

int n, m, x, y, ans = INT_MAX, maxn = INT_MAX;

int main()
{
	cin >> n >> m;
	for (int i = 0; i <= n - 1; i++)
	{
		cin >> x >> y;
		if (y <= m)
		{
			if (x <= ans) ans = x;
		}
	}
	if (ans == maxn) cout << "TLE" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=2005;
const int zero=3*MAXN;
int n,mod;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int f[3*MAXN][6*MAXN];
int main()
{
	n=read();mod=read();
	f[3*n][zero]=1;
	for(int i=3*n;i>=1;i--)for(int j=-(3*n-i)+zero;j<=(3*n-i)+zero;j++)if(f[i][j])
	{
		if(i-1>=0)ad(f[i-1][j+1],f[i][j]);
		if(i-2>=0)ad(f[i-2][j-1],1LL*f[i][j]*(i-1)%mod);
		if(i-3>=0)ad(f[i-3][j],1LL*f[i][j]*(i-1)%mod*(i-2)%mod);
	}int ans=0;
	for(int i=zero;i<=zero+3*n;i+=3)ad(ans,f[0][i]);
	pr2(ans);
	return 0;
}



Measured memory_bytes: 282496
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
	IN(int, n);
	LL ans = 0;
	inc1(i, n) {
	inc1(j, n) {
	inc1(k, n) {
		ans += gcd(gcd(i, j), k);
	}
	}
	}
	OUT(ans);
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int a, b, c; cin >> a >> b >> c;
  cout<<a+b+c-max({a,b,c})<<endl;

  return 0;
}


Measured memory_bytes: 256
// I want to AC  


#include <vector>
#include<stdio.h>
#include<string.h>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
#include<cstring>
#include<queue>
#include<assert.h>
#define ll long long
#define MODD 1000000007
#define  pii  pair<int,int>
#include<stdio.h>
#include<string.h>
//#define  ll long long
using namespace std;
const int maxn = 1e6;


ll exgcd(ll a, ll b, ll &x, ll &y) {
 if (b == 0) { x = 1; y = 0; return a; }
 ll ret = exgcd(b, a % b, y, x);
 y -= a / b * x;
 return ret;
 }
ll inv(ll a, ll M) {
 static ll x, y;
 assert(exgcd(a, M, x, y) == 1);
 return (x % M + M) % M;
 }
//void gcd(ll a,ll b,ll &d,ll &x,ll &y){
//    if(!b){
//        d=a;x=1;y=0;
//    }else{
//        gcd(b,a%b,d,y,x);
//        y-=x*(a/b);
//    }
//}
//ll inv(ll a,ll n){
//    ll d,x,y;
//    gcd(a,n,d,x,y);
//    return d==1?(x+n)%n:-1;
//}
// LL get_inv(LL a, LL M) {
// static LL x, y;
// assert(exgcd(a, M, x, y) == 1);
// return (x % M + M) % M;
// }

//欧拉函数
ll euler(ll n)
{
    ll rt = n;
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            rt -= rt / i;
            while (n % i == 0)
                n /= i;
        }
    if (n > 1)
        rt -= rt / n;
    return rt;
}

bool st[1000005];
int primes[50005];
void prime(int n)
{
    int cnt =0 ;
	for(int i=2;i<=n;i++)
	{
		if(!st[i])
		{
			primes[cnt++]=i;
		}
		for(int j=0;j<cnt&&i*primes[j]<=n;j++)
		{
			st[primes[j]*i]=true;
			if(i%primes[j]==0)
			{
				break;
			}
		}
	}

}


vector<int > div(int x){
	vector<int > res;
	for(int i=1 ;i<=x/i;i++) {
		if(x%i==0){
			res.push_back(i);
			if(i!=x/i) res.push_back(x/i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}
ll mod = 1e9+7;
inline void read(int &x){
    x=0;int f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x*=f;
}


int cnt =0 ;
ll dp[maxn];
char ch [2500][2500];
int main() {
  	
	int n;cin >>n;
	map<ll , int > mp;int f=0 ;
	for(int i=0;i<n;i++){
		ll k ;
		cin >>k;
		if(mp[k]==0)mp[k]=1;
		else {
			f =1 ;mp[k]++;
		}
	}
	if(!f)cout<<"YES";
	else cout<<"NO";
	cout<<endl;
    return 0;



}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int a,even=0,even4=0,odd=0;
  REP(i,n) {
    cin >> a;
    if (a%2) odd++;
    else if (a%4) even++;
    else even4++;
  }
  bool ans = 0;
  if (even == 0) {
    if (odd <= even4+1) ans=1;
  } else {
    if (odd <= even4) ans=1;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#ABC177 B
S = list(input())
T = list(input())
min0 = len(T)
min = len(T)

for i in range(len(S) - len(T) + 1):
  c = 0
  for j in range(len(T)):
    if S[i + j] == T[j]:
      c += 1
  if (min0 - c) < min:
    min = min0 - c

print(min)
    

Measured memory_bytes: 8940
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<unordered_map>
#include<map>
#include<string>
#include<cstring>
#include<stack>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define sflf(n) scanf("%lf", &n)
#define sfll(n) scanf("%lld", &n)
#define pfd(n) printf("%d", n)
#define pflf(n) printf("%lf", n)
#define pfll(n) printf("%lld", n)
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define PI 3.1415926
#define MAX 100000
#define M 1e18

using namespace std;

int main() {
 	int a, x;
 	sfd(a);
 	sfd(x);
 	if( a<x ) {
 		pfd(0);
	}else {
		pfd(10);
	}
	

	return 0;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	long long H, num;
	long long ans=0;

	cin >> H;
	num = 1;

	while (H > 0) {
		ans += num;
		H = H / 2;
		num = num * 2;
	}

	cout << ans;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  map<char,bool> mp;
  for (int i=0;i<n;i++){
  	char c;
    cin>>c;
    if (mp[c]!=true){
    	ans++;
      mp[c]=true;
    }
  }
  
  cout<<((ans==3)?"Three":"Four")<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

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

using namespace std;

int main() {
    
    int N,X;
    
    cin >> N >> X;
    
    vector<int> m(N);
    FOR(i, 0, N){
        cin >> m[i];
    }
    
    FOR(i, 0, N){
        X -= m[i];
    }
    
    int min = *min_element(m.begin(),m.end());
    
    int ans = X/min;
    
    ans += N;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n,m,x,y;
    cin>>n>>m;
    
    vector<int> adj[n+2];
    int inorder[n+2];
    
    //Sorting using Kahn Algorithm..
    memset(inorder,0,sizeof(inorder));
    
    for(int i=1;i < n+m ;i++) {
        cin>>x>>y;
        adj[x].push_back(y); //DAG
        inorder[y]++; // taking account of incoming edges
    }
    
    queue<int> q;
    int parent[n+2]; // Result
    
    for(int i=1; i<=n;i++) {
        if(inorder[i] == 0) q.push(i); // root has no incoming edges so inorder[root ] = 0..
                                        // searching the root   
    }
    
    parent[q.front()] = 0; // parent[root] = 0
    
    // Sorting ...
    while(q.size() != 0) {
        int u = q.front();
        q.pop();
        
        for(int v : adj[u]) {
            if(--inorder[v] == 0) {
                q.push(v);
                parent[v] = u; // Next Vertex in DFS..
            }
        }
    }
    
    for(int i=1;i<=n;i++) cout<<parent[i]<<"\n";
    return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <utility>


#define  PB push_back
#define  pB pop_back
#define  MP make_pair
#define  endl "\n"
using ll = long long;
using namespace std;
//128 bit integer :- __int128_t
const int INF = 1e9;
const int N = 1e5+1;

int idx (int a, int b, int x) 
{
    if (a <= b) return x;
    return x+1;
}
int main () {
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    
  //10/08/2020
    int n, i, k, j;
    cin >> n >> k;
    int a [n];
    int ans [n];
    for (i = 0; i < n; i++) {
        cin >> a [i];
    }
    ans [n-1] = 0;
    for (i = n-2; i >= 0; i--) {
        ans [i] = INF;
        for (j = i; j < n && j <= i+k; j++) {
            if (abs (a [i]-a [j])+ans [j] < ans [i]) {
                ans [i] = abs (a [i]-a [j])+ans [j];
            }    
        }
    }
    cout << ans [0];
    return 0;
}

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

int main(void)
{
    long long N, x;
    cin >> N >> x;

    vector<long long> a(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    long long ans = 0;
    for (long long i = 1; i < N; i++)
    {
        if (a[i-1] + a[i] > x)
        {
            ans += a[i-1] + a[i] - x;
            if (a[i] > a[i-1] + a[i] - x)
            {
                a[i] -= a[i-1] + a[i] - x;
            }
            else
            {
                a[i] = 0;
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n; cin >> n;
    vector<int> t(n);
    int total = 0;
    for(int i = 0; i < n; i++) {
        cin >> t[i];
        total += t[i];
    }
    int m; cin >> m;
    vector<int> p(m), x(m);
    for(int i = 0; i < m; i++) {
        cin >> p[i] >> x[i];
        cout << total - t[p[i]-1] + x[i] << endl;
    }
    return 0;
}

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

int main(){
  string A ,B ; 
  cin >> A >> B ; 
  
  if(A.size() > B.size()){
    cout << "GREATER" << endl ; 
  }
  else if (A.size() < B.size()){
    cout << "LESS" << endl;
  }
  else{
    for(int i = 0 ; i < A.size() ; i++){
      if(A.at(i) > B.at(i)){
        cout << "GREATER" << endl ; 
        return 0 ; 
      }
      else if(A.at(i) < B.at(i) ){
        cout << "LESS" << endl ; 
        return 0 ; 
      }
    }
    
    cout << "EQUAL" << endl ; 
  }
  
  
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;

long long n,a,b,h[100010];

bool solve(long long t){
    long long damage1=b*t,damage2=0;
    for(int i=0;i<n;i++){
        if(h[i]>damage1)damage2+=(h[i]-damage1+(a-b)-1)/(a-b);
    }
    if(damage2<=t)return true;
    else return false;
}

int main(void){
    cin>>n>>a>>b;
    long long r=0;
    for(int i=0;i<n;i++){
        cin>>h[i];
        r=max(r,h[i]);
    }
    r/=b;
    long long l=0,mid;
    for(int i=0;i<100;i++){
        mid=(r+l)/2;
        if(solve(mid))r=mid;
        else l=mid;
    }
    for(int i=mid;i<mid+100000;i++){
        if(solve(i)){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1024
N = gets.to_i
xu_n = N.times.map{|_| gets.split}

ans = xu_n.inject(0.0) do |result, x|
  if x[1] == "JPY"
    result += x[0].to_i
  else
    result += x[0].to_f * 380000
  end
end
p ans

Measured memory_bytes: 14272
import java.util.Scanner;

class Main{
    final static int LEN = 105;
    public static void main(String args[]){
	Integer[][] graph = new Integer[LEN][LEN];
	Integer[] minCost = new Integer[LEN];
	int count=0;
	int v;
	Boolean[] used = new Boolean[LEN];

	Scanner in = new Scanner(System.in);

	//read
	int n = in.nextInt();
	for(int i=0; i<n; i++){
	    for(int j=0; j<n; j++){
		int k = in.nextInt();
		graph[i][j]=(k==-1? Integer.MAX_VALUE : k);
	    }
	}

	//make prim
	for(int i=0; i<n; i++){
	    minCost[i]=Integer.MAX_VALUE;
	    used[i]=false;
	}

	minCost[0]=0;

	while(true){
	    v = -1;
	    for(int i=0; i<n; i++){
		if(!used[i] && (v==-1 || minCost[i] < minCost[v]))v=i;
	    }

	    if(v==-1)break;
	    used[v]=true;
	    count+=minCost[v];

	    for(int i=0; i<n; i++){
		minCost[i]=Math.min(minCost[i], graph[v][i]);
	    }
	}

	//print
	System.out.println(count);
    }
}

Measured memory_bytes: 13000
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#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
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  map<string, int> s;
  rep(i, n){
    string temp;
    cin >> temp;
    s[temp]++;
  }
  int m;
  cin >> m;
  map<string, int> t;
  rep(i, m){
    string temp;
    cin >> temp;
    t[temp]++;
  }
  int ans = 0;
  for(auto a : s){
    ans = max(ans, a.second - t[a.first]);
  }
  cout << ans << endl;
}

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

int main() {
    int N, Y;
    cin >> N >> Y;
    int ten_k = -1, five_k = -1, one_k = -1;
    for(int i = 0; i <= N; i++) {
        for(int j = 0; i + j <= N; j++) {
            int k = N - i - j;
            int total = 10000 * i + 5000 * j + 1000 * k;
            if(total == Y) {
                ten_k = i;
                five_k = j;
                one_k = k;
            }
        }
    }
    cout << ten_k << " " << five_k << " " << one_k << endl;
    return 0;
}

Measured memory_bytes: 256
H, N = list(map(int, input().split()))
ab_list = []
max_a = -float("inf")
for _ in range(N):
    a, b = list(map(int, input().split()))
    ab_list.append((a, b))
    max_a = max(max_a, a)

dp_table = [[0] + [float("inf")] * H for _ in range(N + 1)]

for i in range(1, N + 1):
    a, b = ab_list[i - 1]
    next_j = 0
    # for j in range(H + max_a):
    over_min_cost = float("inf")
    for j in range(H + 1):
        # 攻撃jをしない場合
        before_best_cost = dp_table[i - 1][j]
        dp_table[i][j] = min(dp_table[i][j], before_best_cost)
        # 攻撃jをする場合
        if j - a >= 0:
            cost = dp_table[i - 1][j - a] + b
            min_cost = min(before_best_cost, cost)

            cost = dp_table[i][j - a] + b
            min_cost = min(min_cost, cost)

            dp_table[i][j] = min(dp_table[i][j], min_cost)

        if j + a > H:
            cost = dp_table[i - 1][j] + b
            dp_table[i][H] = min(dp_table[i][H], cost)
            cost = dp_table[i][j] + b
            dp_table[i][H] = min(dp_table[i][H], cost)
            dp_table[i][H] = min(dp_table[i][H], dp_table[i - 1][H])

ans = dp_table[-1][H]
print(ans)


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

int map[50][50];
int w, h;

void dfs(int x, int y){
	map[y][x] = 0;
	for(int i = -1; i <= 1; i++){
		for(int j = -1; j <= 1; j++){
			int nx = x + i, ny = y + j;
			if(nx >= 0 && nx < w && ny >= 0 && ny < h && map[ny][nx] == 1)	dfs(nx, ny);
		}
	}
	return;
}

int main(void){
	int cnt;
	while(true){
		cin >> w >> h;
		if(!w && !h)	break;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> map[i][j];
			}
		}
		cnt = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(map[i][j] == 1){
					dfs(j, i);
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
  return 0;
}

Measured memory_bytes: 1312
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner a = new Scanner(System.in);
        int x = a.nextInt();
        int y = a.nextInt();
        if(x>y)
            System.out.println("a > b");
        else if (x<y)
            System.out.println("a < b");
        else if (x==y)
            System.out.println("a == b");
        }
    }

Measured memory_bytes: 17352
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    const char R = 'r';
    const char S = 's';
    const char P = 'p';
    IOS
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t; cin >> t;

    ll ans = 0;
    vector<bool> v(n);
    REP(i,n) {
        int sc;
        switch (t[i])
        {
        case R:
            sc = p;
            break;
        case S:
            sc = r;
            break;
        case P:
            sc = s;
            break;
        default:
            sc = 0;
            break;
        }
        if (i >= k) {
            if (t[i] == t[i-k]) {
                if (!v[i-k]) {
                    sc = 0;
                    v[i] = true;
                }
            }
        }
        ans += sc;
        // cerr << ans << endl;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 512
import sys
from bisect import bisect
def input():
	return sys.stdin.readline()[:-1]

def calc(x, i, j):
	prev = [s[i-1], s[i], t[j-1], t[j], s[i-1], s[i], t[j-1], t[j]]
	foll = [t[j-1], t[j-1], s[i-1], s[i-1], t[j], t[j], s[i], s[i]]
	res = 10**11
	for p, f in zip(prev, foll):
		res = min(res, abs(p-x) + abs(f-p))
	return res

a, b, q = map(int, input().split())
s, t = [-10**11], [-10**11]
for _ in range(a):
	s.append(int(input()))
s.append(10**11)
for _ in range(b):
	t.append(int(input()))
t.append(10**11)

for _ in range(q):
	x = int(input())
	print(calc(x, bisect(s, x), bisect(t, x)))

Measured memory_bytes: 12188
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>
#include <sstream>

using namespace std;

double EPS = 1e-12;

//誤差を考慮して足し算を行う
double add(double a, double b) {
	if( abs(a + b) < EPS * (abs(a) + abs(b))) {
		return 0;
	}

	return a + b;
}

//二次元ベクトル構造体
struct P {
	double x, y;

	P() {};
	P(double x, double y) : x(x), y(y) {
	}
	P operator + (P p) {
		return P(add(x, p.x), add(y, p.y));
	}
	P operator - (P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator * (double d) {
		return P(x * d, y * d);
	}
	double dot(P p) {	//　内積
		return add(x * p.x, y * p.y);
	}
	double det(P p) {	//　外積
		return add(x * p.y, -y * p.x);
	}
};

//　線分p1-p2上に点qがあるか判定
bool on_seg(P p1, P p2, P q) {
		return (p1 - q).det(p2 - q) == 0 && (p1 - q).dot(p2 - q) <= 0;
}

//　直線p1-p2と直線q1-q2の交点
P intersection(P p1, P p2, P q1, P q2) {
	return p1 + (p2 - p1) * ((q2 - q1).det(q1 - p1) / (q2 - q1).det(p2 - p1));
}

int ccw(P a, P b, P c) {
	a = b - a;
	b = c - b;

	if(a.det(b) < 0) {
		return -1;
	} else if(a.det(b) > 0) {
		return 1;
	}

	return 0;
}


int main() {
	
	P p[4];
	char dummy;

	while( cin >> p[0].x >> dummy >> p[0].y >> dummy >> p[1].x >> dummy >> p[1].y >> dummy >> p[2].x >> dummy >> p[2].y >> dummy >> p[3].x >> dummy >> p[3].y ) {

		int count = 0, ans = 0;
		for(int i = 0; i < 4; i++) {
			int c = ccw(p[i], p[(i + 1) % 4], p[(i + 2) % 4]);
			count += c;
			ans += abs(c);
		}

		if(ans == abs(count)) {
			cout << "YES" << endl;
		} else { 
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 1220
a = list(input())
count=0
if a.count('R')==3:
  print(3)
elif a.count('R')==1:
  print(1)
elif a.count('R')==0:
  print(0)
else:
  flag = True
  for i in range(1,3):
    if a[i]=='R':
      if a[i-1]=='R':
        print(2)
        flag =False
        break
  if flag==True:
    print(1)
    

Measured memory_bytes: 9080
var
	n,m,i,a,b,c:Longint;
	pa,p:array[1..100000]of Longint;
function f(u:Longint):Longint;
begin
	if pa[u]<>u then pa[u]:=f(pa[u]);
	f:=pa[u];
end;
begin
	read(n,m);
	for i:=1 to n do begin
		read(p[i]);
		pa[i]:=i;
	end;
	for i:=1 to m do begin
		read(a,b);
		a:=f(a);
		b:=f(b);
		if a<>b then pa[a]:=b;
	end;
	for i:=1 to n do if f(p[i])=f(i)then inc(c);
	writeln(c);
end.


Measured memory_bytes: 896
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()],dtype=np.int64)

"""
F_2 上の線形代数。基本変形で簡単な基底を得る。
"""

xor = np.bitwise_xor.reduce(A)

A = np.concatenate([np.array([1<<i for i in range(60) if xor&(1<<i)],np.int64),A])

for k in range(60,-1,-1):
    bit = 1<<k
    one = (A&bit != 0)
    i = np.where(one & (A < (1<<(k+1))))[0]
    if len(i) == 0:
        continue
    i = i[0]
    x = A[i]
    A[one] ^= x
    A[i] = x

A = A[A != 0]
A.sort()
A = A[::-1]

if len(A) > 0:
	red = np.bitwise_xor.reduce(A)
else:
    red = 0
blue = red^xor
answer = red + blue
print(answer)

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int H, W, M;
	cin >> H >> W >> M;
	vector<int> X(W), Y(H);
	map<P,int> mp;
	rep(i,M){
		int h, w;
		cin >> h >> w;
		h--; w--;
		mp[P(h,w)]++;
		X[w]++, Y[h]++;
	}
	vector<int> Max_X, Max_Y;
	int MX=0, MY=0;
	rep(i,W) MX=max(MX,X[i]);
	rep(i,H) MY=max(MY,Y[i]);
	rep(i,W){
		if(X[i]==MX) Max_X.emplace_back(i);
	}
	rep(i,H){
		if(Y[i]==MY) Max_Y.emplace_back(i);
	}
	rep(i,Max_Y.size()){
		rep(j,Max_X.size()){
			int x=Max_X[j], y=Max_Y[i];
			if(mp[P(y,x)]==0){
				cout << MX+MY << endl;
				//cout << x << " " << y << endl;
				return 0;
			}
		}
	}
	cout << MX+MY-1 << endl;

	return 0;
}

Measured memory_bytes: 28440