akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int a[30] = {};
    string s;
    cin>>s;
    int i;
    int n = s.size();
    FOR0(i, n)
        a[s[i]-'A']++;
    int ans = 0;
    FOR0(i, 26) if(a[i]) ans++;
    if(ans > 2) 
    {
        cout<<"No";
        return 0;
    }
    bool is = true;
    FOR0(i, 26)
    {
        if(a[i] > 0 && a[i] != 2) is = false;
    }
    if(is) cout<<"Yes";
    else cout<<"No";
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
def main():
  N,M,*alst=map(int, open(0).read().split())
  mod=10**9+7
  if M==0:
    dp = [0] * (N+1)
    dp[:2] = [1, 1]
    for i in range(2, N+1):
      dp[i] = (dp[i-2] + dp[i-1])%mod
    print(dp[N])
    quit()
  tmp=0
  a0=alst[0]
  alst+=[N+1]
  dp = [0] * (N+1)
  dp[:2] = [1, 1 if alst[tmp]!=1 else 0]
  if a0==1:
    tmp=1
  for i in range(2, N+1):
    if i!=alst[tmp]:
      dp[i] = (dp[i-2] + dp[i-1])%mod
    else:
      tmp+=1
  print(dp[N])
main()

Measured memory_bytes: 13940
N = int(input())
S = input()

cost = list(S).count("E")

ans = 1000000
for si in S:
    if si == "E":
        cost -= 1
    else:
        if cost < ans:
            ans = cost
        cost += 1
else:
    if cost < ans:
        ans = cost
print(ans)

Measured memory_bytes: 5928
import java.util.Scanner;
 
public class Main{
    long count = 0;
 
    public static void main(String[] args) {
        new Main().run();
    }
    private void run() {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        StringBuilder builder = new StringBuilder();
        int[] A = new int[n];
        int[] B = new int[n];
        int K = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            A[i] = scanner.nextInt();
            K = Math.max(K, A[i]);
        }
        CountingSort(A, B, K);
        builder.append(B[0]);
        for (int i = 1; i < n; i++) {
            builder.append(' ').append(B[i]);
        }
        System.out.println(builder);
    }
 
    private void CountingSort(int[] a, int[] b, int k) {
        int[] C = new int[k + 1];
        for (int i = 0; i < a.length; i++)
            C[a[i]]++;
 
        for (int i = 1; i <= k; i++)
            C[i] += C[i - 1];
 
        for (int i = a.length - 1; i >= 0; i--) {
            C[a[i]]--;
            b[C[a[i]]] = a[i];
 
        }
    }
}


Measured memory_bytes: 517072
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  int a, b, total = 0, amtotal = 0, am = 0;
  char c;
  while (cin >> a >> c >> b) {
    total += a * b;
    amtotal += b;
    am++;
  }
  cout << total << endl
    << (int) (round(amtotal / (double) am)) << endl;
}

Measured memory_bytes: 1168
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    int ans = 0;
    rep(i, 0, N) {
        if (i % 2 == 0 && A[i] % 2) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main(void){
  
  int n,i;
  ll a[100005],b[100005],s=0;
  
  cin >> n;
  for (i=0;i<n;i++) cin >> a[i] >> b[i];
  
  for (i=n-1;i>=0;i--){
    a[i]+=s;
    if (a[i]%b[i] > 0){
      s+=b[i]-a[i]%b[i];
    }
  }
  
  cout << s << endl;
  
  return 0;
}

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

using namespace std;

#define MAXN 100000

int a[MAXN+5];
vector<int> v;
map<int,int> id;
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        v.push_back(a[i]);
    }
    int order = 0;
    sort(v.begin(), v.end());
    for (auto k: v) {
        id[k] = order;
        ++order;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (id[a[i]] % 2 != i % 2) {
            ++ans;
        }
    }
    printf("%d\n", ans/2);
    return 0;
}


Measured memory_bytes: 5752
#include<iostream>
using namespace std;
int main(){
	string s; cin >> s;
	int a = (s[0]-'0')*10 + (s[1]-'0');
	int b = (s[2]-'0')*10 + (s[3]-'0');
	if(a>12 || a==0){
		if(b>12 || b==0)	cout << "NA";
		else				cout << "YYMM";
	}else{
		if(b>12 || b==0)	cout << "MMYY";
		else				cout << "AMBIGUOUS";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  ll int n, k;
  cin >> n >> k;
  
  ll int a = n % k;
  if(a == 0){
    cout << "0\n";
    return 0;
  }
  ll int b = a - k;
  b = b * (-1);
  if(a < b){
    cout << a << "\n";
    return 0;
  }
  cout << b << "\n";
}
  

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

using namespace std;

const int INF = 100005;

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

  vector<int> alp(26, INF);
  for (int i = 0; i < n; i++) {
    vector<int> tmp(26, 0);
    string s;
    cin >> s;
    for (int j = 0; j < (int)s.size(); j++) {
      int num = s[j] - 'a';
      tmp[num]++;
    }
    for (int i = 0; i < 26; i++) {
      alp[i] = min(alp[i], tmp[i]);
    }
  }

  if (*max_element(alp.begin(), alp.end()) == 0) {
    return 0;
  }
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < alp[i]; j++) {
      cout << (char)('a' + i);
    }
  }
  cout << endl;

  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vs a(3);
  rep(i,3) cin>>a[i];
  
  vll pos(3);
  ll nxt=0;
  while(true){
    ll prev=nxt;
    // cout<<a[prev][pos[prev]]<<endl;
    
    if(a[prev].size()<=(pos[prev])){
      cout<<char('A'+prev)<<endl;
      return 0;
    }
    
    nxt=a[prev][pos[prev]]-'a';
    pos[prev]++;
    
  }
  
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
A = [int(num) for num in input().split()]

cost_0 = 0
cost_n = 0
for num in A:
  if num < x:
    cost_0 += 1
  else:
    cost_n += 1
  
print(min(cost_0, cost_n))

Measured memory_bytes: 38256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std; 
int main()
{
    std::vector<int> A(3);
    scanf("%d %d %d", &A[0], &A[1], &A[2]);
    std::sort(A.begin(), A.end());
    for(int i = 0; i < A.size(); i++){
        if(i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1048
N,K=map(int, input().split())
H=[0]*N
for i in range(N):
  h=int(input())
  H[i]=h
  
H=sorted(H)
ans=10**9+7
for i in range(N-K+1):
  ans=min(ans, H[i+K-1]-H[i])
  
print(ans)

Measured memory_bytes: 8240
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}

ll test[12345678];
signed main() {
	ll n, m, k, q, a = 0, b = 0, c = 0, cnt = 0, ans = 0; string s, t;
	cin >> s >> t;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] != t[h]) { cnt++; }
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3924
#include<stdio.h>
int main(void)
{  
    int X,Y,Z;
    int tmp;
  
    scanf("%d%d%d",&X,&Y,&Z);
  
      tmp=X;
      X=Y;
      Y=tmp;
  
      tmp=X;
      X=Z;
      Z=tmp;
    
    printf("%d %d %d\n",X,Y,Z);

    return 0;
}
    
  
      
  


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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


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

	int r,g; cin>>r>>g;
	cout<<2*g-r<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ef(i,u) for(int i=b[u];i;i=nxt[i])
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define PII pair<int,int>
#define ull unsigned long long
#define ll long long
#define fi first
#define se second
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
char s[N];
int suf[N],cnt[2020];
int qpow(int a,int b){
    int res=1;
    while(b){
        if(b&1)res=(res*a)%2019;
        a=(a*a)%2019;
        b>>=1;
    }
    return res;
}
int main(){
    cin>>(s+1);
    int n=strlen(s+1),now=0;
    per(i,n,1){
        suf[i]=(suf[i+1]+(s[i]-'0')*qpow(10,now))%2019;
        now++;
    }
    //per(i,n,1)cout<<suf[i]<<'\n';
    int ans=0;
    per(i,n,1){
        if(suf[i]==0)ans++;
        ans+=cnt[suf[i]];
        cnt[suf[i]]++;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 4556
def solve(bfo2, bfo1):
    ans = [bfo2, bfo1]
    for i in s:
        if ((bfo1 == 'S' and i == 'o')
                or (bfo1 == 'W' and i == 'x')):
            ans.append(bfo2)
        elif ((bfo1 == 'S' and i == 'x')
                or (bfo1 == 'W' and i == 'o')):
            ans.append(*({'S', 'W'} - {bfo2}))
        bfo1, bfo2 = ans[-1], bfo1
    if ans[:2] == ans[-2:]:
        print(*ans[1:-1], sep='')
        exit()


n, s = int(input()), input()
for i in ['S', 'W']:
    for j in ['S', 'W']:
        solve(i, j)
print(-1)


Measured memory_bytes: 89784
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N;
    cin >> N;
    vector<int> X(N), L(N);
    rep(i,N) cin >> X[i] >> L[i];
    vector<P> tasks(N);
    rep(i,N) tasks[i] = make_pair(X[i] + L[i], X[i] - L[i]);
    sort(tasks.begin(), tasks.end());
    
    int ans = 1;
    int now_x = tasks[0].first;
    for (int i = 1; i < N; i++) {
        if (now_x <= tasks[i].second) {
            ans++;
            now_x = tasks[i].first;
        }
    }

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >>N;
   vector<int> X(N);
   for (int i = 0; i < N; i++) {
    cin >> X.at(i);
  }
  int ans=10000001;
  for (int P = 1; P <= 100; P++) {
    int now =0;
   for (int i = 0; i < N; i++) {
     now += (X[i]-P)*(X[i]-P);
   }
       ans =min(ans,now);
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 200000 + 50;
int n, k;
struct BIT {
	int tree[MAXN];
	#define lowbit(x) ((-x) & x)
	inline void add(int x, int v) {
		++x;
		while (x <= n) {
			tree[x] += v;
			x += lowbit(x);
		}
	}
	inline int sum(int x) {
		++x;
		int res = 0;
		while (x) {
			res += tree[x];
			x -= lowbit(x);
		}
		return res;
	}
	inline int query(int l, int r) {
		return sum(r) - sum(l - 1);
	}
}	Bit;
int a[MAXN], l[MAXN];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	cin >> n >> k;
	int ans = 1;
	rep (i, 1, n) {
		cin >> a[i];
	}
	per (i, n, 1) {
		if (a[i] < a[i + 1]) l[i] = l[i + 1] + 1;
		else l[i] = 1;
	}
	rep (i, 1, k) {
		Bit.add(a[i], 1);
	}
	int flag = 0;
	if (l[1] >= k) --ans, flag = 1;
	rep (i, 1, n - k) {
		Bit.add(a[i], -1);
		if (l[i + 1] >= k && a[i + 1] < a[i]) --ans, flag = 1;
		if (Bit.query(0, a[i]) || Bit.query(a[i + k], n - 1)) ++ans;
		Bit.add(a[i + k], 1);
	}
	cout << ans + flag << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    int n,m;
    cin >> n >> m;
    vector<string>s(n);
    rep(i,n)cin >> s[i];
    vector<string>p(n),q(n);
    string a,b,c,d;
    rep(i,m){
        if(i!=m-1){
            a.push_back('#');
        }else{
            a.push_back('.');
        }
    }
    rep(i,m){
        if(i!=0){
            b.push_back('#');
        }else{
            b.push_back('.');
        }
    }
    rep(i,m){
        if(i!=0){
            c.push_back('.');
        }else{
            c.push_back('#');
        }
    }
    rep(i,m){
        if(i!=m-1){
            d.push_back('.');
        }else{
            d.push_back('#');
        }
    }
    rep(i,n){
        if(i%2==0){
            p[i] = a;
        }else{
            p[i] = c;
        }
    }
    rep(i,n){
        if(i%2==1){
            q[i] = b;
        }else{
            q[i] = d;
        }
    }
    rep(i,n){
        rep(j,m){
            if(s[i][j]=='#'){
                p[i][j] = '#';
                q[i][j] = '#';
            }
        }
    }
    rep(i,n){
        cout << p[i] << endl;
    }
    cout << endl;
    rep(i,n){
        cout << q[i] << endl;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int result = 800*N - 200*(N/15);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 154 A - Remaining Balls
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/30
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstring>
using namespace std;

char s[10];
char t[10];
char u[10];
int a, b;

void solve() {

    if (!strncmp(u, s, strlen(u)))
        printf("%d %d\n", a-1, b);
    else
        printf("%d %d\n", a, b-1);

}

int main() {

    scanf("%s", s);
    scanf("%s", t);
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%s", u);

    solve();

}

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


void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}


int main()
{
    fastIO();

    map <int, int> mp;
    bool flag = true;
    int n, m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int s, c;
        cin >> s >> c;
        if(mp.find(s) ==  mp.end()){
            mp[s] = c;
        }
        else if(mp[s] != c){
            flag = false;
        }
    }
    if(!flag){
        cout << -1 << '\n';
        return 0;
    }
    if(n!= 1 && mp.find(1)!= mp.end() && mp[1] == 0){
        cout << -1 << '\n';
        return 0;
    }
    if(n == 1 && mp.find(1) == mp.end())
        mp[1] = 0;
    for(int i=1;i<=n;i++){
        if(i == 1 && mp.find(1) == mp.end()){
            mp[1] = 1;
        }
        cout << mp[i];
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

bool ch[202][202];
ll d[202][202];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			d[i][j]=inf;
			char now;
			cin>>now;
			//cout <<now;
			ch[i][j]=now-'0';
			//cout << ch[i][j];
			if(ch[i][j]==1){
			d[i][j]=ch[i][j];
			}
			if(i==j){
				d[i][j]=0;
			}
		}
	}
	for(ll k=0;k<n;k++){
		for(ll i=0;i<n;i++){
			for(ll j=0;j<n;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	//cout << d[0][0];
	ll ans=0;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<n;j++){
			if(i==j){
				continue;
			}
			if(ch[i][j]){
				if(d[0][i]%2==d[0][j]%2){
					cout << -1;
					return 0;
				}
			}
			if(d[i][j]!=inf){
			ans=max(ans,d[i][j]);
			}
		}
	}
	cout <<ans+1;
	// your code goes here
	return 0;
}

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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  int a = a1 + a2 + a3;
  if (a >= 22 ){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

constexpr int MAXN = 100;
int V[MAXN][MAXN];
int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int id, e_num;
        std::cin >> id >> e_num;
        for (int j = 0; j < e_num; j++) {
            int t;
            std::cin >> t;
            V[id - 1][t - 1] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j) std::cout << " ";
            std::cout << V[i][j];
        }
        std::cout << std::endl;
    }
}


Measured memory_bytes: 3132
# ABC106D - AtCoder Express 2
def build_2dcum(A: "Array[Array[int]]") -> "Array[Array[int]]":
    from itertools import accumulate as acc

    return [list(acc(a)) for a in zip(*[acc(a) for a in A])]


def respond_2dcum(l: int, r: int, A: "Array[Array[int]]") -> int:
    return A[r][r] - A[l - 1][r] - A[r][l - 1] + A[l - 1][l - 1]


def main():
    # 2D cumulative sum (naive ver.)
    N, M, Q, *X = map(int, open(0).read().split())
    LR, PQ = X[: 2 * M], X[2 * M :]
    imos = [[0] * (N + 1) for _ in range(N + 1)]
    for l, r in zip(*[iter(LR)] * 2):
        imos[l][r] += 1
    imos = build_2dcum(imos)
    ans = []
    for p, q in zip(*[iter(PQ)] * 2):
        x = respond_2dcum(p, q, imos)
        ans.append(x)
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

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

#define int long long
#define INF (int)0x3f3f3f3f*(int)0x3f3f3f3f
#define db double

#define MAXN 1005
int n,m;
db f[MAXN],g[MAXN];
bool b[MAXN][MAXN];
int du[MAXN];

void get_f()
{
	for(int j = n-1; j >= 1; j --)
	{
		g[j] = 0;
		for(int i = j+1; i <= n; i ++)
		if(b[j][i])  {
			if(du[j] == 0) {
		//		cout<<j<<"???\n";
				while(1);
			}
			g[j] += (g[i]+1)/du[j];
	//		printf("%.3lf %.3lf???\n",g[i],g[j]);
		}
	//	cout<<g[j]<<" "<<j<<"\n";
	//	printf("------%lld %.4lf-----\n",j,g[j]);
	//	if(g[j] >= 100 || g[j] <= -100) while(1);
	}
}

db ans = 1e9;

signed main()
{
	cin >> n >> m;
	for(int i = 1; i <= m; i ++) {
		int x,y;
		cin >> x >> y;
		b[x][y] = 1;
		du[x] ++;
	}
	get_f();
	for(int i = 1; i <= n; i ++)
		f[i] = g[i];
//	for(int i = 1; i <= n; i ++)
//		printf("%.3lf ",g[i]);
//	cout<<"\n";
//	for(int i = 1; i <= n; i ++)
//		cout<<du[i]<<" ";
//	cout<<"\n\n";
//	return 0;
	ans = g[1];
	for(int i = 1; i < n; i ++) {
		if(du[i] == 1) continue;
		db l = 0;
		int u = 0;
		for(int j = i+1; j <= n; j ++)
		if(f[j] > l && b[i][j]) {
			l = f[j];
			u = j;
		}
		b[i][u] = 0;
		du[i] --;
		get_f();
		ans = min(ans,g[1]);
		b[i][u] = 1;
		du[i] ++;
		
	}
	printf("%.7lf",ans);
	return 0;
}

Measured memory_bytes: 896
import sys, math, re
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    D = [list(mi()) for i in range(N)]
    for i in range(N-2):
        if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
            print('Yes')
            return

    print('No')

if __name__ == "__main__":
    main()

Measured memory_bytes: 9956
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        string s; cin >> s;
        if(sz(s)==1){
            cout<<0<<endl;
            return 0;
        }
        int b = 0, w = 0;
        for(int i = 0; i<sz(s)-1; i++){
            if(s[i]==s[i+1]){
                if(s[i]=='1' and s[i+1]=='1'){
                    s[i+1] = '0';
                    b++;
                }
                if(s[i]=='0' and s[i+1]=='0'){
                    s[i+1] = '1';
                    w++;
                }
            }
        }
       cout<<b+w<<endl;

return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  vin a(3);
  rep(i,0,3) cin>>a[i];
  sort(all(a));
  cout<<a[2]-a[0]<<endl;
}

Measured memory_bytes: 3612
a, b, c, d = map(int, input().split())
if a <= c and d <= b:
  print(d - c)
elif c <= a and b <= d:
  print(b - a)
elif a <= d and c <= b :
  print(min(d - a, b - c))
elif (a < b < c < d) or (c < d < a < b):
  print(0)

Measured memory_bytes: 3060
n = int(input())

buttons = [0] * 10**5

for i in range(n):
    buttons[i] = int(input())

next = 1
i = 0
while next != 2:
    i += 1
    next = buttons[next-1]
    if next == 2:
        print(i)
        exit()
    if i >= 10**5:
        print(-1)
        break


Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
int main (){
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    vector <queue <int> > island(n + 1);
    bool ans = false;
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        island[a[i] - 1].push(b[i]);
    };
    while(!island[0].empty()){ 
        while(!island[island[0].front() - 1].empty()){
            if(island[island[0].front() - 1].front() == n)
                ans = true; 
            island[island[0].front() - 1].pop();
        }
        island[0].pop();
    }
    cout << (ans ? "POSSIBLE" : "IMPOSSIBLE" ) << endl;
    return 0;
}

Measured memory_bytes: 136576
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
d = defaultdict(int)
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = tuple(tmp)
    d[tmp] += 1
res = 0
for key in list(d):
    v = d[key]
    res += v*(v-1)//2
print(res)

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

int main(void){
    int N, M; cin >> N >> M;
    int A[M]; for(int i = 0; i < M; i++) cin >> A[i];
    
    int sum_A = 0;
    for(int i = 0; i < M; i++){
        sum_A += A[i];
    }
    
    cout << max(-1, N - sum_A) << endl;
}


Measured memory_bytes: 3664
import copy
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [0] * M
X = [0] * M
for i in range(M):
    P[i], X[i] = map(int, input().split())

for i in range(M):
    T_copy = copy.copy(T)
    drink_number = P[i]
    T_copy[drink_number - 1] = X[i]
    print(sum(T_copy))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
	
using namespace std;


typedef int ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

 
const int MAX = 1e6+10;
const ll inf = 1e9+10;



ll a[MAX],p[MAX];

vi d[MAX];

void divi(ll n){
	if(d[n].size()!=0) return;
	ll fac=p[n],e=0,aux=n;
	while(aux%fac==0) aux/=fac,e++;
	divi(aux);
	ll a=1;
	f(i,0,e+1){
		f(j,0,d[aux].size()){
			d[n].push_back(d[aux][j]*a);
		}
		a*=fac;
	}
}

map<ll,ll> rep;

int main(){
	fastio;
	d[1].push_back(1);
	p[1] = 1;
	f(i,2,MAX){
		if(p[i]==0){
			f(j,1,MAX/i+1){
				if(i*j>=MAX) break;
				p[j*i]=i;
			}
		}
	}
	ll n,ans = 0;
	cin>>n;
	set<ll> s;
	f(i,0,n) cin>>a[i],s.insert(a[i]),rep[a[i]]++;
	f(i,0,n){
		divi(a[i]);
		bool go=true;
		f(j,0,d[a[i]].size()){
			ll dd = d[a[i]][j];
			if(dd==a[i]) continue;
			if(s.count(dd)) go=false;
		}
		if(rep[a[i]]>1) go=false;
		if(go) ans++;
	}
	cout<<ans<<endl;
}	

Measured memory_bytes: 68748
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    char a[114],b[114],c[114];
    scanf("%s %s %s",&a,&b,&c);
    printf("%c%c%c\n",a[0],b[0],c[0]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  string s; cin>>s;
  int n = s.size();
  int d[4]; CLR(d);
  rep(i,n){
    if(s[i]=='N') d[0]++;
    else if(s[i]=='S') d[1]++;
    else if(s[i]=='W') d[2]++;
    else d[3]++;
  }
  if(d[0]||d[1]){
    if(d[0]*d[1]==0) return cout<<"No"<<endl,0;
  }
  if(d[2]||d[3]){
    if(d[2]*d[3]==0) return cout<<"No"<<endl,0;
  }
  cout<<"Yes"<<endl;



  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 100001
#define ll long long
#define rep(i,n) for(int i=0;i<=(n);i++)
using namespace std;
int a[101];
bool f[101];
int main(){
  rep(i,100)a[i]=0;
  int n;
  cin>>n;
    for(int i=2;i<=n;i++){
        a[i]++;
        for(int j=2;j<i;j++){
            if(i%j==0){
                int k=j;
                while(k<=i){
                if(i%k==0)a[j]++;
                k*=j;
                }
            }
        }
    }
    for(int i=2;i<=n;i++){
        if(!f[i]){
            int j=2;
            while(i*j<=n){
                f[i*j]=true;
                j++;
            }
        }
    }
    int a3=0,a5=0,a15=0,a25=0,a75=0;
    for(int i=2;i<=n;i++){
        if(!f[i])if(a[i]>=2){
            a3++;
            if(a[i]>=4){
                a5++;
                if(a[i]>=14){
                    a15++;
                    if(a[i]>=24){
                        a25++;
                        if(a[i]>=74)a75++;
                    }
                }
            }
    
        }
    }
    int ans=a75+a25*(a3-1)+a15*(a5-1)+a5*(a5-1)*(a3-2)/2;
    //cout<<a[3]<<endl;
    /*cout<<a[5]<<endl;
     cout<<a3<<endl<<a5<<endl<<a15<<endl<<a25<<endl<<a75<<endl;*/
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0; long double ans = 0;
  cin >> N;
  vector<long double>A(N);
  rep(i,N){
    cin >> A[i];
    ans += 1/A[i];
  }
  cout << fixed << setprecision(10);
  cout << 1/ans;
}

  

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

int main() {
    int n;
    cin >> n;
    string s;
    map<string,int> S;
    S["AC"]=0;
    S["WA"]=0;
    S["TLE"]=0;
    S["RE"]=0;
    for(int i=0; i<n; i++){
        cin >> s;
        S[s]++;
    }
    cout <<"AC"<< " "<< "x"<< " "<< S.at("AC")<< endl;
    cout <<"WA"<< " "<< "x"<< " "<< S.at("WA")<< endl;
    cout <<"TLE"<< " "<< "x"<< " "<< S.at("TLE")<< endl;
    cout <<"RE"<< " "<< "x"<< " "<< S.at("RE")<< endl;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL x;
    cin>>x;
    FOR(i,-1000,1001){
        FOR(j,-1000,1001){
            if(1LL*i*i*i*i*i-1LL*j*j*j*j*j==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }

}


Measured memory_bytes: 3636
import itertools

N,K = map(int,input().split())
al = ((N-1)*(N-2))//2
if al < K:
    print(-1)
    exit()

result = []
for i in range(1,N):
    result.append((N, i))

it = itertools.combinations(range(1,N), 2)

cnt = 0
for pair in it:
    if cnt >= al - K:
        break
    cnt += 1
    # print(pair[0], pair[1])
    result.append(pair)


print(len(result))
for r in result:
    print(r[0], r[1])

Measured memory_bytes: 44912
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    int ans = 0;

    for(int i = 0; i < n; i++){
        int h;
        cin >> h;

        if(h >= k) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999



struct Seg {
	int btms;//bottom size
	int trs;//tree size
	vector<pair<int, int>> tree;//val, id
};

int N, M;
Seg S;

void init(int N) {
	int btmsiz = 1;
	while (btmsiz < N) (btmsiz <<= 1);
	S.btms = btmsiz;
	S.trs = 2 * S.btms - 1;
	for (int i = 0; i < S.trs; i++)
		S.tree.push_back(make_pair(0, -1));
	return;
}

void update(int nid) {
	nid += S.btms - 1;
	S.tree[nid].first /= 2;
	while (nid) {
		nid = (nid - 1) / 2;
		S.tree[nid] = max(S.tree[nid * 2 + 1], S.tree[nid * 2 + 2]);
	}
	return;
}


int main() {
	cin >> N >> M;
	init(N);
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		S.tree[S.btms - 1 + i] = make_pair(A, i);
	}
	for (int i = S.btms - 2; i >= 0; i--) {
		if (S.tree[i * 2 + 1].first >= S.tree[i * 2 + 2].first)
			S.tree[i] = S.tree[i * 2 + 1];
		else S.tree[i] = S.tree[i * 2 + 2];
	}
	for (LL i = 0; i < M; i++) update(S.tree[0].second);
	LL ans = 0;
	for (int i = 0; i < N; i++) {
		int id = i + S.btms - 1;
		ans += S.tree[id].first;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define tmp(x) std::cout<<"& "<<(x)<<" &\n"
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
typedef long long ll;
#define  pii pair<int,int>
#define  pll pair<ll,ll>
#define  vi vector<int>


using namespace std;
const int maxn=2e5+100;
int n,t;

int main(){
//	freopen("in.txt","r",stdin);
//    ios::sync_with_stdio(false);
//    cin.tie(0);

	int a,b,c,k;
	 cin>>a>>b>>c>>k;
	 int flg=0;
	 rep(i,0,k){
	 	if(((b<<i)>a)&&(c<<(k-i)>(b<<i)))flg=1;
	 }
	 if(flg)cout<<"Yes";
	 else cout<<"No";
	 
 
 
 
 
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    long int N = 0;
    int T  = 0;
    long int x;
    cin >> x;
    while( T < 1e7){
        N = ( N*10 + 7 ) % x;
        T++;
        if (N == 0){
            cout << T << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3168
a,b=map(int,input().split())
s,t=[1],[1]
for i in range(2,int(a**0.5)+1):
    if a%i==0:
        s.append(i)
        while a%i==0:
            a//=i
    if a==1:
        break
if a!=1:
    s.append(a)
for i in range(2,int(b**0.5)+1):
    if b%i==0:
        t.append(i)
        while b%i==0:
            b//=i
    if b==1:
        break
if b!=1:
    t.append(b)
print(len(set(s)&set(t)))

Measured memory_bytes: 40044
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int n,A,B,C;
vi l;

int dfs(int cnt, int a, int b, int c){
  if(cnt == n){
    int ans = 1e9;
    if(a*b*c > 0) ans = abs(A-a) + abs(B-b) + abs(C-c) - 30;
    return ans;
  }
  int ret0,ret1,ret2,ret3;
  ret0 = dfs(cnt+1,a,b,c);
  ret1 = dfs(cnt+1,a + l[cnt], b, c) + 10;
  ret2 = dfs(cnt+1,a, b + l[cnt], c) + 10;
  ret3 = dfs(cnt+1,a, b, c + l[cnt]) + 10;

  int ret = min(ret0,ret1);
  ret = min(ret,ret2);
  ret = min(ret,ret3);
  return ret;

}

int main(){
  cin >> n >> A >> B >> C;
  l.resize(n);
  rep(i,n) cin >> l[i];

  cout << dfs(0,0,0,0) << endl;
}


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


def solve(N: int, K: int, p: "List[int]"):
    p = [(p_ +1)/2 for p_ in p]
    temp = sum(p[0:K])
    max_s = temp

    for i in range(K, N):
        temp = temp - p[i-K] + p[i]
        max_s = max(max_s, temp)
    
    print(max_s)




    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 32540
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <numeric>
#include <string>
#include <bitset>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <cstring>


using namespace std;

int main() {
	string S;
	cin >> S;
	int G;
	G= S.size();
	int sum = 0;
	for (int i = 0; i < G; i += 2) {
		if (S.at(i) == 'L') {
			sum++;
			break;
		}
	}
	for (int i = 1; i < G; i+=2) {
		if (S.at(i) == 'R') {
			sum++;
			break;
		}
	}
	if (sum == 0) {
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	
}

Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cini(n);
    cini(k);
    cinai(a,n);
    for(int i=k; i<n; i++) {
        if(a[i]<=a[i-k]) {
            cout<<"No"<<endl;
        } else 
            cout<<"Yes"<<endl;
    }
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 4780
(defun split (string &key (delimiterp #'(lambda (c) (char= c #\Space))))
  (loop :for beg = (position-if-not delimiterp string)
        :then (position-if-not delimiterp string :start (1+ end))
        :for end = (and beg (position-if delimiterp string :start beg))
        :when beg :collect (subseq string beg end)
        :while end))

(destructuring-bind (a b c) (mapcar #'parse-integer (split (read-line)))
  (format t "~d~%" (min (+ a b) (+ b c) (+ a c))))


Measured memory_bytes: 15848
N = int(input())
B = list(map(int, input().split()))

out = []

for i in range(N):
    cand = []
    for j in range(len(B)):
        if B[j] == j + 1:
            cand.append(j)
    if len(cand) > 0:
        candmax = max(cand)
        out.append(candmax + 1)
        del B[candmax]
    else:
        print(-1)
        exit()
print(*out[::-1])


Measured memory_bytes: 9128
import java.util.*;
class Main {
    public static void main(String[]$) {
        Scanner c=new Scanner(System.in);
        int n=c.nextInt();
        long s=0,a=0;
        Map<Long,Long> m=new HashMap<>();
        m.put(s, 1l);
        while(n-->0){
            s+=c.nextLong();
            long k=m.containsKey(s)?m.get(s):0;
            m.put(s, k+1);
            a+=k;
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 102064
#include<stdio.h>
#include<string.h>
main()
{
    int n,score1=0,score2=0;
    char s1[100],s2[100];
    scanf("%d",&n);
    while(n--)
    {
        scanf("%s %s",&s1,&s2);
        if(strcmp(s1,s2)>0)
            score1+=3;
        if(strcmp(s1,s2)<0)
            score2+=3;
        if(strcmp(s1,s2)==0)
        {
            score1++;
            score2++;
        }
    }
    printf("%d %d\n",score1,score2);
}



Measured memory_bytes: 2044
#include<stdio.h>
#include<stdlib.h>
#define N 1000000000
int main(){
  int x=0,y=0,z=0,w=0,a=0;
  int i;
  scanf("%d%d",&x,&y);
  if(x<=N&&y<=N){
  if(x>y){ z = x%y; w =y;}
  if(y > x){ z = y%x; w =x;}
  if(x==y){ printf("%d\n",x); return 0;}
  }
  a = w%z;
  while(a!=0){
    w=z;
    z=a;
    a=w%z;
  }
  printf("%d\n",z);
  return 0;
}



Measured memory_bytes: 2072