akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;
const long long MOD = 1000000007;

void solve(long long N){
    map<ll, ll> res;
    for(ll n=2; n<= N; n++){
        ll nnew = n;
        for(ll i=2; i*i <= nnew; i++){
            while(nnew % i == 0){
                ++res[i];
                nnew /= i;
            }
        }
        if(nnew != 1) {
            ++res[nnew];
        }
    }
    ll cnt = 1;
    for(auto it = res.begin(); it != res.end(); ++it){
        cnt *= (it->second+1);
        cnt = cnt % MOD;
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), H = ip[0], W = ip[1];
	auto s = readMatrix!char(H, W);
	bool[][] visited = new bool[][](H, W);
	alias Pair = Tuple!(int, "y", int, "x", int, "c");
	Pair[] stack = [Pair(0, 0, 0)];
	auto m = s.map!(i => i.map!(j => j == '.' ? 1 : 0).sum).sum;
	int a;
	int[] dx = [1, 0, -1, 0], dy = [0, 1, 0, -1];
	while(stack != []) {
		auto p = stack.front;
		stack.popFront;
		foreach(k; 0..4) {
			auto y = p.y + dy[k], x = p.x + dx[k];
			if(0 <= y && y < H && 0 <= x && x < W
				&& s[y][x] == '.' && !visited[y][x]) {
				stack ~= Pair(y, x, p.c+1);
				visited[y][x] = true;
				if(y == H-1 && x == W-1) {
					a = p.c+1;
					stack = null;
				}
			}
		}
	}
	if(visited[H-1][W-1]) (m - a - 1).writeln;
	else writeln(-1);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 508
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i, N)
    {
        cin >> H[i];
    }
    sort(H);
    //
    ll total = 0;
    for (ll i = 0; i < int(H.size())-K; ++i)
    {
        total += H[i];
    }
    cout << total;

    //
    return 0;
}

Measured memory_bytes: 4748
#include<bits/stdc++.h>
using namespace std;
#define MAX 100
#define INF 1<<25
int n,cost[MAX][MAX];
int mincost[MAX];
bool used[MAX];
int prim(){
  for(int i=0;i<n;i++)mincost[i]=INF,used[i]=false;
    mincost[0]=0;
  int res=0;
  while(1){
    int v=-1;
    for(int u=0;u<n;u++)
      if(!used[u]&&(v==-1||mincost[u]<mincost[v]))v=u;
    if(v==-1)break;
    used[v]=1;
    res+=mincost[v];
    for(int u=0;u<n;u++)mincost[u]=min(mincost[u],cost[v][u]);
  }
return res;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e;
      cin>>e;
      cost[i][j]=(e==-1)?INF:e;
    }
  }
  cout<<prim()<<endl;
}

Measured memory_bytes: 3068
import java.io.*;
class Main{
    public static void main (String[] args) throws IOException{

	BufferedReader br=
	    new BufferedReader(new InputStreamReader(System.in));
	String buf;
	while((buf=br.readLine())!= null){
	    String[] buf2=buf.split(" ");
	    int  data2=0;
	    for(int i=0;i!=buf2.length;i++){
		data2+=Integer.parseInt(buf2[i]);
	    }
	    String ans=(new Integer(data2)).toString();
	    System.out.println(ans.length());
	}
    }
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N;
    cin >> N;
    int dist[N][N];
    rep(i, N) rep(j, N) {
        cin >> dist[i][j];
    }
    vector<vector<bool>> judge(N, vector<bool>(N, true));
    rep(i, N) rep(j, N) {
        rep(k, N) {
            if(k == i || k == j) continue;
            if(dist[i][k] + dist[k][j] < dist[i][j]) {
                cout << -1 << endl;
                return 0;
            }
            if(dist[i][k] + dist[k][j] == dist[i][j]) {
                judge[i][j] = false;
                judge[j][i] = false;
            }
        }
    }
    int ans = 0;
    rep(i, N) rep(j, N) {
        if(judge[i][j]) ans += dist[i][j];
    }
    cout << ans / 2 << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

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

using namespace std;

int main(){
    int n,l;
    cin >> n >>l;
    vector<string> v(n);
    rep(i,n){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    rep(i,n){
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int A[9],B, N;
	int X[9] = { 0,0,0,0,0,0,0,0,0 };
	rep(i, 9) {
		cin >> A[i];
	}
	cin >> N;
	rep(i, N) {
		cin >> B;
		rep(j, 9) {
			if (A[j] == B)
				X[j] = 1;
		}
	}
	rep(i, 3) {
		if ((X[i] == 1 && X[i + 3] == 1) && X[i + 6] == 1) {
			cout << "Yes";
			return 0;
		}
		if ((X[3 * i] == 1 && X[3 * i + 1] == 1) && X[3 * i + 2] == 1) {
			cout << "Yes";
			return 0;
		}
	}
	if ((X[0] == 1 && X[4] == 1) && X[8] == 1) {
		cout << "Yes";
		return 0;
	}
	if ((X[2] == 1 && X[4] == 1) && X[6] == 1) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
}

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

int main(){
  int D;
  cin >> D;
  if(D == 22){
    cout << "Christmas Eve Eve Eve" << endl;
  } else if( D== 23){
    cout << "Christmas Eve Eve" << endl;
  } else if (D == 24){
    cout << "Christmas Eve" << endl;
  } else if ( D== 25){
    cout << "Christmas" << endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;

int main() {
	cin >> N >> M;
	vector<pair<int, int>>fight;
	for (int i = 0; i < M; i++) {
		int l, r;
		cin >> l >> r;
		fight.push_back(make_pair(l, r));
	}
	sort(fight.begin(), fight.end(), [](pair<int,int> &a, pair<int, int> &b) {return a.second < b.second; });
	int end = 0;
	for (int i = 0; i < M;i++) {
		if (fight[i].first >= end) {
			end = fight[i].second;
			ans++;
		}
	}
	cout << ans << endl;
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

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

    priority_queue<ll> que;

    rep(i, N)
    {
        ll a;
        cin >> a;
        que.push(a);
    }


    std::priority_queue<int> quel;

    rep(i, M)
    {
        ll tmp = que.top();
        que.pop();
        que.push(tmp/2);
    }

    ll ans=0;
    rep(i, N)
    {
        ans+=que.top();
        que.pop();
    }

 
    cout << ans << endl;
 

    return 0;
}

Measured memory_bytes: 1400
N, K, Q = map(int, input().split())
A = [int(input()) for i in range(Q)]
r = [0]*N
for a in A:
    r[a-1] = r[a-1]+1
for n in range(len(r)):
    print('Yes' if K-(Q-r[n]) > 0 else 'No')

Measured memory_bytes: 8648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  set<char> st;
  string s; cin >> s;
  rep(i,3){
    st.insert(s[i]);
  }
  if(st.size()==2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

template<class T> class BIT   // 1-indexed (0 is not used)
{
private:
    int num;
    vector<T> bit;
public:
    BIT(int n):bit(vector<T>(n+1, 0)), num(n) {}

    T sum(int i) {   // sum of 1..i
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, T x) {
        if (i > num) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

int main(int argc, char* argv[])
{
    int n, K;
    scanf("%d%d", &n, &K);

    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]); 
        a[i]-=K;
    }
    
    vector<ll> s(n+1);
    for(i=0; i<n; i++) {
        s[i+1]=s[i]+a[i];
    }

    map<ll,int> z;
    for(i=0; i<=n; i++) {
        z[s[i]]=0;
    }
    int cnt=0;
    auto it=z.begin();
    for(; it!=z.end(); ++it) {
        cnt++;
        it->second=cnt;
    }

    ll ans=0;
    BIT<int> bit(cnt);
    for(i=0; i<=n; i++) {
        ans += bit.sum(z[s[i]]);
        bit.add(z[s[i]],1);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 15872
H =int(input())

#h= 1
#while 2**(h+1) <= H:
#    h += 1
#
#n=2**(h+1) - 1
#print(n)
#
import math
def helper(h):
    if h ==1:
        return 1
    return 1 + 2 * helper(math.floor(h/2))
print(helper(H))

Measured memory_bytes: 9172
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#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;

void mainmain(){
	int t;
	vint v(5);
	while(cin>>v[0],v[0]){
		vint a(4,0);
		a[v[0]]++;
		rep(i,4){
			cin>>v[i+1];
			a[v[i+1]]++;
		}
		if(a[1]&&a[2]&&a[3]){
			rep(i,5){
				cout<<3<<endl;
			}
		}
		else if(a[1]==5||a[2]==5||a[3]==5){
			rep(i,5){
				cout<<3<<endl;
			}
		}
		else{
			int win;
			if(a[1]==0){
				win=2;
			}
			else if(a[2]==0){
				win=3;
			}
			else{
				win=1;
			}
			rep(i,5){
				if(v[i]==win){
					cout<<1<<endl;
				}
				else{
					cout<<2<<endl;
				}
			}
		}
	}
}



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

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}


int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s,t;cin>>s>>t;
    reverse(s.begin(),s.end());
    if(s==t) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <string>

using namespace std;
using ll = long long int;

int main(){
    char a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a == b || b == c || c==d){
        std::cout << "Bad" << endl;
    }else{
        std::cout << "Good" << endl;
    }
}


Measured memory_bytes: 764
N, K = map(int, input().split())

point = [int(i) for i in range(N+1)]
count = 0

max_val = int(sum(point[-K:]))
min_val = int(sum(point[:K]))
count = int(max_val - min_val + 1)%1000000007

for i in range(K, N+1):
    max_val = max_val + point[-i-1]
    min_val = min_val + point[i]
    count += int(max_val - min_val + 1)%1000000007 
print(int(count)%1000000007)

Measured memory_bytes: 18616
#include <cstdio>
#include <cstring>

#define maxn 210
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
char mp[maxn][maxn];
int d[maxn][maxn];
bool vis[maxn], flag;
int dep[maxn], ans, n, fa[maxn], col[maxn];
void dfs(int x)
{
	dep[x] = dep[fa[x]] + 1;
	col[x] = col[fa[x]] ^ 1;
	vis[x] = 1;
	for (int i = 1; i <= n; ++i)
		if (mp[x][i] == '1')
		{
			if (!vis[i])
			{
				fa[i] = x;
				dfs(i);
			}
			else if (col[x] == col[i]) flag = 1;
		}
}
int q[maxn];
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%s", mp[i] + 1);
	dfs(1);
	if (flag) {puts("-1"); return 0;}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			d[i][j] = mp[i][j] - '0';
	for (int i = 1; i <= n; ++i)
	{
		memset(dep, 0, sizeof (dep));
		int head = 0, tail = 1; dep[q[1] = i] = 1;
		while (head < tail)
		{
			int now = q[++head]; cmax(ans, dep[now]);
			for (int i = 1; i <= n; ++i)
				if (d[now][i] && !dep[i])
					dep[q[++tail] = i] = dep[now] + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

	using namespace std;

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

		int n;

		cin >> n;

		for(int i = 1; i <= n; ++i){
			for(int j = i + 1; j <= n; ++j){
				for(int idx = 0; true; ++idx){
					if((i & (1 << idx)) != (j & (1 << idx))){
						cout << idx + 1 << " ";
						break;
					}
				}
			}
			cout << "\n";
		}

		return 0;
	}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>

using namespace std;

int x,n,m;

int main(){
    cin >> x;
    n = 0;
    m = 0;

    while(x >= 500){
        x -= 500;
        n++;
    }
    while(x >= 5){
        x -= 5;
        m++;
    }

    cout << n*1000+m*5 << endl;
}

Measured memory_bytes: 256
main = do
    l <- getLine
    let (a:b:[]) = map read $ words l :: [Int]
        x = area a b
        y = circumference a b
    putStrLn $ show x ++ " " ++ show y

area :: Int -> Int -> Int
area a b = a * b

circumference :: Int -> Int -> Int
circumference a b = (a + b) * 2

Measured memory_bytes: 3520
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<int>> dis(N,vector<int>(N,Inf));
	
	vector<pair<pair<int,int>,int>> V(M);
	for(int i=0;i<M;i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		V[i]=make_pair(make_pair(a,b),c);
		dis[a][b]=c;
		dis[b][a]=c;
	}
	
	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				if(dis[i][k]+dis[k][j]<dis[i][j]){
					dis[i][j]=dis[i][k]+dis[k][j];
				}
			}
		}
	}
	
	int ans = 0;
	
	for(int i=0;i<M;i++){
		if(dis[V[i].first.first][V[i].first.second]!=V[i].second)ans++;
	}
	
	cout<<ans<<endl;	
	
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

        int S = scanner.nextInt();
        int W = scanner.nextInt();

        String ans;
        if (S <= W) {ans = "unsafe";}
        else {ans = "safe";}

        System.out.println(ans);

        scanner.close();
    }
}

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

int main() {
    int a,b,sum=0;
    cin>>a>>b;
    rep(i,2) {
        if (a>=b) {
            sum+=a;
            a--;
        } else {
            sum+=b;
            b--;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long x,n,a[100002][102],c,inf,s,ok,b;
pair<long long,long long>p[102];
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
     cin>>n>>x;
     inf=0x7fffffffff;
     for(int i=0;i<n;i++){
     	cin>>b>>c;
     	ok=ok+c;
     	p[i]=make_pair(b,c);
     }
	 for(int i=1;i<ok+1;i++){
	 	for(int j=0;j<n;j++){
	 		a[i][j]=inf;
	 	}
	 }
	 a[p[0].second][0]=p[0].first; 
	 for(int i=0;i<ok+1;i++){
	 	for(int j=1;j<n;j++){
	 		if(p[j].second<=i)
	 		     a[i][j]=min(p[j].first+a[i-p[j].second][j-1],a[i][j-1]);
		    else
		         a[i][j]=a[i][j-1];
		 }
	 }
	 s=ok;
	 while(a[s][n-1]>x){
	 	s--;
	 }
	 cout<<s;
return 0;
}

Measured memory_bytes: 80000
'use strict'

function main(s) {

  s = s.split('\n');
  const n = Number(s[0]);
  const d = Number(s[1].split(' ')[0]);
  const remain = Number(s[1].split(' ')[1]);
  const a = s.slice(2, -1).map(el => Number(el));
  let eaten = 0;

  for (let num of a) {
    let i = 0;
    while ((num * i) + 1 <= d) {
      eaten += 1;
      i += 1;
    }
  }

  const ans = remain + eaten;
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
n=int(input())
t,a=list(map(float,input().split()))
h=list(map(int,input().split()))
tmp=float(1e9+7)
ans=0
for i in range(n):
    if abs(a-(t-h[i]*0.006))<tmp:
        tmp=abs(a-(t-h[i]*0.006))
        ans=i+1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int N_MAX=1e5+1;
  bool is_prime[N_MAX];
  bool is_2017[N_MAX];
  rep(i,N_MAX){
    is_prime[i]=true;
    is_2017[i]=true;
  }
  is_prime[0]=is_prime[1]=false;
  is_2017[0]=is_2017[1]=is_2017[2]=false;
  for(int i=2; i<N_MAX;i++){
    if(is_prime[i]){
      for(int j=2*i; j<=N_MAX; j+=i){
	is_prime[j]=false;
	is_2017[j]=false;		
      }
      if(!is_prime[(i+1)/2] && i!=2) is_2017[i]=false;
    }
  }
  //  rep(i,N_MAX) if(is_2017[i]) cout << i << endl;
  int sum[N_MAX+1];
  sum[0]=0;
  rep1(i,N_MAX){
    if(is_2017[i-1]) sum[i]=1;
    else sum[i]=0;
    sum[i]+=sum[i-1];
  }
  int Q;
  cin >> Q;
  int l[Q],r[Q];
  rep(i,Q) cin >> l[i] >> r[i];
  rep(i,Q) cout << sum[r[i]+1]-sum[l[i]] << endl;
    

  
  
  return 0;

}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> l;

    rep(i,n){
        int tmp;
        cin >> tmp;
        l.pback(tmp);
    }

    sort(ALL(l));

    int ans = 0;

    for(int i = n - 1; i >= 1; i--){
        for(int j = i - 1; j >= 0; j--){

            auto itr = upper_bound(l.begin(), l.end(), l[i] - l[j]);
            int index = distance(l.begin(), itr);

            if(index < j){
                //cerr << index << " " << j << " " << i << endl;
                ans += j - index;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

#define mp make_pair
#define fi first
#define se second
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) (((a) * (b)) / (__gcd((a), (b))))
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define setbits(x) __builtin_popcountll(x)
#define unsetend(x) __builtin_ctzll(x)
#define unsetfront(x) __builtin_clzll(x)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define ll long long
#define endl "\n"
#define Endl "\n"

// long long expo(long long a, long long b, long long mod)
// {
//     ll ret = 1;
//     while (b > 0)
//     {
//         if (b % 2 == 1)
//             ret = (((ret)%mod) * ((a)%mod))%mod;
//
//         a = ((a)%mod) * ((a)%mod)%mod;
//         b = b / 2;
//     }
//     return (ret%mod);
// }

// vector<long long> seive()
// {
//    long long i,j;
//    vector<long long> hash(1000001,1);
//    vector<long long> primes;
//
//    for(i=2;i*i<=1000000;i++)
//    {
//        if(hash[i])
//        {
//            for(j=i*i;j<=1000000;j+=i)
//            hash[j]=0;
//        }
//    }
//    for(i=2;i<1000001;i++)
//    {
//        if(hash[i])
//        primes.pb(i);
//    }
//    return primes;
// }

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

    int n, a, b, c;
    cin >> n;

    int dp[3][n + 1];
    cin >> a >> b >> c;
    dp[0][1] = a;
    dp[1][1] = b;
    dp[2][1] = c;
    int i = 2;
    for (i = 2; i <= n; i++)
    {
        cin >> a >> b >> c;
        dp[0][i] = a + max(dp[1][i - 1], dp[2][i - 1]);
        dp[1][i] = b + max(dp[0][i - 1], dp[2][i - 1]);
        dp[2][i] = c + max(dp[1][i - 1], dp[0][i - 1]);
    }
    cout << max(dp[0][n], max(dp[1][n], dp[2][n]));
}


Measured memory_bytes: 4820
import math

def koch(n, p1, p2):
    if n == 0: return

    sx = (2*p1[0] + p2[0]) / 3
    sy = (2*p1[1] + p2[1]) / 3
    s = [sx,sy]
    tx = (p1[0] + 2*p2[0]) / 3
    ty = (p1[1] + 2*p2[1]) / 3
    t = [tx,ty]
    ux = (t[0] - s[0]) * 0.5 - (t[1] - s[1]) * math.sin(math.radians(60)) + s[0]
    uy = (t[0] - s[0]) * math.sin(math.radians(60)) + (t[1] - s[1]) * 0.5 + s[1]
    u = [ux,uy]
    
    koch(n-1, p1, s)
    print(s[0], " ", s[1]) 
    koch(n-1, s, u)
    print(u[0], " ", u[1]) 
    koch(n-1, u, t)
    print(t[0], " ", t[1]) 
    koch(n-1, t, p2)

n = int(input())
p1 = [0,0]
p2 = [100,0]

print(p1[0], " ", p1[1])
koch(n, p1, p2)
print(p2[0], " ", p2[1])


Measured memory_bytes: 5808
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);

    rep(i,n)cin >> a[i];
    int s = 0;
    rep(i,n)s += a[i];

    set<int> y;
    for(int i = 1;i < sqrt(s)+1;i++){
        if(s%i == 0){
            y.insert(i);
            y.insert(s/i);
        }
    }

    int ans = 1;
    for(auto x:y){
        // cerr << x <<  " ";
        int ss = 0;
        vector<int> b(n);
        rep(i,n){
            ss += a[i]%x;
            b[i] = a[i]%x;
        }
        SORT(b);
        //判定
        // if(ss <= k*2)ans = max(ans,x);
        int er = ss/x;
        int h = 0;
        for(int i = 0;i < n-er;i++){
            h += b[i];
        }
        if(h <= k)ans = x;
    }
    // cerr << endl;
    cout << ans << endl;

    

    
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc136.contest.atcoder.jp/tasks/abc136_b


Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#endif
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int len[2005];
int calc(int x,int y){
	int L=y,R=n+1;
	while(R-L>1){
		int mid=L+R>>1;
		if(len[mid]>=len[x]+len[y])R=mid;
		else L=mid;
	}
	return L-y;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>len[i];
	sort(len+1,len+n+1);
	ll ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			ans+=calc(i,j);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

ll MOD = 1e9+7;
int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);

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

    vector<ll> adc(100001);
    vector<ll> bdc(100001);
    ll i;
    int num = A;
    for (i = 2; i * i <= num; i++){
        while (num % i == 0){
            adc.at(i)++;
            num /= i;
        }
    }
    if(num > 1){
        adc.at(num)++;
    }

    num = B;
    for (i = 2; i * i <= num; i++){
        while (num % i == 0){
            bdc.at(i)++;
            num /= i;
        }
    }
    if(num > 1){
        bdc.at(num)++;
    }
    ll answer = 1;
    for(i = 2; i <= 100000; i++){
        int maxAB = max(adc.at(i), bdc.at(i));
        for(int j = 0 ; j < maxAB; j++){
            answer *= i;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct region {
  int xmin = 51;
  int xmax = -1;
  int ymin = 51;
  int ymax = -1;
};


bool hoge(int h, int w, vector<vector<char>> &image, vector<region> regions, vector<int> indexes)
{
  bool flag = false;

  do {
    vector<vector<int>> image2(50, vector<int>(50));

    for (int i = 0; i < h; ++i)
      for (int j = 0; j < w; ++j)
        image2[i][j] = '.';

    for (auto &idx : indexes) {
      char c = char(idx + 'A');
      region r = regions[idx];
      for (int x = r.xmin; x <= r.xmax; ++x)
        for (int y = r.ymin; y <= r.ymax; ++y)
          image2[x][y] = c;
    }

    flag = true;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (image[i][j] != image2[i][j]) {
          flag = false;
          break;
        }
      }
    }
    if (flag)
      break;
  } while (next_permutation(indexes.begin(), indexes.end()));

  return flag;
}

int main() {
  int h, w;

  cin >> h; // dummy

  while (cin >> h >> w) {
    vector<vector<char>> image(50, vector<char>(50));
    vector<region> regions(25);
    vector<int> indexes;

    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> image[i][j];

        if (image[i][j] == '.')
          continue;

        int idx = int(image[i][j] - 'A');
        regions[idx].xmin = (i < regions[idx].xmin) ? i : regions[idx].xmin;
        regions[idx].xmax = (regions[idx].xmax < i) ? i : regions[idx].xmax;
        regions[idx].ymin = (j < regions[idx].ymin) ? j : regions[idx].ymin;
        regions[idx].ymax = (regions[idx].ymax < j) ? j : regions[idx].ymax;
        indexes.push_back(image[i][j] - 'A');
      }
    }

    sort(indexes.begin(), indexes.end());
    indexes.erase(unique(indexes.begin(), indexes.end()), indexes.end());

    cout << (hoge(h, w, image, regions, indexes) ? "SAFE" : "SUSPICIOUS") << endl;
  }
}


Measured memory_bytes: 3092
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int n;
	scanf("%d\n", &n);
	int T[250];

	for (int i = 1; i < n + 1; i++) {
		int m;
		scanf("%d", &m);
		T[i] = m;
	}

	for (int i = 1; i < n + 1; i++) {
		printf("node %d: key = %d, ", i, T[i]);
		if (i != 1) {
			printf("parent key = %d, ", T[i / 2]);
		}
		if (i * 2 <= n) {
			printf("left key = %d, ", T[i * 2]);
			if (i * 2 + 1 <= n) {
				printf("right key = %d, \n", T[i * 2 + 1]);
			}
			else {
				printf("\n");
			}
		}
		else {
			printf("\n");
		}
	}

	return 0;
}


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

int main() {
    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        long long a, b;
      int res;
        cin >> a >> b;
        long long q = ceil(sqrt(a * b));
        if (a == b) {
            res = 2 * (a - 1);
        } else if(a * b > q * (q - 1)) {
            res = 2 * (q - 1) - 1;
        } else {
            res = 2 * (q - 2);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;
int INF=10000;
int dp[40001][401][41];

int main(){
    int n,ma,mb;cin>>n>>ma>>mb;
    int a[n+1],b[n+1],c[n+1];for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i];
    
    for(int i=0;i<=400;i++)for(int j=0;j<=400;j++)for(int k=0;k<=n;k++)dp[i][j][k]=INF;
    dp[0][0][0]=0;
    for(int i=0;i<=400;i++)for(int j=0;j<=400;j++)for(int k=1;k<=n;k++){
        if(i<a[k]||j<b[k])dp[i][j][k]=dp[i][j][k-1];
        else dp[i][j][k]=min(dp[i][j][k-1],dp[i-a[k]][j-b[k]][k-1]+c[k]);
    }
    int min=INF;
    for(int i=1;i<=400/(max(ma,mb));i++){
        if(dp[i*ma][i*mb][n]<min)min=dp[i*ma][i*mb][n];
    }
    if(min==INF)cout<<"-1"<<endl;
    else cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 27008
s = input()

s = s.replace('BC', 'V')

ans = 0
cnt = 0
flag = False

for i in range(len(s)):
    if s[i] == 'A':
        flag = True
        cnt += 1
    elif flag and s[i] == 'V':
        ans += cnt
    else:
        flag = False
        cnt = 0

print(ans)


Measured memory_bytes: 3500
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   
    ll n;
    cin >> n;
    vector <ll> v;
    for (ll i=0;i<n;i++){
        ll tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    long double ans = 0;
    ll div = 1;
    for (ll i=0;i<n-1;i++){
        div *= 2;
        ans += v[i] / (long double)div;
    }
    ans += v[n-1] / (long double)div;
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=[]
ans=0
for i in range(2,n):
    if i*i>n:
        break
    x=0
    while n%i==0:
        n//=i
        x+=1
    a.append(x)
if n!=1:
    ans+=1

for i in a:
    b=1
    while b<=i:
        i-=b
        b+=1
        ans+=1
print(ans)

Measured memory_bytes: 16868
import numpy as np

N = input()
a_list = np.array(list(map(int, input().split())))
b_list = np.array(list(map(int, input().split())))

#  # すべての準備度が必要度を上回っている場合
#  if all([a >= b for a, b in zip(a_list, b_list)]):
#      print(0)
#  # 準備度が足りていない試験がある場合
#  else:
# そもそも準備度の総量が足りない場合
if sum(a_list) < sum(b_list):
    print(-1)
else:
    # 準備度を移動すれば受かる場合
    # 一番数の大きいところから足りていないところに割り振る戦略
    # a_listをcopy
    # 準備度の余裕をリストに格納
    diff_list = a_list - b_list
    # 昇順にソート
    diff_list.sort()
    start = 0
    end = -1
    current_value = diff_list[end]
    while diff_list[start] < 0:
        # 最大値から減算
        current_value += diff_list[start]
        while current_value < 0:
            end -= 1
            current_value += diff_list[end]
        start += 1
    if start == 0:
        print(0)
    else:
        print(start - end)
        


Measured memory_bytes: 23904
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  double t,x;
  cin >> t >>x;


  double ans = 0;





  cout << (t/x);

  // cout << (ans-mx/2) <<endl;


}




















Measured memory_bytes: 256
#include<cctype>
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

int rotx(string &dice){
	char t=dice[0];
	dice[0]=dice[1];
	dice[1]=dice[5];
	dice[5]=dice[4];
	dice[4]=t;
}

int roty(string &dice){
	char t=dice[0];
	dice[0]=dice[3];
	dice[3]=dice[5];
	dice[5]=dice[2];
	dice[2]=t;
}

int rotz(string &dice){
	char t=dice[1];
	dice[1]=dice[3];
	dice[3]=dice[4];
	dice[4]=dice[2];
	dice[2]=t;
}

void next(string &dice,int i){
	if(i%4==0){
		if(i%8==0)	rotx(dice);
		else		roty(dice);
	}
	rotz(dice);
}

int main(){
	string dice[8];
	while(1){
		for(int i=0;i<8;i++)	cin>>dice[i];
		if(dice[0]=="0")	break;

		char co[128];
		for(int c='A';c<='Z';c++)	co[c]=tolower(c);
		for(int c='a';c<='z';c++)	co[c]=toupper(c);

		bool exist[8][128]={};
		for(int i=0;i<8;i++)for(int j=0;j<6;j++)	exist[i][dice[i][j]]=true;

		bool ok=false;
		int i[]={0,1,2,3,4,5,6,7};
		int a,b,c,d,e,f,g,h;
		string diceA,diceB,diceC,diceD,diceE,diceF,diceG,diceH;
		do{
			a=i[0];	b=i[1];	c=i[2];	d=i[3];
			e=i[4];	f=i[5];	g=i[6];	h=i[7];
			diceA=dice[a];	diceB=dice[b];	diceC=dice[c];	diceD=dice[d];
			diceE=dice[e];	diceF=dice[f];	diceG=dice[g];	diceH=dice[h];

			for(int ia=0;ia<24;ia++,next(diceA,ia)){
if(!exist[b][co[diceA[2]]])	continue;
if(!exist[e][co[diceA[5]]])	continue;
				for(int ib=0;ib<24;ib++,next(diceB,ib)){
					if(co[diceA[2]]!=diceB[3])	continue;
if(!exist[c][co[diceB[4]]])	continue;
if(!exist[f][co[diceB[5]]])	continue;
					for(int ic=0;ic<24;ic++,next(diceC,ic)){
						if(co[diceB[4]]!=diceC[1])	continue;
if(!exist[d][co[diceA[4]]] || !exist[d][co[diceC[3]]])	continue;
if(!exist[g][co[diceC[5]]])	continue;
						for(int id=0;id<24;id++,next(diceD,id)){
							if(co[diceA[4]]!=diceD[1] || co[diceC[3]]!=diceD[2])	continue;
							for(int ie=0;ie<24;ie++,next(diceE,ie)){
								if(co[diceA[5]]!=diceE[0])	continue;
								for(int iF=0;iF<24;iF++,next(diceF,iF)){
									if(co[diceB[5]]!=diceF[0] || co[diceE[2]]!=diceF[3])	continue;
									for(int ig=0;ig<24;ig++,next(diceG,ig)){
										if(co[diceC[5]]!=diceG[0] || co[diceF[4]]!=diceG[1])	continue;
										for(int ih=0;ih<24;ih++,next(diceH,ih)){
											if(co[diceD[5]]!=diceH[0] || co[diceE[4]]!=diceH[1] || co[diceG[3]]!=diceH[2])	continue;
											ok=true;
											goto FOUND;
										}
									}
								}
							}
						}
					}
				}
			}
		}while(next_permutation(i+1,i+8));

		FOUND:
		cout<<(ok?"YES":"NO")<<endl;
	}

	return 0;
}

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

bool can_reach(string s, int start, int end) {
  for (int i = start; i + 1 <= end; i++)
    if (s.substr(i, 2) == "##") return false;
  return true;
}

bool can_overlap(string s, int start, int end) {
  for (int i = start; i <= end; i++) {
    if (s.substr(i - 1, 3) == "...") return true;
  }
  return false;
}

int main() {
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  a--, b--, c--, d--;

  if (!can_reach(s, a, c) || !can_reach(s, b, d)) {
    cout << "No" << endl;
    return 0;
  }

  if (c > d && !can_overlap(s, b, d)) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define MAX 150
int graph[MAX][MAX];
int d[MAX],f[MAX];
int time=0,n;
 
 void dfs(int i){
  int j;
  time++;
  d[i]=time;
  for(j=0;j<n;j++){
    if(graph[i][j]!=0 && d[j]==0){
      dfs(j);
    }
  }
  time++;
  f[i]=time;
}
 
int main(){
  int u,k,v;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      graph[u-1][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    if(d[i]==0) dfs(i);
  }
 
  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

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

int getmd(int a,int b,int c,int d){
    return abs(a-c)+abs(b-d);
}

int main(){
    int h,w,x,y;
    cin >> h >> w >> x >> y;
    cout << h*w-(x*w+y*h-x*y) << endl;

    return 0;
}

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

int main() {
	int N, L;
	cin >> N;
	int total = 0;
	vector<int> vec(2 * N);
	for (int i = 0; i < 2 * N; i++) {
		cin >> L;
		vec.at(i) = L;
	}
	sort(vec.begin(), vec.end());
	for (int j = 0; j < 2 * N; j += 2) {
		total += vec.at(j);
	}
	cout << total << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll lo = 0; ll hi = ll(1e13);
	ll n,m; cin>>n>>m;
	ll ans =0;
	while(lo<=hi)
	{
		ll mid = (lo+hi)>>1;
		ll tmp = m - 2LL*mid;
		if(tmp<0)
		{
			hi=mid-1;
			continue;
		}
		ll nn = n + tmp/2;
		if(nn>=mid)
		{
			ans=mid;
			lo=mid+1;
		}
		else hi=mid-1;
	}
	cout<<ans<<'\n';
}


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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int main() {
    
    
  int a , b ;
  char op ;
  cin >> a >> op >> b ;
  if( op == '+' ) cout << a + b ;
  else cout << a - b ;  
    

  return 0 ;
}










Measured memory_bytes: 256
#include <iostream>
int main()
{
	std::string a,b,c;
	int A,B,C;
	std::cin >> A;
	std::cin >> B;
	std::cin >> C;
	const int MAX_NUM = 10000;
	for(int i=1; i<A+MAX_NUM; i++)
	{
		int modAB = (A*i) % B;
		//std::cout << modAB << std::endl;
		bool result = modAB==C;
		if(result){
			std::cout << "YES" << std::endl;
			return 0;
		}
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,s=0;
	scanf("%d\n%d\n%d\n%d",&a,&b,&c,&d);
	s+=a<b?a:b;
	s+=c<d?c:d;
	printf("%d",s);
	return 0;
}

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

long int R,S,P;

long int point(char s){
  long int x=0;
  switch(s){
    case 'r':
      x=P;
      break;
    case 's':
      x=R;
      break;
    case 'p':
      x=S;
      break;
  }
  return x;
}

int main(void){
  char str[1000000];
  long int K,N,i,j,k,sum;
  int flag=0;
  
  fgets(str,sizeof(str),stdin);
  N=atoi(strtok(str," "));
  K=atoi(strtok(NULL," "));
  fgets(str,sizeof(str),stdin);
  R=atoi(strtok(str," "));
  S=atoi(strtok(NULL," "));
  P=atoi(strtok(NULL," "));
  fgets(str,sizeof(str),stdin);
  
  sum=0;
  for(i=0;i<K;i++){
    flag=0;
    sum+=point(str[i]);
    for(j=1;i+j*K<N;j++){
      if(str[i+j*K]!=str[i+(j-1)*K]){
        sum+=point(str[i+j*K]);
        flag=0;
      }else{
        if(flag==0){
          flag=1;
        }else{
          sum+=point(str[i+j*K]);
          flag=0;
        }
      }
    }
  }
  printf("%ld\n",sum);
  return 0;
}
      
  

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, P = map(int, input().split())
    S = input()

    if P == 2 or P == 5:
        ans = 0
        for i in range(N):
            if int(S[i]) % P == 0:
                ans += i + 1
    else:
        val = [0] * P
        cur = 0
        tenfactor = 1
        val[cur] += 1
        for i in range(N):
            cur = (cur + int(S[N - i - 1]) * tenfactor) % P
            tenfactor *= 10
            tenfactor %= P
            val[cur] += 1

        ans = 0
        for v in val:
            ans += v * (v - 1) // 2

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3500
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::string;

string S;
long long int ans;
long long int i = 0;

auto main()->int
	{
    cin >> S;
    auto str = S.c_str();
    long long int num_of_zero = 0;
    long long int num_of_one  = 0;
    while(str[i] != '\0')
    	{
        if(str[i] == '0')
        	{
            ++num_of_zero;
            }
        else
        	{
            ++num_of_one;
            }
        ++i;
        }
    cout << (num_of_zero < num_of_one ? num_of_zero * 2 : num_of_one * 2 ) << '\n';
    return 0;
    }
    

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC169D
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong N = ulong.Parse(Console.ReadLine().Trim());
            var prime = PrimeFactors(N);
            Dictionary<ulong, ulong> dic = new Dictionary<ulong, ulong>();
//            Console.WriteLine("{0} = {1}", N, string.Join(" x ", prime));
            foreach(var i in prime){
                if(!dic.ContainsKey(i)) dic.Add(i, 1ul); else dic[i]++;
            }
            ulong count = 0;
            foreach(var i in dic){
//                Console.WriteLine("Prime = {0} ^ {1}", i.Key, i.Value);
                count += tri(i.Value);
            }
            Console.WriteLine(count);
//            Console.WriteLine("{0} {1} {2} {3} {4}",tri(1ul), tri(2ul), tri(3ul), tri(5ul), tri(6ul));

        }

        static ulong tri(ulong x){
            ulong i = 0;
            ulong total = 0;
            while(total < x){
                i++; total += i; 
            }
            if(total == x) return i; else return i-1;
        }
        static IEnumerable<ulong> PrimeFactors(ulong n)
        {
            ulong i = 2;
            ulong tmp = n;

            while (i * i <= n) //※1
            {
                if(tmp % i == 0){
                    tmp /= i;
                    yield return i;
                }else{
                    i++;
                }
            }
            if(tmp != 1) yield return tmp;//最後の素数も返す
        }
    }
}


Measured memory_bytes: 27932