akhauriyash/Code-Regression huggingface dataset:
//============================================================================
// Name        : at20181013.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdint>
using namespace std;

int main() {
	//cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!

	uint64_t N;
	uint64_t M;
	cin >> N >> M;

	string S;
	cin >> S;

	string T;
	cin >> T;

	if (S[0] != T[0]) {
		cout << "-1" << endl;
		return 0;
	}

	//cout << "M " << M << " N " << N << endl;
	//cout << S << endl;
	//cout << T << endl;

	uint64_t i = 1;
	while (1) {
		const uint64_t MIN_NM = min(N, M);
		const uint64_t MAX_NM = max(N, M);
		const uint64_t L = MIN_NM * i;
		//cout << "L " << L << endl;

		if (L >= (10000000000L)) {
			cout << "-1" << endl;
			break;
		}

		if ((L % MAX_NM) != 0) {
			// can not div.
			++i;
			continue;
		}
		//cout << "i " << i << endl;

		const uint64_t l_n = L / N;
		const uint64_t l_m = L / M;
		//cout << "l_n " << l_n << " l_m " << l_m << endl;

		uint64_t s_index = 1;
		uint64_t t_index = 1;
		while ((s_index <= N) && (t_index <= M)) {
			const uint64_t idx_n = (s_index * l_n) + 1;
			const uint64_t idx_m = (t_index * l_m) + 1;
			if (idx_n == idx_m) {
				//cout << "eq idx_n _m " << idx_n << endl;
				if (S[s_index] != T[t_index]) {
					cout << "-1" << endl;
					return 0;
				}
			}

			if (idx_n < idx_m) {
				++s_index;
			} else {
				++t_index;
			}
		}

		cout << L << endl;
		break;
	}

	return 0;
}


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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

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

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


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
vll dp(10000);
void mainmain(){
	int n;
	while(cin>>n,n){
		rep(i,10000) dp[i]=0;
		vector<pii> card;
		rep(i,n){
			int a,b;
			cin>>a>>b;
			card.PB(mkp(a,b));
		}
		dp[0]=1;
		// sort(ALL(card));
		rep(i,card.size()){
			vll tmp=dp;
			rep(k,card[i].S){
				int t=card[i].F+card[i].F*k;
				for(int j=10000;j>=t;j--){
					if(tmp[j-t]) dp[j]+=tmp[j-t];
				}
			}
			// rep(j,121){
				// cout<<j<<" "<<dp[j]<<endl;
			// }
			// cout<<endl;
		}
		// rep(i,200){
			// cout<<i<<" "<<dp[i]<<endl;
		// }
		int m;
		cin>>m;
		rep(i,m){
			int g;
			cin>>g;
			cout<<dp[g]<<endl;
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1340
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n, p;
std::string s;
long num[200005];
std::vector<long> sum(1, 0);

int main(){
    scanf("%ld%ld", &n, &p);
    std::cin >> s;
    for(int i = 0; i < n; i++){
        num[n-i-1] = s[i] - '0';
    }
    if(p == 2 || p == 5){
        long ans = 0;
        for(int i = 0; i < n; i++){
            if(num[i] % p == 0){
                ans += n - i;
            }
        }
        printf("%ld\n", ans);
        return 0;
    }
    long tpow = 1;
    for(long i = 0; i < n; i++){
        num[i] *= tpow;
        num[i] %= p;
        tpow *= 10;
        tpow %= p;
    }
    for(long i = 0; i < n; i++){
        sum.push_back((sum[sum.size() - 1] + num[i]) % p);
    }

    /*
    for(int i = 0; i <= n; i++){
        printf("%3ld ", sum[i]);
    }
    printf("\n");
    //*/
    std::map<long, long> nums;
    for(int i = 0; i <= n; i++){
        nums[sum[i]]++;
    }
    long ans = 0;
    for(auto it : nums){
        long cnt = it.second;
        ans += cnt * (cnt-1) / 2;
    }
    printf("%ld\n", ans);
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

#define encode(state,lock) (state|(lock<<10))
#define getState(v) (v&((1<<10)-1))
#define getLock(v) (v>>10)
#define isLock(state, lock) (state&(1<<lock))

void init(int n,string s,unordered_set<int> &S) {
  int state = 0;
  rep(i,n) {
    if( s[i] == 'u' ) {
      state = 0;
    } else {
      int lock = s[i] - '0';
      S.insert(encode(state,lock));
      state = state | (1<<lock);
    }
  }
}

bool hasDeadlock(int n,string s) {
  rep(i,n-1) if( s[i] != 'u' && s[i] == s[i+1] ) return true;

  unordered_set<int> S;
  init(n,s,S);
  bool update = true;
  while(update) {
    update = false;
    vector<int> buffer;
    for(auto v1 : S) {
      int state1 = getState(v1);
      int lock1  = getLock(v1);
      for(auto v2 : S) {
        int state2 = getState(v2);
        int lock2  = getLock(v2);
        if( state1 & state2 ) continue;
        if( state2 & (1<<lock1) ) buffer.push_back(encode((state1|state2),lock2));
        if( isLock(state1,lock2) && isLock(state2,lock1) ) {
          return true;
        }
      }
    }
    rep(i,(int)buffer.size()) {
      if( S.count(buffer[i]) ) continue;
      S.insert(buffer[i]);
      update = true;
    }
  }
  return false;
}

int main() {
  int n;
  string s;
  while( cin >> n, n ) {
    cin >> s;
    puts(hasDeadlock(n,s)?"UNSAFE":"SAFE");
  }
  return 0;
}

Measured memory_bytes: 3208
#include<stdio.h>
#include<stdbool.h>

int main(void) {
  int N, M;
  scanf("%d %d", &N, &M);
  char A[50][51];
  for(int i = 0; i < N; i++) {
    scanf("%s", A[i]);
  }
  char B[50][51];
  for(int i = 0; i < M; i++) {
    scanf("%s", B[i]);
  }

  for(int y = 0; y <= (N-M); y++) {
    for(int x = 0; x <= (N-M); x++) {

      bool find = true;
      for(int i = 0; i < M; i++) {
	for(int j = 0; j < M; j++) {
	  if(B[i][j] != A[y+i][x+j]) {
	    find = false;
	    break;
	  }
	}
	if(find == false)
	  break;
      }
      if(find == true) {
	printf("Yes\n");
	return 0;
      }

    }
  }

  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val n = sc.nextInt

	for( i <- 0 until n) {
		val a, b, c = sc.nextInt
		if(isRightAngle(a, b, c))	println("YES")
		else						println("NO")
	}

	def isRightAngle(a: Int, b: Int, c: Int): Boolean = {
		if(a*a + b*b == c*c)	true
		else if(b*b + c*c == a*a)	true
		else if(c*c + a*a == b*b)	true
		else false
	}
}

Measured memory_bytes: 50476
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

int main(){ _
	string s;
	
	while (cin >> s)
	{
		int rd = 0;
		
		for (int i = 0; i < s.length(); i++)
			if (s[i] == 'R')
				rd++;
		
		if (s[0] == 'R' && s[2] == 'R' && rd == 2)
			rd = 1;
		
		cout << rd << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3604
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int ans = 0;
	for (int i = 0; i < n; i++) {
		int h; cin >> h;
		if (h >= k)ans++;
	}

	cout << ans << endl;

	return 0;
}

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

	};
	if(abs(Max) >= abs(Min)){
		//+
		rep(i,n)push(indMax,i);
		rep(i,n-1)push(i,i+1);
	}
	else{
		//-
		rep(i,n)push(indMin,i);
		for(int i = n-1;i;i--)push(i,i-1);
	}
	cout << ans.size() << endl;
	rep(i,ans.size()){
		cout << ans[i].first+1 <<" " <<  ans[i].second+1 << endl;
	}
	//trace(a);
	return 0;
}

Measured memory_bytes: 3636
include Math

def get_center(x1, y1, x2, y2, x3, y3)
  a1 = 2*(x2 - x1)
  b1 = 2*(y2 - y1)
  c1 = x1**2 - x2**2 + y1**2 - y2**2
  a2 = 2*(x3 - x1)
  b2 = 2*(y3 - y1)
  c2 = x1**2 - x3**2 + y1**2 - y3**2
  x = (b1*c2 - b2*c1)/(a1*b2 - a2*b1)
  y = (c1*a2 - c2*a1)/(a1*b2 - a2*b1)
  return x, y
end

def get_length(x1, y1, x2, y2, x3, y3)
  a = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2))
  b = sqrt((x2 - x3)*(x2 - x3) + (y2 - y3)*(y2 - y3))
  c = sqrt((x3 - x1)*(x3 - x1) + (y3 - y1)*(y3 - y1))
  return a, b, c
end

def get_radius(x1, y1, x2, y2, x3, y3)
  a, b, c = get_length(x1, y1, x2, y2, x3, y3)
  s = (a + b + c)/2.0
  area = sqrt(s*(s-a)*(s-b)*(s-c))
  (a*b*c)/(4.0*area)
end

n = gets.to_i
n.times do
  x1, y1, x2, y2, x3, y3 = gets.split(/\s/).map(&:to_f)
  r = get_radius(x1, y1, x2, y2, x3, y3)
  cx, cy = get_center(x1, y1, x2, y2, x3, y3)
  puts sprintf('%.3f %.3f %.3f', cx, cy ,r)
end

Measured memory_bytes: 6184
import java.util.Scanner;
public class Main {
	public static void main (String[] args){
		
        Scanner scan = new Scanner(System.in);
        
        while(true) {
            int H = scan.nextInt();
            int W = scan.nextInt();
            if(H == 0 && W == 0) 
            break;
            for(int i = 0; i < H; i++) {
                for(int j = 0; j < W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 35128
#include <iostream>
#include <cmath>

int main() {
  int A, B;
  std::cin >> A >> B;

  int ans=1;
  for (; std::floor(ans * 0.08) < A || std::floor(ans * 0.10) < B; ans++);

  if (std::floor(ans * 0.08) == A && std::floor(ans * 0.10) == B) {
    std::cout << ans << std::endl;
  } else {
    std::cout << -1 << std::endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N, K;
    cin >> N >> K;
    vector<vector<int>> A(2 * K, vector<int>(2 * K, 0)), B(2 * K, vector<int>(2 * K, 0));
    rep(i, N) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'B') ++A[x % (2 * K)][y % (2 * K)];
        else ++B[x % (2 * K)][y % (2 * K)];
    }
    vector<vector<int>> A_sum(2 * K + 1, vector<int>(2 * K + 1, 0)), B_sum(2 * K + 1, vector<int>(2 * K + 1, 0));
    rep(i, 2 * K) rep(j, 2 * K) {
        A_sum[i + 1][j + 1] = A_sum[i][j + 1] + A_sum[i + 1][j] - A_sum[i][j] + A[i][j];
        B_sum[i + 1][j + 1] = B_sum[i][j + 1] + B_sum[i + 1][j] - B_sum[i][j] + B[i][j];
    }
    int ans = 0;
    rep(i, K) rep(j, K) {
        int res = 0;
        rep(k, 3) rep(l, 3) {
            int x = min(i + k * K, 2 * K);
            int y = min(j + l * K, 2 * K);
            int z = max(i + (k - 1) * K, 0);
            int w = max(j + (l - 1) * K, 0);
            if ((k + l) & 1) {
                res += A_sum[x][y] - A_sum[x][w] - A_sum[z][y] + A_sum[z][w];
            } else {
                res += B_sum[x][y] - B_sum[x][w] - B_sum[z][y] + B_sum[z][w];
            }
        }
        ans = max(ans, res);
        res = 0;
        rep(k, 3) rep(l, 3) {
            int x = min(i + k * K, 2 * K);
            int y = min(j + l * K, 2 * K);
            int z = max(i + (k - 1) * K, 0);
            int w = max(j + (l - 1) * K, 0);
            if (!((k + l) & 1)) {
                res += A_sum[x][y] - A_sum[x][w] - A_sum[z][y] + A_sum[z][w];
            } else {
                res += B_sum[x][y] - B_sum[x][w] - B_sum[z][y] + B_sum[z][w];
            }
        }
        ans = max(ans, res);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 63104
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

posi = []
nega = []
zeros = 0
A.each do |ai|
  if ai < 0
    nega << ai
  elsif ai > 0
    posi << ai
  else
    zeros += 1
  end
end

posi.sort!
nega.sort!.reverse!

posi_size = posi.size
nega_size = nega.size

nega_pairs = posi_size * nega_size
zero_pairs = zeros * (zeros - 1) / 2 + zeros * (N - zeros)
nega_zero_pairs = nega_pairs + zero_pairs

inf = 10**18+1

ans = (-inf..inf).bsearch do |mid|
  
  if mid >= 0
    cnt = nega_zero_pairs
    [posi, nega].each do |a|
      l = 0
      r = a.size - 1
      while l < r
        r -= 1 while l < r && a[l] * a[r] > mid
        cnt += r - l
        l += 1
      end
    end
  else
    cnt = 0
    r = nega_size - 1
    posi_size.times do |l|
      r -= 1 while(r >= 0 && posi[l] * nega[r] <= mid)
      cnt += nega_size - r - 1
    end
  end

  cnt >= K
end

puts ans

Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll N, *arr, p;
	cin >> N;
	arr = new ll[N];
	for(int i=0;i<N;i++)cin >> arr[i];
	ll *brr = new ll[N];
	for(int i=0;i<N;i++)brr[i] = arr[i];
	sort(arr, arr+N);
	p = N/2;
	for(int i=0;i<N;i++)cout << arr[p-(arr[p]<=brr[i])] << "\n";
	return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<complex>
#include<array>
#include<vector>
#include<cstdio>
#include<cassert>
using namespace std;

const double EPS = 1e-10;
template<class T>
bool eq(const T& a, const T& b) {return abs(a - b) < EPS;}

typedef  complex<double> point;

double cross(const point& a, const point& b) {
	return imag(conj(a)*b);
}
double dot(const point& a, const point& b) {
	return real(conj(a)*b);
}
int ccw(point a, point b, point c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;  // counter clockwise
	if (cross(b, c) < 0)   return -1;  // clockwise
	if (dot(b, c) < 0)     return +2;  // c--a--b on line
	if (norm(b) < norm(c)) return -2;  // a--b--c on line
	return 0;  // a--c--b on line or a----bc
}

typedef array<point, 2> line;

point projection(const line& l, const point& p) {
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}

point reflection(const line& l, const point& p) {
	return p + 2. * (projection(l, p) - p);
}
 typedef array<point, 2> line;
//using line = array<point, 2>;
/*
 * 平行かどうか
 */
bool is_parallel(const line& s, const line& t) {
	return eq(cross(s[0] - s[1], t[0] - t[1]), 0.0);
}

bool is_orthogonal(const line& s, const line& t) {
	return eq(dot(s[0] - s[1], t[0] - t[1]), 0.0);
}

bool intersectLL(const line& l, const line& m) {
	return !eq(cross(l[1]-l[0], m[1]-m[0]), 0.) || // non-parallel
			eq(cross(l[1]-l[0], m[0]-l[0]), 0.);   // same line
}
bool intersectSS(const line &s, const line &t) {
	return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
			ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

point crosspoint(const line& l, const line& m) {
	double A = cross(l[1] - l[0], m[1] - m[0]);
	double B = cross(l[1] - l[0], l[1] - m[0]);
	if (eq(A, 0.) && eq(B, 0.)) return m[0]; // same line
	if (eq(A, 0.)) assert(false); // 交点が無い場合に落ちる 実行前に交差判定
	return m[0] + B / A * (m[1] - m[0]);
}

int main()
{
  int q;
  cin>>q;
  for(;q--;)
    {
      line l1,l2;
      double x,y;
      cin>>x>>y;
      l1[0]=point(x,y);
      cin>>x>>y;
      l1[1]=point(x,y);
      cin>>x>>y;
      l2[0]=point(x,y);
      cin>>x>>y;
      l2[1]=point(x,y);

      if(intersectSS(l1,l2))
	{
	  point p=crosspoint(l1,l2);
	  printf("%.10lf %.10lf\n",p.real(),p.imag());
	  //	  cout<< p.real()<<" "intersectSS(l1,l2) <<endl;
	}
    }
}

Measured memory_bytes: 1264
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = new Set(nextIntArray());
	myout(one.size);
}


Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const int MAX_N=100010;
int prime[MAX_N]; //i番目の素数
bool is_prime[MAX_N+1];  //iが素数ならtrue
bool is_likeprime[MAX_N+1];

//n以下の素数の数を返す
int sieve(int n){
    int p = 0;
    rep(i,0,n+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    rep(i,2,n+1){
        if (is_prime[i]){
            p++;
            prime[p]=i;
            for (int j=2*i; j<=n; j+=i) is_prime[j]=false;
        }
    }
    return p;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    rep(i,0,MAX_N+1) is_likeprime[i]=false;
    int t=sieve(MAX_N);
    rep(i,2,t){
        if (is_prime[(prime[i]+1)/2]) is_likeprime[prime[i]]=true;
    }
    int c[MAX_N+1];
    c[0]=0;
    rep(i,1,MAX_N+2){
        if (is_likeprime[i])c[i]=c[i-1]+1;
        else c[i]=c[i-1];
    }
    int Q;
    cin >> Q;
    rep(i,0,Q){
        int l,r;
        cin >> l>>r;
        cout << c[r]-c[l-1] << "\n";
    }
}

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

const int N = 2e5+10;
int a[N];
int order[N];

void solve() {
    int n;
    ll k;
    scanf("%d%lld", &n, &k);
    for (int i = 1; i <= n; i++) scanf("%d", a+i);

    vector<int> cir;
    cir.push_back(0);

    int cur = 1, cnt = 0;
    while (!order[cur]) {
        cir.push_back(cur);
        order[cur] = ++cnt;
        cur = a[cur];
    }

    if (k <= order[cur]-1) {
        printf("%d\n", cir[k+1]);
        return ;
    }
    k -= order[cur]-1;
    int cirlen = cnt - order[cur] + 1;
    k %= cirlen;
    printf("%d\n", cir[order[cur]+k]);
}
// 1 6 2 5 3 2 

int main(){
    solve();

	return 0;
}


Measured memory_bytes: 5896
#include<stdio.h>

//関数プロトタイプ宣言
void diceRoll(int *d,char *r);

int main(){
	int dice[6];	//サイコロ
	int q;			//質問の数
	int up;			//サイコロの上面
	int front;		//サイコロの前面
	
	//サイコロの作成
	for(int i = 0;i < 6;i++){
		scanf("%d",&dice[i]);
	}
	//質問の数の入力
	scanf("%d",&q);
	
	for(int i = 0;i < q;i++){
		//上面と前面の入力
		scanf("%d %d",&up,&front);
		
		//サイコロの上面が入力されたものと違うとき
		if(dice[0] != up){
			//入力された上面が前面にあったとき
			if(dice[1] == up){
				diceRoll(dice,"N");
			}
			//右面にあったとき
			else if(dice[2] == up){
				diceRoll(dice,"W");
			}
			//左面にあったとき
			else if(dice[3] == up){
				diceRoll(dice,"E");
			}
			//後面にあったとき
			else if(dice[4] == up){
				diceRoll(dice,"S");
			}
			//底面にあったとき
			else if(dice[5] == up){
				diceRoll(dice,"NN");
			}
		}
		
		//サイコロの前面が入力されたものと違うとき
		if(dice[1] != front){
				//入力された前面が右面にあったとき
			if(dice[2] == front){
				diceRoll(dice,"R");
			}
			//左面にあったとき
			else if(dice[3] == front){
				diceRoll(dice,"L");
			}
			//後面にあったとき
			else if(dice[4] == front){
				diceRoll(dice,"RR");
			}
		}
		
		//右面を表示
		printf("%d\n",dice[2]);
	}
	
	return 0;
}

void diceRoll(int *d,char *r){
	int x;	//入れ替え用変数
	for(int i = 0;r[i] != '\0';i++){
		switch(r[i]){
			//右に転がす
			case 'E':
				x = d[0];
				d[0] = d[3];
				d[3] = d[5];
				d[5] = d[2];
				d[2] = x;
				break;
			//奥に転がす
			case 'N':
				x = d[0];
				d[0] = d[1];
				d[1] = d[5];
				d[5] = d[4];
				d[4] = x;
				break;
			//手前に転がす
			case 'S':
				x = d[0];
				d[0] = d[4];
				d[4] = d[5];
				d[5] = d[1];
				d[1] = x;
				break;
			//左に転がす
			case 'W':
				x = d[0];
				d[0] = d[2];
				d[2] = d[5];
				d[5] = d[3];
				d[3] = x;
				break;
			//右に９０度回す
			case 'R':
				x = d[1];
				d[1] = d[2];
				d[2] = d[4];
				d[4] = d[3];
				d[3] = x;
				break;
			//左に９０度回す
			case 'L':
				x = d[1];
				d[1] = d[3];
				d[3] = d[4];
				d[4] = d[2];
				d[2] = x;
				break;
		}
	}
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if (A == 1) A = 14;
    if (B == 1) B = 14;
    if (A > B) cout << "Alice" << endl;
    else if(A == B) cout << "Draw" << endl;
    else cout << "Bob" << endl;
}

Measured memory_bytes: 256
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	ll a[n];
	input(a,n);
	map<ll,ll>mp;
	ll ans=0,val=0;
	vector<ll>arr;
	for(ll i=0;i<n-1;i++)
	if(a[i]!=a[i+1])
	arr.push_back(a[i]);
	arr.push_back(a[n-1]);
	for(ll i=0;i<arr.size();i++)
	{
		val=ans;
		if(mp[arr[i]])
		ans=(ans+mp[arr[i]])%mod;
		mp[arr[i]]=(mp[arr[i]]+1+val)%mod;
		
	}
	cout<<ans+1;
}


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


int n,OK;//n点的个数，OK（是否找到）控制循环停止
int x[105] , y[105] , h[105] ;//存数据
int sum, ri, hi;//sum（差的和）用于计算hi（假定高度）
int hh,hh_n;
int main(){
	scanf("%d ",&n);
	for(int i = 1 ; i <= n ; i++){
		scanf("%d %d %d", &x[i] , &y[i] , &h[i] );
		if(h[i])	hh_n=i;
	}

	for(int i=0 ; i<=100 && OK==0 ; i++ ){

		for(int j=0 ; j<=100 && OK==0 ; j++ ){//枚举坐标

			sum = abs( x[hh_n]-i )+ abs( y[hh_n]-j );
			hi  = h[hh_n] + sum;//算出假定高度
			ri=0;
			for( int k=1 ; k<=n ; k++ ){
				sum = abs( x[k]-i ) + abs( y[k]-j );
				if( h[k] == max(hi - sum, 0)) ri++;//满足假定高度++
			}

			if( ri == n ){//所有的点都满足假定高度
				printf("%d %d %d",i,j,hi);
				OK = 1;
			}
		}
	}	
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;

int main(void) {
  string s;
  string ans = "";
  while(cin >> s){
    if( s.find("apple") != -1 ) s.replace(s.find("apple"), 5, "peach");
    else if( s.find("peach") != -1 ) s.replace(s.find("peach"), 5, "apple");
    ans += s;

    ans += ' ';
  }
  cout << ans.substr(0, ans.size()-1) << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3024
#include <stdio.h>

int main(void)
{
  int A, B, C, K;
  int i;
  scanf("%d %d %d %d", &A, &B, &C, &K);
  
  if(B < C) { int tmp = B; B = C; C = tmp; }
  if(A < B) { int tmp = A; A = B; B = tmp; }
  
  for(i = 0; i < K; i++) A *= 2;
  printf("%d\n", A + B + C);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair



int main() {
    int N; cin >> N;
    vector<int> L(N); REP(i, N) cin >> L[i];

    int cnt_triangle = 0;
    REP(i, N) REP2(j, i+1, N) REP2(k, j+1, N) {
        if (abs(L[i] - L[j]) < L[k] && L[k] < L[i] + L[j] && L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) cnt_triangle++;
    }
    PRINT(cnt_triangle);
    return 0;
}

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

using namespace std;

typedef long long ll;

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

ll N, M, K;

ll dfs(ll S, ll cnt) {
  
  if(cnt == N) {
    if(S-K <= 0) { return 1; }
    return S-K;
  }
  
  ll ret = 0;
  REP(i,1,M+1) {
    ret += dfs(S+i, cnt+1);
  }
  return ret;
}

int main() {
  
  while(cin >> N >> M >> K && (N|M|K)) {
    printf("%.10f\n", dfs(0, 0) / pow(M, N));
  }
  
  return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    if (!(cin >> N)) { return; }
    string A, B, C;
    cin >> A >> B >> C;
    ll ans  =0;
    for (int i = 0; i < N; ++i) {
        set<int> sc{};
        sc.insert(A[i]);
        sc.insert(B[i]);
        sc.insert(C[i]);
        ans += sc.size() - 1;
    } // end i
    cout << ans << endl;

}

int main(int argc, char *argv[]) {
    string FileName("B"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        while (cin) { solve(cin); }
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int main() {
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  vector<int> dp(N);
  dp.at(0)=0;
  dp.at(1)=abs(h.at(1)-h.at(0));
  for (int i = 2; i < N; i++) {
    dp.at(i)=dp.at(i-1)+abs(h.at(i)-h.at(i-1));
    if(K<=i){
      for (int j = 0; j <= K; j++) {
      dp.at(i)=min(dp.at(i),dp.at(i-j)+abs(h.at(i)-h.at(i-j)));
      }
    }
    else{
      for (int j = 0; j <= i; j++) {
      dp.at(i)=min(dp.at(i),dp.at(i-j)+abs(h.at(i)-h.at(i-j)));
      }
    }
  }
    cout<<dp.at(N-1)<<endl;
  
}






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

int main(void) {
    int n;
    int cnt = 0;

    cin >> n;
    int v[n];
    int c[n];

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

    for (int i=0; i < n; i++) {
        cin >> c[i];
        if (v[i] - c[i] >= 0) {
            cnt += v[i] - c[i];
        }
    }
    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check(int a)
{
	int bai=a/100,ge=a%10;
	if(bai==ge) return true;
	return false;
}
int main()
{
	int a;
	cin>>a;
	if(check(a)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;
    std::string S;
    std::cin >> N >> S;

    auto check = [&]{

        if (S.size()%2 == 1) return "No";

        for (uint64_t i = 0; i < S.size()/2; ++i) {
            auto left = S.at(i);
            auto right = S.at(S.size()/2 + i);
            if (left != right) return "No";
        }

        return "Yes";
    };


    std::cout << check() << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> y(n);
    rep(i, n) { cin >> x.at(i) >> y.at(i); }
    vector<ll> ptn(n);
    rep(i, n) ptn.at(i) = i;
    double cnt = 0;
    double res = 0;

    do {
        cnt++;
        for(size_t i = 0; i < n - 1; i++) {
            res += sqrt(pow(x.at(ptn.at(i)) - x.at(ptn.at(i + 1)), 2) +
                        pow(y.at(ptn.at(i)) - y.at(ptn.at(i + 1)), 2));
        }

    } while(next_permutation(all(ptn)));
    cout << fixed << setprecision(15) << res / cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sycnt2_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pow10(n) stoll("1"+string(n,'0'))
//fill(all(arr),1)
//if(map.count(key)){}
//bitset<20>(n);
//int mini=min({a,b,c,d,e});
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;
 
int32_t main()
{
 char c;
 cin>>c;
 if(c<'a')cout<<"A";
 else cout<<'a';
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] arr = new int[100000];


        for (int i = 1; i*i <= 10000; i++) {
            for (int j = 1; j*j <=10000 ; j++) {
                for (int k = 1; k*k <=10000 ; k++) {
                    int val = i*i+j*j+k*k+i*j+i*k+j*k;
                    arr[val]++;
                }
            }
        }

        for (int i = 1; i <= N; i++) {
            System.out.println(arr[i]);
        }

    }



}


Measured memory_bytes: 39064
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <fstream>
#include <iomanip>
using namespace std;

#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define double long double
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const i64 MOD = 1000000007;
const i64 INF = 2e15;

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

	double w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << setprecision(9) << fixed << (w * h) / 2 << " ";

	if (x * 2 == w && y * 2 == h) cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

bool check(int n){
    return( n/100 == (n%100)/10 && n/100 == (n%10)   );
    
}

int main()
{
    int n;
    cin >> n;
    
    while(!check(n))n++;
    cout << n << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX-1;
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };


int main(){
	int n;
	cin >> n;
	double sum = (double)0;
	rep(i, 0, n) {
		double x;
		string u;
		cin >> x >> u;
		if (u == "JPY") {
			sum += x;
		}
		else if (u == "BTC") {
			sum += x * (double)(380000);
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	in := sc.Text()

	vars := strings.Split(in, " ")
	a, _ := strconv.Atoi(vars[0])
	b, _ := strconv.Atoi(vars[1])
	c, _ := strconv.Atoi(vars[2])

	if a < b && b < c {
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}

}



Measured memory_bytes: 1120
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>

#define MAX_N 5000000

using namespace std;

vector<int>  primes;
vector<bool> is_prime;

void Init()
{
  is_prime.resize(MAX_N + 1, true);
  for (int i = 2; i <= MAX_N; i++)  {
    if (is_prime[i]) {
      primes.push_back(i);
      for (int j = i * 2; j <= MAX_N; j += i) {
        is_prime[j] = false;
      }
    }
  }
}

int Func(int N, int P)
{
  vector<int> vi;
  int offset;
  for (offset = 0; offset < primes.size(); offset++) 
    if (primes[offset] > N)
      break;

  for (int i = 0; i < P; i++)
    for (int j = i; j < P; j++) {
      vi.push_back(primes[i + offset] + primes[j + offset]);
    }

  sort(vi.begin(), vi.end());
  return vi[P - 1];
}

int main()
{
  Init();
  int N, P;
  while (cin >> N >> P && N != -1 && P != -1) {
    cout << Func(N, P) << endl;
  }
}

Measured memory_bytes: 3016
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A1=sc.nextInt();
    int A2=sc.nextInt();
    int A3=sc.nextInt();
    
    if(A1+A2+A3 < 22) {
      System.out.println("win");
    }
      else {
        System.out.println("bust");
      }
  }
}

Measured memory_bytes: 21844
#import sys
#import numpy as np
import itertools
from scipy.sparse import coo_matrix, lil_matrix
from scipy.sparse.csgraph import dijkstra, bellman_ford, floyd_warshall
#sys.setrecursionlimit(10000)

#H, W = [int(i) for i in input().split()]
N = int(input())

rows = []
cols = []
weights = []

"""
for _ in range(M):
    # u v 間のコスト
    u, v, a = [int(i) for i in input().split()]
    rows.append(u-1)
    cols.append(v-1)
    weights.append(a)
"""

for i in range(N):
    rows.append(i)
    cols.append((i+1)%N)
    weights.append(1)

for i in range(N):
    if i - ((10 * i) % N) == -1:
        weights[i] = 0
    elif i == N-1 and i - ((10 * i) % N) == 1:
        weights[i] = 0
    else:
        rows.append(i)
        cols.append((10 * i) % N)
        weights.append(0)

graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()
#graph = coo_matrix((weights, (cols, rows)), shape=(10, 10)).tocsr()
#print(graph)
d1 = dijkstra(graph, indices=1, directed=True, unweighted=False)

print(int(d1[0]+1.5))



Measured memory_bytes: 43876
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
using namespace std;

using ll = long long;

bool is_prime(int x) {
    if (x < 2) return false;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    int x;
    cin >> x;
    while (!is_prime(x)) x++;
    cout << x << '\n';
    return 0;
}


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

A = [input() for i in range(N)]
B = [input() for i in range(M)]


for i in range(N-M+1):
    for j in range(N-M+1):
        flg = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] == B[k][l]:
                    pass
                else:
                    flg=False
                    break
            if flg==False:
                break

        if flg:
            break
    if flg:
        break
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63744
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
int main(){
    int n,q; cin >> n >> q;
    vector<vector<int> > v(n);
    /* 
    for(int i = 0; i < n; i++){
        cout << i << "size:" << v[i].size() << endl;
    }
    */
    for(int i = 0; i < q; i++){
        int num; cin >> num;
        if (num == 0){
            int t,x; cin >> t >> x;
            v[t].push_back(x);
        } else if (num == 1){
            int t; cin >> t;
            if (v[t].size() == 0) cout << endl;
            else {
                cout << v[t][0];
                for(int j = 1; j < v[t].size(); j++){
                    cout << " " << v[t][j];
                }
                cout << endl;
            }
        } else if (num == 2){
            int t; cin >> t;
            v[t].clear();
        }
    }
}
  




Measured memory_bytes: 5740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int N = V[0], A = V[1], B = V[2];
            int max = Math.Min(A, B);
            int min = Math.Max(A + B - N, 0);
            Console.WriteLine("{0} {1}", max, min);
        }
    }
}


Measured memory_bytes: 13140
def main():
    n = int(input())
    grid = [input() for _ in [0]*n]
    for i in grid:
        if "#" in i:
            break
    else:
        print(-1)
        return
    ans = 10**20
    # i行目に何個黒があるか
    black_cnt = [0]*n
    # i列目に黒が一つでもあればTrue
    exist = [False]*n
    for i in range(n):
        for j in range(n):
            if grid[i][j] == "#":
                black_cnt[i] += 1
                exist[j] = True
    # 縦一列が既に黒の列の数
    all_cnt = 0
    for j in range(n):
        for i in range(n):
            if grid[i][j] == ".":
                break
        else:
            all_cnt += 1
    for i in range(n):
        if exist[i]:
            ans = min(ans, n-black_cnt[i]+n-all_cnt)
        else:
            ans = min(ans, 2*n-black_cnt[i]-all_cnt+1)
    print(ans)


main()


Measured memory_bytes: 3316
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll X,Y;cin>>X>>Y;
    REP(i,X+1){
        REP(j,X+1){
            if(i+j!=X)continue;
            if(i*2+j*4==Y){
                cout<<"Yes"<<"\n";
                exit(0);
            }
        }
    }
    cout<<"No\n";
}

Measured memory_bytes: 3640