akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += (b % mod + mod)) %= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    int N = 1000005;
    vector<int> v(N);
    set<int> s;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        s.emplace(a);
        ++mp[a];
    }
    for (int si : s) for (int j = si; j < N; j += si) ++v[j];
    int c = 0;
    for (int si : s) {
        if (mp[si] >= 2) continue; // debuged
        if (v[si] == 1) ++c;
    }
    cout << c << endl;
}


Measured memory_bytes: 25848
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int main()
{
	int s,w;
	cin>>s>>w;
	puts(w<s?"safe":"unsafe");
	return 0;
}

Measured memory_bytes: 3636
import java.io.*;

public class Main{
    public static void main(String[]args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = Integer.parseInt(br.readLine());
        int[] data = new int[3];

        for(int i=0; i<count; i++){
            String[] str = br.readLine().split(" ");
            for(int k=0; k<3; k++){
                data[k] = Integer.parseInt(str[k]);
            }
            int maxIndex = 0;

            for(int k=1; k<3; k++){
                if(data[k]>data[maxIndex]){
                    maxIndex = k;
                }
            }
            //??\?????????
            int tmp = data[maxIndex];
            data[maxIndex] = data[0];
            data[0] = tmp;

            if(data[1] * data[1] + data[2] * data[2] == data[0] * data[0]){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }

        }
    }
}

Measured memory_bytes: 26388
#include<bits/stdc++.h>
using namespace std;
void solve();
typedef long long ll;
int main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  solve();
  return 0;
}

void solve()
{
  int n;
  cin >> n;
  int* arr = new int[n];
  for (int i = 0; i < n; i++)
    cin >> arr[i];
  ll* dp = new ll[n];
  dp[0] = 0;
  for (int i = 1; i < n; i++)
    dp[i] = min(abs(arr[i] - arr[i - 1]) + dp[i - 1], abs(arr[i] - arr[i - 2]) + dp[i - 2]);
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//問題文のとおりの変数
int N, M;
//vector<int> X;

//オリジナル変数
vector<vector<int>> kind;//種類分け(第1-indexがmod M)
int ans = 0;

//サブ関数
//入力
void input() {
	cin >> N >> M;
	REP(i, M)kind.push_back(vector<int>());

	REP(i, N) {
		int tmp;
		cin >> tmp;
		kind[tmp%M].push_back(tmp);
	}
}

//計算
int matching(vector<int> little, vector<int> big) {
	if (little.size() > big.size()) {
		vector<int> tmp = little;
		little = big;
		big = tmp;
	}
	int pair = little.size();
	int bigPair = 0;
	int maxBigPair = (big.size() - little.size()) / 2;

	sort(big.begin(), big.end());
	REP(i, (int)big.size() - 1) {
		if (big[i] == big[i+1]) {
			bigPair++;
			i++;
		}
	}

	return pair + min(maxBigPair, bigPair);
}

void calc() {
	int small = 1;
	int large;
	while (small < (large = M - small)) {
		if (kind[small].size() < kind[large].size()) {
			ans += matching(kind[small], kind[large]);
		}
		else {
			ans += matching(kind[large], kind[small]);
		}
		small++;
	}

	//例外処理
	ans += (int)kind[0].size() / 2;
	if (M % 2 == 0)ans += (int)kind[M / 2].size() / 2;
}

//出力
void output() {
	cout << ans << endl;
}

//デバッグ
void debug() {
	cin >> N;
}

//メイン関数
int main() {

	input();
	calc();
	output();
	//debug();

	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T &b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T &b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;
int A[maxn];
int length = 0;

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

int main()
{
    int N;
    cin >> N;
    _for(i,0,N){
        int num;
        cin >> num;
        auto it = upper_bound(A,A+length,num,&compare);
        if(it == A+length) A[length++] = num;
        else *it = num;
    }
    cout << length << endl;


    return 0;
}


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

class Main {
    public static void main(String[] args) throws IOException {
		// Input
//		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(
//				new FileInputStream("src/data/input.txt"))));
		// ** For submission. 
		Scanner sc = new Scanner(System.in);
		
		
		
        String s = sc.nextLine();
//        int i = sc.nextInt();
        String[] str = s.split("\\s+");
        
        
        System.out.format("A%sC", str[1].charAt(0));
        
        
        
        
        
        
    }
}







































Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC153A
{
    class Program
    {
        static void Main(string[] args)
        {
            int H, A, N;
            var word = Console.ReadLine().Split(' ');

            H = int.Parse(word[0]);
            A = int.Parse(word[1]);

           
           if (H % A == 0)
            {
                N = H / A;
                Console.WriteLine(N);
            }
           else
            {
                N = H / A;
                Console.WriteLine(N + 1);
            }
            
            Console.ReadKey();
        }
    }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


// xが与えられた時、
// [0, x)でもっとも右にある神社と寺の位置をもとめる O(log(x))
// [x, inf)でもっとも左にある神社と寺の位置をもとめる O(log(10^10))

#define INF 100000000000

int main() {
    i64 A, B, Q; cin >> A >> B >> Q;
    vector<i64> s(A);
    vector<i64> t(B);
    REP(i, A) cin >> s[i];
    REP(i, B) cin >> t[i];

    i64 x;
    REP(q, Q) {
        cin >> x;
        auto it = lower_bound(s.begin(), s.end(), x);
        i64 si = distance(s.begin(), it);
        it = lower_bound(t.begin(), t.end(), x);
        i64 ti = distance(t.begin(), it);

        i64 sr = si < A ? s[si] : INF;
        i64 tr = ti < B ? t[ti] : INF;
        i64 sl = (si > 0) ? s[si - 1] : -INF;
        i64 tl = (ti > 0) ? t[ti - 1] : -INF;

        i64 mind = max(sr - x, tr - x);
        chmin(mind, max(x - sl, x - tl));
        chmin(mind, (sr - x) + (x - tl) + min(sr - x, x - tl));
        chmin(mind, (tr - x) + (x - sl) + min(tr - x, x - sl));
        cout << mind << endl;
    }

    return 0;
}

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

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  ll n;cin>>n;
  string s;
  map<string,ll> map;
  rep(i,n){
    cin>>s;
    sort(s.begin(),s.end());
    map[s]++;
  }
  ll ans=0;
  for(auto itr = map.begin(); itr != map.end(); ++itr){
    ans+=itr->second*(itr->second-1)/2;
  }
  cout<<ans<<endl;
}

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

int main() {
    int i,s,m,n,d[1000];
    while(cin >> n >> m && n!=0) {
		for (i=0,s=0;i<n;i++) { cin >> d[i]; s+=d[i]; }
		sort(d,d+n,greater<int>());
		for (i=m-1;i<n;i+=m) s-=d[i];
		cout << s << endl;
		} 
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    int ans=0;
    string S;
    cin >> N;
    cin >> S;
    for(int i=0; i<N ; i++){
        if(S[i]=='O' && S[i+1]=='X' || S[i]=='X' && S[i+1]=='O'){
            ans++;
            i++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
int a,b;
  cin>>a>>b;
  int c=a%b;
  cout<<min(c,b-c);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
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();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const int MAX_N = 8;
const int MAX_MP = 1000000000;
int N, A, B, C;
int l[MAX_N];

int solve_one(int a, int b, int c, int mp) {
    if (a == 0 || b == 0 || c == 0) return MAX_MP;
    return mp + abs(a - A) + abs(b - B) + abs(c - C);
}

int solve_all(int i, int a, int b, int c, int mp) {
    if (i == N) {
        return solve_one(a,b,c,mp);
    }

    std::vector<int> ans;
    ans.push_back(solve_all(i+1, a+l[i], b, c, mp + 10));
    ans.push_back(solve_all(i+1, a, b+l[i], c, mp + 10));
    ans.push_back(solve_all(i+1, a, b, c+l[i], mp + 10));
    ans.push_back(solve_all(i+1, a, b, c, mp));
    return *min_element(all(ans));
}

int solve() {
    return solve_all(0,0,0,0,-30);
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> A >> B >> C;
    REP(i,0,N) cin >> l[i];
    cout << solve() << "\n";
    return 0;
}



Measured memory_bytes: 256
#pragma region Include
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << endl
template <class T>
using VV = vector<vector<T>>;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;
#pragma endregion

int main() {
  int N;
  cin >> N;
  vector<pii> A(N);
  int tmp;
  rep(i, N) {
    cin >> tmp;
    A[i] = mp(tmp, i);
  }
  sort(all(A));
  rep(i, N) {
    if (i != 0) cout << " ";
    cout << A[i].se + 1;
  }
  return 0;
}

Measured memory_bytes: 1536
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
W = LI()
ans = INF
for i in range(1, n):
    # print(W[:i], W[i:])
    ans = min(ans, abs(sum(W[:i])-sum(W[i:])))
print(ans)

Measured memory_bytes: 63468
#include<stdio.h>
int main(void)
{
	int h,a,w;
	scanf("%d %d",&h,&a);
	w=h%a;
	if(w==0){
		printf("%d\n",h/a);
	}
	else{
		printf("%d\n",h/a+1);
	}
	return 0;	
}

Measured memory_bytes: 128
<?php

$input = explode(' ', trim(fgets(STDIN)));
$h = (int)$input[0];
$w = (int)$input[1];

$graph = [];
for ($i=1; $i <= $h; $i++) { 
	$input = trim(fgets(STDIN));
	for ($j=1; $j <= $w; $j++) { 
		$graph[$i][$j] = [
			'color' => $input[$j-1],
			'check' => false
		];
	}
}


$sum = 0;
for ($i=1; $i <= $h; $i++) { 
	for ($j=1; $j <= $w; $j++) { 
		if ($graph[$i][$j]['check'] === false) {
			$result = dfs($i, $j);
			$sum += $result['#'] * $result['.'];
		}
	}
}
echo $sum;

function dfs($i, $j){
	global $graph;
	$count = ['#'=>0, '.'=>0];
	$cur_c = $graph[$i][$j]['color'];
	$count[$cur_c] = 1;
	$graph[$i][$j]['check'] = true;
	$cand = [];
	if (isset($graph[$i][$j-1])) {
		$cand[] = [$i, $j-1];
	}
	if (isset($graph[$i][$j+1])) {
		$cand[] = [$i, $j+1];
	}
	if (isset($graph[$i+1][$j])) {
		$cand[] =[$i+1, $j];
	}
	if (isset($graph[$i-1][$j])) {
		$cand[] = [$i-1, $j];
	}
	foreach ($cand as $val) {
		if ($graph[$val[0]][$val[1]]['color'] !== $cur_c && $graph[$val[0]][$val[1]]['check'] === false) {
			$result = dfs($val[0], $val[1]);
			$count['#'] += $result['#'];
			$count['.'] += $result['.'];
		}
	}
	return $count;
}

Measured memory_bytes: 605048
import sys
import itertools
from collections import Counter
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
cumsum = itertools.accumulate([0] + a)
counter = Counter(cumsum)
ans = 0

for value in counter.values():
    ans += value * (value - 1) // 2

print(ans)


Measured memory_bytes: 40552
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
int k;
cin>>k;
int x=max((a,b),c);
int y=x;
for(int i=0;i<k;i++)
{
y*=2;
}
cout<<a+b+c+y-x;   
system("pause");
return 0;
}
    

Measured memory_bytes: 504
<?php
list($a,$b,$c,$k)=explode(" ",trim(fgets(STDIN)));
if($k<=$a){
  echo $k;
  exit;
}elseif($k<=$a+$b){
  echo $a;
  exit;
}else{
  $k-=$a+$b;
  echo $a-$k;
  exit;
}

Measured memory_bytes: 16188
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

int n;
int h[100005];
int dp[100005] = {0};

int main(){
	memset(dp,0x3f,sizeof(dp)); dp[1] = 0;
	scanf("%d",&n);
	for(int i = 1;i <= n;i ++) scanf("%d",&h[i]);
	for(int i = 2;i <= n;i ++) dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),dp[i - 2] + abs(h[i] - h[i - 2]));
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h> 
int main(){
  int n,i,sum=100000;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    sum*=1.05;
    if(sum%1000>=1)sum=sum-(sum%1000)+1000;
}
printf("%d\n",sum);
return 0;   
}

Measured memory_bytes: 592
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector dp(n, vector(n, -LINF));
  vector prev(n, vector(n, make_pair(-1, -1)));
  REP(i, n) dp[i][i] = a[i];
  for (int len = 3; len <= n; len += 2) for (int i = 0; i + len <= n; ++i) {
    int j = i + len - 1;
    vector r(len, make_pair(-LINF, -1));
    r[len - 1] = {dp[j][j], j};
    for (int k = j - 2; k > i; k -= 2) {
      r[k - i] = dp[k][j] > r[k - i + 2].first ? make_pair(dp[k][j], k) : r[k - i + 2];
    }
    ll l = -LINF;
    int sec = -1;
    for (int k = i; k < j; k += 2) {
      if (dp[i][k] > l) {
        l = dp[i][k];
        sec = k;
      }
      if (l + r[k + 2 - i].first > dp[i][j]) {
        dp[i][j] = l + r[k + 2 - i].first;
        prev[i][j] = {sec, r[k + 2 - i].second};
      }
    }
  }
  ll ans = -LINF;
  int l, r;
  REP(i, n) for (int j = i; j < n; j += 2) {
    if (dp[i][j] > ans) {
      ans = dp[i][j];
      l = i;
      r = j;
    }
  }
  // cout << l << ' ' << r << '\n';
  vector<bool> exist(n, true);
  vector<int> idx;
  for (int i = n - 1; i > r; --i) {
    idx.emplace_back(i);
    exist[i] = false;
  }
  REP(i, l) {
    idx.emplace_back(0);
    exist[i] = false;
  }
  vector<int> ope;
  queue<pair<int, int>> que;
  que.emplace(l, r);
  while (!que.empty()) {
    auto [i, j] = que.front(); que.pop();
    if (prev[i][j].first != -1) {
      if (prev[i][j].first + 2 == prev[i][j].second) {
        ope.emplace_back(prev[i][j].first + 1);
      } else {
        for (int k = prev[i][j].first + 2; k < prev[i][j].second - 1; k += 2) {
          ope.emplace_back(k);
        }
        ope.emplace_back(prev[i][j].second - 2);
      }
      que.emplace(i, prev[i][j].first);
      que.emplace(prev[i][j].second, j);
    }
  }
  for (int e : ope) {
    int cur = 0;
    REP(i, e) cur += exist[i];
    idx.emplace_back(cur);
    for (int i = e - 1; i >= 0; --i) {
      if (exist[i]) {
        exist[i] = false;
        break;
      }
    }
    FOR(i, e + 1, n) {
      if (exist[i]) {
        exist[i] = false;
        break;
      }
    }
  }
  cout << ans << '\n';
  cout << idx.size() << '\n';
  for (int e : idx) cout << e + 1 << '\n';
  return 0;
}


Measured memory_bytes: 19348
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        System.out.println(String.format("%.7f", r * r * Math.PI) + " " + String.format("%.7f", 2 * r * Math.PI));

    }
  
}


Measured memory_bytes: 28100
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


class BIT():
    def __init__(self,init_value):
        self.n = len(init_value)
        self.tree = [0]*(self.n+1)
        for i in range(1,self.n+1):
            x = init_value[i-1]
            while i <= self.n:
                self.tree[i] += x
                i += i & (-i)

    def update(self,i,x):  # i(1-index)番目の値を+x
        while i <= self.n:
            self.tree[i] += x
            i += i & (-i)
        return

    def query(self,i):  # 1番目からi(1-index)番目までの和を返す
        res = 0
        while i > 0:
            res += self.tree[i]
            i -= i & (-i)
        return res


N,Q = MI()

A,B = [0]*N,[0]*N
A[0],B[0] = N-2,N-2
A[N-1],B[N-1] = -(N-2),-(N-2)

I,J = BIT(A),BIT(B)
i_min,j_min = N,N
ans = (N-2)**2

for _ in range(Q):
    a,x = MI()
    if a == 1:
        ans -= I.query(x)
        if x < i_min:
            i_min = x
            y = J.tree[1]
            J.update(1,x-2-y)
            J.update(j_min,-(x-2-y))
    else:
        ans -= J.query(x)
        if x < j_min:
            j_min = x
            y = I.tree[1]
            I.update(1,x-2-y)
            I.update(i_min,-(x-2-y))

print(ans)


Measured memory_bytes: 74804
#include <bits/stdc++.h>
#define ll long long
#define mod 998244353
using namespace std;

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;}
        base *= base;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

int cnt[101][101];

int main(){
    //freopen("ip.txt", "rt", stdin);
    //freopen("op.txt", "wt", stdout);
    int a, b, c;
    cin >> a >> b >> c;
    int d = a^b;
    d = d^c;
    cout << d;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int maxN = 2 * (int)1e5 + 100;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int n;
vector < int > solve(int, int);
vector < int > solve(int a, int b, int n) {
    vector < int > v = solve(b ^ a, n);
    for (auto& t : v) t ^= a;
    return v;
}
void swap_bits(int& a, int x, int y) {
    if (x == y) return ;
    int bit1 = (a >> x) & 1;
    int bit2 = (a >> y) & 1;
    if (bit1) a ^= (1 << x);
    if (bit2) a ^= (1 << y);
    if (bit1) a ^= (1 << y);
    if (bit2) a ^= (1 << x);
}
vector < int > solve(int a, int n) {
    if (n == 0) return {0};
    if (n == 1) {
        return {0, 1};
    }
    int need_bit = 0;
    int na = a;
    for (int bit = 0; bit < n; bit++) {
        if (a & (1 << bit)) need_bit = bit;
    }
    swap_bits(na, need_bit, n - 1);
    //na = a ^ (1 << need_bit);
    //na ^= (1 << (n - 1));
    int need_i = 1;
    auto v1 = solve(0, need_i, n - 1);
    auto v2 = solve(need_i, na ^ (1 << (n - 1)), n - 1);
    for (auto& t : v1) {
        swap_bits(t, n - 1, need_bit);
    }
    for (auto& t : v2) {
        t ^= (1 << (n - 1));
        swap_bits(t, n - 1, need_bit);
        v1.push_back(t);
    }
    return v1;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    int nb = b ^ a;
    int val = 0;
    for (int bit = 0; bit < 17; bit++) {
        if (nb & (1 << bit)) val++;
    }
    if (val % 2 == 0) {
        cout << "NO" << '\n';
        return 0;
    }
    cout << "YES" << '\n';
    auto v = solve(nb, n);
    for (auto t : v) {
        cout << (t ^ a) << " ";
    }
    return 0;
}


Measured memory_bytes: 1648
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
using System.Diagnostics;

class Scanner
{
    private readonly char Separator = ' ';
    private int Index = 0;
    private string[] Line = new string[0];
    public string Next()
    {
        if (Index >= Line.Length)
        {
            Line = Console.ReadLine().Split(Separator);
            Index = 0;
        }
        var ret = Line[Index];
        Index++;
        return ret;
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    private long NextLong()
    {
        return long.Parse(Next());
    }
}

class Magatro
{
    private int H,W;
    private char[][] S;
    private void Scan()
    {
        var sc = new Scanner();
        H = sc.NextInt();
        W = sc.NextInt();
        S = new char[H][];
        for (int i = 0; i < H; i++)
        {
            S[i] = sc.Next().ToArray();
        }
    }

    public void Solve()
    {
        Scan();
        for(int i=0;i<H;i++)
        {
            for (int j = 0; j < W; j++)
            {
                int cnt = 0;
                if (S[i][j] == '#') continue;
                for(int k=-1;k<=1;k++)
                {
                    for(int l=-1;l<=1;l++)
                    {
                        if(k==0&&l==0)
                        {
                            continue;
                        }
                        if (i + k < 0 || i + k >= H)
                        {
                            continue;
                        }
                        if (j + l < 0 || j + l >= W)
                        {
                            continue;
                        }
                        if (S[i + k][j + l] == '#')
                        {
                            cnt++;
                        }
                    }
                }
                S[i][j] = (char)('0' + cnt);
            }
        }
        foreach(var line in S)
        {
            Console.WriteLine(new string(line));
        }
    }

    static public void Main()
    {
        new Magatro().Solve();

    }
}


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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

int main() {

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

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

    vector<int> cnt(N, 1);
    vector<bool> has_red(N);
    has_red[0] = true;

    REP(_, M) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        --cnt[x];
        ++cnt[y];
        if (has_red[x]) {
            has_red[y] = true;
            if (cnt[x] == 0) {
                has_red[x] = false;
            }
        }
    }

    cout << accumulate(all(has_red), 0) << endl;

    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    int A[100100];
    int Os[100100];
    REP(i,N) Os[i] = 0;
    REP(i,Q) cin >> A[i];
    REP(i,Q){
        Os[A[i]-1]++;
    }
    REP(i,N){
        if(Q-Os[i] < K) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

int len;
char s[105];

int main() {
    scanf("%d", &len);
    scanf("%s", s);
    if (len%2) {
        printf("No\n");
        return 0;
    }
    len /= 2;
    for (int i = 0; i < len; i++) {
        if (s[i] != s[len+i]) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,ans=1e12;
int main(){
	cin>>n;
	for(int i=1;i<=sqrt(n);i++)
	    if(n%i==0) ans=min(ans,n/i+i-2);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<PP,vector<PP>,greater<PP>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

int main(){
  ll n;cin>>n;
  if(n%2)cout<<0<<endl;
  else{
    ll ans=0;
    n/=2;
    while(n){
      ans+=n/5;
      n/=5;
    }
    cout<<ans<<endl;
  }
}

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

#define MAX_N 50

// int N = 3;
// int d[] = {3, 1, 2};

int N, d[MAX_N];
int ans = 0;

int main() {
    cin >> N;
    rep(i, N) {
        cin >> d[i];
    } 
    rep(i, N - 1) {
        for (int j = i + 1; j <= N - 1; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n;
vector<long long> a;
bool check(int i, long long  m)
{
	vector<long long>::iterator hoge = lower_bound(a.begin() + i, a.begin() + i + n - 1, m + *(a.begin() + i - 1));
	vector<long long>::iterator hage = lower_bound(hoge, a.begin() + i + n - 1, m + *hoge);//
	if (*(a.begin() + i + n - 1) - (*hage) >= m)return true;
	return false;
}


int main()
{
	a.push_back(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		a.push_back(x);
	}
	for (int i = 1; i <= n; i++)a.push_back(a[i]);
	for (int i = 1; i < a.size(); i++)a[i] += a[i - 1];
	long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		long long  l = 0,r = 500000000000000000;
		while (r != l){
			long long m = (r + l+1) / 2;
			if (check(i+1, m))
			{
				l = m;
			}
			else
			{
				r = m - 1;
			}
		}
		ans = max(ans, l);
	}
	cout << ans << endl;

}

Measured memory_bytes: 3116
#include <iostream>
#include <string>

using namespace std;

int main(){
    int min_value = 1000;
    string S;
    cin >> S;

    for(int i = 0; i < S.length() - 2; i++){
        int x = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0');

        int tmp = abs(x - 753);
        min_value = min(min_value, tmp);
    }

    cout << min_value << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
#include <stack>

using namespace std;
typedef long long Int;
#define REP(i , x) for(Int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;


int main()
{
	int n;
	cin >> n;
	REP(i, n){
		string a, b;
		int a_a[100] = { 0 };
		int b_a[100] = { 0 };
		int c_a[100] = { 0 };
		cin >> a >> b;

		vector<char> a_b(a.rbegin(), a.rend());
		vector<char> b_b(b.rbegin(), b.rend());

		if (a_b.size() > 80 || b_b.size() > 80){
			cout << "overflow" << endl;
			continue;
		}

		int carry(0);
		vector<int> ans;

		if (a_b.size() > b_b.size()){
			b_b.resize(a_b.size(), '0');
		}
		else{
			a_b.resize(b_b.size(), '0');
		}

		REP(i, a_b.size()){
			int temp = a_b[i] - '0' + b_b[i] - '0' + carry;
			carry = temp / 10;
			ans.push_back(temp % 10);
		}

		if (carry)
			ans.push_back(carry);

		if (ans.size() > 80){
			cout << "overflow" << endl;
			continue;
		}

		for (unsigned i = 0; i < ans.size(); i++) {
			cout << ans[ans.size() - 1 - i];
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1236
import java.util.ArrayDeque
fun coloring(matrix: MutableMap<Int, MutableMap<Int,Long>>,num_nodes:Int) : Array<Boolean?> {

    val color_allocation: Array<Boolean?> = arrayOfNulls(num_nodes)

        val index_queue: ArrayDeque<Int> = ArrayDeque()
        val root_index = color_allocation.indices.first {color_allocation[it] == null }
        
        color_allocation[root_index] = true
        index_queue.add(root_index)

        while(! index_queue.isEmpty()) {
            val index = index_queue.poll()
            matrix[index]?.forEach { 
                    if(color_allocation[it.key] == null) {
                        index_queue.add(it.key)
                        it.value.run { 
                            color_allocation[it.key] = color_allocation[index]?.let { c->
                                c xor (this % 2 != 0L) 
                            }
                        }                    
                    }
            }
        }
    // color_allocation.forEach{print("${it} ")}
    // println()
    return color_allocation
}
fun main(args:Array<String>) {
    val N = readLine()!!.toInt()
    val graph:MutableMap<Int, MutableMap<Int,Long>> = mutableMapOf()
    1.until(N).forEach {
        val (u,v,w) = readLine()!!.split(" ").map(String::toLong)
        val (i,j) = Pair((u-1).toInt(), (v-1).toInt())
        // graph[i][j] = w 
        // graph[j][i] = w
        if(!graph.contains(i)) {
            graph.set(i, mutableMapOf())
        }
        if(!graph.contains(j)) {
            graph.set(j, mutableMapOf())
        }
        graph[i]!!.set(j, w)
        graph[j]!!.set(i, w)
    }
    // graph.values.forEach {row ->
    //     row.values.forEach {
    //     print("${it} ")
    //     }
    //     println()
    // }
    // println()
    
    val color_allocation = coloring(graph,N)

    color_allocation.forEach {
        ((it?.let{c -> if(c) {"1"} else {"0"}}) ?: "-1").run(::println)
    }
}


Measured memory_bytes: 116268
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int a = cin.Int();
        int b = cin.Int();
        int c = cin.Int();

        int max = Math.Max(Math.Max(a, b), c);
        if ((3 * max - a - b - c) % 2 == 0) Console.WriteLine((3 * max - a - b - c) / 2);
        else Console.WriteLine((3 * (max + 1) - a - b - c) / 2);
        Console.ReadLine();
    }
}

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

int main(){
  string s,t;cin>>s>>t;
  int ans=0;
  REP(i,s.size()){
    if(s.at(i)!=t.at(i)) ans++;
  }

  cout<<ans;
}

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

int main()
{
    cin>>m;
    cin>>n;
    ll turn[m];
    for(int i=0;i<m;i++)
        cin>>turn[i];
    bool win[n+1];
    fill(win,win+n+1,1);
    for(int i=0;i<=n;i++)
    {
        if(win[i])
        {
            for(int j=0;j<m;j++)
            {
                if(turn[j]+i<=n)
                    win[i+turn[j]]=0;
                else
                    break;
            }
        }
    }
    if(!win[n])
        cout<<"First";
    else
        cout<<"Second";
}

Measured memory_bytes: 384
/* the logic is pretty simple 
 we are following a simple series in this ques
 n -> 2*floor(n/2) -> 4*floor(n/4) -> 8*floor(n/4).....
 
 the ans=biggest power of 2 which doesnt exceed n;
 
 there is  a shortcut method to compute the biggest power of 2 that doesnt excceed k;
 
 b=1LL<<(63-_buitin_clzll(k)
 ans =2*b-1;
 */



#include<bits/stdc++.h>
using namespace std;
using ll =long long int ;
int main()
{
  ll n;
  cin>>n;
  ll b=1LL<<(63-__builtin_clzll(n));
  
  cout<<2*b-1<<endl;
  
  
}


Measured memory_bytes: 3544
def solve():
    n = int(input())
    s = list(map(int, input().split()))
    tmp = 0
    res = 0
    for a, b in zip(s, s[1:]):
        if a >= b:
            tmp += 1
            res = max(res, tmp)
        else:
            tmp = 0
    print(res)


solve()


Measured memory_bytes: 20580
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int;

#define int long long
const int INF = 100000000000000000;

const int MAX_N = 100005;
const int MAX_M = 100005;

int N, M;
int A[MAX_M], B[MAX_M];

bool used[MAX_M];
vector<int> L[MAX_N];
vector<int> R[MAX_N];

signed main()
{
    string A, B;
    cin >> A >> B;
    for(int i = 0; i <= A.length(); i++) {
        if(A==B) {
            cout << "Yes" << endl;
            return 0;
        }
        A =  A[A.length()-1] + A.substr(0, A.length()-1);
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

bool dfs(bool t, set<i64> a, set<i64> b, i64 l, i64 r)
{
  if (a.size() == 0)
    return true;
  if (b.size() == 0)
    return false;
  bool ret;
  set<i64> tmp;
  if (t)
  {
    ret = false;
    if (a.find(l - 1) != a.end())
    {
      tmp = a;
      tmp.erase(l - 1);
      ret |= dfs(!t, tmp, b, l - 1, r);
    }
    if (a.find(r + 1) != a.end())
    {
      tmp = a;
      tmp.erase(r + 1);
      ret |= dfs(!t, tmp, b, l, r + 1);
    }
    if (a.find(l - 1) == a.end() && a.find(r + 1) == a.end())
      ret = dfs(!t, a, b, l, r);
  }
  else
  {
    ret = true;
    if (b.find(l - 1) != b.end())
    {
      tmp = b;
      tmp.erase(l - 1);
      ret &= dfs(!t, a, tmp, l - 1, r);
    }
    if (b.find(r + 1) != b.end())
    {
      tmp = b;
      tmp.erase(r + 1);
      ret &= dfs(!t, a, tmp, l, r + 1);
    }
    if (b.find(l - 1) == b.end() && b.find(r + 1) == b.end())
      ret = dfs(!t, a, b, l, r);
  }
  return ret;
}

int main()
{
  i64 n;
  cin >> n;
  for (i64 _ = 0; _ < n; _++)
  {
    set<i64> a, b;
    for (i64 i = 0; i < 6; i++)
    {
      i64 k;
      cin >> k;
      a.insert(k);
    }
    for (i64 i = 1; i <= 13; i++)
      if (i != 7 && a.find(i) == a.end())
        b.insert(i);
    if (dfs(true, a, b, 7, 7))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}



Measured memory_bytes: 3136
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var r = int.Parse(_[0]);
            var d = int.Parse(_[1]);
            var x = int.Parse(_[2]);

            var ary = new int[10];
            ary[0] = r * x - d;
            for(var i = 1; i < 10; i++){
                ary[i] = r * ary[i-1] - d;
            }

            foreach(var i in ary){
                Console.WriteLine(i);
            }
        }
    }
}


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

int main(void){
    int h,w;
    cin >> h >> w;

    vector<string> vec(h);
    for(int i=0;i<h;i++) cin >> vec.at(i);

    const vector<int> dx = {1,0,-1,0,1,-1,-1,1};
    const vector<int> dy = {0,1,0,-1,1,1,-1,-1};

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(vec.at(i).at(j)=='#') continue;

            int num = 0;
            for(int k=0;k<8;k++){
                int ni = i+dx.at(k);
                int nj = j+dy.at(k);
                if(ni<0 || h<=ni) continue;
                if(nj<0 || w<=nj) continue;
                if(vec.at(ni).at(nj)=='#') num++;
            }
            vec.at(i).at(j) = char(num+'0');
        }
    }
    for(int i=0;i<h;i++) cout << vec.at(i) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  char tmp_s[100001];
  cin >> s;
  int ans = 0;
  // 1番左をそのままにする場合
  s.copy(tmp_s, s.length());
  int tmp1 = 0;
  for(int i=1; i<s.length(); i++){
    if(tmp_s[i]==tmp_s[i-1]){
      tmp_s[i] = (tmp_s[i]=='0'?'1':'0');
      tmp1++;
    }
  }
  // 1番左を変えるとき
  s.copy(tmp_s, s.length());
  int tmp2 = 1;
  tmp_s[0] = (tmp_s[0]=='0'?'1':'0');
  for(int i=1; i<s.length(); i++){
    if(tmp_s[i]==tmp_s[i-1]){
      tmp_s[i] = (tmp_s[i]=='0'?'1':'0');
      tmp2++;
    }
  }
  ans = min(tmp1, tmp2);
  cout <<  ans << endl;
  return 0;
}

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

vector<int> G[100000];
int num[100000];
int len[100000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif


	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		num[b]++;
	}

	queue<int> q;
	for(int i = 0; i < N; i++){
		if(num[i] == 0) q.push(i);
	}

	while(q.size()){
		int v = q.front();
		q.pop();
		for(auto u : G[v]){
			len[u] = max(len[u], len[v] + 1);
			num[u]--;
			if(num[u] == 0) q.push(u);
		}
	}

	cout << *max_element(len, len + N) << endl;
}


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

ll gcd(ll a, ll b) { return (b?gcd(b, a%b):a); }

const int M = 1000000007;
ll mul(ll a, ll b) { return (a*b)%M; }
ll mod_pow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b&1) r = mul(r, a);
    b >>= 1;
    a = mul(a, a);
  }
  return r;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, zero = 0;
  cin >> n;
  map<pair<ll, ll>, P> mp;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      ++zero;
      continue;
    }
    ll g = gcd(x, y);
    x /= g;
    y /= g;
    if (y < 0) { x = -x, y = -y; }
    if (x == 0) y = 1;
    if (y == 0) x = 1;
    if (x > 0) mp[{x, y}].first++;
    else mp[{y, -x}].second++;
  }
  ll ans = 1;
  for (auto k : mp) {
    ll now1 = mod_pow(2, k.second.first);
    ll now2 = mod_pow(2, k.second.second);
    ans = mul(ans, (now1+now2-1)%M);
  }
  ans = (ans+M+zero-1)%M;
  cout << ans << endl;
}

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

int main() {
    int s,w;
    cin>>s>>w;
    string ans="safe";
    if (w>=s) ans="unsafe";
    cout<<ans<<endl;
}


Measured memory_bytes: 3628