akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

static const int MAX = 1e6;
static const int NIL = -1;
static const ll INF = 1<<21;
static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    ll ans = 0;
    for(int i=0;i<n;i++) {
        cin >> a.at(i) >> b.at(i);
        c.at(i) = a.at(i) + b.at(i);
        ans -= b.at(i);
    }

    sort(c.begin(), c.end(), greater<ll>());

    int num = n / 2;
    if(n%2==1) num++;

    for(int i=0;i<2*num-1;i+=2) {
        ans += c.at(i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
using namespace std;

int N, A, B, C;
vector<int> l;
vector<int> abc;
int ans = INT_MAX;

int calc(vector<int>& v)
{
	int ret = 0;
    vector<int> n(4, 0), cnt(4, 0);
    for (int i = 0; i < v.size(); i++) {
		n[v[i]] += l[i];
		cnt[v[i]]++;
    }

	for (int i = 0; i < 3; i++) {
		if (cnt[i] == 0)
			return INT_MAX;
	}

	for (int i = 0; i < 3; i++) {
		ret += (cnt[i] - 1) * 10;
		ret += abs(abc[i] - n[i]);
	}

	return ret;
}

void dfs(int depth, vector<int>& v)
{
	if (depth == v.size()) {
		ans = min(ans, calc(v));
		return;
	}

    for (int i = 0; i < 4; i++) {
        v[depth] = i;
        dfs(depth + 1, v);
    }
}

int main(void)
{
    cin >> N >> A >> B >> C;
	abc = vector<int>(3);
	abc[0] = A;
	abc[1] = B;
	abc[2] = C;

    l = vector<int>(N);
    for (int i = 0; i < N; i++)
        cin >> l[i];

    vector<int> v(N, 0);
    dfs(0, v);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(K: int, X: int):
    if K*500 >= X : print(YES)
    else : print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int g[101][101];
int main(void){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int u,k;
    cin>>u>>k;
    for(int j=0;j<k;j++){
      int v;
      cin>>v;
      g[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout<<g[i][j]<<" \n"[j==n];
    }
  }
  return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[5],op[2] = {'+','-'};

int main(){

	scanf("%s",buf);

	int num[4];

	for(int i = 0; i < 4; i++){

		num[i] = buf[i]-'0';
	}

	int result[3];

	for(int a = 0; a < 2; a++){
		if(a == 0){

			result[0] = num[0]+num[1];

		}else{

			result[0] = num[0]-num[1];
		}
		for(int b = 0; b < 2; b++){
			if(b == 0){

				result[1] = result[0] + num[2];

			}else{

				result[1] = result[0] - num[2];
			}

			for(int c = 0; c < 2; c++){
				if(c == 0){

					result[2] = result[1] + num[3];

				}else{

					result[2] = result[1] - num[3];
				}
				if(result[2] == 7){

					printf("%d%c%d%c%d%c%d=7\n",num[0],op[a],num[1],op[b],num[2],op[c],num[3]);
					return 0;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
vll div(ll N)
{
    vll yakusuu;
    for (ll i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            yakusuu.push_back(i);
            if (i * i != N)
                yakusuu.push_back(N / i);
        }
    }
    return yakusuu;
}
vint table(1100000);
vint pf(int n)
{
    vint res;
    while (n > 1)
    {
        res.push_back(table[n]);
        int div=table[n];
        //while (n % div == 0)
            n /= div;
    }
    return res;
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
    int N;
    cin>>N;
    iota(all(table), 0);
    for (ll i = 2; i * i < N; i++)
    {
        if (table[i] < i)
            continue;
        for (ll j = i; i * j < N; j++)
        {
            if (table[i * j] == i * j)
                table[i * j] = i;
        }
    }
    ll ans = 0;
    for (int c = 1; c < N; c++)
    {
        auto p = pf(N-c);
        map<int,int> cnt;
        for (auto &&k : p)
        {
            cnt[k]++;
        }
        ll tmp = 1;
        for (auto &&k : cnt)
        {
            tmp *= (k.second+1);
        }
        ans += tmp;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 7304
#include <bits/stdc++.h>
#include <limits>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define lli long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define um unordered_map
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define mem(data_structure, val) memset(data_structure, val, sizeof(data_structure))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define endl "\n"
const ll mod = 1e9+7;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
um<pii, int, hash_pair> map_with_pair{};
priority_queue <int, vector<int>, greater<int> > pq_desc; // decreasing order


int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
  
	lli n, d;
	cin >> n >> d;
	cout << ceil(n*1.0/(2*d+1)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int n;
    while(1){
        vector<int> c;
        cin>>n;
        if(n==-1)break;
        if(n==0)
        cout<<0;
        while(n>0){
        c.push_back(n%4);
        n/=4;
        }
        for(int i=c.size()-1;i>=0;i--)
        cout<<c[i];
        cout<<endl;

    }
    return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int POW[17],M,N;
double dp[65536][16];
double table[16][16];

double dfs(int state,int enemy){

	if(enemy == N)return 1.0;
	if(state == 0)return 0.0;

	if(dp[state][enemy] >= 0.0)return dp[state][enemy];

	double maximum = 0.0;

	for(int cat = 0; cat < M; cat++){
		if(!(state & (1 << cat)))continue;

		double sum = 0.0,prob = 1.0;
		int next_state = state - POW[cat];

		for(int i = enemy; i < N; i++){
			sum += dfs(next_state,i)*prob*(1.0-table[cat][i]);
			prob *= table[cat][i];
		}
		sum += prob;

		maximum = max(maximum,sum);
	}

	return dp[state][enemy] = maximum;
}

int main(){

	for(int i = 0; i <= 16; i++)POW[i] = pow(2,i);

	scanf("%d %d",&M,&N);

	for(int i = 0; i < M; i++){
		for(int k = 0; k < N; k++)scanf("%lf",&table[i][k]);
	}

	int limit = POW[M];

	for(int i = 0; i < limit; i++){
		for(int k = 0; k < N; k++){
			dp[i][k] = -1.0;
		}
	}

	printf("%.12lf\n",dfs(limit-1,0));

	return 0;
}

Measured memory_bytes: 11592
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define nyan "(=^･ω･^=)"
#define read_input         freopen("in.txt","r", stdin)
#define print_output       freopen("out.txt","w", stdout)
typedef long long ll;
typedef long double ld;
using namespace std;

int visited[100005], dist[100005];
vector<pii> adj[100005];

void bfs(int src) {
	deque<int> q;
	q.push_back(src);
	dist[src] = 0;
	visited[src] = 1;

	while(not q.empty()) {
		int u = q.front();
		q.pop_front();

		visited[u] = 1;
		for(pii v : adj[u]) {
			if(not visited[v.first]) {
				dist[v.first] = dist[u] + v.second;

				if(v.second == 1) q.push_back(v.first);
				else q.push_front(v.first);
			}
		}
	}
}

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

	for(int i = 1; i <= n; i++) {
		adj[i].pb({(i+1) % n, 1});
		adj[i].pb({(i*10) % n, 0});
	}

	bfs(1);
	cout << dist[0] + 1 << endl;
    return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<vector>
#include<string>

int main(){
    int n;
    int sum = 0;
    std::string S;
    std::cin >> n >> S;
    for(int i = 0; i < n; i++){
        if(S[i] == '1') sum++;
    }

    // 例外処理
    if(sum == 0){
        for(int i = 0; i < n; i++){
            std::cout << 1 << std::endl;
        }
        return 0;
    }

    // 2^iの剰余
    std::vector<int> count_p1(n), count_m1(n);
    count_p1[0] = 1 % (sum + 1);
    if(sum != 1) count_m1[0] = 1 % (sum - 1);
    for(int i = 1; i < n; i++){
        count_p1[i] = (count_p1[i - 1] * 2) % (sum + 1);
        if(sum != 1) count_m1[i] = (count_m1[i - 1] * 2) % (sum - 1);
    }

    // Xに対して事前の剰余計算
    int r_p1 = 0, r_m1 = 0;
    for(int i = 0; i < n; i++){
        if(S[i] == '1'){
            r_p1 += count_p1[n - 1 - i];
            if(sum != 1) r_m1 += count_m1[n - 1 - i];
            r_p1 %= sum + 1;
            if(sum != 1) r_m1 %= sum - 1;
        }
    }

    // 後は愚直に
    for(int i = 0; i < n; i++){
        int r = 0;
        if(S[i] == '1'){
            if(sum == 1){
                std::cout << 0 << std::endl;
                continue;
            }
            // sum - 1の剰余で, 2^(n - 1- i)桁目が消える
            r = r_m1;
            r -= count_m1[n - 1 - i];
            while(r < 0){
                r += sum - 1;
            }
        }else{
            r = r_p1;
            r += count_p1[n - 1 - i];
            r %= sum + 1;
        }

        int cnt = 1;
        while(r > 0){
            // popcountの計算
            int x = r;
            int popcount = 0;
            while(x > 0){
                if(x % 2 == 1) popcount++;
                x /= 2;
            }

            r %= popcount;
            cnt++;
        }

        std::cout << cnt << std::endl;
    }
    return 0;
}


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



int main()
{
    char c ;
    cin >> c;
    if (c=='a'|| c=='o' || c=='u' || c=='e' || c=='i')
        cout << "vowel" <<endl;
    else
        cout<< "consonant" << endl;
}


Measured memory_bytes: 256
import heapq
from functools import reduce

n, m = map(int, input().split())
h = list(map(lambda a: -int(a), input().split()))
heapq.heapify(h)  # input().split()))

for i in range(m):
    mx = -(-heapq.heappop(h) // 2)
    heapq.heappush(h, mx)

print(-reduce(lambda a, b: a+b, h))


Measured memory_bytes: 14748
n = gets.to_i

hs = gets.chomp.split(" ").map(&:to_i)

last = hs[0]
no = false  # f**k ruby 2.3.3
for i in 1...n do
  if last < hs[i] then
    last = hs[i]
  elsif hs[i] == last || hs[i] == last - 1 then
  else
    no = true  # f**k ruby 2.3.3
    break  # f**k ruby 2.3.3
  end
end
puts no ? 'No' : 'Yes'

Measured memory_bytes: 9604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  int ans{};
  cin >> n >> d;
  for(int i=0; i<n; i++){
    int x,y;
    cin >> x >> y;
    if(sqrt(pow(x,2) + pow(y,2)) <= d) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
import java.util.*;
     
    public class Main{
      public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k;
        int count = 0;
        for(int i = 1; i <= n; i++){
          k = i % 2;
          if(k != 0){
            count++;
          }
        }
        System.out.println((double)count / n);
      }
    }

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

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

const int maxn=200003;
const int mo=998244353;

int f[maxn][3][3][2],n;
char s[maxn];

void add(int &x,int y){
	x+=y;
	if(x>=mo)x-=mo;
}

void solve(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int want=s[1]-'a',ret=1;
	bool flag=true;
	for(int i=2;i<=n;++i){
		if(s[i]!=s[1])flag=false;
		want+=s[i]-'a';
		ret&=(s[i]!=s[i-1]);
	}
	if(flag){
		puts("1");
		return ;
	}
	if(n==2){
		puts("2");
		return ;
	}
	if(n==3&&s[1]!=s[2]&&s[3]!=s[2]&&s[1]!=s[3]){
		puts("3");
		return ;
	}
	want%=3;
	for(int i=0;i<3;++i)f[1][i][i][0]=1;
	for(int i=1;i<n;++i)
		for(int last=0;last<3;++last)
			for(int sum=0;sum<3;++sum)
				for(int adj=0;adj<2;++adj){
					for(int c=0;c<3;++c){
						int nsum=(sum+c)%3,nadj=adj|(last==c);
						add(f[i+1][c][nsum][nadj],f[i][last][sum][adj]);
					}
				}
	for(int i=0;i<3;++i)
		add(ret,f[n][i][want][1]);
	printf("%d\n",ret);
}


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



Measured memory_bytes: 14464
#include <iostream>
  
using namespace std;
int main(void){
      
    int n,i,a[100];
    cin >> n;
      
    for(i=0;i<n;i++){
        cin >> a[i];
    }
     
    for(i=n-1;i>=0;i--){
        cout << a[i];
        if(i!=0) cout << " ";
        else cout << endl;
    }
      
}


Measured memory_bytes: 3080
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int table[4][3][10] = {};
	int n;
	cin >> n;
	rep(i, n) {
		int x, y, z, w;
		cin >> x >> y >> z >> w; x--; y--; z--;
		table[x][y][z] += w;
	}
	rep(i, 4) {
		rep(j, 3) {
			rep(k, 10) {
				cout << " " << table[i][j][k];				
			}
			cout << endl;
		}
		if (i != 3)cout << "####################" << endl;
	}
	return 0;
}


Measured memory_bytes: 3120
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  int N;
  cin >> N;
  cout <<(double)((int)(N+1)/2)/N;
  
  return 0;
}


Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func reverse(a sort.Interface, start int, size int) {
	for end := start + size - 1; start < end; start++ {
		a.Swap(start, end)
		end--
	}
}

func nextPermutation(a sort.Interface, n int) bool {
	if n < 0 || a.Len() < n {
		return false
	}
	reverse(a, n, a.Len()-n)
	i := 0
	for i = a.Len() - 2; i >= 0; i-- {
		if a.Less(i, i+1) {
			break
		}
	}
	if i < 0 {
		reverse(a, 0, a.Len())
		return false
	}
	k := i
	for i = a.Len() - 1; i >= k+1; i-- {
		if a.Less(k, i) {
			break
		}
	}
	l := i
	a.Swap(k, l)
	reverse(a, k+1, a.Len()-(k+1))
	return true
}

func sameSlice(a, b []int) bool {
	if len(a) != len(b) {
		return false
	}

	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func main() {
	n := nextInt()
	p, q := make([]int, n), make([]int, n)
	s := make([]int, n)

	for i := 0; i < n; i++ {
		p[i] = nextInt()
	}
	for i := 0; i < n; i++ {
		q[i] = nextInt()
		s[i] = i + 1
	}

	c := 1
	pc, qc := 0, 0
	for {
		if sameSlice(s, p) {
			pc = c
			if qc != 0 {
				fmt.Println(pc - qc)
				return
			}
		}
		if sameSlice(s, q) {
			qc = c
			if pc != 0 {
				fmt.Println(qc - pc)
				return
			}
		}

		nextPermutation(sort.IntSlice(s), len(s))

		c++
	}
}


Measured memory_bytes: 1920
# coding: utf-8
N, K = map(int, input().split())
P = list(map(int, input().split()))
# P.sort(reverse=True)
l = []
for i in range(N):
    l.append((P[i]+1) / 2)
ans = 0
tmp = sum(l[:K-1])
p = l[0]
idx = 0
for i in range(K-1, N):
    tmp += l[i]
    # print(tmp)
    ans = max(ans, tmp)
    p = l[idx]
    tmp -= p
    idx += 1
print(ans)

Measured memory_bytes: 77448
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long

int N,K,R,S,P,ans=0;
string T,ME;
int dp[10001][2];//rsp r<p<s<r kati/make
int w[3]={2,1,0};

int main() {
	cin>>N>>K>>R>>S>>P>>T;
	for(int i=0;i<N;i++){
		int tmp;
		char tag;
		if(T[i]=='r'){tmp=P;tag='p';}
		else if(T[i]=='s'){tmp=R;tag='r';}
		else {tmp=S;tag='s';}
		if(i<K){ans+=tmp;ME+=tag;}
		else {
			if(T[i]!=T[i-K] || ME[i-K]!=tag){ans+=tmp;ME+=tag;}
			else{
				if(i+K>=N)ME+=' ';
				else if(T[i+K]=='r'){
					if(tag=='s')ME+='r';
					else ME+='s';
				}
				else if(T[i+K]=='s'){
					if(tag=='p')ME+='s';
					else ME+='p';
				}
				else{
					if(tag=='r')ME+='p';
					else ME+='r';
				}
			}
		}
	
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
struct node{
	int pre, to;
}edge[10010];
int head[2010], tot;
int n, x, y;
int cnt[2010];
int dis[2010];
bool vis[2010];
priority_queue<pair<int, int> > q;
void dijkstra(int s) {
	memset(vis, 0, sizeof(vis));
	memset(dis, 0x3f, sizeof(dis));
	dis[s] = 0;
	q.push(make_pair(0, s));
	while (!q.empty()) {
		int u = q.top().second;
		q.pop();
		if (vis[u]) continue;
		vis[u] = 1;
		for (int i = head[u]; i; i = edge[i].pre) {
			int v = edge[i].to;
			if (dis[v] > dis[u] + 1) {
				dis[v] = dis[u] + 1;
				q.push(make_pair(-dis[v], v));
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		if (i != s && dis[i] < 0x3f3f3f3f) {
			cnt[dis[i]]++;
		}
	}
}
void add(int u, int v) {
	edge[++tot] = node{head[u], v};
	head[u] = tot;
}
int main() {
	cin >> n >> x >> y;
	for (int i = 1; i < n; i++) {
		add(i, i + 1);
		add(i + 1, i);
	}
	add(x, y);
	add(y, x);
	for (int i = 1; i <= n; i++) {
		dijkstra(i);
	}
	for (int i = 1; i < n; i++) {
		cout << cnt[i] / 2 << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
def factors(z):
    ret = []
    for i in range(2, int(z**(1/2))+1):
        if z%i == 0:
            ret.append(i)
            while z%i == 0:
                z //= i
    if z != 1:
        ret.append(z)
    return ret

def eratosththenes(N):
    if N == 0:
        return [0]
    work = [True] * (N+1)
    work[0] = False
    work[1] = False
    for i in range(N+1):
        if work[i]:
            for j in range(2* i, N+1, i):
                work[j] = False
    return work


N = int( input())
A = [ int( input()) for _ in range(N+1)]
E = eratosththenes(N)
Primes = [ i for i in range(N+1) if E[i] == 1]
ANS = []
F = factors( abs(A[0]))
for f in F:
    if f >= N+1:
        Primes.append(f)
for p in Primes:
    if p >= N+1:
        check = 1
        for i in range(N+1):
            if A[i]%p != 0:
                check = 0
                break
        if check == 1:
            ANS.append(p)
    else:
        poly = [0]*(p-1)
        for i in range(N+1): # フェルマーの小定理
            poly[(N-i)%(p-1)] = (poly[(N-i)%(p-1)] + A[i])%p
        check = 0
        if sum(poly) == 0 and A[N]%p == 0: # a_0 が 0 かつ、g が恒等的に 0 であることをチェックしている
            check = 1
        if check == 1:
            ANS.append(p)
for ans in ANS:
    print(ans)

Measured memory_bytes: 47832
h, w = list(map(int, input().split()))
a = [input() for i in range(h)]
x, y = [], []
for i in range(h):
  f = True
  for j in range(w):
    if a[i][j]=="#":
      f = False
  if f:
    y.append(i)
for j in range(w):
  f = True
  for i in range(h):
    if a[i][j]=="#":
      f = False
  if f:
    x.append(j)
for i in range(h):
  if i in y:
    continue
  for j in range(w):
    if j in x:
      continue
    print(a[i][j], end="")
  print()

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a,b,c; cin>>a>>b>>c;
    cout << (a>b?(c>a?a+b:c+b):(c>b?a+b:c+a)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const int MAX=2e5;

ll fact[MAX+1],factInv[MAX+1];

inline void factorial(ll n) {
  fact[0]=fact[1]=1;
  for (int i=2; i<=n; i++) {
    fact[i]=(i*fact[i-1])%MOD;
  }
}
inline ll power(ll x,ll n) {
  if (n==0) {
    return 1LL;
  }
  ll ret=power((x*x)%MOD,n/2)%MOD;
  if (n%2) {
    ret=(ret*x)%MOD;
  }
  return ret;
}
inline void factorial_Inverse(ll x) {
  factInv[x]=power(fact[x],MOD-2);
  for (int i=x-1; i>=1; i--) {
    factInv[i]=((factInv[i+1]*(i+1))%MOD);
  }
}
inline void init(ll n) {
  factorial(n);
  factorial_Inverse(n);
}
inline ll nCr(ll n,ll r) {
  if (n<r || r<0) {
    return 0LL;
  }
  if (n==r || r==0) {
    return 1LL;
  }
  return (((fact[n]*factInv[r])%MOD)*factInv[n-r])%MOD;
}
inline ll nPr(ll n,ll r) {
  if (n<r || r<0) {
    return 0LL;
  }
  return (fact[n]*factInv[r])%MOD;
}
int main() {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int H,W,A,B;
  cin>>H>>W>>A>>B;
  init(MAX);
  ll ans=0;
  for (int i=B; i<W; i++) {
    ans=(ans+(nCr(H-A-1+i,i)*nCr(A-1+W-i-1,W-i-1)))%MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	long long a,b;
	scanf("%lld %lld",&a,&b);
//	cout<<a<<b;
	if((a+b)%2 == 0)
		cout<<(a+b)/2<<endl;
	else
		cout<<"IMPOSSIBLE\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main(void) {
  ll i, j, k, l;
  
  string s;
  cin >> s;
  ll N=s.size();
  
  ll f=1;
  for(i=0; i<N; i++) {
    if(s[i]!=s[N-1-i]) f=0;
  }
  
  string t=s.substr(0, N/2);
  for(i=0; i<t.size(); i++) {
    if(t[i]!=t[(ll)t.size()-1-i]) f=0;
  }
  
  
  
  
  t=s.substr(N/2+1, N/2);
  for(i=0; i<t.size(); i++) {
    if(t[i]!=t[(ll)t.size()-1-i]) f=0;
  }
  
  
  
  if(f) pt("Yes");
  else pt("No");
  
  
}




Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

#define min(a, b) ((a) < (b)) ? (a) : (b)
#define max(a, b) ((a) > (b)) ? (a) : (b)
#define swap(a, b, typ) \
    do { \
        typ tmp = a; \
        a = b; \
        b = tmp; \
    } while (0)

int main(void) {
    int r;
    scanf("%d\n", &r);
    printf("%d\n", r * r);

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


/////////////////////////////////////////////////////////////////////////////////////

int main() {
    int n,m; 
    long long k;
    cin >> n >> m >> k;
    vector<long long> a(n), b(m);
    vector<long long> asum(n+1), bsum(m+1);
    int ans = 0;
    asum[0] = 0, bsum[0] = 0;

    for (int i = 1;i <= n;i++){
        cin >> a[i-1];
        asum[i] = asum[i-1] + a[i-1];
    }

    for (int i = 1;i <= m;i++){
        cin >> b[i-1];
        bsum[i] = bsum[i-1] + b[i-1];
    }
    int j = m;
    for (int i = 0;i <= n;i++){
        if (asum[i] > k){
            break;
        }

        while(asum[i] + bsum[j] > k){
            j--;
        }
        ans = max(ans, i+j);
    }

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

Measured memory_bytes: 9528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main (void){
    int N, M;
    cin >> N >> M;
    int sum = 0;
    rep(i,M) {
        int in;
        cin >> in;
        sum += in;
    }
    if (N - sum < 0) cout << -1 << endl;
    else cout << N - sum  << endl;
}


Measured memory_bytes: 3600
#include <stdio.h>
int main(void){
    char a,b;
    int na,nb,ans;
    scanf("%c %c",&a,&b);
    if(a=='H'){
        na=0;
    };
    if(a=='D'){
        na=1;
    };
    if(b=='H'){
        nb=0;
    };
    if(b=='D'){
        nb=1;
    };
    ans=(na+nb)%2;
    if(ans==0){
        printf("H");
    }
    else{
        printf("D");
    };
    return 0;
};


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

#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--)

typedef long long ll;

ll calc(ll x, ll y)
{
	if (x == 0) return 0;
	rep(i, 10){
		ll nx = x - y * i;
		if (nx % 10 == 0){
			return calc(nx / 10, y * -1) * 10 + i;
		}
	}
}

int main()
{
	ll x;
	while (cin >> x, x){
		cout << calc(x, 1) << endl;
	}
}

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

using namespace std;
int main(){
int n=0;
long long sum=0;
int arr[200009]={0};
priority_queue<pair< int,pair<int,int> > >pq;
cin>>n;
for(int i=0;i<n;i++)cin>>arr[i];
sort(arr,arr+n);
reverse(arr,arr+n);
sum=arr[0];
pq.push(  make_pair(arr[1],make_pair(0,1))    );
pq.push(  make_pair(arr[1],make_pair(0,1))    );
for(int i=2;i<n;i++){
long long v=pq.top().first,l=pq.top().second.first,r=pq.top().second.second;
pq.pop();
sum+=v;

v=min(arr[i],arr[l]);
pq.push(  make_pair(v,make_pair(i,l))    );

v=min(arr[i],arr[r]);
pq.push(  make_pair(v,make_pair(i,r))    );

}


cout<<sum;
    return 0;
}


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

int n;
deque<int> dq;

void solve();

int main() {
  cin >> n;
  solve();
  n = dq.size();
  for(int i = 0; i < n; ++i) {
    if(i != 0) cout << " ";
    cout << dq.front();
    dq.pop_front();
  }
  cout << endl;
  return 0;
}

void solve() {
  string s;
  int x;
  for(int i = 0; i < n; ++i) {
    cin >> s;
    if(s == "deleteAll") dq.clear();
    if(s == "insert") {
      cin >> x;
      dq.push_front(x);
    }
    else if(s == "insertLast") {
      cin >> x;
      dq.push_back(x);
    }
    else if(s == "deleteFirst")
      dq.pop_front();
    else if(s == "deleteLast")
      dq.pop_back();
    else if(s == "delete") {
      cin >> x;
      stack<int> st;
      while(!dq.empty()) {
        int num = dq.front();
        dq.pop_front();
        if(num == x) break;
        st.push(num);
      }
      while(!st.empty()) {
        dq.push_front(st.top());
        st.pop();
      }
    }
  }
}


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

int main() {
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  if(n >= k) {
  cout << x*k + (n-k)*y << endl;
  }else if(n < k) {
    cout << x*n << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
int main ()
{
    string str;
    int b[str.size()];
    int c[26]={0};
    while(getline(cin,str)){
        for(int i=0;i<str.size();i++){
            if('a'<=str[i]&&str[i]<='z')c[str[i]-'a']++;
            if('A'<=str[i]&&str[i]<='Z')c[str[i]-'A']++;
        }   
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",i+'a',c[i]);
    }
  return 0;
}


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

int main() 
{
    ios::sync_with_stdio(0); 
    int x , y , z ;
    int res = 0 ;
    cin >> x >> y >> z ;
    x -= z ;
    while ( x >= (y+z) ) 
    {
        x -= (y+z) ; 
        res++ ; 
    }
    cout << res << endl ; 
    return 0 ; 
}

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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    ll N, K;
    cin >> N >> K;
    ll t = N % K;
    cout << min(t, K-t) << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
c = int(input())
s = list(map(int, input().split()))

for x in range(1, len(s)):
    print(*s, sep=' ')
    stash = s[x]
    if stash < s[x-1]:
        y = x
        while True:
            s[y] = s[y-1]
            y -= 1
            if y == 0 or stash > s[y-1]:
                break
        s[y] = stash
print(*s, sep=' ')



Measured memory_bytes: 5976
import numpy as np

N=int(input())
A=np.array([int(x) for x in input().split()])

ans=0
M=pow(10,9)+7
for i in range(100):
  one=int(np.sum((A>>i)&1))
  zero=N-one
  ans+=(one*zero)*pow(2,i)
  ans%=M
  #print(one,zero)
print(ans)

Measured memory_bytes: 68840
// 簡易競プロテンプレ
#include <bits/stdc++.h>
using namespace std;
int n;
int main(void){
 cin >> n;
 for(int i=1;;i++){
  if (n <= i*(i+1)/2) {cout << i << endl; return 0;}
 }
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=(n);;i++)
using namespace std;
int main(){
	
	int n;
	cin>>n;
	for(int i=n;;i++){
		if(i%10==i/100 && i/100==(i%100-i%10)/10){
			cout<<i<<endl;
			break;
		}
	}
	
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;
    A.sort!"a > b";

    long ans = 0;

    foreach (i; 0..N) {
        long left = i == 0 ? 1L : (i + 2) * powmod(2, i - 1, MOD) % MOD;
        left = left * powmod(2, i, MOD) % MOD;
        long right = powmod(4, N - i - 1, MOD);
        (ans += left * right % MOD * A[i] % MOD * 2 % MOD) %= MOD;
    }

    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}


Measured memory_bytes: 13588
a = int(input())
jud = []
for i in range(a):
	jud.append(input().strip())

print('AC x '+str(jud.count('AC')))
print('WA x '+str(jud.count('WA')))
print('TLE x '+str(jud.count('TLE')))
print('RE x '+str(jud.count('RE')))

Measured memory_bytes: 16168
#include<iostream>
using namespace std;
int main()
{
	
	int n;
	string a,b,c;
	cin>>n;
	cin>>a>>b>>c;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==b[i] && b[i]==c[i]) ;
		else if(a[i]==b[i] || b[i]==c[i] || c[i]==a[i]) cnt++;
		else cnt+=2;
	}
	cout<<cnt<<'\n';
	
	return 0;
}

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

using namespace std;

#define td typedef
td long long ll;

ll in()
{
    ll a;
    scanf("%lld",&a);
    return a;
}

ll kola[100005];

int main()
{
    ll n=in();
    for(int i=0;i<n;i++)
        kola[i]=in();
    ll mn=-1,mx=-1;
    ll lo=2,hi=1000000000000000000,mid=(hi+lo)/2;
    while(hi>=lo)
    {
        ll ase=mid;
        for(int i=0;i<n;i++)
        {
            ase=(ase/kola[i])*kola[i];
        }
        if(ase==2)
        {
            hi=mid-1;
            mn=mid;
        }
        else if(ase>2)
            hi=mid-1;
        else
            lo=mid+1;
        mid=(hi+lo)/2;
    }
    lo=2,hi=1000000000000000000,mid=(hi+lo)/2;
    while(hi>=lo)
    {
        ll ase=mid;
        for(int i=0;i<n;i++)
        {
            ase=(ase/kola[i])*kola[i];
        }
        if(ase==2)
        {
            lo=mid+1;
            mx=mid;
        }
        else if(ase>2)
            hi=mid-1;
        else
            lo=mid+1;
        mid=(hi+lo)/2;
    }
    if(mn==-1)
        printf("-1\n");
    else
        printf("%lld %lld\n",mn,mx);
}


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

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


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

int main()
{
    ll k, n, num;
    cin >> n >> k;
    deque<ll> a(n, 0);
    rep(i, n)
    {
        cin >> num;
        a[num - 1]++;
    }

    sort(a.begin(), a.end());

    int ans = 0;
    rep(i, n - k)
    {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{

    int n;
    std::cin >> n;

    //int D1[n];
    //int D2[n];
    //
    //for(int i; i<n; i++)
    //{
    //    std::cin >> D1[i] >> D2[i];
    //}
    
    int flag = 0;

    for(int i; i<n ; i++)
    {
        int D1, D2;
        std::cin >> D1 >> D2;

        if(D1==D2)//1kaime
        {
            int D1, D2;
            std::cin >> D1 >> D2;

            if(D1==D2)//2kaime
            {
                int D1, D2;
                std::cin >> D1 >> D2;

                if(D1==D2)//3kaime
                {
                    flag = 1;
                }
            }
        }
    }

    if(flag==1)
        std::cout << "Yes" << std::endl;
    else
    {
        std::cout << "No" << std::endl;
    }
    
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
 
template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}

const ll LINF = 1LL<<60;
const int N_MAX = 20;
vector<P> xy[N_MAX];

int count(int x){
  if(x==0) return 0;
  return count(x>>1)+(x&1);
}

int main() {
  int n; cin >> n;
  for(int i=0; i<n; i++){
    int a; cin >> a;
    for(int j=0; j<a; j++){
      int x, y; cin >> x >>y;
      x--;
      xy[i].push_back(make_pair(x,y));
    }
  }

  int ans=0;
  for(int bit=0; bit < (1<<n); bit++) {
    // このパターンでの矛盾を検証
    bool isOK = true;
    for(int i=0; i<n; i++){
      if(bit & (1<<i)){ // 正直検証対象
        for(P p : xy[i]){
          if((p.second==1 && !(bit & 1<<p.first)) || (p.second==0 && (bit & 1<<p.first))) { // NGパターン
              isOK = false;
            }
          }
        }
      }
    if(isOK) ans=max(ans, count(bit));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int H;
  int W;
  scanf("%d",&H);
  scanf("%d",&W);
  char s[H+2][W+2]={0};
  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
      char c;
      scanf("%c",&c);
      if(c=='\n'){
        scanf("%c",&s[i][j]);
      }
      else{
        s[i][j]=c;
      }
    }
  }
  
  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
      if(s[i][j]=='#'){
        if(s[i-1][j]!='#'&&s[i+1][j]!='#'&&s[i][j+1]!='#'&&s[i][j-1]!='#'){
          printf("No");
          exit(0);
        }
      }
    }
  }
  printf("Yes");
    return 0;
}





Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

typedef pair<ll, ll> P;

vector<ll>path[101010];
ll cost[101010][3];

int main(){

    for(ll i = 0; i < 101010; i++){
        for(ll j = 0; j < 3; j++){
            cost[i][j] = -3;
        }
    }

    ll N, M, S, T;
    cin >> N >> M;
    for(ll i = 0; i < M; i++){
        ll u, v;
        cin >> u >> v;
        path[u].push_back(v);
    }
    cin >> S >> T;
    queue<P>Q;
    Q.push(P(S, 0));
    cost[S][0] = 0;
    while(!Q.empty()){
        ll A = Q.front().first;
        ll B = Q.front().second;
        Q.pop();
        if(A == T && B == 0)break;
        for(ll i = 0; i < path[A].size(); i++){
            ll a = path[A][i];
            ll b = (B + 1) % 3;
            if(cost[a][b] >= 0)continue;
            Q.push(P(a, b));
            cost[a][b] = cost[A][B] + 1;
        }
    }
    cout << cost[T][0] / 3 << endl;

    return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 3;
 
int main(){
    fast;
    ll n, m, k;
    cin >> n >> m >> k;
    ll a[n+1], b[m+1], prefix_sum[n+1], prefix_sum1[m+1];
    prefix_sum[0] = 0;
    prefix_sum1[0] = 0;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        prefix_sum[i] = prefix_sum[i-1] + a[i];
    }
    for(int i = 1; i <= m; ++i){
        cin >> b[i];
        prefix_sum1[i] = prefix_sum1[i-1] + b[i];
    }
    ll mx = 0;
    for(int i = 0; i <= n; ++i){
        ll diff = k - prefix_sum[i], ans = 0;
        if(diff < 0)
            break;
        ll low = 1, high = m;
        while(low <= high){
            ll mid = (low + high)/2;
            if(prefix_sum1[mid] <= diff){
                ans = mid;
                low = mid + 1; 
            }
            else
                high = mid - 1;
        }
        mx = max(mx, i+ans);  
        // cout << i << ' ' << ans << ' ';
    }
    cout << mx;
    return 0;
}

Measured memory_bytes: 9880
#include <iostream>
#include <vector>

using namespace  std;

int main(){
  int N, M, C;
  int count = 0, tmp=0;
  int A[20][20], B[20];
  cin >> N >> M >> C;
  for(int i=0; i<M;i++){
    cin >> B[i];
  }
  for(int i=0;i < N;i++){
    for(int j=0;j < M;j++){
        cin >> A[i][j];
      }  
  }
  for(int i=0;i < N; i++){
    tmp = 0;
    for(int j=0;j<M; j++){
      tmp += A[i][j]  * B[j];
    }
    if(tmp + C > 0){
      count++;
    }
  }
  cout <<  count <<  endl;
}

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

int main(void) {
  int N, K, cnt=0;
  cin >> N >> K;
  int h[N];
  
  for(int i=0; i<N; i++){
    cin >> h[i];
    if(h[i] >= K)
      cnt++;
  }
  
  cout << cnt << endl;
  
  
  return 0;
}

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

long long n,a[100005],r;

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

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0)
            r+=abs(a[i]);
        else
            r+=abs(a[i]-a[i-1]);
    }
    r+=abs(a[n-1]);

    for(int i=0;i<n;i++)
    {
        if(i==0)
            cout<<r+abs(a[1])-(abs(a[0])+abs(a[1]-a[0]))<<endl;
        else if(i==n-1)
            cout<<r+abs(a[n-2])-(abs(a[n-1])+abs(a[n-1]-a[n-2]))<<endl;
        else
            cout<<r+abs(a[i+1]-a[i-1])-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))<<endl;
    }

    return 0;
}


Measured memory_bytes: 4380
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[100100];

int main(){
  ll n,m;
  cin>>n>>m;
  clr(d,0);
  rep(i,0,m){
    ll a,b;
    cin>>a>>b;
    d[a]++;
    d[b+1]--;
  }
  rep(i,1,100100){
    d[i] += d[i-1];
  }
  ll ans = 0;
  rep(i,0,100100){
    if(d[i]==m)ans++;
  }
  cout << ans << endl;
  return 0;
}

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


int main(){
    int a;
    cin >> a;
    cout<<a*a*a<<endl;
   
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

    vector<bool> is_ac(n, false);
    vector<int> wa_cnt(n, 0);

    for (int i = 0; i < m; i++) {
        int p;
        string s;
        cin >> p >> s;

        if (s == "AC") {
            is_ac[p - 1] = true;
        } else if (!is_ac[p - 1]) {
            wa_cnt[p - 1]++;
        }
    }

    int res_ac = 0, res_wa = 0;
    for (int i = 0; i < n; i++) {
        if (is_ac[i]) {
            res_ac++;
            res_wa += wa_cnt[i];
        }
    }

    cout << res_ac << " " << res_wa << endl;
}


Measured memory_bytes: 640
import numpy as np
from sys import stdin
H,W=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(H):
    data.append([ 1 if x == "#" else 0 for x in list(input())])
data=np.array(data)
index_col=[]
for j in range(W):
    if sum(data[:,j]) == 0:
        index_col.append(j)
data=np.delete(data, index_col, 1)

index_row=[]
for k in range(H):
    if sum(data[k]) == 0:
        index_row.append(k)
data=np.delete(data,index_row,0)
for l in data:
    tmp=""
    for m in l:
        if m == 1:
            tmp=tmp+"#"
        else:
            tmp=tmp+"."
    print(tmp)

Measured memory_bytes: 12640
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

import copy
t = copy.copy(H)
m = 100000
ans = 0
for i in range(N):
    t[i] = abs(T-0.006*H[i]-A)
    if t[i]<m:
        m = t[i]
        ans = i+1
print(ans)


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

int main(){ 
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,t;
  int n[50];

  scanf("%d",&t);

  n[0]=n[1]=1;
  for(i=2;i<=t;i++){
    n[i]=n[i-1]+n[i-2];
}
  printf("%d\n",n[t]);
  return 0; 
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    LLI N;
    cin >> N;
    LLI sq = sqrt(N) + 1;
    LLI mi = N;

    for(LLI i = 1; i < sq; i++) {
        if(N % i == 0) {
            chmin(mi, i + N / i - 2);
        }
    }
    cout << mi;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(2,vector<int>(N));
  for(int i=0;i<2;i++){
    for(int j=0;j<N;j++){
      cin >> A.at(i).at(j);
    }
  }

  int a=0,b=0;
  for(int k=0;k<N;k++){
    for(int j=0;j<N;j++){
      b += A.at(0).at(j);
      if(j==k){
        for(int j=k;j<N;j++){
          b += A.at(1).at(j);
        }
      }
      else continue;
      j = N-1;
    }
    a = max(a,b);
    b = 0;
  }

  cout << a << endl;
}

Measured memory_bytes: 256