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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,n2=1,q,c[500010],lst[500010],dat[2000010],ans[500010];
vector <pii> que[500010];

void upd(int k,int lb,int ub,int tlb,int tub)
{
	if(ub<tlb||tub<lb) return;
	if(tlb<=lb&&ub<=tub)
	{
		dat[k]++;
		return;
	}
	upd(k*2+1,lb,(lb+ub)/2,tlb,tub);
	upd(k*2+2,(lb+ub)/2+1,ub,tlb,tub);
}

int query(int k)
{
	int ret=dat[k];
	while(k>0)
	{
		k=(k-1)/2;
		ret+=dat[k];
	}
	return ret;
}

int main()
{
	cin>>n>>q;
	rep(i,n) scanf("%d",&c[i]);
	int x,y;
	rep(i,q)
	{
		scanf("%d%d",&x,&y);
		x--;
		y--;
		que[y].pb(mpr(x,i));
	}
	rep(i,500005) lst[i]=-1;
	while(n2<n) n2*=2;
	rep(i,n)
	{
		upd(0,0,n2-1,lst[c[i]]+1,i);
		lst[c[i]]=i;
		rep(j,que[i].size()) ans[que[i][j].se]=query(que[i][j].fi+n2-1);
	}
	rep(i,q) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 35172
#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>;
int main() {
    int n; cin >> n;
    vector<int> a(n+1);
    map<int, int> mp;
    for(int i=1; i<=n; i++) {
        cin >> a[i];
        mp[a[i]+i]++;
    }
    ll cnt = 0;
    for(int i=1; i<=n; i++) {
        cnt += mp[i-a[i]];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 21120
/*
 * 	The way if it's all predetermined
 * 		And the way i should go all my life
 * 			I swear to go wherever will be
 * 				'Cause there'll be something to see and to find
 */
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}


int powm(int a, int b) {
	a%=mod;
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return res;
}

vi gra[2005];
string s;
int can[2005],tot[2005],mam[2005],para[2005];
void dfs(int fr, int at) {
	int maxi=0,total=0;
	if(s[at]=='1')
		tot[at]++;
	for(int i:gra[at]) {
		if(i!=fr) {
			dfs(at,i);
			maxi=max(maxi,2*(mam[i]+tot[i])-can[i]);
			mam[at]+=mam[i]+tot[i];
			tot[at]+=tot[i];
			para[at]+=tot[i]+para[i];
		}
	}
	can[at]=min(mam[at],2*mam[at]-maxi);
	if(can[at]&1)
		can[at]--;
}
void solve() {
	int n;
	cin>>n>>s;
	s='0'+s;
	fr(i,2,n) {
		int u,v;
		cin>>u>>v;
		gra[u].pb(v);
		gra[v].pb(u);
	}
	int ans=infl;
	fr(i,1,n) {
		fill(can+1,can+n+1,0);
		fill(tot+1,tot+n+1,0);
		fill(mam+1,mam+n+1,0);
		fill(para+1,para+n+1,0);
		dfs(i,i);
		if(can[i]==mam[i]) {
			ans=min(ans,para[i]);
		}
		trace(para[i]);
	}
	if(ans==infl)
		cout<<-1<<endl;
	else
		cout<<ans/2<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{

int D,T,S;
cin >> D >> T >> S; //標準入力

int minutes;

if(D%S){
    minutes = D/S + 1;
}else{
    minutes = D/S;
}

if(minutes<=T){
    cout << "Yes\n";
}else{
    cout << "No\n";
}
}

Measured memory_bytes: 3604
package main

import (
	"fmt"
)

func main() {
	var s string
	_, _ = fmt.Scan(&s)
	//s = "11011010001011"
	bs := []byte(s)
	ones := 0
	zeros := 0

	for i := 0; i < len(bs); i++ {
		if bs[i] == '0' {
			zeros++
		} else {
			ones++
		}
	}
	if ones < zeros	{
		fmt.Println(ones * 2)
	} else {
		fmt.Println(zeros * 2)
	}
}

Measured memory_bytes: 1408
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  a.sort!"a > b";
  auto p = new int[](2);
  foreach (int i, ai; a) p[i%2] += ai;

  writeln(p[0]-p[1]);
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
q = int(input())

for i in range(q):
    b, e, t = list(map(int, input().split()))
    
    for j in range(e - b):
        A[b + j], A[t + j] = A[t + j], A[b + j]

print(*A)


Measured memory_bytes: 5836
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
hands = {"r": P, "s": R, "p": S}
K_list = [""]*K

for i in range(N):
    K_list[i % K] += T[i]

for k in range(K):
    K_list[k] = K_list[k].replace("rr", "r")
    K_list[k] = K_list[k].replace("ss", "s")
    K_list[k] = K_list[k].replace("pp", "p")

ans = 0
for k_list in K_list:
    for s in k_list:
        ans += hands[s]

print(ans)

Measured memory_bytes: 6132
// 2018/12/20 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	int A[1000], B[1000];
	for(int i=0; i<M; i++){
		cin >> A[i] >> B[i];
	}

	sort(A, A+M);

	int sum = 0;

	for(int i=1; i<M; i++){
		if(A[i]>=N)
			break;

		sum += (N-A[i]);
	}

	cout << sum << endl;

	return 0;
}



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

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: i32,
        y: i32,
    };

    let mut ijk = (-1, -1, -1);

    'outer: for i in 0..n+1 {
        for j in 0..n-i+1 {
            let k = n - i - j;
            if i*1000 + j*5000 + k*10000 == y {
                ijk = (i, j, k);
                break 'outer;
            }
        }
    }

    println!("{} {} {}", ijk.2, ijk.1, ijk.0);

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin>>N ;
    long long sum = 0;
    for(long long i=1;i<N;i++){
        if(N%i ==0) sum+=((N/i)-1);
        else sum+=(N/i) ;
    }
    cout<<sum;
}

Measured memory_bytes: 3620
h,w=map(int,input().split())
li=[[]]*h
for i in range(h):
  li[i]=[str(k) for k in input()]
  
lil=[[0 for i in range(w)] for j in range(h)]
#[h][w]=着くまでの最小操作回数
for i in range(h):
  for j in range(w):
    if i==0 and j==0:
      if li[0][0]==".":
        lil[0][0]=0
      else:
        lil[0][0]=1
    elif i==0:
      if li[i][j]==li[i][j-1] or li[i][j]==".":
        lil[i][j]=lil[i][j-1]
      elif li[i][j]=="#":
        lil[i][j]=lil[i][j-1]+1
    elif j==0:
      if li[i][j]==li[i-1][j] or li[i][j]==".":
        lil[i][j]=lil[i-1][j]
      elif li[i][j]=="#":
        lil[i][j]=lil[i-1][j]+1
    else:
      if li[i][j]==li[i-1][j] or li[i][j]==".":
        ko=lil[i-1][j]
      elif li[i][j]=="#":
        ko=lil[i-1][j]+1
      if li[i][j]==li[i][j-1] or li[i][j]==".":
        ks=lil[i][j-1]
      elif li[i][j]=="#":
        ks=lil[i][j-1]+1
      lil[i][j]=min(ko,ks)
print(lil[h-1][w-1])  

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>


int main() {
	int n; std::cin >> n;
	std::vector<int> values(n); for (auto& a : values) std::cin >> a;
	std::deque<int> queue;
	for (auto i = 0; i < n; ++i) {
		if (i % 2 == 0) {
			queue.push_back(values[i]);
		}
		else {
			queue.push_front(values[i]);
		}
	}
	if (n % 2 == 0) {
		for (auto i = 0; i < n; ++i) {
			if (i != 0) std::cout << ' ';
			std::cout << queue.front();
			queue.pop_front();
		}
	}
	else {
		for (auto i = 0; i < n; ++i) {
			if (i != 0) std::cout << ' ';
			std::cout << queue.back();
			queue.pop_back();
		}
	}
	std::cout << '\n';
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;

int mod = 1000000007;

#define mul(a, b) ((a % mod) * (b % mod)) % mod

long long int dp[55][55][2600];

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

    dp[0][0][0] = 1;

    rep(i, n + 1)
    {
        rep(j, i + 1)
        {
            rep(k, score + 1)
            {
                dp[i + 1][j][k + j * 2] += dp[i][j][k] % mod;

                dp[i + 1][j + 1][k + (j + 1) * 2] += dp[i][j][k] % mod;

                dp[i + 1][j][k + j * 2] += mul(dp[i][j][k], 2 * j);

                if (j >= 1)
                {
                    dp[i + 1][j - 1][k + (j - 1) * 2] += mul(mul(dp[i][j][k], j), j);
                }
            }
        }
    }

    OP(dp[n][0][score] % mod)

    return 0;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0; i<s.size();i++){
        if(s.at(i)==t.at(i)){
            count++;
        }
    }
    if(s.size()+1==t.size() && count==s.size()){
        cout<<"Yes"<<endl;

    }

    else 
        cout<<"No"<<endl;
    
}

Measured memory_bytes: 3600
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    // solver code...
    let x = read::<i32>();
    let ans = match x {
        0 => "1",
        1 => "0",
        _ => "-1",
    };
    println!("{}", ans);
}


Measured memory_bytes: 2152
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll n, d;
  cin >> n >> d;
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    if(x * x + y * y <= d * d) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
function Main(input){
  
  var str = input.trim().split(" ");
  var a = parseInt(str[0],10);
  var b = parseInt(str[1],10);
  var c = parseInt(str[2],10);
  if(a<b&&a<c&&c<b){
    console.log("Yes");}
  else if(b<a&&b<c&&c<a){
     console.log("Yes");}
  else{
 console.log("No");}

  
  
  
}//function end
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>

using namespace std;

int main()
{
    int t;

    cin >> t;
    while (t--) {
        int n, up, down, a, b;

        cin >> n;
        up = down = 0;
        --n;

        cin >> a;
        for (int i = 0; i < n; ++i) {
            cin >> b;
            if (a >= b)
                down = max(down, a - b);
            else
                up = max(up, b - a);

            a = b;
        }

        cout << up << " " << down << endl;
    }

    return 0;
}

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

int main() {
  string t;
  cin >> t;
  if(t.size() == 1){
    if(t[0] == 'P'){
      cout << t << endl;
      return 0;
    }else {
      cout << "D" << endl;
      return 0;
    }
  }
  rep(i, t.size()){
    if(t[i] == '?'){
      //if(i + 1 < t.size() && (t[i+1] == 'D' || t[i+1] == '?')){
      //  t[i] = 'P';
      //  t[i+1] = 'D';
      //}else {
      //  t[i] = 'D';
      //}
      t[i] = 'D';
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3752
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define gcd(a,b)    __gcd((a),(b))
#define fill(a,value) memset(a,value,sizeof(a));
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    vi a(n);
    f(i,n)cin>>a[i];
    vi ans(n);
    f(i,n)
    {
        ans[a[i]-1]=(i+1);
    }
    for(auto p:ans)cout<<p<<" ";
    return 0;
}

Measured memory_bytes: 4696
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d", &n);

	int a[100];
	
	for(int i = 0; i < n; i++){
		
		scanf("%d", &a[i]);
	}
	
	for(int i = 0; i < n; i++){
		
		printf("%d", a[n - 1 - i]);
		if(i != n - 1){
			printf(" ");
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 2748
// ABC044B - 美しい文字列

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

int main() {
	string w;
	cin >> w;
	map<char, int> n;

	for (int i = 0; i < w.size(); i++) {
		n[w[i]]++;
	}
	bool answer = true;
	for (map<char, int>::iterator it = n.begin(); it != n.end(); it++) {
		pair<char, int> temp = *it;
		if (temp.second % 2 == 1) {
			answer = false;
			break;
		}
	}

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


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

int main(){
	int a, b;
	cin >> a >> b;
	if(a<b){
		cout << "a < b" << endl;
	}else if(a>b){
		cout << "a > b" << endl;
	}else{
		cout << "a == b" << endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
using namespace std;
char a[200000];
int main(){
    int n;
    int sum = 0;
    scanf("%d",&n);
    scanf("%s",a);
    for(int i = 0; i <= n - 1;i++){
        int j = i + 1;
        if(a[i] != a[j]) {
            sum +=1;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 384
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
void fx(vector<int> &a,int n, int m){

}

// -----------------------------------------------------------------------

int arr[3000000];
void input(int n){
	for(int i=0;i<n;++i)
	cin>>arr[i];
}

// -----------------------------------------------------------------------



void q1(){
	int n;
	cin>>n;
	n*=(n+1);
	n/=2;
	cout<<n;
}
// -----------------------------------------------------------------------


void q2(){
	string s,t;
	cin>>s;
	t="";
	int skip=0;
	for(int i=(int)s.size()-1;i>=0;i--){
		if(s[i]=='B'){
			skip++;
		} else{
			if(skip>0){
				skip--;
			} else{
				t+=s[i];
			}
		}
	}
	for(int i=sz(t)-1;i>=0;--i)
	cout<<t[i];
}

// -----------------------------------------------------------------------

void q3(){
	int n;
	cin>>n;
	input(n);
	ld sum=0;
	for(int i=0;i<n;++i){
		sum+=arr[i];
	}
	sum/=n;
	int l=sum;
	sum+=1.00;
	int u=sum;
	int pp,p;
	pp=0;
	sum=l;
	for(int i=0;i<n;++i){
		pp+=((arr[i]-sum)*(arr[i]-sum));
	}p=0;sum=u;
	for(int i=0;i<n;++i){
		p+=((arr[i]-sum)*(arr[i]-sum));
	}
	cout<<min(p,pp);
}


// -----------------------------------------------------------------------

void q4(){
	string s;
	cin>>s;
	int xp=sz(s);
	for(int i=0;i<xp-2;++i){
		if(s[i]==s[i+1]){
			cout<<i+1<<" "<<i+2<<endl;
			return ;
		}
		if(s[i]==s[i+2]){
			cout<<i+1<<" "<<i+3<<endl;
			return ;
		}
	}
	if(s[xp-1]==s[xp-2]){
		cout<<xp-1<<" "<<xp<<endl;
		return ;
	}
	cout<<"-1 -1\n";
	return ;
}

// -----------------------------------------------------------------------


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	q4();
	return 0;
}


Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][10000],a[200000], b[2000000];
string str, ss, dd;
bool f,ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (a[i] % 4 == 0)
			b[0]++;
		else if (a[i] % 2 == 0)
			b[1]++;
	}
	b[2] = n - b[1] - b[0];
	if (b[2] - b[0] == 1 && b[2] + b[0] == n)
		f = 1;
	if (b[1] == n)
		f = 1;
	if (b[0] >= b[2])
		f = 1;
	yn(f);
	return 0;
}

Measured memory_bytes: 4608
a,b,c, d = [ int(i) for i in list(input()) ]



def calc(x,y,op):
    if op == '+':
        return x+y
    else:
        return x-y


op_l = ['+','-']
for op1 in op_l:
    for op2 in op_l:
        for op3 in op_l:
            x = calc(calc(calc(a,b,op1),c,op2),d, op3)
            if x == 7:
                ans = str(a)+op1+str(b)+op2+str(c)+op3+str(d)+"=7"
                break
print(ans)

Measured memory_bytes: 9080
#include <stdio.h>
#include<math.h>
#include<bitset>
#include<string>
#include<iostream>
#include<vector>
using namespace std;

int main()
{
    string Ans[3];
    int a,b,c,d,abcd;
    cin>>abcd;
    a=abcd/1000;
    b=(abcd-a*1000)/100;
    c=(abcd-(a*1000+b*100))/10;
    d=abcd-(a*1000+b*100+c*10);

    
    for(int bit=0;bit<(1<<3);bit++){
        int ans=0;
        
        if(bit&(1<<0)){
            ans=a+b;
            Ans[0]="+";
        }else{
            ans=a-b;
            Ans[0]="-";
        }
        
       
        
        if(bit&(1<<1)){
            ans+=c;
            Ans[1]="+";
        }else{
            ans-=c;
            Ans[1]="-";
        }
        
        if(bit&(1<<2)){
            ans+=d;
            Ans[2]="+";
        }else{
            ans-=d;
            Ans[2]="-";
        }
        
        
        
        if(ans==7){
            break;
        }
    }
   
    cout<<a<<Ans[0]<<b<<Ans[1]<<c<<Ans[2]<<d<<"=7"<<endl;

    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define rep(i,n)for(int i=0;i<(int)(n);i++)
int main(){
    int n,m,x,c[12]={0},a[12][12]={0},y,z[12],b,d=2e9;
    scanf("%d%d%d",&n,&m,&x);
    rep(i,n){
    scanf("%d",&c[i]);
        rep(j,m){
            scanf("%d",&a[i][j]);
        }
    }
    rep(i,2){rep(j,2){rep(k,2){rep(l,2){rep(o,2){rep(p,2){rep(q,2){rep(r,2){rep(s,2){rep(t,2){rep(u,2){rep(v,2){
        y=i*c[0]+j*c[1]+k*c[2]+l*c[3]+o*c[4]+p*c[5]+q*c[6]+r*c[7]+s*c[8]+t*c[9]+u*c[10]+v*c[11];
        for(b=0;b<m;b++){
            z[b]=i*a[0][b]+j*a[1][b]+k*a[2][b]+l*a[3][b]+o*a[4][b]+p*a[5][b]+q*a[6][b]+r*a[7][b]+s*a[8][b]+t*a[9][b]+u*a[10][b]+v*a[11][b];
            if(z[b]<x)break;
        }
        if(b==m&&y<d)d = y;
    }}}}}}}}}}}}
    if(d==(int)2e9)puts("-1");
    else printf("%d",d);
    return 0;
}

Measured memory_bytes: 1732
import math
ans = 0
N = int(input())
for i in range(N):
    ans += i+1
for i in range(N-1):
    for j in range(i+1,N):
        ans += 6*math.gcd(i+1,j+1)
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            ans += 6*math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
print(ans)

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



i64 n;
bool b[1010101];
void solve(){
	cin >> n;
	
	i64 cnt = 7;
	int ans = 0;
	while(1){
		ans++;
		if(cnt % n == 0){
			cout << ans << endl;
			return;
		}
		if(b[cnt]) break;
		b[cnt] = 1;
		cnt = cnt*10+7;
		cnt %= n;
	}
	cout << -1 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 4588
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
int n,m,sum,a[N],t[N<<2];
vector<int>v[N];
void update(int k)
{
    t[k]=min(t[k<<1],t[k<<1|1]);
}
void build(int l,int r,int k)
{
    if(l==r)
    {t[k]=l!=0?inf:0;return;}
    int m=l+r>>1;
    build(l,m,k<<1);build(m+1,r,k<<1|1);
    update(k);
}
void fix(int l,int r,int k,int x,int v)
{
    if(l==r)
    {
        t[k]=min(t[k],v);
        return;
    }
    int m=l+r>>1;
    if(x<=m) fix(l,m,k<<1,x,v);
    else fix(m+1,r,k<<1|1,x,v);
    update(k);
}
int query(int l,int r,int k,int x,int y)
{
    if(r<x||l>y) return inf;
    if(l>=x&&r<=y) return t[k];
    int m=l+r>>1;
    return min(query(l,m,k<<1,x,y),query(m+1,r,k<<1|1,x,y));
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i]==0;
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
    {
        int l,r;scanf("%d%d",&l,&r);v[l].push_back(r);
    }
    build(0,n,1);
    for(int i=1;i<=n;i++)
    {
        sort(v[i].begin(),v[i].end(),greater<int>());
        for(int j:v[i])
        {
            int ans=query(0,n,1,i-1,j);
            fix(0,n,1,j,ans);
        }
        int ans=query(0,n,1,i-1,i-1);
        ans+=a[i]==0?-1:1;
        fix(0,n,1,i,ans);
    }
    printf("%d\n",query(0,n,1,n,n)+sum);
}


Measured memory_bytes: 12800
#include<iostream>
#include<set>
#include<string>
using namespace std ;

set<int> s ;

bool ok(int n){
  string str = to_string(n) ;
  for(int i=0;i<str.size();i++){
    if(s.count(str.at(i)-'0')){
      return false ;
    }
  }
  return true ;
}

int main(){
  int n,k ;
  cin >> n >> k ;
  for(int i=0;i<k;i++){
    int x ; cin >> x ;
    s.insert(x) ;
  }
  while(1){
    if(ok(n)){
      cout << n << endl ;
      return 0 ;
    }
    n++ ;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> v(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

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

	double ans = v[0];
	for (int i = 1; i < n; i++) {
		ans = (ans + v[i])  / 2;
	}
	printf("%.9f\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define P pair<int,int>
const LL inf = 0x3f3f3f3f;
const LL mod = 1e9+7;
const LL N = 2e3+10;
template <typename tp> inline void read(tp &x)
{
	x=0;char c=getchar();int f=0;
	for(;c>'9'||c<'0';f|=(c=='-'),c=getchar());
	for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	if(f) x=-x;
}
int n,k,ans=inf;
struct Edge{int next,to;}edge[N*2];
P e[N];
int head[N],cnt;
void add(int from,int to)
{
	edge[++cnt].next=head[from];
	edge[cnt].to=to;
	head[from]=cnt;
}
int dfs(int now,int fa,int dp,int ret=1)
{
	if(!dp) return 0;
	for(int i=head[now];i;i=edge[i].next)
	{
		int to=edge[i].to;
		if(to==fa) continue;
		ret+=dfs(to,now,dp-1);
	}
	return ret;
}
signed main()
{
	read(n),read(k);
	for(int i=1;i<n;i++) read(e[i].first),read(e[i].second),add(e[i].first,e[i].second),add(e[i].second,e[i].first);
	if(k%2==0) for(int i=1;i<=n;i++) ans=min(ans,n-dfs(i,i,k/2+1));
	else for(int i=1;i<n;i++) ans=min(ans,n-dfs(e[i].first,e[i].second,k/2+1)-dfs(e[i].second,e[i].first,k/2+1));
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

const int N = 1234567;

int ans[42];
pair<int, int> a[N], b[N];

int main() {
  int h, w, n;
  scanf("%d %d %d", &h, &w, &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first, &a[i].second);
    for (int dx = 0; dx < 3; dx++) {
      for (int dy = 0; dy < 3; dy++) {
        b[i * 9 + dx * 3 + dy].first = a[i].first - dx;
        b[i * 9 + dx * 3 + dy].second = a[i].second - dy;
      }
    }
  }
  sort(a, a + n);
  sort(b, b + n * 9);
  long long total = (h - 2) * 1LL * (w - 2);
  for (int i = 0; i < n * 9; i++) {
    int x = b[i].first;
    int y = b[i].second;
    if (i > 0 && x == b[i - 1].first && y == b[i - 1].second) {
      continue;
    }
    if (x < 1 || y < 1 || x > h - 2 || y > w - 2) {
      continue;
    }
    int cnt = 0;
    for (int dx = 0; dx < 3; dx++) {
      for (int dy = 0; dy < 3; dy++) {
        pair<int, int> p = make_pair(x + dx, y + dy);
        int pos = lower_bound(a, a + n, p) - a;
        if (pos < n && a[pos] == p) {
          cnt++;
        }
      }
    }
    ans[cnt]++;
    total--;
  }
  cout << total << endl;
  for (int j = 1; j <= 9; j++) {
    cout << ans[j] << endl;
  }
  return 0;
}


Measured memory_bytes: 12544
#include<cstdio>
using namespace std;
int H,W,h,w,i,j;
long long a[510][510],s;
int main()
{
	scanf("%d%d%d%d",&H,&W,&h,&w);
    int cnt=(H/h)*(W/w);
	int inc=H*W-cnt*h*w;
	if (inc==0)
	{
		printf("No\n");
		return 0;
	}
	int m=cnt/inc+1;//m<=H/h*W/w
    long long M=-(m*(w*h-1)+1);
    if (-M>1e9)
    {
		printf("No\n");
		return 0;
	}
	//ans=inc*?-cnt
	for (i=1;i*h<=H;i++)
	  for (j=1;j*w<=W;j++)
	    a[i*h][j*w]=M;
	for (i=1;i<=H;i++)
	  for (j=1;j<=W;j++)
	    if (a[i][j]==0)
	      a[i][j]=m;
	printf("Yes\n");
	for (i=1;i<=H;i++)
	   for (j=1;j<=W;j++)
	   {
	     printf("%lld",a[i][j]);
	     if (j!=W) printf(" ");
		 else printf("\n");
	   }
}

Measured memory_bytes: 3200
#include<stdio.h>

int main(){
	int x,a,b;
	scanf("%d %d %d", &x,&a,&b);
	int xa,xb;
	if(x>a){
		xa=x-a;
	}
	else xa=a-x;
	if(x>b){
		xb=x-b;
	}
	else xb=b-x;
	if(xa<xb){
		printf("A");
	}
	else printf("B");
	return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		char[][] A = new char[N][N];
		char[][] B = new char[M][M];
		for (int i=0; i<N; i++) {
			char[] t = sc.next().toCharArray();
			for (int j=0; j<N; j++) {
				A[i][j] = t[j];
			}
		}
		for (int i=0; i<M; i++) {
			char[] t = sc.next().toCharArray();
			for (int j=0; j<M; j++) {
				B[i][j] = t[j];
			}
		}
		boolean exist = false;
		for (int i=0; i<N; i++) {
			for (int j=0; j<N; j++) {
				if ( j+M-1>=N || i+M-1>=N ) continue;
				boolean flg = true;
				for (int k=0; k<M; k++) {
					for (int l=0; l<M; l++) {
						if ( A[i+k][j+l] != B[k][l] ) flg = false;
					}
				}
				if (flg) exist = true;
			}
		}
		if (exist) System.out.println("Yes");
		else System.out.println("No");
	}
}


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

using namespace std;

int N;
string S;

int main() {
  cin >> N >> S;
  
  int ans = 0;
  for(int i = 1; i < N; i++){
    string s1 = S.substr(0, i);
    string s2 = S.substr(i, N-i);
    int ctn = 0;
    for(int j = 0; j < 26; j++){
      bool flag1 = false;
      bool flag2 = false;
      for(int k = 0; k < s1.length(); k++){
        if(s1[k] - 'a' == j) flag1 = true;
      }
      for(int k = 0; k < s2.length(); k++){
        if(s2[k] - 'a' == j) flag2 = true;
      }
      if(flag1 && flag2) ctn++;
    }
    if(ctn > ans) ans = ctn;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF  1001001001;
#define PI  3.14159265358979323846;
 
int main(){
 // グリッドの高さ、幅、スタート点、ゴール点の座標受け取り
    int H,W,count_white=0;
    cin>>H>>W;

    // グラフ入力受取 (ここでは無向グラフを想定)
    vector<vector<char>> G(H,vector<char>(W+1));
    rep(i,H){
        rep(j,W){
            cin>>G[i][j];
            if(G[i][j]=='.'){
                count_white++;
            }

        }
    }


    // BFS のためのデータ構造
    vector<vector<int>> min_white(H,vector<int>(W,-1)); // 全頂点を「未訪問」に初期化
    queue<int> que_y,que_x;

    // 初期条件 (頂点 (sx,sy) を初期ノードとする)
    min_white[0][0] = 1;
    que_y.push(0);
    que_x.push(0); 
    //移動方法4通り
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que_x.empty()) {
        int y = que_y.front(); // キューから先頭頂点を取り出す
        que_y.pop();
        int x = que_x.front();
        que_x.pop();

        // (x,y) から辿れる頂点をすべて調べる
       rep(i,4) {
            if ((x+dx[i]>=0)&&(x+dx[i]<W)&&(y+dy[i]>=0)&&(y+dy[i]<H)&&(G[y+dy[i]][x+dx[i]]=='.')){ //道でなければ飛ばす
            if(min_white[y+dy[i]][x+dx[i]] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな頂点について距離情報を更新してキューに追加する
            min_white[y+dy[i]][x+dx[i]] = min_white[y][x] + 1;
            que_y.push(y+dy[i]);
            que_x.push(x+dx[i]);
            }
        }
    }
    if(min_white[H-1][W-1]==-1){
        cout<<-1<<endl;
    }
    else{
        cout<<count_white-min_white[H-1][W-1]<<endl;

    }
return 0;
}

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

using namespace std;

int N,V,P;
long long int M, A[100005];

vector<long long int > W;

long long int INF = 9999999999999999;

int check[100005];

vector<long long int> H;

long long int c[100005];

int IsPossible(int k) {

	if (k <= 0) { return -1; }

	H.clear();

	for (int i = 1; i <= N; i++) { c[i] = 0; }

	long long int rem = M*V;
	c[k] = M; rem -= M;

	long long int tmp;

	for (int i = 1; i <= N; i++) {
		if (i == k) { continue; }

		if (i < k) { tmp = min(M, rem);  c[i] = tmp;  rem -= tmp; }
		else if ((i > k) && (W[k] + c[k] < W[i])) { tmp = min(M, rem); c[i] = tmp; rem -= tmp; }
	}

	for (int i = k + 1; i <= N; i++) {
		if (W[k] + c[k] >= W[i]) {
			tmp = min(rem, W[k] + c[k] - W[i]); c[i] += tmp; rem -= tmp;
		}
	}

		for (int i = N; i >= 0; i--) {
			if (c[i] < M && rem>0) {
				tmp =min( M - c[i],rem);
				c[i] += tmp; rem -= tmp;
			}
		}

		for (int i = 1; i <= N; i++) {
			H.push_back(W[i] + c[i]);
		}

		sort(H.rbegin(), H.rend());

		int pos = 0;

		for (int i = 0; i < N; i++) {
			if (W[k] + c[k] == H[i]) { pos = i + 1; break; }
		}

		if (pos <= P) { return 1; }
	


	/*for (auto y : H) {
		cout << " " << y;
	}cout << endl;
	*/
	return -1;
}

int Binary_Search(void) {

	int left = 0;
	int right = N;

	int med;

	while (right >left+1) {
		med = (right + left) / 2;

		if (IsPossible(med) == 1) { right = med; }
		else { left = med; }
	}

	return right;
}

int main(void) {

	cin >> N >> M>>V>>P;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		W.push_back(A[i]);
	}

	W.push_back(-INF);

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

	//for (auto y : W) { cout << " " << y; }cout << endl;


	//cout << "i= 3 " << IsPossible(3) << endl;
	/*for (int i = 0; i <= N; i++) {
		cout << "i= " << i <<" W["<<i<<"]= "<<W[i]<< endl;
		cout << W[i] << " " << IsPossible(i) << endl;
	}*/

	//cout << Binary_Search() << endl;

	cout << N - Binary_Search() + 1 << endl;

	return 0;
}

Measured memory_bytes: 4084
'use strict'
const main = (input: string) => {
    const std: string[] = input.split('\n')
    const n: number = ~~std.shift()
    const s: string = std.shift()
    if (n === 1) {
        return console.log('No')
    }
    const left = s.slice(0,n/2)
    const right = s.slice(n/2)
    console.log(left === right ? 'Yes' : 'No')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7372
import java.util.List;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

	public static void main(String[] args) {

		Input stdIn = new Input();
		List<Integer> inputline = stdIn.getLine();
		int x = inputline.get(0);
		int y = inputline.get(1);
		int q,r;

		while(true) {
			q = x / y;
			r = x % y;
			if (r == 0) {
				System.out.println(y);
				break;
			} else {
				x = y;
				y = r;
			}
		}
	}
}
class Input{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public Input() {
	}

	public int getValue() {
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return n;
	}

	public List<Integer> getLine() {
		try {
			String[] s = br.readLine().trim().split(" ");
			List<Integer> ary = new ArrayList<>();
			for (int i = 0; i < s.length; i++) {
				ary.add(Integer.parseInt(s[i]));
			}
			return ary;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	public void close() {
		try {
			br.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24180
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define par pair<pair<int,int>, int>
#define f first
#define s second

int n,k,d,c;
double ans,p,s;

int main() {
    scanf("%d%d",&n,&k);
    d = n-k+1;
    p = 1.0/n;
    if(d > 0) ans = p*d;
    for(int i=1; i<min(n+1,k); i++)
    {
        c = 0;
        for(int x=i; x<k; x*=2) c++;
        s = pow(0.5,c);
        ans += p*s;
    }
    printf("%.12lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];
bool F[1000010];
int num[1000010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		num[A[i]]++;
	}
	sort(A,A+N);
	int ans=0;
	REP(i,N){
		if(F[A[i]]==true)continue;
		int t=A[i];
		while(t<=1000000){
			F[t]=true;
			t+=A[i];
		}
		if(num[A[i]]==1){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 13776
#include <stdio.h>
#include <stdlib.h>
int main(void){
    char map[9][6]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"},suzi[2];
    int num,i,o,mozi=0;
    scanf("%d",&num);
    scanf("%1c",&suzi[0]);
    for(i=0;i<num;i++){
        o=-1;
        for(scanf("%1c",&suzi[0]);suzi[0] != '\n';scanf("%1c",&suzi[0])){
            if('0' == suzi[0]){
                if(mozi-1 == 0)
                    o%=5;
                else if(mozi-1 == 6 || mozi-1 == 8)
                    o%=4;
                else
                    o%=3;
                if(mozi != 0)
                printf("%c",map[mozi-1][o]);
                mozi=0;
                o=-1;
            }
            else{ 
                mozi=atoi(suzi);
                o++;
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 568
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<int> t(n), v(n);
    rep(i, n) cin >> t[i];
    rep(i, n) cin >> v[i];

    const int max_v = *max_element(v.begin(), v.end());
    constexpr int zoom = 2;

    vector<double> cur(zoom * max_v + 3, - INFINITY);
    vector<double> pre(zoom * max_v + 3, - INFINITY);

    cur[0] = 0;
    rep(i, n) {
        fill(cur.begin() + (zoom * v[i] + 1), cur.end(), - INFINITY);
        fill(pre.begin() + (zoom * v[i] + 1), pre.end(), - INFINITY);

        rep(tick, zoom * t[i]) {
            cur.swap(pre);
            cur[0] = max(pre[0], pre[1] + 0.5 / zoom);

            loop(a, 1, zoom * v[i] + 1) {
                cur[a] =
                    max({ pre[a - 1] - 0.5 / zoom,
                          pre[a],
                          pre[a + 1] + 0.5 / zoom })
                    + a / (double)(zoom * zoom);
            }
        }
    }
    printf("%.12lf\n", cur[0]);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size();
  long long sum = 0;
 
  for(int temp = 0; temp < (1 << n-1); temp++){
  long long t = s[0] - '0';
 
    for(int i = 0; i < n-1; i++){
 
      if(temp & (1 << i)){ 
        sum += t;
        t = s[i+1] - '0';
      }
      else{
        t *= 10;
        t = t + s[i+1] - '0';
      }
    }
    sum = sum + t;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
using System;

namespace atCoder
{
    class Program
    {
        static void Main()
        {
            string[] temp = Console.ReadLine().Split(' ');
            int a = int.Parse(temp[0]);
            int b = int.Parse(temp[1]);
            int c = int.Parse(temp[2]);
            int d = a % b;

            while (d != 0)
            {
                d = (a + d) % b;

                if (d == c)
                {
                    Console.WriteLine("YES");

                    return;
                }
            }

            Console.WriteLine("NO");
        }
    }
}

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

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

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

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

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

  ll n;
  std::string s;
  std::cin>>n>>s;

  ll ans=1,query=0;

  rep(i,0,2*n){
    if(s[i]=='B'){
        if(query%2==1){
          ans=(ans*query)%MOD;
          query--;
        }else{
          query++;
        }
    }else{
      if (query % 2 == 0) {
        ans = (ans * query) % MOD;
        query--;
      } else {
        query++;
      }
    }

    if(2*n-1-i<query)ans=0;
  }

  ll temp=1;

  rep(i,1,n+1)temp=(temp*i)%MOD;

  std::cout<<(temp*ans)%MOD;


  return 0;
}

Measured memory_bytes: 720
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTaxRate solver = new BTaxRate();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTaxRate {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            double price = n / 1.08;
            int p = (int) Math.ceil(price);
            if (p * 1.08 - n >= 1) {
                out.println(":(");
                return;
            }
            out.println(p);
        }

    }
}



Measured memory_bytes: 23636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
 
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { //
	return a < b ? a = b, 1 : 0; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// IGNORE
//
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int L, R, d;
	cin >> L >> R >> d;
	cout << R / d - (L - 1) / d << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef		 long long int    ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     print(v)        for(ll i:v) cout<<i<<ss
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
const double eps = 1e-8;


int main()
{

  ll a,b;
  cin>>a>>b;
  cout<<lcm(a,b)<<nn;





}


/* Final check before submit :

1. array size or integer overflow,like uninitialised 0 index.

2. Think twice,code once.check all possible counter test case.

3. Be careful about corner case! n=1?k=1? something about 0?

4. avoid stupid mistake!complexity(t/m)?precision error?submit same code twice?

5. if got WA than remember that you are missing something common.
   *** Be confident!!! who knows? may be your one step back to AC ***
4. minus mod ans=(ans-k+mod)%mod;

*/






Measured memory_bytes: 3636