akhauriyash/Code-Regression huggingface dataset:
main = do
    s <- fmap (takeWhile (\l -> l /= [0, 0]) . map (map read) . map words . lines) getContents
    mapM (mapM putStrLn . line) $ s
    where 
        line (h:w:_) = (map (l w) [1..h]) ++ [""]
        l w i = map dot $ map (+i) [1..w]
        dot p = if even p then '#' else '.'



Measured memory_bytes: 5080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n;
  cin >> n;
  vector<int> prime;
  prime.push_back(2);
  for(int i=3;i<100;i+=2){
    bool flag = true;
    for(p:prime)
      flag = flag && !(i%p==0);
    if(flag)
      prime.push_back(i);
  }
  vector<int> count(n+1,0);
  for(int i=2;i<=n;i++){
    int buf = i;
    while(buf>1){
      for(p:prime) if(buf%p==0){
        count[p]++;
        buf /= p;
      }
    }
  }
  int sf = 0, tf = 0, ft = 0, f = 0, t = 0;
  rep(i,n+1){
    int d = count[i];
    if(d >= 2) t++;
    if(d >= 4) f++;
    if(d >= 14) ft++;
    if(d >= 24) tf++;
    if(d >= 74) sf++;
  }
  int ans = 0;
  ans += max(0,sf);
  ans += max(0,tf * (t-1));
  ans += max(0,ft * (f-1));
  ans += max(0,(t-2) * f * (f-1) / 2);
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N;cin>>N;
  int card[N];for(int i=0;i<N;i++)cin>>card[i];
  
  sort(card, card+N, greater<int>());
  int alice=0; int bob = 0;
  for(int i=0; i<N;i++){
  if(i%2==0)alice+=card[i];
    else bob+=card[i];
  }
  cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc071_a.cpp
 * time   : Tue Apr 28 23:35:59 2020
 * quest  : A - Meal Delivery
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x, a, b;
  cin >> x >> a >> b;
  cout << (abs(a - x) > abs(b - x) ? 'B' : 'A') << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i, l, r) for (int i = l; i < r; i++)
#define max(i, j) i > j ? i : j
#define MAX 100001

int main(void) {
  int n;
  scanf("%d", &n);
  int v[MAX];
  rep(i, 0, n)
    scanf("%d", &v[i]);
  
  /* 最頻値を数える */
  int mode1[MAX] = {0};
  int mode2[MAX] = {0};
  // 奇数列
  for (int i = 0; i < n; i += 2)
    mode1[v[i]]++;
  // 偶数列
  for (int i = 1; i < n; i += 2)
    mode2[v[i]]++;

  int max1[2] = {0}, next1 = 0;  // max[頻度][数], 2番目の頻値
  int max2[2] = {0}, next2 = 0; 
  rep(i, 0, MAX) {
    if (mode1[i] > max1[0]) {
      next1 = max1[0];
      max1[0] = mode1[i];
      max1[1] = i;
    } else if (mode1[i] > next1) {
      next1 = mode1[i];
    }
  }
  rep(i, 0, MAX) {
    if (mode2[i] > max2[0]) {
      next2 = max2[0];
      max2[0] = mode2[i];
      max2[1] = i;
    } else if (mode2[i] > next2) {
      next2 = mode2[i];
    }
  }
  
  int ans;
  if (max1[1] == max2[1]) {
    if (next1 > next2) 
      ans = n - next1 - max2[0];
    else
      ans = n - next2 - max1[0]; 
  } else
    ans = n - max1[0] - max2[0];
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main()
{
	int i, u, w, N, M, s[21], t[21], adj[51][51] = {};
	scanf("%d", &N);
	for (i = 1; i < N; i++) {
		scanf("%d %d", &u, &w);
		adj[u][w] = i;
		adj[w][u] = i;
	}
	scanf("%d", &M);
	for (i = 0; i < M; i++) scanf("%d %d", &(s[i]), &(t[i]));
	
	int P[21][51] = {}, prev[51], q[51], head, tail;
	for (i = 0; i < M; i++) {
		for (u = 1; u <= N; u++) prev[u] = -1;
		q[0] = s[i];
		prev[s[i]] = s[i];
		for (head = 0, tail = 1; head < tail; head++) {
			u = q[head];
			for (w = 1; w <= N; w++) {
				if (adj[u][w] == 0) continue;
				else if (w == t[i]) break;
				else if (prev[w] == -1) {
					prev[w] = u;
					q[tail++] = w;
				}
			}
			if (w <= N) break;
		}
		for (; w != u; w = u, u = prev[u]) P[i][adj[u][w]] = 1;
	}
	
	int j, sum[2], white[51];
	long long n, bit[51] = {1}, ans = (long long)1 << N - 1;
	for (i = 1; i <= 50; i++) bit[i] = bit[i-1] << 1;
	for (n = 1; n < bit[M]; n++) {
		for (j = 1; j < N; j++) white[j] = 0;
		for (i = 0; i < M; i++) {
			if ((n | bit[i]) == n) {
				for (j = 1; j < N; j++) white[j] |= P[i][j];
			}
		}
		for (j = 1, sum[0] = 0; j < N; j++) sum[0] += white[j];
		for (i = 0, sum[1] = 0; i < M; i++) sum[1] += n / bit[i] % 2;
		if (sum[1] % 2 == 1) ans -= bit[N-1-sum[0]];
		else ans += bit[N-1-sum[0]];
	}

	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
class dice
{
private:
	std::vector<int> faces;
public:
	dice(int *surface){
		for(int i = 0 ; i < 6 ; i ++){
			faces.push_back(surface[i]);
		}
	};
	dice(){};
	int getSurface(){
		return faces[0];
	};
	int getRight(){
		return faces[2];
	};
	dice roll(char d)
	{
		int *s = new int[6];
		switch(d){
			case 'S':
			s[0] = faces[4]; s[1] = faces[0]; s[2] = faces[2];
			s[3] = faces[3]; s[4] = faces[5]; s[5] = faces[1];
			break;
			case 'N':
			s[0] = faces[1]; s[1] = faces[5]; s[2] = faces[2];
			s[3] = faces[3]; s[4] = faces[0]; s[5] = faces[4];
			break;
			case 'E':
			s[0] = faces[3]; s[1] = faces[1]; s[2] = faces[0];
			s[3] = faces[5]; s[4] = faces[4]; s[5] = faces[2];
 			break;
			case 'W':
			s[0] = faces[2]; s[1] = faces[1]; s[2] = faces[5];
			s[3] = faces[0]; s[4] = faces[4]; s[5] = faces[3];
			break;
		}
		dice newdice(s);
		delete[] s;
		return newdice;
	};
	bool isAnswer(int top,int 	front)
	{
		if(faces[0] == top && faces[1] == front){
			return true;
		}else{
			return false;
		}
	};
	int answerQuestion(int top,int front)
	{
		std::vector<std::string> patterns = {
			"","E","EE","W",
			"S","SE","SEE","SW",
			"SS","SSE","SSEE","SSW",
			"N","NE","NEE","NW",
			"ES","ESE","ESEE","ESW",
			"WS","WSE","WSEE","WSW"};
		std::vector<dice> canditates;
		for(std::string pattern : patterns){
			dice d = (*this);
			for(char op : pattern){
				d = d.roll(op);
			}
			canditates.push_back(d);
		}
		for(dice canditate : canditates){
			if(canditate.isAnswer(top,front)){
				return canditate.getRight();
			}
		}
		return -3;
	};
};


int main(int argc, char const *argv[])
{
	int *s = new int[6];
	for(int i = 0 ; i < 6 ; i ++){
		std::cin >> s[i];
	}
	dice d(s);

	int q;
	int top;
	int front;
	std::cin >> q;
	for(int i = 0 ; i < q ; i ++){
		std::cin >> top;
		std::cin >> front;
		std::cout << d.answerQuestion(top,front) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3208
// みなさん私はカーティキー・シャルマです。LNMIITで勉強しています。私は2年目で、コロナパンデミックが発
// 生しています。世界は終わりそうだ。だから私はそれを最大限に生きたいと思っています。それはつまり、コー
// ドを最大限に意味しているのです。私の好きなアニメは「キメツノヤイバ」で、私の一番の男の子はゼニツで、
// 私の一番の女の子はネズコです。私の好きな呼吸スタイルは息吹です。私の最高の悪魔の血の芸術は、
// ククシボによって使用される月の息です。ムーザンは亡くなり、今ではタンジローがポップの新しい魔王です。
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld r, d, x;
      cin >> r >> d >> x;
      lld A[11];
      A[0] =  x;
      for(lld i = 1; i <= 10; i += 1){
      	A[i] = r*A[i-1] - d;
      	cout << A[i] <<"\n";
      }
      return 0;
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N;
  cin >> N;
  cout << fixed << setprecision(10) << 2 * M_PI * N;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 3764
#include <stdio.h>
int main() {
	int n, a, b[100000] = {}, c = 0, max, min, mid;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a);
		max = c - 1;
		min = 0;
		while (min < max)
		{
			mid = (max + min) / 2;
			if (b[mid] < a) max = mid;		
			else min = mid + 1;
		}
		if (min < c && b[min] < a) b[min] = a;
		else b[c++] = a;
	}
	printf("%d", c );
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
const int BUF = 100005;


int nVal;
long long nPair;
long long val[BUF];

void read() {
    cin >> nVal >> nPair;
    for (int i = 0; i < nVal; ++i) cin >> val[i];
}


void work() {
    sort(val, val + nVal);
    reverse(val, val + nVal);
    
    int L = 0, R = 200001;

    while (L < R) {
        int mid = (L + R) / 2;
        
        int idx = nVal - 1;
        while (idx >= 0 && val[0] + val[idx] < mid) --idx;

        long long cnt = idx + 1;
        for (int loop = 1; loop < nVal; ++loop) {
            while (idx >= 0 && val[loop] + val[idx] < mid) --idx;
            cnt += idx + 1;
        }
        
        if (cnt > nPair) {
            L = mid + 1;
        } else {
            R = mid;
        }
    }
    --L;
    
    long long sum[BUF];
    sum[0] = val[0];
    for (int i = 1; i < nVal; ++i) {
        sum[i] = sum[i - 1] + val[i];
    }
    
    
    long long ans = 0;

    int idx = nVal - 1;
    while (idx >= 0 && val[0] + val[idx] < L) --idx;

    long long cnt = idx + 1;
    ans += val[0] * (idx + 1) + sum[idx]; 
    for (int loop = 1; loop < nVal; ++loop) {
        while (idx >= 0 && val[loop] + val[idx] < L) --idx;
        cnt += idx + 1;
        ans += val[loop] * (idx + 1) + (idx < 0 ? 0 : sum[idx]); 
    }
    
    ans -= (cnt - nPair) * L;

    cout << ans << endl;
}


int main() {
    for (int i = 0; i < 1; ++i) {
        read();
        work();
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	cout << min(n%k,k-n%k) << endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    int A, P;
    static const int AtoPmul = 3;

    cin >> A >> P;

    int pieceCount = P + A * AtoPmul;
    int pieNum = pieceCount / 2;

    cout << pieNum << endl;



    return 0;
}

Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,k,q;
    cin>>n>>k>>q;
    int a[n];
    for(int i=0;i<n;i++)    a[i] = -q;
    for(int i=0;i<q;i++){
        int x;
        cin>>x;
        x--;
        a[x]++;
    }
    for(int i=0;i<n;i++){
        if(a[i]+k>0)    cout<<"Yes\n";
        else            cout<<"No\n";
    }
    return 0;
}



Measured memory_bytes: 1024
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d){
        cout << "Yes\n";
    }
    else cout << "No\n";
    return 0;
}
///Alhamdulillah



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

int main(){
    int N;
    cin >> N;
    int max_cnt = 0;
    int ans;

    for ( int i = 1 ; i <= N ; i++ ){
        int cnt = 0;
      	int j = i;
        if( j % 2 == 0 ){
            while( j % 2 == 0){
              	cnt++;
                j /= 2 ;
            }
        }
        if ( cnt > max_cnt ){
        	max_cnt = cnt;
          	ans = i;
        } 
    }
  	if ( N == 1 ) ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32, b: i32, x: i32,
    }

    if a <= x && x <= (a + b) {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vp vector< pair<int,int> >

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N,W;
    cin>>N>>W;
    vi w(N+1),v(N+1);
    rep(i,1,N)
    {
        cin>>w[i]>>v[i];
    }
    ll dp[100001];
    for(int i=1;i<=100000;i++)
    {
        dp[i]=W+W;
    }
    for(int i=1;i<=N;i++)
    {
        for(int j=100000;j>=v[i];j--)
        {
            dp[j]=min(dp[j],w[i]+dp[j-v[i]]);
        }
    }
    ll ans=0;
    for(ll i=1;i<=100000;i++)
    {
        if(dp[i]<=W)
        {
            ans=i;
        }
    }
    cout<<ans<<endl;

    return 0;
}






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

int main() {
    long long int a, b, x;
    cin >> a >> b >> x;

    long long int low, up;
    if (a%x == 0) low = a/x;
    else low = a/x + 1;
    if (b%x == 0) up = b/x;
    else up = b/x;

    cout << up-low+1 << endl; 
}

Measured memory_bytes: 256
// ABC134-D
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る

vector<int> a(200010,0);
vector<int> c(200010,0); 
vector<bool> sh(200010,false); //ボールを入れる
int ball=0;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    cin>>n;
    rep(i,n) cin>>a[i+1];
    for(int i=n;i>=1;i=i-1){
        if(c[i]%2!=a[i]){
            ball++;
            sh[i]=true;
            for(int j=1;j*j<=i;j++){
                if(i%j==0){
                    c[j]++;
                    if(j*j!=i) c[i/j]++;
                }
            }
        }
    }
    cout<<ball<<endl;
    if(ball!=0){
        rep(i,n){
            if(sh[i+1]) cout<<i+1<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 2688
// @author: arch_

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

int main(void) {
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0
            || to_string(i).find("3") != string::npos)
            cout << " " << i;
    } cout << "\n";
    return 0;
}

Measured memory_bytes: 3280
<?php
echo str() == "ABC" ? "ARC":"ABC";
function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 16204
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
// typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<pair<int, int >> a(n);
  REP(i,n){
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  sort(a.begin(), a.end()) ;
  REP(i,n) cout << a[i].second << endl;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    const ll INF = 1e15;

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

    vll s(A + 2);
    s.front() = -INF;
    for (int i = 1; i <= A; i++) {
        cin >> s[i];
    }
    s.back() = INF;

    vll t(B + 2);
    t.front() = -INF;
    for (int i = 1; i <= B; i++) {
        cin >> t[i];
    }
    t.back() = INF;

    ll x;
    for (int q = 0; q < Q; q++) {
        cin >> x;

        auto its = lower_bound(all(s), x);
        ll sL = *prev(its), sR = *its;

        auto itt = lower_bound(all(t), x);
        ll tL = *prev(itt), tR = *itt;

        ll c1 = max(sR, tR) - x;
        ll c2 = x - min(sL, tL);

        ll c3 = 2 * (x - sL) + (tR - x);
        ll c4 = 2 * (x - tL) + (sR - x);

        ll c5 = (x - sL) + 2 * (tR - x);
        ll c6 = (x - tL) + 2 * (sR - x);

        cout << min({ c1, c2, c3, c4, c5, c6 }) << "\n";
    }

    return 0;
}



Measured memory_bytes: 2944
N=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

plist=factorization(N)
if [1,1] in plist:
    plist.remove([1,1])
elist=[v[1] for v in plist]
ans=0
for e in elist:
    k=0
    n=0
    while n<=e:
        ans+=1
        k+=1
        n+=k
print(ans-len(elist))


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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define loop(i, a, b) for(int i = a; i < b; i++)
#define pb push_back

const int maxn = 1e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define MAX 100005
bool visited[MAX];
int dp[MAX];
vector<int> graph[MAX];
int n, m;

void dfs(int i)
{
	visited[i] = true;
	for(int j = 0; j < graph[i].size(); j++)
	{
		if(!visited[graph[i][j]])
			dfs(graph[i][j]);
		dp[i] = max(dp[i], dp[graph[i][j]] + 1);
	}

}

int main()
{
	fastIO;
	cin >> n >> m;
	int M = m;
	while(m--)
	{
		int a, b;
		cin >> a >> b;
		graph[a].pb(b);
	}
	for(int i = 1; i <= n; i++)
	{
		if(!visited[i])
			dfs(i);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
		if(ans <= dp[i])
			ans = dp[i];
	cout << ans;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp(x,y) make_pair(x,y)
#define scd(n) scanf("%d",&n)
#define sclf(n) scanf("%lf",&n)
#define scl(n) scanf("%I64d",&n)
#define repi(a,b,c) for(int i=a;i<b;i+=c)
#define repis(a,b,c) for(int i=a-1;i>=b;i-=c)
#define repj(a,b,c) for(int j=a;j<b;j+=c)
#define repjs(a,b,c) for(int j=a-1;j>=b;j-=c)
#define repk(a,b,c) for(int k=a;k<b;k+=c)
#define repks(a,b,c) for(int k=a-1;k>=0;k-=c)
#define fi first
#define se second

/*
 fast I/O

 ios::sync_with_stdio(0);
 cin.tie();

 freeopen

 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
 */

typedef pair<ll,ll> ii;
const int mx = 200100;
const int md = 1000000007;
const double EULER = 2.71828182845904523536;

int n,k,d,dp[200][3];

ll solve(int ans,int cek) {
    if(ans > n) return 0;
    if(ans == n and cek) return 1;
    if(dp[ans][cek] != -1) return dp[ans][cek];
    dp[ans][cek] = 0;
    repi(1,k+1,1) dp[ans][cek] = (dp[ans][cek]%md + solve(ans+i,(i >= d || cek) )%md)%md;
    return dp[ans][cek];
}

int main() {
    double a,b;
    cin >> a >> b;
    cout << b*2-a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main(){
    int A,B,C; cin >> A >> B >> C;
    int X,Y; cin >> X >> Y;
    int num_xy = min(X,Y);
    int ans = 0;
    ans += min(A+B,2*C) * num_xy;
    if (X>Y) {
        ans += min(A,2*C) * (X - Y);
    }
    else if (X<Y) {
        ans += min(B,2*C) * (Y - X);
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long int;
using ld = long double;

auto p = [](auto s){
    cout << s << endl;
};

int main() {
    ld L;
    cin >> L;
    ld h = L / 3.0l;
    cout << setprecision(20) << h * h * h << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////

ll cal(ll p,ll x,ll y){
    ll res=inf;
    Min(res,abs(p-x)+abs(x-y));
    Min(res,abs(p-y)+abs(y-x));
    return res;
}


int main(){fastio;
    ll a,b,q;cin>>a>>b>>q;
    ll s[a+2];rep(i,1,a)cin>>s[i];s[0]=-inf;s[a+1]=inf;
    ll t[b+2];rep(i,1,b)cin>>t[i];t[0]=-inf;t[b+1]=inf;
    while(q--){
        ll p;cin>>p;
        ll x=lower_bound(s,s+a+2,p)-s;
        ll y=lower_bound(t,t+b+2,p)-t;
        ll ans=inf;
        Min(ans,cal(p,s[x],t[y]));
        Min(ans,cal(p,s[x-1],t[y]));
        Min(ans,cal(p,s[x],t[y-1]));
        Min(ans,cal(p,s[x-1],t[y-1]));
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

char t[50][51];
uint d[50][50];
int main(int argc, char *argv[], char *envp[]){
	int h=nextpint();
	int w=nextpint();
	for(int i=0; i<h; i++){
		scanf("%s", t[i]);
	}
	int sum=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			d[i][j]=UINT_MAX;
			if(t[i][j]=='.') sum++;
		}
	}
	d[0][0]=0;
	int s[2500][2], S=0;
	if(t[0][0]=='.'){s[0][0]=0; s[0][1]=0; S++;}
	while(S!=0){
		S--; int i=s[S][0], j=s[S][1];
		int D=d[i][j]+1;
		if(i!=0   && t[i-1][j]=='.' && D<d[i-1][j]){d[i-1][j]=D; s[S][0]=i-1; s[S][1]=j; S++;}
		if(i!=h-1 && t[i+1][j]=='.' && D<d[i+1][j]){d[i+1][j]=D; s[S][0]=i+1; s[S][1]=j; S++;}
		if(j!=0   && t[i][j-1]=='.' && D<d[i][j-1]){d[i][j-1]=D; s[S][0]=i; s[S][1]=j-1; S++;}
		if(j!=w-1 && t[i][j+1]=='.' && D<d[i][j+1]){d[i][j+1]=D; s[S][0]=i; s[S][1]=j+1; S++;}
	}
	int D=d[h-1][w-1];
	printf("%d\n", D==UINT_MAX?-1:sum-D-1);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 1000000007
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define sz(x) int(x.size())
int main(){
	int n;
	cin>>n;
	vector<int> xn(n);
	vector<int> yn(n);
	rep(i,n){
		cin>>xn.at(i)>>yn.at(i);
	}
	double ans=0;
	rep(i,n){
		rep(k,n){
			ans+=sqrt(pow((xn.at(i)-xn.at(k)),2.0)+pow((yn.at(i)-yn.at(k)),2.0));
		}
	}
	ans/=n;
	printf("%.8lf",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cassert>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define N 1000

void solve(vector<int> *dist,int *en,vector<int>*edge,vector<int>&inp,
	   int &p,int ff,int &cnt){//from first
  int now = inp[p++];
  int node = cnt;
  dist[ff].push_back(node);
  en[node] = cnt==0?now:now-1;
  cnt++;
  
  while(p<inp.size() && en[node]){
    if ( inp[p]<0){
      int to=-100;      
      rep(i,dist[ff+inp[p]].size() ){
	//for(int i=(int)dist[ff+inp[p]].size()-1;i>=0;i--){
	if ( en[dist[ff+inp[p]][i]] >0){
	  to=dist[ff+inp[p]][i];
	  break;
	}	
      }    

      edge[to].push_back(node);
      edge[node].push_back(to);      
      en[node]--;
      en[to]--;
      p++;
    }else if (inp[p]>0){
      en[node]--;
      edge[node].push_back(cnt);
      edge[cnt].push_back(node);
      solve(dist,en,edge,inp,p,ff+1,cnt);
    }
    
  }
  /*
  REP(i,ff,N){
    dist[i].clear();
  }
  */
}


main(){
  int te;
  cin>>te;
  while(te--){
    vector<int> edge[N];
    vector<int> inp;
    vector<int> dist[N];
    int n,en[N]={0},p=0,cnt=0;
    while(cin>>n && n !=0)inp.push_back(n);

    solve(dist,en,edge,inp,p,0,cnt);
    rep(i,N){
      if ( edge[i].size() == 0)continue;
      sort(edge[i].begin(),edge[i].end());
      cout << i+1 ;
      rep(j,edge[i].size())cout << " " << edge[i][j]+1;
      cout << endl;
    }

  }
  
}

Measured memory_bytes: 0
//Taken from IGamil
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
    int main() {
        int n,m;
        int p=31;
        long long mod = 1e9 + 9;
        long long pi[51];
        pi[0]=1;
        for(int i=1;i<=50;i++)pi[i]=pi[i-1]*p %mod;
        string s;
        cin>>n>>m;
        int ha[n][n+1];
        int hb[m][m+1];
        for(int i=0;i<n;i++)
        {
            cin>>s;
            ha[i][0]=0;
            for(int j=0;j<n;j++)
            {
                ha[i][j+1]= (ha[i][j] + (s[j]=='.'?2:3) * pi[j]) %mod;
            }
        }
        for(int i=0;i<m;i++)
        {
            cin>>s;
            hb[i][0]=0;
            for(int j=0;j<m;j++)
            {
                hb[i][j+1]= (hb[i][j] + (s[j]=='.'?2:3) * pi[j]) %mod;
            }
        }
        bool ok = 0;
        int inner;
        for(int i=0;i+m<=n;i++)
        {
     
     
            for(int j=0;j+m<=n;j++)
            {
                long long curAval = (ha[i][j+m] - ha[i][j] +mod)%mod;
                curAval = curAval * pi[n-1-j] %mod;
                long long curBval = (hb[0][0+m] +mod)%mod;
                curBval = curBval * pi[n-1] %mod;
                if(curAval==curBval)
                {
                    inner = 1;
                    for(inner = i+1;inner<i+m;inner++)
                    {
                        curAval = (ha[inner][j+m] - ha[inner][j] +mod)%mod;
                        curAval = curAval * pi[n-1-j] %mod;
                        curBval = (hb[inner-i][0+m] +mod)%mod;
                        curBval = curBval * pi[n-1] %mod;
                        if(curAval!=curBval)break;
                    }
                    if(inner==i+m)ok=1;
                }
            }
     
        }
     
     
        if(ok)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
     
     
        return 0;
    }

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

using namespace std;

typedef long long int ll;

const ll N=2e5+1;

vector<ll>v[N];
int visited[N]={0};

ll dfs(int node,ll cnt){
    visited[node]=1;
    for(auto x:v[node]){
        if(!visited[x])
            cnt=dfs(x,cnt+1);
    }
    return cnt;
}

int main(){
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++){
        ll x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(!visited[i])
            ans=max(ans,dfs(i,1));
    }
    cout<<ans<<"\n";
    return 0;
}


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

vector<vector<int>> g;
int n;

void bfs(int node,vector<vector<int>> &diff){
  queue<pair<int,int>> que;
  que.emplace(node,0);
  vector<int> seen(n);
  seen[node]=1;

  while(!que.empty()){
    int now = que.front().first;
    int cost = que.front().second;
    que.pop();

    for(int next:g[now]){
      if(seen[next]) continue;
      diff[node][next] = min(diff[node][next],cost+1);
      que.emplace(next,cost+1);
      seen[next]=1;
    }
  } 
}

int main(){
  int x,y;
  cin >> n >> x >> y;
  g.assign(n,vector<int>());
  x--;
  y--;

  for (int i = 0; i < n-1; i++)
  {
    g[i].push_back(i+1);
    g[i+1].push_back(i);
  }
  g[x].push_back(y);
  g[y].push_back(x);

  const int INF = 1e9;
  vector<vector<int>> diff(n,vector<int>(n,INF));
  for (int i = 0; i < n; i++)
  {
    bfs(i,diff);
  }

  vector<int> anss(n);
  for (int i = 0; i < n; i++)
  {
    for (int j = i+1; j < n; j++)
    {
      if(diff[i][j]<n) anss[diff[i][j]]++;
    }
  }

  for (int i = 1; i < n; i++)
  {
    cout << anss[i] << endl;
  }  
}

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

typedef struct SAManberMyers_ {
  string s;
  vector<int> rank;
  vector<int> tmp;
  vector<int> sa;
  int n, k;
  SAManberMyers_(string ss){
    s = ss;
    n = s.size();
    rank.resize(n + 1);
    tmp.resize(n + 1);
    sa.resize(n + 1);
    k = 0;

    // construct suffix array
    construct();
  }
  bool comp(const int &a, const int &b){
    if(rank[a] != rank[b])return rank[a] < rank[b];
    int ra = a + k <= n ? rank[a + k] : -1;
    int rb = b + k <= n ? rank[b + k] : -1;
    return ra < rb;
  }
  void construct(){
    for(int i = 0; i <= n; i++){
      sa[i] = i;
      rank[i] = i < n ? s[i] : -1;
    }

    for(k = 1; k <= n; k *= 2){
      sort(sa.begin(), sa.end(), [this] (const int &a, const int &b) {return comp(a, b);});

      tmp[sa[0]] = 0;
      for(int i = 1; i <= n; i++){
        tmp[sa[i]] = tmp[sa[i-1]] + (comp(sa[i-1], sa[i]) ? 1 : 0);
      }
      for(int i = 0; i <= n; i++){
        rank[i] = tmp[i];
      }
    }
  }
} SAManberMyers;

vector<int> sa_search_(SAManberMyers &sa, string s, string t){
  vector<int> res;
  t += "$";
  s += "$";
  int ld = -1;
  int rd = sa.sa.size() - 1;
  while(rd - ld > 1){
    int md = (rd + ld) / 2;
    if(s.substr(sa.sa[md]) < t)ld = md;
    else rd = md;
  }
  t = t.substr(0, t.size() - 1);
  while(rd < sa.sa.size()){
    if(s.substr(sa.sa[rd], t.size()) != t)break;
    res.push_back(sa.sa[rd]);
    rd++;
  }
  sort(res.begin(), res.end());
  return res;
}

vector<int> sa_search(string s, string t){
  SAManberMyers sa(s);
  vector<int> res = sa_search_(sa, s, t);
  return res;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  auto res = sa_search(s, t);
  rep(i, sz(res))cout << res[i] << endl;
	return 0;
}



Measured memory_bytes: 3264
#include<stdio.h>
#include<string.h>

#define LEN 13
#define LIM 1000000

char H[LIM][LEN];

int toInt(char c) {
  if ( c == 'A' ) return 1;
  else if ( c == 'C' ) return 2;
  else if ( c == 'G' ) return 3;
  else if ( c == 'T' ) return 4;
  else return 0;
}

int getKey(char str[]) {
  int sum = 0, p = 1;
  for ( int i = 0; i < strlen(str); i++ ) {
    int v = toInt(str[i]);
    sum += v * p;
    p *= 5;
  }
  return sum;
}

int h1(int key) { return key % LIM; }
int h2(int key) { return 1 + key % (LIM - 1); }
int hashValue(int key, int i) { return (h1(key) + i * h2(key)) % LIM; }

int insert(char str[]) {
  int key = getKey(str);
  for ( int i = 0; i < LIM; i++ ) {
    int h = hashValue(key, i);
    if ( strcmp(H[h], str) == 0 ) {
      return 1;
    } else if ( strlen(H[h]) == 0 ) {
      strcpy(H[h], str);
      return 1;
    }
  }
  return 0;
}

int find(char str[]) {
  int key = getKey(str);
  for ( int i = 0; i < LIM; i++ ) {
    int h = hashValue(key, i);
    if ( strcmp(H[h], str) == 0 ) {
      return 1;
    } else if ( strlen(H[h]) == 0 ) {
      return 0;
    }
  }
  return 0;
}

int main() {
  int n;
  char com[7], str[LEN];
  scanf("%d", &n);

  while( scanf("%s %s", com, str) != EOF ) {
    if ( com[0] == 'i' ) {
      insert(str);
    } else if (com[0] == 'f' ) {
      if (find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int h,w; cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> s[i][j];

    rep(i, h) rep(j, w) {
        if(s[i][j] == '#') {
            if(i > 0 && s[i-1][j] == '#') continue;
            if(i < h-1 && s[i+1][j] == '#') continue;
            if(j > 0 && s[i][j-1] == '#') continue;
            if(j < w-1 && s[i][j+1] == '#') continue;
            cout << "No" << endl;
            return 0;
        }
    }

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



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

using namespace std;

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

class Edge{
public:
    ll w;
    int f;
    int s;

    Edge(ll a=0, int b=0, int c=0) : w(a), f(b), s(c) {}

    bool operator < (const Edge& e2){
        return w < e2.w;
    }
};

#define MAX_N 100100
int par[MAX_N];
int rank_u[MAX_N];

vector<P> x;
vector<P> y;

void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        rank_u[i] = 0;
    }
}

//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)  return;

    if(rank_u[x] < rank_u[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if(rank_u[x] == rank_u[y])  rank_u[x]++;
    }
}

//xとyが同じ集合に属するかどうか
bool same(int x, int y){
    return find(x) == find(y);
}

vector<Edge> x_edge;
vector<Edge> y_edge;


int main(){
    int N;  cin >> N;
    for(int i = 0; i < N; i++){
        ll xx, yy;    cin >> xx >> yy;
        x.emplace_back(P(xx, i));
        y.emplace_back(P(yy, i));
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    for(int i = 0; i < N-1; i++) {
        Edge ex(x[i+1].first - x[i].first, x[i].second, x[i+1].second);
        x_edge.push_back(ex);

        Edge ey(y[i+1].first - y[i].first, y[i].second, y[i+1].second);
        y_edge.push_back(ey);
    }

    sort(x_edge.begin(), x_edge.end());
    sort(y_edge.begin(), y_edge.end());

    int xi = 0, yi = 0;
    ll res = 0;
    init(N);
    while(xi < x_edge.size() && yi < y_edge.size()){
        Edge e;
        if(x_edge[xi] < y_edge[yi]){
            e = x_edge[xi];
            xi++;
        }
        else{
            e = y_edge[yi];
            yi++;
        }

        if(same(e.f, e.s))  continue;
        else{
            unite(e.f, e.s);
            res += e.w;
        }
    }

    cout << res << endl;



    return 0;
}

Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n, x = 0, ans = 1;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    x ^= a.at(i);
  } 
  for(int i = 0; i < n; i++) {
    if(x ^ a.at(i) != a.at(i)) ans=0;
  }
  if(ans) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 640
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
 
for i in range(n):
  a = list(map(int, input().split()))
  p = c
  for j in range(m):
  	p += a[j] * b[j]
  if 0 < p:
    count += 1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int a,b,c,r;

  scanf("%d%d",&a,&b);

  if(b>a){
    c=a;
    a=b;
    b=c;
  }


  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }

  printf("%d\n",b);
  
    return 0;
}



Measured memory_bytes: 2124
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {in_s: String};
    let mut nums = HashMap::new();
    let mut val = 0;
    let mut mul = 1;

    nums.insert(0, 1);

    for c in in_s.as_str().chars().rev() {
        let x: usize = c.to_string().parse().unwrap();

        val = (val + mul * x) % 2019;
        mul = (mul * 10) % 2019;

        if !nums.contains_key(&val) {
            nums.insert(val, 0);
        }

        nums.insert(val, nums[&val] + 1);
    }

    let mut count = 0;

    for (_, v) in &nums {
        if *v < 2 {
            continue;
        }

        count += *v * (*v - 1) / 2;
    }

    println!("{}", count);
}


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

#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define FOR(i,l,r) for(long long i=l; i<r; i++)
#define FOR_REV(i,r,l) for(long long i=r; i>=l; i--)
#define pb push_back
#define mp make_pair

int last(int n)
{
    return n%10;
}

int first(int n)
{
    int a = log10(n);

    int t = pow(10, a);

    return n/t;
}

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

    int cnt[11][11]= {0};

    FOR(i,1,n+1)
    {
        int f = first(i);
        int l = last(i);

        cnt[f][l]++;
    }

    ll ans=0;

    FOR(i,1,10)
    {
        FOR(j,1,10)
        {
            ans += cnt[i][j]*cnt[j][i];
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 384