akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#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 pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w)), b(h, vector<int>(w));
    vector<vector<vector<int>>> dp(h, vector<vector<int>>(w, vector<int>((h+w)*100, false)));
    rep(i, h)rep(j, w)cin >> a[i][j];
    rep(i, h)rep(j, w)cin >> b[i][j];
    dp[0][0][abs(a[0][0]-b[0][0])] = true;
    rep(i, h)rep(j, w){
        rep(k, (h+w)*100){
            if(!dp[i][j][k])continue;
            if(i+1 < h)dp[i+1][j][k+abs(a[i+1][j]-b[i+1][j])] = true;
            if(j+1 < w)dp[i][j+1][k+abs(a[i][j+1]-b[i][j+1])] = true;
            if(i+1 < h)dp[i+1][j][abs(k-abs(a[i+1][j]-b[i+1][j]))] = true;
            if(j+1 < w)dp[i][j+1][abs(k-abs(a[i][j+1]-b[i][j+1]))] = true;
        }
    }
    int ans = -1;
    rep(i, (h+w)*100)if(dp[h-1][w-1][i]){ans = i; break;}
    cout << ans << endl;
}

Measured memory_bytes: 408704
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll a;
  std::string s;
  std::cin>>a>>s;
  if(a>=3200)std::cout<<s;
  else std::cout<<"red";
  return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    ll ans=0;
    rep(i,3)if(s[i]==t[i])ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
//#define M   1000000007 // 1e9 + 7
#define MAXN 400100
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,double> pdd;
inline int mod(int n, int m){int ret = n%m; if(ret < 0) ret += m; return ret;}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

int32_t main(){
	fastio;
	int n;
	cin>>n;
	cout<<n*n<<endl;

	
	
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#define rep(i,k,n)for(ll i=k;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int gcd(ll a, ll b) {

	if (b == 0) {

		return a;
	}
	else {
		a = a%b;
		gcd(b, a);
	}
}
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
mint func(ll n, ll a,mint q,ll p,mint ans) {
	mint N = n;
	
	if (p == a) {

		return ans;
	}else{
		ans *=(N - q) / (q + 1);
		q += 1;
		p++;
		func(n, a, q, p,ans);
	}
	
}

int main() {
	ll A, B, C,K;
	cin >> A >> B >> C>>K;
	ll ans=0;
	if (A >= K) {
		ans +=K;
	}
	else if(A+B>=K){
		ans += A;
	}
	else {

		ans = A - (K - A - B);

	}
	cout << ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
using namespace std;
void yaku(int a,int b){
    for(int i=2;i<=a&&i<=b;i++){
        if(a%i==0&&b%i==0){
            a/=i;
            b/=i;
            i=2;
        }
    }
    cout<<a<<'/'<<b<<endl;
}
int main(void){
    char s[9];
    cin>>s;
    int k=10,x=0,l=strlen(s),i;
    for(i=0;s[i]!='.';i++){
        x*=10;
        x+=int(s[i]-'0');
    }
    int m=1;
    for(i++;s[i]!='(';i++,k*=10,m*=10){
        x*=10;
        x+=int(s[i]-'0');
        if(i==l-1){
            yaku(x,k);
            return 0;
        }
    }
    int y=x;
    for(i++;s[i]!=')';i++,k*=10){
        x*=10;
        x+=int(s[i]-'0');
        
    }
    k/=10;
    yaku(x-y,k-m);
}

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

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'
#define MAX 501

using namespace std;

void quick () {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);/*//*/
}

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

int diva (int n) {
    int counter = 0;
    for (int i = 1 ; i <= n ;i++){
        if (n%i==0)counter++;
    }
    return counter;
}

void readFromText(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif // ONLINE_JUDGE
}

int main()
{
    quick();
//    readFromText();
    string s ; int k ; cin >> s >> k ; int oCtr = 0 ;
    for (int i = 0 ; i < s.length () ; i++){
        if (s[i]=='1')oCtr++;
        else break;
    }
    if (oCtr<k)cout<<s[oCtr];
    else cout << 1 ;
    return 0;
}


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

/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/


using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}

int freq[(int)2e5 + 9];
//int freq2[]
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n , m;
    cin >> n >> m;
    int x[n];
    ll sum = 0;
    loop(n)
    {
    	cin >> x[i];
    	sum += x[i];
    }
    int counter = 0;
    loop(n)
    {
    	double z = (double)( (double)1 / (4 * m) ) * sum;
    	if (x[i] >= z)
    	{
    		counter++;
    	}
    	if (counter == m)
    	{
    		cout << "Yes" << endl;
    		return 0;
    	}
    }
    cout << "No" << endl;
    return 0;
}


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

using namespace std;

int dp[100002][2][2][2];
int helper(vector<vector<int> >&happy,int i,int a,int b,int c){
	if(dp[i][a][b][c] >= 0){
		return dp[i][a][b][c];
	}
	if(i >= happy.size()){
		return 0;
	}
	else{
		if(a == 1){
			dp[i][a][b][c] = max(happy[i][1]+helper(happy,i+1,0,1,0),happy[i][2]+helper(happy,i+1,0,0,1));
			return dp[i][a][b][c];
		}
		if(b == 1){
			dp[i][a][b][c] = max(happy[i][0]+helper(happy,i+1,1,0,0),happy[i][2]+helper(happy,i+1,0,0,1));
			return dp[i][a][b][c];
		}
		if(c == 1){
			dp[i][a][b][c] = max(happy[i][0]+helper(happy,i+1,1,0,0),happy[i][1]+helper(happy,i+1,0,1,0)); 
			return dp[i][a][b][c];
		}
	}
}
int main(){
	int n;cin>>n;
	vector<vector<int> >happy(n,vector<int>(3,0));
	for(int i=0;i<n;i++){
		cin>>happy[i][0]>>happy[i][1]>>happy[i][2];
	}
	int ans = INT_MIN;
	for(int i=0;i<100002;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				for(int l=0;l<2;l++){
					dp[i][j][k][l] = -1;
				}
			}
		}
	}
	ans = max(happy[0][0]+helper(happy,1,1,0,0),max(happy[0][1]+helper(happy,1,0,1,0),happy[0][2]+helper(happy,1,0,0,1)));
	cout<<ans;
}



Measured memory_bytes: 16640
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <iomanip>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int n;
double fans;
vector <vector <double> > dp(3050,vector <double> (3050,0));
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	vector <double> v(n);
	for(double &x:v)
		cin >> x;
	if(n==1)
	{
		cout << v[0];
		return 0;
	}
	fans=0;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			dp[i][j]+=dp[i-1][j]*(1-v[i-1]);
			if(j)
				dp[i][j]+=dp[i-1][j-1]*v[i-1];
		}
	}
	for(int i=n;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(j>n/2)
				fans+=dp[i][j];
		}
	}
	cout << fixed << setprecision(10) << fans ;
}

Measured memory_bytes: 73088
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>

typedef long long ll;
const ll INF = 1e18 + 1;
const ll MOD = 1e9 + 7;

template<typename T> T lminimum(const std::vector< T >& v) {return *std::min_element(v.begin(), v.end());}
template<typename T> T lmaximum(const std::vector< T >& v) {return *std::max_element(v.begin(), v.end());}
template<typename T> void lunique(std::vector< T >& v) {v.erase(std::unique(v.begin(), v.end()), v.end());}
template<typename T> void lsort(std::vector< T >& v) {std::sort(v.begin(), v.end());}
template<typename T> void lgreatersort(std::vector< T >& v) {std::sort(v.begin(), v.end(), std::greater<>());}
template<typename T> bool lnext_permutation(std::vector< T >& v) {return std::next_permutation(v.begin(), v.end());}

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  std::vector< ll > vb(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i] >> vb[i];
  }

  ll a = 1;
  ll b = 1;
  for (ll i = 0; i < N; i++) {
    ll n = std::max((a + va[i] - 1) / va[i], (b + vb[i] - 1) / vb[i]);
    a = n * va[i];
    b = n * vb[i];
    //std::cout << a << " " << b << std::endl;
  }

  std::cout << a + b << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int C = Integer.parseInt(tokens[2]);
		if (B + C > A) {
			System.out.println((C - (A - B)));

		} else {
			System.out.println(0);
		}
	}
}


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

int main() {
    int n, x;

    while (true) {
        cin >> n >> x;
        if (n == 0 && x == 0) {
            break;
        }

        int count = 0;
        for (int a = 1; a <= n-2; a++) {
            for (int b = a+1; b <= n-1; b++) {
                for (int c = b+1; c <= n; c++) {
                    if (a + b + c == x) {
                        count += 1;
                    }
                }
            }
        }
        cout << count << endl;
    }
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i=1;
    int x,y;
    while(true)
    {
        cin>>x>>y;
        if(x==0&&y==0)
            break;
            if(x>y){
            swap(x,y);
            }
        cout<<x<<" "<<y<<"\n";
}

    return 0;
}



Measured memory_bytes: 3084
(n, m), *q = [[*map(int, i.split())] for i in open(0)]
b = [0] * (n + 1)
b[1] = 1
c = [1] * (n + 1)
for x, y in q:
    c[x] -= 1
    c[y] += 1
    b[y] |= b[x]
    b[x] *= c[x] > 0
print(sum(b))


Measured memory_bytes: 28596
n,m=map(int,input().split())
a=[]
for _ in range(m):
    a.append(int(input()))
ans=1
a.sort()
d={0:1,1:1,2:2,3:3,4:5,5:8,6:13,99500:49759705584609,99501:49760296517401}
def func(n):
    if n in d:
        return d[n]
    else:
        v = (func(n-1)+func(n-2))%(10**9+7)
        d[n]=v
        return v
ps=-1
a.append(n+1)
for ai in a:
    c=ai-ps-2
    ps=ai
    if c<0:
        print(0)
        exit()
    c=func(c)
    ans*=c
    ans%=10**9+7

print(ans%(10**9+7))

Measured memory_bytes: 7032
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

long long ct = 0;

void div2(long long num)
{
  //  cout << num << endl;
  ct++;
  if(num<=1)
    return;
  div2(num/2);
  div2(num/2);
}

int main()
{
  long long H;

  cin >> H;

  long long i;
  
  long long n = (long long)log2(H);
  
  cout << std::setprecision(13)  << pow(2, n+1)-1 << endl;
  
  return 0;
}



Measured memory_bytes: 512
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;

void main(){
    auto n=readln().chomp.to!int;
    long[] Ts;
    long[] As;
    foreach(i;0..n){
        auto ln=readln.split.map!(to!long).array;
        Ts~=ln[0];
        As~=ln[1];
    }

    foreach(i;1..n){
        long rate=max(1+(Ts[i-1]-1)/Ts[i],1+(As[i-1]-1)/As[i]);
        Ts[i]*=rate;
        As[i]*=rate;
    }
    writeln(Ts[n-1]+As[n-1]);
}

Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std ;
int a[3] ;
int main()
{
	cin >> a[0] >> a[1] >> a[2] ;
	sort ( a , a+3 ) ;
	int x = a[2] * 10 + a[1] ;
	cout << x + a[0] << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define pb emplace_back
#define em emplace
#define fi first
#define se second
#define USE1(...) template <typename __VA_ARGS__> inline
#define USE2(T, ...) USE1(T, typename __VA_ARGS__)
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

using ll = long long;
template<typename T> using vec = std::vector<T>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE2(T=int,V=vec<T>)V reserved(int n){V v;v.reserve(n);return v;}
USE1(T=int)vec<T>in(int n){auto v=reserved<T>(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=std::pair<T,int>)vec<U>enume(const vec<T>&x,int s=0){int N=x.size();auto v=reserved<U>(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE2(T,U)void prif(bool b,T t,U f){if(b)pr(t);else pr(f);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(20);
    std::cout.setf(std::ios::fixed);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

vec<int> ch[100100];

int dfs(int v = 1) {
  const int sz = ch[v].size();

  auto r = reserved<int>(sz);
  for (int u : ch[v]) {
    r.pb(dfs(u));
  }
  sort(ALL(r));
  int maxi = 0;
  rep(i, sz) {
    chmax(maxi, r[i] + sz - i);
  }
  return maxi;
}

signed main() {
  int N = in();

  rep(i, N - 1) {
    int A = in();
    ch[A].pb(i + 2);
  }
  pr(dfs());
  return 0;
}


Measured memory_bytes: 18176
using CompLib.Util;
using System;
using System.Collections.Generic;

public class Program
{
    int N;
    int[] P;

    int[] dx = new int[] { 1, 0, -1, 0 };
    int[] dy = new int[] { 0, 1, 0, -1 };
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        P = sc.IntArray();
        for (int i = 0; i < N * N; i++)
        {
            P[i]--;
        }

        var dist = new int[N, N];
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                dist[i, j] = Math.Min(Math.Min(i + 1, j + 1), Math.Min(N - i, N - j));
            }
        }

        long ans = 0;
        bool[,] flag = new bool[N, N];
        var xq = new Queue<int>();
        var yq = new Queue<int>();
        foreach (var i in P)
        {
            int y = i / N;
            int x = i % N;
            dist[y, x]--;
            flag[y, x] = true;
            ans += dist[y, x];
            xq.Enqueue(x);
            yq.Enqueue(y);
            while (xq.Count > 0)
            {
                int xx = xq.Dequeue();
                int yy = yq.Dequeue();
                for (int j = 0; j < 4; j++)
                {
                    int nx = xx + dx[j];
                    int ny = yy + dy[j];
                    if (nx < 0 || nx >= N) continue;
                    if (ny < 0 || ny >= N) continue;
                    int nc = dist[yy, xx] + (flag[ny, nx] ? 0 : 1);
                    if (dist[ny, nx] <= nc) continue;
                    dist[ny, nx] = nc;
                    xq.Enqueue(nx);
                    yq.Enqueue(ny);
                }
            }

        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;

#define _ << " " <<
#define pb push_back
#define ff first
#define ss second


typedef long long ll;
typedef long double ld;

#define int ll

const ll MOD = 1e9 + 7;

vector<int> fact(2e6 + 100);

void  build() {
    fact[0] = 1;
    for (int i = 1; i < fact.size(); ++i) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
    }
}

int pw(int x, int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return pw(x * x % MOD, y / 2) % MOD;
    return (x * pw(x, y - 1)) % MOD;
}

void solve() {
    ll i, j;
    cin >> i >> j;
    if ((2 * j - i) % 3 != 0 || (2 * i - j) % 3 != 0 || (2 * i - j) < 0 || (2 * j - i) < 0) {
        cout << 0;
    } else {
        ll x = (2 * j - i) / 3 % MOD;
        ll y = (2 * i - j) / 3 % MOD;
        //cout << x _ y << endl;
        cout << (fact[x + y] * pw(fact[x], MOD - 2)) % MOD * pw(fact[y], MOD - 2) % MOD;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("dominoes.in", "r", stdin);
    //freopen("dominoes.out", "w", stdout);
    int test = 1;
    //cin >> test;
    build();
    while (test--) {
        solve();
    }
}


Measured memory_bytes: 15872
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <numeric>
#include <cassert>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long LL;
typedef double LD;
typedef pair<LD, LD> PLD;
typedef pair<PLD, PLD> PPLD;

#define FOR(k,a,b) for(int k(a); k < (b); ++k)
#define FORD(k,a,b) for(int k(b-1); k >= (a); --k)
#define REP(k,a) for(int k=0; k < (a); ++k)
#define ABS(a) ((a)>0?(a):-(a))
#define EPS 1e-9
#define P45 acos(0.0)/2
#define P90 acos(0.0)

LD cross(PLD a, PLD b) { return a.first * b.second - a.second * b.first; }
LD area2(PLD a, PLD b, PLD c) { return cross(a, b) + cross(b, c) + cross(c, a); }

struct CIRCLE
{
	LD x, y, R;
	CIRCLE() {}
	CIRCLE(LD _x, LD _y, LD _R) : x(_x), y(_y), R(_R) {}
	void Read()
	{
		double _x, _y;
		scanf("%lf %lf", &_x, &_y);
		x = _x, y = _y, R = -1;
	}

	PPLD InterSection(const CIRCLE& other)
	{
		LD lx = x, ly = y, lR = R, ox = other.x, oy = other.y, oR = other.R;
		LD d = (lx - ox)*(lx - ox) + (ly - oy)*(ly - oy);
		d = sqrt(d);
		if (ABS(lR + oR - d) < EPS)
			return PPLD(PLD((x + other.x) / 2, (y + other.y) / 2), PLD(x, y));
		if (d < lR + oR)
		{
			LD a = (lR * lR - oR*oR + d*d) / (2.0*d);
			LD h = sqrt(lR*lR - a*a);
			PLD tp1(lx + a*(ox - lx) / d, ly + a*(oy - ly) / d);
			PLD p1(tp1.first + h*(oy - ly) / d, tp1.second - h*(ox - lx) / d);
			PLD p2(tp1.first - h*(oy - ly) / d, tp1.second + h*(ox - lx) / d);
			return PPLD(p1, p2);
		}
		return PPLD(PLD(x, y), PLD(x, y));
	}	
	bool IsIn(const PLD& p) const
	{
		return ABS((p.first - x)*(p.first - x) + (p.second - y)*(p.second - y)) <   R * R + EPS;
	}
};


int main(int argc, char** argv) {
#ifdef HOME
	freopen("in.txt", "rb", stdin);
	freopen("out.txt", "wb", stdout);
#endif
	int N, M;
	scanf("%d", &N);
  	M=N;
	vector<CIRCLE> v(N);
	REP(i, N)
		v[i].Read();
	LD lo = 0, hi = 2000;
	while (ABS(hi - lo) > 0.00000001)
	{
		LD actR = (hi + lo) / 2;
		REP(i, N)
			v[i].R = actR;
		int mx = 0;
		REP(i, N) FOR(j,i+1,N)
		{
			PPLD ip = v[i].InterSection(v[j]);
			CIRCLE c1,c2;
			c1.x = ip.first.first, c1.y = ip.first.second, c1.R = actR;
			int db1 = 0, db2 = 0;
			REP(k, N)
			{
				if (c1.IsIn(make_pair(v[k].x, v[k].y)))
					++db1;
			}
			c2.x = ip.second.first, c2.y = ip.second.second, c2.R = actR;
			REP(k, N)
			{
				if (c2.IsIn(make_pair(v[k].x, v[k].y)))
					++db2;
			}
			mx = max<int>(max<int>(db1, db2),mx);
		}
		if (mx >= M)
			hi = actR;
		else
			lo = actR;
	}
	printf("%.7lf\n", lo);
	return 0;
}

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

int main()
{
	int n; cin >> n;
	
	vector<int> a(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans += a[i];
	}
	
	ans -= n;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.*;

public class Main {
	public static void main(String[] args){
		double ce, cf;
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		//キーボードからr(半径の値)を入出力
		double r = Double.parseDouble(a);
		ce = Math.pow(r,2)*Math.PI;
		//円の面積⇒r二乗(Math.pow(値,何乗))*円周率（Math.PI）
		cf = 2*r*Math.PI;
		//円周⇒2*r*円周率
		System.out.printf("%f %f",ce,cf);
		//計算結果を10進数の形式で出力
	}
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int X,Y,Z; cin >> X >> Y >> Z;
    swap(X,Y); swap(X,Z);
    cout << X << " " << Y << " " << Z << endl;
    return 0;
}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;
int dp[N],dp1[N];
int main(){
	
	string s;
	cin>>s;
	int n = s.size();
	for(int i=1;i<=n;i++){
		dp[i] = dp[i-1]^1;
	}

	dp1[1] = 0;
	for(int i=2;i<=n;i++){
		dp1[i] = dp1[i-1]^1;
	}
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(s[i]-'0' != dp[i+1])cnt++;
	}	

	int cnt1 = 0;

	for(int i=0;i<n;i++){
		if(s[i]-'0' != dp1[i+1])cnt1++;
	}	

	cout<<min(cnt,cnt1)<<endl;
	

	return 0;
}

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

int main() {
  int n, ma = 0;
  cin >> n;
  map<string, int> str;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    if (str.count(s)) ++str[s];
    else str[s] = 1;
    if (ma < str[s]) ma = str[s];
  }
  for (auto s : str) {
    if (s.second == ma) cout << s.first << "\n";
  }
}

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


int main() {
    long long  n;
    cin >> n;
    long long mod = 1;
    long long x = 0;

    for (int i=0; i<=11; i++) {
        if (n <= (x+1)*26) {
            n -= x;
            break;
        }
        mod *=26;
        x = (x+1)*26;
    } 
    n--;
    char tmp;
    while (mod != 1) {
        tmp = ((int) 'a' + n / mod);
        cout << tmp ;
        n %= mod;
        mod /= 26;
    }
    n++;
    tmp = ((int) 'a' + n / mod-1);
    cout << tmp << endl;

    return 0;
}

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

int main(){
  int N, X, T, count;
  cin >> N >> X >> T;
  if(N % X != 0){
    cout << T*(N/X+1) << endl;
  }else{
    cout << T*N/X << endl;
  }
  return 0;
}

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

int main() {

	int N;
	cin >> N;
	
	int t[N+1],x[N+1],y[N+1];
    int time_gap[N];
    int d_gap[N];
    
    t[0]=0;
    x[0]=0;y[0]=0;
    
    bool check=false;      
	for (int i = 1; i <= N; i++) {
        cin>>t[i]>>x[i]>>y[i];
        
        time_gap[i-1]=t[i]-t[i-1];
        d_gap[i-1]=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        
        if(time_gap[i-1]%2!=d_gap[i-1]%2){check=true;break;}
        if(time_gap[i-1]<d_gap[i-1]){check=true;break;}

	}
	
	if(check)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 2176
# -*- coding: utf-8 -*-
S=input()
X3=0
X1=""
Y1=0
Y2=""
Y3=""
if int(S)==10**18:
    X1=0
    Y3=10**9
    X2=10**9
    Y2=0
elif len(S)>9:
    for i in range(0,len(S)-9):
        X1=X1+S[i]
    Y2=10**9
    for j in range(len(S)-9,len(S)):
        Y3=Y3+S[j]
    Y3=int(Y3)
    X1=int(X1)
    X2=X1+1
else:
    Y2=0
    X2=int(S)
    Y3=1
    X1=0

print(X1,Y1,X2,Y2,X3,Y3)

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

int main(void){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, d;
    cin>>d>>n;
    if(n==100){
    	n++;
	}
    int ans;
    if(d==0){
    	ans= n;
	}
	if(d==1){
		ans = 100*n;
	}
	if(d==2){
		ans = 10000*n;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100100
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

string s, t;
ll dp[3003][3003];

void printLcs(ll i, ll j) {
    if(i==0 || j==0) return;
    
    if(s[i-1]==t[j-1]) {
        printLcs(i-1, j-1);
        cout << s[i-1];
    }else if(dp[i-1][j]>=dp[i][j-1]) {
        printLcs(i-1, j);
    }else {
        printLcs(i, j-1);
    }
}

int main(void) {
    cin >> s >> t;
    ll i, j;
    ll slen=s.size();
    ll tlen=t.size();
    
    for(i=1; i<=slen; i++) {
        for(j=1; j<=tlen; j++) {
            if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
        }
    }
    
    printLcs(slen, tlen);
    cout << "\n";
}













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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

ll fact(ll n){
	ll ret = 1;
	for(int i=n; i>=1; i--){
		ret *= i;
		ret %= MOD;
	}

	return ret;
}

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	ll n, m;
	cin >> n >> m;
	if(abs(n-m) > 1){
		puts("0");
		return 0;
	}

	if(n == m){
		ll ans = 1;
		for(int i=n; i>=1; i--){
			ans *= i;
			ans %= MOD;
		}
		ans *= ans;
		ans %= MOD;
		ans *= 2;
		ans %= MOD;

		cout << ans << endl;
		return 0;
	}else{
		ll ans = fact(n) * fact(m);
		ans %= MOD;

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


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

using namespace std;
long long gcd(long long a,long long b)
{
    if(b>a)swap(a,b);
    if(b==0)return a;
    return gcd(b,a%b);
}
long long nww(long long a,long long b){return a*b/gcd(a,b);}
int main()
{
    long long a,b;
    cin>>a>>b;
    cout<<nww(a,b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
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;}
int const INF = 1001001001;


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

int n;
cin >> n;
vl a(n);
rep(i,n) cin >> a[i];
sort(all(a), greater<int>());
ll res = 0;
rrep(i,n-1) {
    res += a[i/2];
}
cout << res << endl;
return 0;
}

Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+10,M=1e2+10;
const int mod=1e9+7;
const int inf=1e9;
int w[M],v[M];
int dp[M][N];
 
int main(){
    int W,n;
    int val=0;
    cin>>n>>W;
    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
        val+=v[i];
    }
    dp[0][0]=0;
    for(int i=1;i<=val;i++) dp[0][i]=inf;
    for(int j=1;j<=n;j++){
        for(int i=0;i<=val;i++){
            dp[j][i]=dp[j-1][i];
            if(i>=v[j]){
                dp[j][i]=min(dp[j][i],dp[j-1][i-v[j]] + w[j]);
            }
        }
    }
    
    int ans=0;
    for(int i=1;i<=val;i++){
        if(dp[n][i]<=W) ans=i;
    }
    
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 42844
#include <iostream>
using namespace std;
typedef long long ll;

const ll mod = 1e9+7;

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;

    int K = 0;
    ll ans = 1;
    for(auto c : S){
        if((c == 'W' && K%2 == 0) || (c == 'B' && K%2 == 1)){
            ans *= K;
            ans %= mod;
            if ((--K) < 0)break;
        }else{
            K++;
        }
    }
    if(K != 0){
        cout << 0 << endl;
        return 0;
    }

    for(int i=1;i<=N;i++){
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 120000;

int n;
ll c;
ll x[MAXN];
ll y[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> c;
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
	}
	ll ans = 0;
	ll sum = accumulate(y, y + n, 0ll);
	ll mx = 0;
	ll mx2 = 0;
	ll asum = 0;
	for (int i = n - 1; i >= 0; --i) {
		ans = max(ans, sum - x[i] + mx2);
		ans = max(ans, sum - 2 * x[i] + mx);
		sum -= y[i];
		asum += y[i];
		mx = max(mx, asum - (c - x[i]));
		mx2 = max(mx2, asum - 2 * (c - x[i]));
	}
	ans = max(ans, mx);
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		int count = 0;
		for(int i = a; i <= b; i++){
	        if(c % i == 0) count++; 
		}
		System.out.println(count);
	}
	
	public static void main(String[] args) {
		/* 
		 * Main x;
		 * x = new Main();
		 * x.run();
		 * ??¨????????????
		 */
		new Main().run();
		
	}
}

Measured memory_bytes: 26164
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    int N;
    ll a[10000];
    
    cin >> N;
    rep(i, N) cin >> a[i];

    int ans = 0;
    rep(i, N) {
        while( a[i] > 0 ) {
            if( a[i]%2 == 0 ) {
                ++ans;
                a[i] /= 2;
            }
            else break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
a = [None for i in range(9)]
b = [False for i in range(9)]

a[0], a[1], a[2] = input().split()
a[3], a[4], a[5] = input().split()
a[6], a[7], a[8] = input().split()

N = int(input())

for i in range(N):
    target = input()
    for j in range(9):
        if a[j] == target:
            b[j] = True

bl = [[0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]

ret = "No"
for i in bl:
    for j in i:
        if b[j] is False:
            break
    else:
        ret = "Yes"

print(ret)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<atcoder/modint>
#include<atcoder/fenwicktree>
using namespace std;
using namespace atcoder;
using mint=modint998244353;
int N,K;
int P[2<<17];
long calc()
{
	fenwick_tree<int>A(N+1);
	long ans=0;
	for(int i=0;i<N;i++)
	{
		ans+=i-A.sum(0,P[i]);
		A.add(P[i],1);
	}
	return ans;
}
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)cin>>P[i];
	mint ans=calc();
	ans*=K;
	mint invK=mint(1)/K;
	mint X=mint(K-1)*invK;
	mint Y=mint(K-2)*invK;
	mint invY=mint(1)/(1-Y);
	mint Kinv2=mint(1)/2*K;
	fenwick_tree<int>Q(N+1);
	fenwick_tree<int>R(N+1);
	fenwick_tree<mint>low(N+1);
	for(int j=1;j<N;j++)
	{
		Q.add(P[j-1],1);
		if(j<=K)R.add(P[j-1],1);
		{
			int i=j-1;
			if(i>=K)
			{
				low.add(P[i],X.pow(i).inv());
			}
		}
		int t=min(N-j,N-K);
		mint Yt=Y.pow(t);
		mint T=(1-Yt)*invY+Yt*Kinv2;
		mint tmp=0;
		if(j<=K-1)
		{
			tmp=2*Q.sum(0,P[j])-j;
		}
		else
		{
			tmp=X.pow(j-(K-1))*(2*R.sum(0,P[j])-K);
			mint Xj=X.pow(j);
			tmp+=low.sum(0,P[j])*Xj;
			tmp-=low.sum(P[j],N+1)*Xj;
		}
		ans+=tmp*T;
	}
	cout<<(ans*invK).val()<<endl;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi  va, vb;

queue<pii> q;
void input() {
  ;
  cin>>N;
  rep(i,1,N){
    int a,b;
    cin>>a>>b;
    q.push(pii(a,b));
  }
  ;
}
bool is_prime[1111111];
vector<int> P;
void Eratosthenes(const int N) {
  for (int i = 2; i <= N; i++) {
    is_prime[i] = true;  // initialize.
  }
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
}
int sm[MX*7];
void solve() {
  Eratosthenes(MX*10);
  sm[3] = 1;
  rep(i,4,MX*2 - 1){
    
    if (is_prime[i] && is_prime[(i+1)/2]){
    //  debug(i);
      sm[i]++;
    }
    sm[i] += sm[i-1];

  }
  while(q.size()){
    pii x = q.front();
    q.pop();
   // debug(x.first);
    cout<<sm[x.second] - sm[x.first-1]<<endl;
  }

   ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
string a;
bool check(int f,int l){
    for(int i = 0; i <= l -f; i++){
        if(a[f + i] != a[l - i])
            return false;
    }
    return true;
}
int main()
{
    cin >> a;
    int tmp0 = 0;
    int tmp1 = (a.length() - 1) / 2 - 1;
    int tmp2 = (a.length() + 3) / 2 - 1;
    int tmp3 = a.length() - 1;
    if(check(tmp0,tmp3) && check(tmp0,tmp1) && check(tmp1,tmp2)){
        cout << "Yes";
    }
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
import heapq

n, m = map(int, input().split())
a = list(map(lambda x : int(x) * (-1), input().split()))
heapq.heapify(a)

for i in range(m):
    maximum = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-maximum//2))
print(-sum(a))

Measured memory_bytes: 72216
list1=[]

for i in range(6):
    n=int(input())
    list1.append(n)

list2=(list1[4:])  
list1=(list1[:4])

list1.sort()
del list1[0]
list2.sort()
del list2[0]

sum1=sum(list1)


sum2=sum(list2)
print(sum1+sum2)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> A(N);
	for (ll i = 0; i < N; ++i) cin >> A[i];
	sort(A.begin(), A.end());

	vector<pair<ll, ll>> kind;
	for (ll i = 0; i < N;)
	{
		ll j = i + 1;
		while (j < N && A[i] == A[j]) {++j;}
		kind.push_back(pair<ll, ll>(A[i], j-i));
		i = j;
	}

	sort(kind.begin(), kind.end(), [](auto &a, auto &b)
								   {
									   return a.second > b.second;
								   });

	ll res{0};
	if (K >= (ll)kind.size())
		res = 0;
	else
	{
		for (ll i = K; i < (ll)kind.size() ; ++i)
			res += kind[i].second;
	}
	
	std::cout << res << std::endl;
	
}


Measured memory_bytes: 6640
N = int(input())

cnt_dict = {}

for i in range(N):
    s_list = list(input())
    s_list.sort()
    s_str = "".join(s_list)
    if s_str not in cnt_dict.keys():
        cnt_dict[s_str] = 1
        continue
    cnt_dict[s_str] += 1

import itertools
comb = itertools.combinations

total = 0
for key in cnt_dict.keys():
    cnt = cnt_dict[key]
    if cnt < 2:
        continue
    total += cnt * (cnt - 1) // 2

print(total)


Measured memory_bytes: 17808
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 998244353
#define mad(a,b) a=(a+b)%mod
#define N 6010
ll dp[N][N];
ll fac[N],ivf[N],inv[N];
ll C(ll n,ll k){
    return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    fac[0]=ivf[0]=inv[1]=1;
    for(int i=1;i<N;i++){
	if(i>1)inv[i]=(mod-mod/i*inv[mod%i]%mod)%mod;
	fac[i]=fac[i-1]*i%mod;
	ivf[i]=ivf[i-1]*inv[i]%mod;
    }
    ll n,x; cin>>n>>x;
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)dp[i][j]=0;
    dp[0][0]=1;
    for(int i=0;i<n;i++)for(int j=0;j<x;j++){
	mad(dp[i+1][j+1],dp[i][j]);
	mad(dp[i+1][j+2],dp[i][j]);
    }
    ll ans=0;
    for(int i=0;i<=n;i++)for(int j=0;j<x;j++){
	mad(ans,dp[i][j]*C(n,n-i));
    }//cout<<ans<<endl;
    for(int i=x;i<=n;i++){
	if(x%2==1)mad(ans,C(n,n-i));
    }//cout<<ans<<endl;
    for(int p=2;x-p-1>=0;p+=2){
	for(int m=0;m+p<=n;m++){
	    mad(ans,dp[m][x-p-1]*C(n,m+p));
	}
    }
    cout<<ans<<endl;
}




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

#define reint register int
#define coint const int

using namespace std;

coint SIZE = 100000 + 5;

int li[SIZE];

inline int getint(void) {
    reint x = 0, ch = getchar();
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >= '0' && ch <= '9';
            x = (x << 1) + (x << 3) + (ch - '0'), ch = getchar());
    return x;
}

int main(void) {
    coint n = getint();
    for (reint i = 1; i <= n; ++i) li[i] = getint();
    sort(li + 1, li + n + 1);
    printf("%d\n", li[(n >> 1) + 1] - li[n >> 1]);
    return 0;
}



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

int N, M;
bool graph[60][60];
bool vis[60];
int a[60], b[60];
ll ans = 0;

void dfs(int x) {
    if (vis[x]) return;
    vis[x] = true;
    for (int i = 0; i < N; i++) {
        if (graph[x][i]) {
            dfs(i);
        }
    }
}
int main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }

    // 1辺を取り除いた場合

    for (int k = 0; k < M; k++) {
        rep(i, N) {
            vis[i] = false;
        }

        graph[a[k]][b[k]] = false;
        graph[b[k]][a[k]] = false;

        dfs(0);

        bool connected = true;
        for (int j = 0; j < N; j++) {
            if (!vis[j]) connected = false;
        }

        if (!connected) {
            ans++;
        }

        graph[a[k]][b[k]] = true;
        graph[b[k]][a[k]] = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256