akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] field = new int[H][W];
		for (int i = 0; i < H; i++) {
			char[] row = sc.next().toCharArray();
			for (int j = 0; j < W; j++) {
				if (row[j] == '#') {
					field[i][j] = -1;
				} else {
					field[i][j] = row[j] - '1';
				}
			}
		}
		boolean[][][][] visited = new boolean[H][W][6][6];
		visited[0][0][1][2] = true;
		ArrayList<Integer> que = new ArrayList<>();
		que.add(encode(0, 0, 1, 2));
		for (int i = 0; i < que.size(); i++) {
			int cur = que.get(i);
			int r = cur >> 24;
			int c = (cur >> 16) & 0xFF;
			int f = (cur >> 8) & 0xFF;
			int s = (cur >> 0) & 0xFF;
			if (r == H - 1 && c == W - 1) {
				System.out.println("YES");
				return;
			}
			// up
			if (r > 0 && field[r - 1][c] == 5 - f && !visited[r - 1][c][field[r][c]][s]) {
				visited[r - 1][c][field[r][c]][s] = true;
				que.add(encode(r - 1, c, field[r][c], s));
			}
			// down
			if (r < H - 1 && field[r + 1][c] == f && !visited[r + 1][c][5 - field[r][c]][s]) {
				visited[r + 1][c][5 - field[r][c]][s] = true;
				que.add(encode(r + 1, c, 5 - field[r][c], s));
			}
			// left
			if (c > 0 && field[r][c - 1] == 5 - s && !visited[r][c - 1][f][field[r][c]]) {
				visited[r][c - 1][f][field[r][c]] = true;
				que.add(encode(r, c - 1, f, field[r][c]));
			}
			// right
			if (c < W - 1 && field[r][c + 1] == s && !visited[r][c + 1][f][5 - field[r][c]]) {
				visited[r][c + 1][f][5 - field[r][c]] = true;
				que.add(encode(r, c + 1, f, 5 - field[r][c]));
			}
		}
		System.out.println("NO");
	}

	static int encode(int r, int c, int f, int s) {
		return (r << 24) | (c << 16) | (f << 8) | s;
	}

}



Measured memory_bytes: 30984
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
char s[200005];
int n,a[2];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	ll res=0;
	int sum=0;
	int sum2=0;
	For(i,1,n)
		if (s[i]=='1'){
			res+=(sum2+sum%2)/2;
			++a[sum%2]; ++sum;
			res+=(sum+1)/2;
		}
		else{
			++sum2;
			res+=max(a[0],a[1]);
			a[0]=a[1]=max(a[0],a[1]);
		}
	cout<<res<<endl;
}

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

uint xor128(){
	static uint x=1,y=3,z=5,w=8;
	uint t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct node{
	node*l,*r;
	uint pri;
	int cnt,val,Min;
};
node pool[400000];
int p;

inline int cnt(node*t){return t?t->cnt:0;}
inline int Min(node*t){return t?t->Min:INF;}

inline node*update(node*t){
	t->cnt=cnt(t->l)+cnt(t->r)+1;
	t->Min=min({t->val,Min(t->l),Min(t->r)});
	return t;
}
inline node*merge(node*l,node*r){
	if(!l)return r;
	if(!r)return l;
	if(l->pri>r->pri){
		l->r=merge(l->r,r);
		return update(l);
	}
	else{
		r->l=merge(l,r->l);
		return update(r);
	}
}
inline pair<node*,node*>split(node*t,int k){
	if(!t)return make_pair((node*)NULL,(node*)NULL);
	if(k<=cnt(t->l)){
		auto p=split(t->l,k);
		t->l=p.second;
		return make_pair(p.first,update(t));
	}
	else{
		auto p=split(t->r,k-cnt(t->l)-1);
		t->r=p.first;
		return make_pair(update(t),p.second);
	}
}

int main(){
	int n,q;scanf("%d%d",&n,&q);
	node*root=NULL;
	rep(i,n){
		int a;scanf("%d",&a);
		node*t=&pool[p++];
		*t={NULL,NULL,(uint)rand(),1,a,a};
		root=merge(root,t);
	}
	rep(i,q){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		if(x==0){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y-1);
			auto c=split(b.second,1);
			root=merge(merge(merge(a.first,c.first),b.first),c.second);
		}
		else if(x==1){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y);
			printf("%d\n",Min(b.first));
			root=merge(merge(a.first,b.first),b.second);
		}
		else{
			auto a=split(root,y);
			auto b=split(a.second,1);
			b.first->val=b.first->Min=z;
			root=merge(merge(a.first,b.first),b.second);
		}
	}
}


Measured memory_bytes: 9472
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int gcd(int a, int b) {//最大公約数
	if (b == 0)return a;
	return gcd(b, a%b);
}

bool solve(int A, int B, int C, int D) {

	if (B > A)return false;
	if (B > D)return false;
	if (C >= B)return true;

	A %= B;

	int g = gcd(B, D);
	if (B - g + A % g > C)return false;
	return true;
}


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

	int t;
	cin >> t;
	while (t--) {
		int A, B, C, D;
		cin >> A >> B >> C >> D;

		if (solve(A, B, C, D))cout << "Yes" << endl;
		else cout << "No" << endl;

	}

	return 0;
}



Measured memory_bytes: 256
import bisect
counter=0
N=int(input())
L=sorted(list(map(int,input().split())))
for a in range(N-2):
  for b in range(a+1,N-1):
    k=bisect.bisect_left(L,L[a]+L[b])
    counter+=k-b-1
print(counter)
    

Measured memory_bytes: 3316
using System;
using System.Linq;

public class Program {
    public static void Main() {
        var arr = ReadLib.ReadAsIntArray();
        var a = arr[0];
        var b = arr[1];
        var c = arr[2];
        var d = arr[3];

        var canTalk = (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d) || Math.Abs(a - c) <= d;
        Console.WriteLine(canTalk ? "Yes" : "No");
    }
}

static class ReadLib {
    public static long ReadAsLong() {
        return long.Parse(Console.ReadLine());
    }

    public static int ReadAsInt() {
        return int.Parse(Console.ReadLine());
    }

    public static int[] ReadAsIntArray() {
        return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, m;
    cin >> n >> m;
    vector<int> X(m);
    fore(i,0,m) cin >> X[i];
    if (m <= n) {
        cout << "0\n";
        return 0;
    }
    sort(X.begin(), X.end());
    int ans = X[m-1]-X[0];
    fore(i,0,m-1) X[i] = X[i+1]-X[i];
    X.pop_back();
    sort(X.rbegin(), X.rend());
    fore(i,0,n-1) ans -= X[i];
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

long long gcd (long long x, long long y) {
  while (1) {
    if (x < y) {
      swap(x,y);  
    }  
    if (!y) {
      break;  
    }
    x %= y;
  }  
  return x;
}

int main () {
  long long N, X;
  cin >> N >> X;
  vector<long long> x(N);
  for (long long i = 0; i < N; i++) {
    cin >> x[i];    
    x[i] = X - x[i];
    if (x[i] < 0) {
      x[i] = -1 * x[i];  
    }
  } 
  long long sub = 0;
  for (long long i = 0; i < N; i++) {
    if (i == 0) {
      sub = x[i];    
    }  
    if (i < (N - 1)) {
      sub = gcd(sub, x[i + 1]);  
    }
  }
  cout << sub << endl;
  

}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = n/(a+b);
    ans*=a;
    ll md = n%(a+b);
    if(md<=a) ans+=md;
    else ans+=a;
    cout << ans;
}


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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    t.pop_back();

    if(s==t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

void solve(int D, int E) {
	double minv = 1e9;
	for (int x = 0; x <= D; x++) {
		int y = D - x;
		chmin(minv, fabs(sqrt((double)x*x + (double)y*y) - (double)E));
	}
	cout << fixed << setprecision(10) << minv << endl;
}
int main() {
	int D, E;
	while (cin >> D >> E, D || E) solve(D, E);
	return (0);
}


Measured memory_bytes: 3224
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

#define INF 101
int main(void) {
    string str;
    cin >> str;
    int len = str.length();
    vector<int> map(26);
    for(int i = 0; i < len; i++) map[str[i]-'a']++;

    int ans = INF;
    for(int i = 0; i < 26; i++) {
        if(!map[i]) continue;
        // corner-case
        if(map[i] == len) { ans = 0; break; }
        char pivot = i + 'a';
        int cnt = 0;
        string prev = str;
        while(1) {
            cnt++;
            string cur;
            int is_ok = 1;
            for(int j = 0; j < prev.length()-1; j++) {
                char ch = prev[j];
                if(prev[j+1] == pivot) ch = prev[j+1];
                cur.push_back(ch);
                if(ch != pivot) is_ok = 0;
            }
            if(is_ok) break;
            debug("%s\n", cur.c_str());
            prev = cur;
        }
        debug("%c -> %d\n", pivot, cnt);
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
#社協

N = int(input())
binN = format(N, "b").zfill(60)
mod = 7 + 10 ** 9

DP = [[0, 0, 0] for _ in range(60)]
if binN[0] == "0":
    DP[0] = [1, 0, 0]
else:
    DP[0] = [1, 1, 0]

for i in range(1, 60):   
    if binN[i] == "0":
        DP[i][0] = (DP[i-1][0] + DP[i-1][1]) % mod
        DP[i][1] = DP[i-1][1]
        DP[i][2] = (DP[i-1][2] * 3 + DP[i-1][1]) % mod
    else:
        DP[i][0] = DP[i-1][0]
        DP[i][1] = (DP[i-1][0] + DP[i-1][1]) % mod
        DP[i][2] = (DP[i-1][2] * 3 + DP[i-1][1] * 2) % mod
print(sum(DP[-1]) % mod)



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if ( a+b == c || b+c == a || c+a == b ) {  
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  string s; cin >>s;
  cout <<(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") <<endl;
}

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

N = int(input())


def yaku(n):
    ret = []
    for num in range(1, int(math.sqrt(n)+3)):
        if n % num == 0:
            p = n//num
            if num < p:
                ret.append(num)
                ret.append(p)
            elif num == p:
                ret.append(p)
    return ret

ans = len(yaku(N-1))-1
for num in yaku(N):
    if num == 1: continue
    T = N
    while T%num == 0:
        T //= num
    if (T-1)%num == 0:
        ans += 1

print(ans) 

Measured memory_bytes: 39024
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

template <typename T> inline int size(const T& x) { return x.size(); }

pair<int, int> calculate(const vector<string>& lines, int index, int level) {
    if (level >= size(lines[index]))
        return make_pair(-1, index);

    char ch = lines[index][level];
    if ('0' <= ch && ch <= '9')
        return make_pair(ch - '0', index+1);

    assert(ch == '+' || ch == '*');

    int ret_value = (ch == '+') ? 0 : 1;
    int ret_index = index+1;
    for (;;) {
        auto x = calculate(lines, ret_index, level+1);
        if (x.first == -1)
            break;
        ret_value = (ch == '+') ? (ret_value + x.first) : (ret_value * x.first);
        ret_index = x.second;
    }
    return make_pair(ret_value, ret_index);
}

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

    int n;
    while (cin >> n, n) {
        vector<string> lines(n+1);
        REP(i, n) cin >> lines[i];

        cout << calculate(lines, 0, 0).first << endl;
    }
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 1e5 + 100 , N = 1e5 + 5 , SQ = 600 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 17;

int n , m , a[maxn] , can[maxn] , b[maxn];
int mini = INF , idx , T;

inline int gcd(int a , int b) {
   if (b == 0)
       return a;

   return gcd(b , a % b);
}

inline int lcm(int a , int b) {
    return a / gcd(a , b) * b;
}

int32_t main() {
    FAST
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] /= 2;
    }
    sort (a , a + n);
    int mini = a[0] , cnt = 0;
    while((mini & 1) == 0) {
        mini /= 2;
        cnt++;
    }
    T = a[0];
    for (int i = 1; i < n; ++i) {
        T = lcm(T , a[i]);
    }
    int Q = T , c1 = 0;
    while((Q & 1) == 0) {
        Q /= 2;
        c1++;
    }
    if(c1 > cnt) {
        cout << 0 << '\n';
        return 0;
    }
    int ans = m / T;
    if(ans & 1) {
        cout << (ans + 1) / 2 << '\n';
    }
    else {
        cout << (ans / 2) << '\n';
    }
 }


Measured memory_bytes: 4432
#include<stdio.h>
#include<map>
using namespace std;
typedef long long ll;
const ll mx=1e10;
const int T=100000,q3=2154;
int pr[10010];
bool np[T+10];
map<ll,int>rt,c;
map<ll,int>::iterator it;
void sieve(){
	int i,j,M=0;
	for(i=2;i<=T;i++){
		if(!np[i])pr[++M]=i;
		for(j=1;j<=M&&i*pr[j]<=T;j++){
			np[i*pr[j]]=1;
			if(i%pr[j]==0)break;
		}
	}
	for(i=1;i<=M;i++)rt[(ll)pr[i]*pr[i]]=pr[i];
}
ll no3(ll x){
	int i;
	ll t;
	for(i=1;pr[i]<=q3;i++){
		t=pr[i];
		while(x%(t*t*t)==0)x/=t*t*t;
	}
	return x;
}
ll rev(ll x){
	int i,c;
	ll s,t;
	s=1;
	for(i=1;pr[i]<=q3;i++){
		t=pr[i];
		c=0;
		while(x%t==0){
			x/=t;
			c++;
		}
		if(c){
			for(c=3-c;c--;s*=t);
		}
	}
	if(x!=1){
		if(rt.count(x))
			s*=rt[x];
		else{
			if(x*x<=mx/s)
				s*=x*x;
			else
				s=-1;
		}
	}
	return s;
}
int main(){
	sieve();
	int n,s;
	ll x,y;
	scanf("%d",&n);
	s=0;
	while(n--){
		scanf("%lld",&x);
		y=no3(x);
		if(y==1)
			s=1;
		else
			c[y]++;
	}
	for(it=c.begin();it!=c.end();it++){
		if(it->second){
			x=rev(it->first);
			if(!c.count(x))
				s+=it->second;
			else{
				s+=max(it->second,c[x]);
				c[x]=0;
			}
		}
	}
	printf("%d",s);
}

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

int main()
{
    string S;
    cin >> S;
    S.pop_back();
    if (S.size() % 2 == 1)
    {
        S.pop_back();
    }

    for (int i = S.size() / 2; i > 0; i--)
    {
        string s1 = S.substr(0, i);
        string s2 = S.substr(i, i);
        if (s1 == s2)
        {
            cout << i * 2 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
s = input()[::-1]
r = 'YES'
while len(s):
    if s[:5] == 'dream'[::-1] or s[:5] == 'erase'[::-1]:
        s = s[5:]
    elif s[:6] == 'eraser'[::-1]:
        s = s[6:]
    elif  s[:7] == 'dreamer'[::-1]:
        s = s[7:]
    else:
        r = 'NO'
        break
print(r)

Measured memory_bytes: 9200
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

using namespace std;
using ll = long long int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


signed main() {
	ios::sync_with_stdio(false);
	int r, g, b;
	cin >> r >> g >> b;
	int n = r * 100 + g * 10 + b;
	if (n % 4)
		cout << "NO\n";
	else
		cout << "YES\n";

	return 0;
}

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

int H, W, N;
int a[10010];
int B[109][109];

int main() {
   cin >> H >> W >> N;
   int idx = 0;
   for (int i = 0; i < N; i++) {
      int x;
      cin >> x;
      for (int j = 0; j < x; j++) {
         a[idx] = i+1;
         idx++;
      }
   }

   idx = 0;
   for (int i = 0; i < H; i++) {
      if (i%2==0) {
         for (int j = 0; j < W; j++) {
            B[i][j] = a[idx];
            idx++;
         }
      } else {
         for (int j = W-1; j >= 0; j--) {
            B[i][j] = a[idx];
            idx++;
         }
      }
   }
   
   // cerr << endl;
   for (int i = 0; i < H; i++) {
      for (int j = 0; j < W-1; j++) {
         cout << B[i][j] << " ";
      }
      cout << B[i][W-1] << endl;
   }

   return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;

class MyScanner {
    private final InputStream in = System.in;
    private final byte[] buf = new byte[1024];
    private int p = 0;
    private int len = 0;
    private boolean hasNextByte() {
        if (p >= len) {
            p = 0;
            try {
                len = in.read(buf);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return len >= 1;
    }
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buf[p])) p++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        while (hasNextByte() && isPrintableChar(buf[p])) sb.appendCodePoint(buf[p++]);
        return sb.toString();
    }
}

public class Main {
    public static void main(String[] args){
        MyScanner sc = new MyScanner();
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] h = new Integer[n];
        for (int i = 0; i < n; i++) h[i] = Integer.parseInt(sc.next());
        Boolean[] f = new Boolean[n];
        Arrays.fill(f, true);
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next()) - 1;
            int b = Integer.parseInt(sc.next()) - 1;
            if (h[a] <= h[b]) {
                f[a] = false;
            }
            if (h[b] <= h[a]) {
                f[b] = false;
            }
        }
        int c = 0;
        for (boolean i : f){
            if (i) c++;
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 53268
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
using namespace std;

int main(){
  int N, ans = 0, count = 0 ;
  cin >> N ;
  int Dice1[N], Dice2[N] ;
  for(int i=0;i<N;i++){
    cin >> Dice1[i] >> Dice2[i] ;
    if(Dice1[i] == Dice2[i]){
      count++ ;
      if(count > 2) ans = 1 ;
    }
    else{
      count = 0 ;
    }
  }
  if(ans){
    cout << "Yes" << endl ;
  }  
  else{
    cout << "No" << endl ;
  }  
  return 0 ;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>
#include<math.h>
#include<time.h>


int main(void){
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);

    int i = 1;
    time_t start = time(NULL);
    while(1) {
        if(i*A % B == C) {
            printf("YES\n");
            return 0;
        }
        if(time(NULL) - start > 0.0001) {
          printf("NO\n");
          return 0;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    
    for(int i = s.length() - 2; i >= 1; i -= 2){
      if(s.substring(0, i / 2).equals(s.substring(i / 2, i))){
        System.out.println(i);
        break;
      }
    }
  }
}

Measured memory_bytes: 23252
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
a.append(0)
cnt=1
l1,l2=0,0
for i in range(n):
    if a[i]==a[i+1]:
        cnt+=1
    else:
        if cnt>=4:
            if l1==0:
                l1=a[i]
                l2=a[i]
                break
            else:
                l2=a[i]
                break
        elif cnt>=2:
            if l1==0:
                l1=a[i]
                cnt=1
            else:
                l2=a[i]
                break
print(l1*l2)

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

int main(){
  int a,b;
  cin >> a >> b;
  
  if((a+b)%2 == 0){
    int x = (a+b)/2;
    cout << x << endl;
  }else{
    int x = (a+b)/2 +1;
    cout << x << endl;
  }
  
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define nl cout<<'\n';
#define int long long
#define ff first
#define ss second
#define _lmax 1e14
#define pb push_back
void print(int a)                  {              cout<<a<<'\t'<<'\n';}
void print(int a,int b)                {          cout<<a<<'\t'<<b<<'\t'<<'\n';}
void print(int a,int b,int  c)             {      cout<<a<<'\t'<<b<<'\t'<<c<<'\n';}
void print(int a,int  b,int  c,int  d)         {   cout<<a<<'\t'<<b<<'\t'<<c<<'\t'<<d<<'\n';}
void print(int a,int  b,int  c,int  d,int  e)      { cout<<a<<'\t'<<b<<'\t'<<c<<'\t'<<d<<'\t'<<e<<'\n';}
void print(vector<int> &a)  {for(auto i:a)  cout<<i<<" ";   nl;}
void print(string s){cout<<s;nl;}

void MAIN()
{
    int k,n;  cin>>n>>k;
    vector<int> a(n) , dp(n , 1e9+5);
    for(auto &i:a)  cin>>i;

    dp[0] = 0;
    for(int i=0; i<n ; i++)
    {
        for(int j = i+1 ; j<=i+k ; j++ )
        {
            if(j<n)
            dp[j] = min(dp[j] , dp[i] + abs(a[i]-a[j])) ;
        }
    }


    print(dp[n-1]);

}
int32_t main()
{
//      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//     int t;  cin>>t; while(t--)
//     ios_base::sync_with_stdio(0) , cin.tie(0);  int t; cin>>t; while(t--)
    MAIN();
    return 0;
}
/*

9 2
6 19 3 4 4 2 6 7 8
2 5 11 18 30 43 62 83 121






*/


















Measured memory_bytes: 4812
#include<stdio.h>

int main() {
	int n, i, j;
	int tmp;
	int A[1000];
	int flag = 1;

	scanf("%d", &n);

	for (i = 0; i < n; i++) scanf("%d", &A[i]);

	i = 0;

	while (flag) {
		flag = 0;

		for (j = n - 1; j > 0; j--) {
			if (A[j] < A[j - 1]) {
				tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
				flag = 1;

				i++;
			}
		}
	}

	for (j = 0; j < n; j++) {
		printf("%d", A[j]);
		if (j != n - 1) printf(" ");
	}
	printf("\n");
	printf("%d\n", i);

	return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<string> A(N);
  string pattern = "";
  for(int i=0;i<N;i++){cin >> A.at(i);}
  for(int i=0;i<M;i++){
    string temp;
    cin >> temp;
    pattern += temp;
  }
  
  //パターンマッチ
  bool flag = false;
  string x;
  for(int i=0;i<N-M+1;i++){
    for(int j=0;j<N-M+1;j++){
      x = "";
       for(int k=0;k<M;k++){
	       x += A.at(i+k).substr(j,M);
       }
      if(x==pattern){
        flag = true;
        break;
      }
    }
    if(flag){
      break;
    }
  }
  
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long ans = pow(3, N), a, sub = 1;
  for(int i = 0; i < N; i++){
    cin >> a;
    if(a % 2 == 0){
      sub *= 2;
    } 
  }
  cout << ans - sub << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long n = scanner.nextLong();
		long[] max = new long[5];
		for (int i=0; i<5; i++) max[i] = scanner.nextLong();

		long neck = max[0];
		for (int i=1; i<5; i++) neck = Math.min(neck, max[i]);
		if (n%neck==0) System.out.println(n/neck+4);
		else System.out.println(n/neck+5);
	}
}

Measured memory_bytes: 22740
//#pragma GCC optimize("O3") 
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,popcnt,abm,mmx") 
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>                               
using namespace std;

#define PI acos(-1)
#define pb push_back
#define fi first
#define se second
#define TASK ""
#define move djskdfjksl
#define sz(a) (int)(a).size()
#define all(c) (c).begin(), (c).end()
#define TIMESTAMP fprintf(stderr, "Execution time: %.3lf s.\n", (double)clock()/CLOCKS_PER_SEC)

#define has(mask, i) ((mask >> i) & 1)

#ifndef LOCAL
	#define cerr if (0) cerr
#endif

typedef long long ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < ll > vll;
typedef pair < int, int > pii;
typedef vector < vi > vvi;
typedef vector < pii > vpii;
typedef vector < string > vs;

const int MAXN = 2022;

ll N, Z, W;
ll dp[MAXN][2];
ll A[MAXN];

ll go(int n, bool pl) {
	ll &ans = dp[n][pl];
	if (ans != -1)	
		return ans;
	ans = pl ? 0 : INT_MAX;
	for (int i = n + 1; i <= N - 1; i++) {
		ans = pl ? max(ans, go(i, pl ^ 1)) : min(ans, go(i, pl ^ 1));
	}
	ans = pl ? max(ans, abs((n == 0 ? W : A[n]) - A[N])) : min(ans, abs(A[n] - A[N]));
	return ans;
}

void solve() {
	cin >> N >> Z >> W;
	for (int i = 1; i <= N; i++)
		cin >> A[i];
	memset(dp, -1, sizeof(dp));
	ll ans = go(0, 1);
	cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL
	assert(freopen("xxx.in", "r", stdin));
	assert(freopen("xxx.out", "w", stdout));
#else
	//freopen(TASK".in", "r", stdin);
	//freopen(TASK".out", "w", stdout);
#endif		
	solve();
#ifdef LOCAL
	TIMESTAMP;
#endif	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
//#define int long long
using LL = long long;
using namespace std;
using Graph = vector<vector<int>>;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int v[11];
int n, m, q;
vector<vector<int>> g;

LL ans = 0;
void dfs(int d){
    if(d == n){
        LL tmp = 0;
        repe(now, g){
            if(v[now[1]]-v[now[0]]==now[2]) tmp += now[3];
        }
        chmax(ans, tmp);
    }else if(d == 0){
        rep1(i, m+1){
            v[d] = i;
            dfs(d+1);
        }
    }else{
        REP(i, v[d-1], m+1){
            v[d] = i;
            dfs(d+1);
        }
    }
}

signed main(){
    fastcin();
    cin >> n >> m >> q;
    rep(i, q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;b--;
        g.push_back({a,b,c,d});
    }
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

constexpr Int mod = 998244353;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, s; cin >> n >> s;
	vector<Int> a(n);
	for(auto &i:a) cin >> i;
	vector<vector<Int>> dp(n, vector<Int>(s+1, 0));
	Int ans = 0;
	for(Int i=0; i<n; ++i){
		if(i > 0){
			for(Int j=0; j<=s; ++j){
				dp[i][j] += dp[i-1][j];
				dp[i][j] %= mod;
				if(j+a[i] <= s){
					dp[i][j+a[i]] += dp[i-1][j];
					dp[i][j+a[i]] %= mod;
				}
			}
		}
		if(a[i] <= s){
			dp[i][a[i]] += i+1;
			dp[i][a[i]] %= mod;
		}
		ans += dp[i][s];
		ans %= mod;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}


void solve(){
  string S; cin >> S;
  cout<<count(all(S),'1')<<endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
template <int MOD>
class ModInt {
  long long x;

 public:
  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt<MOD> pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream& operator<<(ostream& os, const ModInt& x) { return os << x.x; }

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};

using mint = ModInt<1000000007>;

ll N;

int main() {
  cin >> N;

  vector<ll> c(60, 0);

  rep(i, N) {
    ll A;
    cin >> A;
    rep(j, 60) {
      if ((A >> j) & 1) c[j] += 1;
    }
  }

  mint ans = 0;
  rep(i, 60) {
    mint m = c[i] * (N - c[i]);
    m *= (1LL << i);
    ans += m;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // L(T)
    {
        // char s[45];
        string s;
        cin >> s;
        if (s == "AAA")
        {
            cout << "No" << endl;
        }
        else if (s == "BBB")
            cout << "No" << endl;
        else
        {
            cout << "Yes" << endl;
        }
    }
    return 0;
}


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

long n;

bool ok(long n, long k) {
  if (k == 1) return false;
  if (n < k) return n == 1;
  if (n % k == 0) return ok(n / k, k);
  return ok(n % k, k);
}
int main() {
  cin >> n;
  
  set<long> st;
  for (long k = 1; k * k <= n; ++k) {
    if (n % k != 0) continue;
    long a = k;
    long b = n / k;
    if (ok(n, a)) st.insert(a);
    if (ok(n, b)) st.insert(b);
  }
  for (long k = 1; k * k <= n - 1; ++k) {
    if ((n - 1) % k != 0) continue;
    long a = k;
    long b = (n - 1) / k;
    if (ok(n, a)) st.insert(a);
    if (ok(n, b)) st.insert(b);
  }
  
  cout << st.size() << endl;
}

Measured memory_bytes: 256
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define  SPEED           ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT      mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)      for(ll i = (a); i >= n; i--)
#define  fo(i,n)         for(ll i = 0; i < n; i++)
#define  newl            cout<<"\n";
#define  f               first
#define  s               second
#define  pb              push_back
#define  mp              make_pair
#define  sym(s)          s="#"+s+"#";
#define  sqr(v)          v*v;
#define  all(x)          (x).begin(),(x).end()
#define  alll(x,n)       x+1, x+n+1
#define  uniq(a)         a.resize(unique(a.begin(), a.end()) - a.begin());
#define  mset(x,val)     memset(x,val,sizeof(x))
#define  mset1d(a,n,v)   foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v) foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    

template <typename T> 
using  ordered_set =  tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
using  ll          =  long long;
using  ull         =  unsigned long long;
using  ld          =  long double;
using  pll         =  pair<ll,ll>;
using  vll         =  vector<ll>;
using  vpll        =  vector<pll>;

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n, k, a[N];

/***************************************** FUNCTION IMPLEMENTATIONS **************************************/


/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    int cnt = 0;
    cin>>n>>k;
    for(int i = 1; i <= n; i++){
        ld x, y;
        cin>>x>>y;
        ld d = sqrt(x*x + y*y);
        cnt += d<=k; 
    }
    deb1(cnt);
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 8528
#include <bits/stdc++.h>
#define Maxn 100007
using namespace std;
int n,ans=10000000;
int calc(int x)
{
	int res=0;
	while (x>0)
	{
		res+=x%10;
		x/=10;
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
		ans=min(ans,calc(i)+calc(n-i));
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
using System;
class Program {
    static void Main() {
        string[] str =  Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);

        string comp;
        if (a > b)
            comp = ">";
        else if (a < b)
            comp = "<";
        else
            comp = "==";

        Console.WriteLine("a {0} b", comp);
    }
}

Measured memory_bytes: 8956
#include <stdio.h>
int main(void){
    int n, sum;
    char arr[100001];
    scanf("%d\n", &n);
    scanf("%s", arr);
    sum = n;

    for (int i = 0; i < n; i++)
    {
        int cnt = 0;
        for (int j = i+1; arr[i] == arr[j] && arr[j] != '\0'; j++)
            cnt++;
        sum -= cnt;
        i += cnt;
    }
    
    printf("%d\n", sum);
    return(0);
}

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

int n, a, b, c;
vector<int> vl;
vector<int> vx;
 
void init() {
    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; i++){
        int l;
        cin >> l;
        vl.push_back(l);
    }
}

int solveSub2(){
    int MP = -30;
    int la = 0;
    int lb = 0;
    int lc = 0;
    for(int k = 0; k < n; k++){
        if(vx.at(k) == 1){
            la += vl.at(k);
            MP += 10;
        }
        else if(vx.at(k) == 2){
            lb += vl.at(k);
            MP += 10;
        }
        else if(vx.at(k) == 3){
            lc += vl.at(k);
            MP += 10;
        }
    }
    if(la == 0 || lb == 0 || lc == 0) return 3000;
    MP += abs(a - la) + abs(b - lb) + abs(c - lc);
    return MP;
}

int solveSub1(int idx){
    int minMP = 3000;
    for(int j = 0; j < 4; j++){
        vx.at(idx) = j;
        if(idx < n - 1) minMP = min(minMP, solveSub1(idx + 1));
        else minMP = min(minMP, solveSub2());
    }
    return minMP;
}

int solve(){
    for(int i = 0; i < n; i++){
        vx.push_back(0);
    }
    return solveSub1(0);
}
 
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	init();
	
    cout << solve() << "\n";
 
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val S = Array(3) { ArrayDeque(readLine()!!.toCharArray().toList()) }

    var current = S[0].poll()

    while (true) {
        current = when (current) {
            'a' -> {
                if (S[0].isEmpty()) {
                    println("A")
                    return
                }
                S[0].poll()
            }
            'b' -> {
                if (S[1].isEmpty()) {
                    println("B")
                    return
                }
                S[1].poll()
            }
            'c' -> {
                if (S[2].isEmpty()) {
                    println("C")
                    return
                }
                S[2].poll()
            }
            else -> throw IllegalStateException("")
        }
    }
}


Measured memory_bytes: 34072
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, c, k;
    cin >> n >> c >> k;
    int t[n];
    for (int i = 0; i < n; i++) cin >> t[i];
    sort(t, t+n);
    ll dep = t[0] + k, cnt = 0, ans = 1;
    for (int i = 0; i < n; i++) {
        if (dep < t[i] || cnt == c) {
            dep = t[i] + k, cnt = 0, ans++;
        }
        cnt++;
    }
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  if ((S.at(0) != S.at(1)) && (S.at(1) != S.at(2)) && (S.at(2) != S.at(3))) {
    cout << "Good" << endl;
  }
  else {
    cout << "Bad" << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
string s[105];
int main() {
	cin>>n;
	bool ok=1;
	for(int i=1;i<=n;i++) {
		cin>>s[i];
		if(i>1&&s[i][0]!=s[i-1][s[i-1].size()-1]) ok=0;
		for(int j=1;j<i;j++)
			if(s[j]==s[i]) ok=0;
	}
	puts(ok?"Yes":"No");
	return 0;
}

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

using namespace std;

typedef long long int Int;

int main(void)
{
    Int n,k,sum = 1;

    cin>>n>>k;
    sum *= k;

    for(int i = 1;i < n;i++)
	sum *=(k-1);

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys


def solve(inp):
    (N, M) = map(int, inp.readline().strip().split(' '))

    if N == M:
        return "Yes"
    else:
        return "No"


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()


dx = [-1,  0,  1, -1, 1, -1, 0, 1]
dy = [-1, -1, -1,  0, 0,  1, 1, 1]
H, W = ISI()
l = [list(IS()) for i in range(H)]
for i in range(H):
    for j in range(W):
        if l[i][j] != "#":
            cnt = 0
            for d in range(8):
                ni = i + dy[d]
                nj = j + dx[d]
                if 0 > ni or ni >= H: continue
                if 0 > nj or nj >= W: continue
                if l[ni][nj] == "#":
                    cnt += 1
            l[i][j] = str(cnt)
for i in range(H):
    print("".join(l[i]))

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(long long i = 0; i < n; i++)
using namespace std;
int main()
{
    long long H, W, ans = 0;
    cin>> H >> W;
    vector<vector<long long>>hw(H,vector<long long>(W));
    vector<vector<long long>>magic(10,vector<long long>(10));
    rep(i,10){
        rep(j,10) cin>>magic[i][j];
    }

    rep(i,H){
        rep(j,W) cin>>hw[i][j];
    }

    rep(k,10){
        rep(i,10){
            rep(j,10) magic[i][j] = min(magic[i][j],magic[i][k] + magic[k][j]);
        }
    }

    rep(i,H){
        rep(j,W){
            if(hw[i][j] != -1){
                ans += magic[hw[i][j]][1];
            }
        }
    }

    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

ll x;

int main(){
    cin >> x;
    ll Now = x / 11;
    Now <<= 1;
    ll Yu = x % 11;
    if(Yu > 6) Now += 2;
    else if( Yu > 0) Now += 1;
    cout << Now <<endl;
    return 0;
}



Measured memory_bytes: 256