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

bool imp(string a,string b){
  if(a.size()<b.size())return false;
  for(int i=0;i<(a.length()-b.length());i++){
    if(a.substr(i,b.length())==b)return true;
  }
  return false;
}

int N(string a,string b){
  int res=0;
  for(int i=1;i<=a.length() && i<=b.length();i++){
    if(a.substr(a.length()-i,i)==b.substr(0,i))res=i;
  }
  if(res==0)return b.length();
  return (b.length()-res);
}

int main()
{
  vector<string> s;
  int n;

  while(1){
    cin>>n;
    if(n==0)break;
    s.clear();
    s.resize(n);
    for(int i=0;i<n;i++)cin>>s[i];

    bool flag[14]={};
    for(int i=0;i<s.size();i++){
      for(int j=0;j<s.size();j++){
        if(i==j)continue;
	if(imp(s[i],s[j])){
	  flag[j]=true;
	}
      }
    }
    for(int i=s.size()-1;i>=0;i--){
      if(flag[i])s.erase(s.begin()+i);
    }
    //for(int i=0;i<s.size();i++)cout<<s[i]<<endl;
    int num[14][14];
    for(int i=0;i<s.size();i++){
      for(int j=0;j<s.size();j++){
	if(i==j)num[i][j]=inf;
	else {
	  num[i][j]=N(s[i],s[j]);
	}
      }
    }
    int dp[1<<14][14];
    for(int i=0;i<(1<<14);i++)for(int j=0;j<14;j++)dp[i][j]=inf;
    for(int i=0;i<s.size();i++)dp[1<<i][i]=s[i].length();

    for(int i=0;i<(1<<s.size());i++){
      for(int j=0;j<s.size();j++){
	if((i>>j)%2==1){
	  for(int k=0;k<s.size();k++){
	    if((i>>k)%2==0){
	      int bits=(i|(1<<k));
	      dp[bits][k]=min(dp[bits][k],dp[i][j]+num[j][k]);
	    }
	  }
	}
      }
    }
    int ans=inf;
    for(int i=0;i<s.size();i++){
      ans=min(dp[(1<<s.size())-1][i],ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 2116
# 貪欲法 + 山登り法 + スワップ操作
import time
s__ = time.time()
limit = 1.9
#limit = 10

from numba import njit
import numpy as np

d = int(input())
cs = list(map(int, input().split()))
cs = np.array(cs, dtype=np.int64)
sm = [list(map(int, input().split())) for _ in range(d)]
sm = np.array(sm, dtype=np.int64)

@njit('i8(i8[:], i8)', cache=True)
def total_satisfaction(ts, d):
    ls = np.zeros(26, dtype=np.int64)
    s = 0
    for i in range(d):
        t = ts[i]
        t -= 1
        s += sm[i][t]
        ls[t] = i + 1

        dv = cs * ((i+1) - ls)
        s -= dv.sum()
    return s

@njit('i8[:]()', cache=True)
def greedy():
    ts = np.array([0] * d, dtype=np.int64)
    for i in range(d):
        mx = -1e10
        mxt = None
        for t in range(1, 26+1):
            ts[i] = t
            s = total_satisfaction(ts, i + 1)
            if s > mx:
                mx = s
                mxt = t
        ts[i] = mxt
    return ts

@njit('i8(i8, i8[:])', cache=True)
def loop(mxsc, ts):
    it = 50
    rds = np.random.randint(0, 1, (it,))
    rdd = np.random.randint(1, d, (it,))
    rdq = np.random.randint(1, 26, (it,))
    rdx = np.random.randint(1, d, (it,))
    for i in range(it):
        bk1 = 0
        bk2 = 0
        if rds[0] == 0:
            # trailing
            di = rdd[i]
            qi = rdq[i]

            bk1 = ts[di]
            ts[di] = qi
        else:
            # swap
            di = rdd[i]
            xi = rdx[i]
            
            bk1 = ts[di]
            bk2 = ts[xi]
            ts[di] = bk2
            ts[xi] = bk1

        sc = total_satisfaction(ts, d)

        if sc > mxsc:
            #print(mxsc, '->', sc)
            mxsc = sc
        else:
            # 最大値を更新しなかったら戻す
            if rds[0] == 0:
                ts[di] = bk1
            else:
                ts[di] = bk1
                ts[xi] = bk2

    return mxsc

ts = greedy()
mxsc = total_satisfaction(ts, d)
mxbk = mxsc

s_ = time.time()
mxsc = loop(mxsc, ts)
e_ = time.time()

consume = s_ - s__
elapsed = e_ - s_
#print('consume:', consume)
#print('elapsed:', elapsed)

if consume < limit:
    lp = int((limit - consume)/ elapsed)
    #print('loop', lp)
    for _ in range(lp):
        mxsc = loop(mxsc, ts)

for t in ts:    print(t)
#print(mxbk, mxsc)
#print(time.time() - s__)


Measured memory_bytes: 122728
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n;
  string s;
  cin>>n>>s;
  n*=2;
  int ans=1,cnt=0;
  for(int i=0;i<n;i++){
    if((s[i]=='B'&&cnt%2==0)||(s[i]=='W'&&cnt%2==1))cnt++;
    else {
      cnt--;
      if(cnt<0){
	cout<<0<<endl;
	return 0;
      }
      ans*=cnt+1;
      ans%=MOD;
    }
  }
  if(cnt!=0){
    cout<<0<<endl;
    return 0;
  }
  for(int i=1;i<=n/2;i++){
    ans*=i;
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,inf=0x3f3f3f3f;
#define mst(a) memset(a,0,sizeof a)
int n,d[N],vis[N],sign[N],m;
vector<int>e[N<<1];
void spfa(){
	queue<int>q;
	for(int i=1;i<=n;i++) d[i]=inf;
	q.push(1);vis[1]=1,d[1]=0;
	while(q.size()){
		int u=q.front();q.pop();vis[u]=0;
		for(auto v:e[u]){
			if(d[v]>d[u]+1){
				d[v]=d[u]+1;
				sign[v]=u;
				if(!vis[v]) q.push(v),vis[v]=1; 
			}
		}
	}
	int ok=0;
	for(int i=2;i<=n;i++) 
	if(d[i]==inf){
		 ok=1;
		 break;
	}
	if(ok) puts("No");
	else {
		puts("Yes");
		for(int i=2;i<=n;i++)
			printf("%d\n",sign[i]);
	}
} 
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u); 
	} 
	spfa();
	return 0;
} 


Measured memory_bytes: 13688
N = int(input())
A = [int(i) for i in input().split()]
r = 1
f = False
for i in A:
    r *= i
    if r > 1000000000000000000:
        f = True
        break
if 0 in A:
    print(0)
elif f:
    print(-1)
else:
    print(r)


Measured memory_bytes: 21664
#include <bits/stdc++.h>
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)

using namespace std;
typedef long long ll;

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

int main()
{
  int N;
  cin >> N;
  
  vector<ll> A(N+1);
  for(int i=0; i<N+1; i++)
    cin >> A[i];

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

  ll count=0;
  for(int i=0; i<N; i++)
    {
      if(B[i]<A[i])
	{
	  count += B[i];
	  A[i]-=B[i];
	  B[i]=0;
	}
      else//B[i]>=A[i]
	{
	  count += A[i];
	  B[i]-=A[i];
	  A[i]=0;
	}
      
      if(B[i]<A[i+1])
	{
	  count += B[i];
	  A[i+1]-=B[i];
	  B[i]=0;
	 
	}
      else
	{
	  count += A[i+1];
	  B[i]-=A[i+1];
	  A[i+1]=0;
	}
    }

  cout << count << endl;

  

  return 0;
}


//cout << setprecision(13);
//next_permutation(v.begin(), v.end());



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <bitset>
#include <cmath>
#include <string>
#include <stdlib.h>

#define ll long long
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)

using namespace std;

int N;
vector<bool> S(100010);

bool solve(bool f, bool s) {
    vector<bool> zoo(N); zoo[0] = f; zoo[1] = s;
    repp(i,1,N-1) {
        if (S[i] == zoo[i]) zoo[i+1] = zoo[i-1];
        else zoo[i+1] = !zoo[i-1];
    }

    if ( ((S[0] == zoo[0]) == (zoo[N-1] == zoo[1])) && ((S[N-1] == zoo[N-1]) == (zoo[0] == zoo[N-2])) ) {
        repp(i,0,N) {
            if (zoo[i]) cout << 'S';
            else cout << 'W';
        }
        cout << endl;
        return true;
    }
    return false;
}

int main() {
    cin >> N;
    string s; cin >> s;
    repp(i,0,N) S[i] = s[i] == 'o';

    bool can = false;
    can |= solve(1,1);
    if (can) return 0;
    can |= solve(1,0);
    if (can) return 0;
    can |= solve(0,0);
    if (can) return 0;
    can |= solve(0,1);
    if (can) return 0;
    cout << -1 << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
string s;
int n;
int cnt[3];

void read_input()
{
    cin >> s;
    n = s.length();
    for(char c: s)
        ++cnt[c - 'a'];
}

void solve()
{
    int temp = *min_element(cnt, cnt + 3);
    for(int i = 0; i < 3; ++i)
        if(cnt[i] - temp >= 2)
        {
            cout << "NO\n";
            return;
        }
    cout << "YES\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}


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


int main() {
    string s;
    std::cin >> s;
    ll n = s.length()+1;
    vector<ll> a(n,0);
    vector<ll> b(n,0);
    
    for (int i = 0; i < n-1; i++) {
        if(s[i]=='<'){
            if(i==0){
                a[i] = 0;
                a[i+1]=1;
            }else{
                a[i+1] = a[i]+1;
            }
        }else{
            if(i==0){
                a[i] = 0;
                a[i+1]=0;
            }else{
                a[i+1]=0;
            }
        }
    }
    
    for (int i = n-2; i >=0; i--) {
        if(s[i]=='>'){
            if(i==n-2){
                b[i+1] = 0;
                b[i]=1;
            }else{
                b[i] = b[i+1]+1;
            }
        }else{
            if(i==n-2){
                b[i+1]=0;
                b[i]=0;
            }else{
                b[i]=0;
            }
        }
    }
    
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += max(a[i],b[i]);
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 8708
class atcorder:
    N=int(input())
    add = list(map(int,input().split()))
    total=0
    for i in range(N):
        total+=add[i]
    y=total/N
    
    i=0
    total=0
    for i in range(N):
        
        total+=(add[i]-round(y))**2
        
    print(int(total))

Measured memory_bytes: 3064
# D - RGB Triplets
from collections import defaultdict


def main():
    _ = input()
    S = input().rstrip()
    indices, doubled_indices = defaultdict(list), defaultdict(set)
    for i, c in enumerate(S):
        indices[c].append(i)
        doubled_indices[c].add(2 * i)
    cnt = len(indices["R"]) * len(indices["G"]) * len(indices["B"])
    for x, y, z in ["RGB", "GBR", "BRG"]:
        cnt -= sum(i + j in doubled_indices[z] for i in indices[x] for j in indices[y])
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9628
M = int(input())
dc = [list(map(int,input().split())) for _ in range(M)]
ans = 0
s = 0
for i in dc:
  d = i[0]
  c = i[1]
  ans += c
  s+=d*c
  if s>=10:
    t = (s-1)//9
    ans+=t
    s-= t*9

ans -= 1
print(ans)

Measured memory_bytes: 45360
#!/usr/bin python3
# -*- coding: utf-8 -*-

n = int(input())
l = list(map(int, input().split()))
l.sort()

ret = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]:
                if l[j]!=l[i] and l[k]!=l[j]:
                    ret += 1
print(ret)


Measured memory_bytes: 9112
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
  Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    new Main().run();
  }

  class Edge {
    boolean x;
    int u;
    int v;
    int cost;
  }

  class UF {
    int[] arr;

    UF(int n) {
      arr = new int[n];
      for (int i = 0; i < n; ++i) {
        arr[i] = i;
      }
    }

    void unite(int a, int b) {
      int A = parent(a);
      int B = parent(b);
      arr[B] = A;
    }

    boolean isSame(int a, int b) {
      int A = parent(a);
      int B = parent(b);
      return A == B;
    }

    int parent(int a) {
      if (a == arr[a]) {
        return a;
      }
      return arr[a] = parent(arr[a]);
    }
  }

  void run() {
    int w = ni();
    int h = ni();
    int[] p = new int[w];
    int[] q = new int[h];
    ArrayList<Edge> list = new ArrayList<>();
    for (int i = 0; i < w; ++i) {
      p[i] = ni();
      Edge e = new Edge();
      e.x = true;
      e.u = i;
      e.v = i + 1;
      e.cost = p[i];
      list.add(e);
    }
    for (int i = 0; i < h; ++i) {
      q[i] = ni();
      Edge e = new Edge();
      e.x = false;
      e.u = i;
      e.v = i + 1;
      e.cost = q[i];
      list.add(e);
    }

    int P = h + 1;
    int Q = w + 1;
    Collections.sort(list, (a, b) -> a.cost - b.cost);
    long sum = 0;
    for (int i = 0; i < list.size(); ++i) {
      Edge e = list.get(i);
      if (e.x) {
        sum += (long) P * (long) e.cost;
        --Q;
      } else {
        sum += (long) Q * (long) e.cost;
        --P;
      }
    }
    System.out.println(sum);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 56120
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;

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

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  string s;
  cin >> s;
  rep (i, s.size()) {
    if (s[i] == '7') {
      Yes;
      return 0;
    }
  }
  No;
  return 0;
}

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

int main(){
    int  N;cin>>N;
    map<string,int>S;
    int num_str=0;
    for(int i=0;i<N;i++){
        string tmp;
        cin>>tmp;
        auto itr=S.find(tmp);
        if(itr!=S.end())S[tmp]++;
        else S.insert(make_pair(tmp,1));
        num_str=max(num_str,S[tmp]);

    }
    for(auto x:S){
        if(x.second==num_str)cout<<x.first<<endl;
    }
}

Measured memory_bytes: 26752
#include<stdio.h>

int main(void)
{
	int a,b,c;
	
	//printf("??´??°A");
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b)
	{
		if(b<c)
		{
				printf("Yes\n");
				return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 580
#include<cstdio>
#include<algorithm>
inline void read(int&r)
{
	register char c;r=0;
	do c=getchar();
	while(c<'0'||c>'9');
	do r=r*10+c-'0',c=getchar();
	while(c>='0'&&c<='9');
}

int L=1,first[131073],head[131073],_L,n;
struct ac{ int to,nx; }e[1000000];
inline void addedge(int u,int a,int v,int b)
{
	u=u<<1|a^1,v=v<<1|b^1;
	e[L].to=v,e[L].nx=first[u],first[u]=L++;
	u^=1,v^=1;
	e[L].to=u,e[L].nx=first[v],first[v]=L++;
}


int st[131073],top;
int b[131073],timer;
bool dfs(int u)
{
	if(b[u^1]==timer)
		return false;

	b[u]=timer;
	st[top++]=u;

	for(int j=first[u];j;j=e[j].nx)
		if(!(b[e[j].to]==timer||dfs(e[j].to)))
			return false;
	return true;
}


bool check(int u)
{
	top=0;
	if(dfs(u<<1))return true;
	while(top)b[st[--top]]=0;
	return dfs(u<<1|1);
}


#define x first
#define y second
#define lc now<<1
#define rc now<<1|1
std::pair<int,int>a[20000],s[131073];
int pos[10000];

void init(int now=1,int l=0,int r=n-1)
{
	if(l==r)
	{
		if(~pos[a[l].y])
		{
			int u=pos[a[l].y];
			addedge(u,1,now,0);
			addedge(u,0,now,1);
			a[l].y=now;
		}
		else
			a[l].y=pos[a[l].y]=now;
		s[now].x=s[now].y=a[l].x;
		s[rc].x=2e9;
		return;
	}
	int m=(l+r)>>1;
	init(lc,l,m);
	init(rc,m+1,r);
	s[now].x=s[lc].x;
	s[now].y=s[rc].y;
	addedge(now,0,lc,0);
	addedge(now,0,rc,0);
}

void link(int u,int L,int R,int now=1,int l=0,int r=n-1)
{
	if(L<=l&&s[now].y<=R)return addedge(u,1,now,0);
	int m=(l+r)>>1;
	if(L<=m)link(u,L,R,lc,l,m);
	if(s[rc].x<=R)link(u,L,R,rc,m+1,r);
}

void copy(int now=1,int l=0,int r=n-1)
{
	head[now<<1]=first[now<<1];
	head[now<<1|1]=first[now<<1|1];
	if(l<r)
	{
		int m=(l+r)>>1;
		copy(lc,l,m);
		copy(rc,m+1,r);
	}
}

void paste(int now=1,int l=0,int r=n-1)
{
	first[now<<1]=head[now<<1];
	first[now<<1|1]=head[now<<1|1];
	if(l<r)
	{
		int m=(l+r)>>1;
		paste(lc,l,m);
		paste(rc,m+1,r);
	}
}

bool twosat(int now=1,int l=0,int r=n-1)
{
	if(!check(now))return false;
	if(l<r)
	{
		int m=(l+r)>>1;
		if(!twosat(lc,l,m))return false;
		if(!twosat(rc,m+1,r))return false;
	}
	return true;
}



bool work(int d)
{
	L=_L,paste();
	for(int i=0;i<n;i++)
		link(a[i].y,i+1,a[i].x+d-1);

	return ++timer,twosat();
}


int main()
{
	int i,l=1e9,m,r=1;read(n);
	for(i=0;i<n;i++)pos[i]=-1;n<<=1;
	for(i=0;i<n;i++)
	{
		read(a[i].x);
		a[i].y=i>>1;
		a[i].x<l&&(l=a[i].x);
		a[i].x>r&&(r=a[i].x);
	}
	std::sort(a,a+n);

	init(),_L=L,copy();

	r-=l,l=0;
	while(l<r)
	{
		m=(l+r+1)>>1;
		if(work(m))l=m;
		else r=m-1;
	}
	printf("%d\n",l);
}

Measured memory_bytes: 11136
W, H, X = map(int, input().split())
X /= W
if W*H==X:
    print(0)
    quit()
import math
if H*2*X/pow(H,2)<=W:
    print(90 - math.atan(2*X/pow(H,2)) * 180/math.pi)
else:
    angle = 90 - math.atan(W*W/(2*(W*H-X))) * 180/math.pi
    print(angle)


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int 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 COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n, a, b;
signed main() {
	cin >> n >> a >> b;
	COMinit();
	int p = (mod_pow(2, n, mod) - 1 + mod) % mod;
	int q = (comb(n, a) + comb(n, b)) % mod;
	cout << (p - q + mod) % mod << endl;
	ggr
}


Measured memory_bytes: 7936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Card Game
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		final int[] cards = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int c1, c2, c3, own;
			c1 = Integer.parseInt(st.nextToken());
			c2 = Integer.parseInt(st.nextToken());
			c3 = Integer.parseInt(st.nextToken());
			own = c1 + c2;

			boolean[] hands = new boolean[11];
			hands[c1] = hands[c2] = hands[c3] = true;

			int p = 0;
			for (int i = 1; i < 11; i++) {
				if (!hands[i] && cards[i] + own <= 20) {
					p++;
				}
			}

			if (p / 7.0 >= 0.5) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}

	}
	
}

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

int n;
ll ans;
const ll MAXIMUM = 1000000000000000000;

int main() {
  cin >> n;
  vector<ll> a(n-1);
  cin >> ans;
  rep (i, n-1) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  rep (i, n-1) {
    if (ans == 0 || a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (log10((long double)ans) + log10((long double)a[i]) > 18 || ans*a[i] > MAXIMUM) {
      cout << -1 << endl;
      return 0;
    } else {
      ans *= a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4112
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,f,x,y;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	x=a+b+c+d;
	y=101;
	if(y>a)	y=a;
	if(y>b)	y=b;
	if(y>c)	y=c;
	if(y>d)	y=d;
	x=x-y;
	if(e>f)	x=x+e;
	else	x=x+f;
	printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

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

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<vector<edge>> G(N);
  for (ll i = 0; i < M; i++)
  {
    ll L, R, C;
    cin >> L >> R >> C;
    L--, R--;
    G.at(L).push_back(edge(R, C));
    G.at(R).push_back(edge(L, C));
  }
  for (ll i = 0; i < N - 1; i++)
  {
    G.at(i + 1).push_back(edge(i, 0));
  }

  vector<ll> dist(N, -1);
  using pll = pair<ll, ll>;
  priority_queue<pll, vector<pll>, greater<pll>> Q;
  Q.push(make_pair(0, 0));
  while (!Q.empty())
  {
    ll C = Q.top().first, V = Q.top().second;
    Q.pop();
    if (dist.at(V) != -1)
      continue;
    dist.at(V) = C;
    for (edge nvc : G.at(V))
    {
      ll nv = nvc.to, nc = nvc.cost;
      Q.push(make_pair(dist.at(V) + nc, nv));
    }
    //cerr << C << " " << V << endl;
  }
  cout << dist.at(N - 1) << endl;
}

Measured memory_bytes: 16500
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
// #include "atcoder/all"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


// doc: https://shibh308.github.io/library/library/lib/classes/unionfind.cpp.html
struct UnionFind{
    vector<int> par;
    int count;
    UnionFind(int n) : par(n, -1), count(0){}
    int Find(int x){return par[x] < 0 ? x : Find(par[x]);}
    int Size(int x){return par[x] < 0 ? -par[x] : Size(par[x]);}
    bool Unite(int x, int y){
        x = Find(x);
        y = Find(y);
        if(x == y)
            return false;
        if(par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return ++count;
    }
};


void solve(long long n, long long m, std::vector<long long> a, std::vector<long long> b){
    UnionFind uf(n);
    for(int i = 0; i < m; ++i)
        uf.Unite(a[i] - 1, b[i] - 1);
    cout << n - uf.count - 1 << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 5432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int n, k;
  cin >> n >> k;
  vector<ll> dice(n);
  for (int i = 0; i < n; i++) cin >> dice[i];

  for (int i = 1; i < n; i++) dice[i] += dice[i-1];

  ll temp = dice[k-1];
  for (int i = 0; i + k < n; i++) {
    temp = max(temp, dice[i+k] - dice[i]);
    if (dbgflag) cout << temp << endl;
  }

  cout << (temp + k) / 2;
  cout << (((temp + k)%2 == 0) ? ".00000" : ".50000") << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <math.h>
#include <cstdio>
#include <iomanip>
typedef  long long ll;
using namespace std;

int main(void) {
	ll n;
	ll x[100], y[100];
	double d1 = 0, d2 = 0, d3 = 0, d4 = 0;
	cout << fixed << setprecision(10);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> y[i];
	}

	for (int i = 0; i < n; i++)
	{
		d1 += abs(x[i] - y [i]);
		d2 += abs(x[i] - y [i]) * abs(x[i] - y [i]);
		d3 += abs(x[i] - y [i]) * abs(x[i] - y [i])  * abs(x[i] - y [i]);
		d4 = max(d4, (double)abs(x[i] - y [i]) );
	}

	cout << d1 << endl <<sqrt(d2) << endl << pow(d3, (double)1 / 3) << endl << d4 << endl;

	return 0;
}


Measured memory_bytes: 3420
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(i64, X);
    const i64 n = X / 100;
    const int rem = X % 100;

    // dp[i][sum]
    bool dp[1010][1010]{};
    dp[0][0] = true;

    rep(i, 0, n) rep(sum, 0, rem + 1) {
        dp[i + 1][sum] |= dp[i][sum];
        rep(v, 0, 6) { dp[i + 1][sum + v] |= dp[i][sum]; }
    }

    print(dp[n][rem]);

    return 0;
}


Measured memory_bytes: 1280
class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
    
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}

    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]

        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
        else :
            c=self.u
            self.u=self.s
            self.s=self.d
            self.d=self.n
            self.n=c

import random
u,s,e,w,n,d=map(int,input().split())
dice=Dice(u,w,s,e,n,d)
q=int(input())
for i in range(q):
    a,b=map(int,input().split())
    while True:
        dice.rot(random.randint(0,3))
        if(dice.u==a and dice.s==b):
            print(dice.e)
            break

Measured memory_bytes: 11640
#include<iostream>
using namespace std;
unsigned long xor_x=88172645463325252ULL;
unsigned long rng()
{
	xor_x^=xor_x<<7;
	return xor_x^=xor_x>>9;
}
int D;
int c[26],s[365][26];
int t[365],now;
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		now+=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)now-=c[j]*(i-lst[j]);
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	{
		int lst[26];
		for(int i=0;i<26;i++)lst[i]=-1;
		for(int i=0;i<D;i++)
		{
			int x=-1,tc=-1;
			for(int j=0;j<26;j++)
			{
				int u=s[i][j]+c[j]*(i-lst[j])*5;
				if(tc<u)
				{
					tc=u;
					x=j;
				}
			}
			t[i]=x;
			lst[x]=i;
		}
	}
	calc();
	for(int tm=0;tm<1e7;tm++)
	{
		if(rng()&1)
		{
			int d=rng()%D,q=rng()%26;
			int ret=change(d,q);
			if(ret>=0)
			{
				now+=ret;
				t[d]=q;
			}
		}
		else
		{
			int d1=rng()%(D-1)+1,d2;
			if(d1<16)d2=rng()%d1;
			else d2=rng()%16+d1-16;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
	}
	for(int i=0;i<D;i++)cout<<t[i]+1<<endl;
	cerr<<now<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstring>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

map<pair<int, pair<int, pair<int,int>>>, bool > m;
int X, Y, Z;
int n;
int a[100001];
vector<int> v;

void go(int x, int y, int z, int k) {
	if (x == n) {
		cout << "Yes" << '\n';
		for (int next : v) {
			if (next == 0) {
				cout << "A" << '\n';
			}
			else if (next == 1)cout << "B" << '\n';
			else cout << "C" << '\n';
		}
		exit(0);
	}
	if (m[{x, { y,{z,k} }}])return;
	m[{x, { y,{ z,k } }}] = true;


	if (a[x] == 0) {
		if (y - 1 >= 0) {
			v.push_back(1);
			go(x + 1, y - 1, z + 1, k);
			v.pop_back();
		}
		if (z - 1 >= 0) {
			v.push_back(0);
			go(x + 1, y + 1, z - 1, k);
			v.pop_back();
		}
	}
	else if (a[x] == 1) {
		if (y - 1 >= 0) {
			v.push_back(2);
			go(x + 1, y - 1, z , k + 1);
			v.pop_back();
		}
		if (k - 1 >= 0) {
			v.push_back(0);
			go(x + 1, y + 1, z , k - 1);
			v.pop_back();
		}
	}
	else {
		if (z - 1 >= 0) {
			v.push_back(2);
			go(x + 1, y, z - 1, k + 1);
			v.pop_back();
		}
		if (k - 1 >= 0) {
			v.push_back(1);
			go(x + 1, y , z + 1, k - 1);
			v.pop_back();
		}
	}
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cin >> n >> X >> Y >> Z;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		if (s == "AB")a[i] = 0;
		else if (s == "AC")a[i] = 1;
		else a[i] = 2;
	}
	go(0, X, Y, Z);
	cout << "No" << '\n';






}


Measured memory_bytes: 21256
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      
      int array[] = new int[3];
      array[0] = sc.nextInt();
      array[1] = sc.nextInt();
      array[2] = sc.nextInt();
      int x;

      x = array[0] - array[1] - array[2];
      if(x < 0){
        x = x * -1;
      } else {
        x = 0;
      }
      System.out.println(x);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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 long long INF = 1LL << 60;

//bucket1
// bool ch[10] = {0};
// bool check(int n){
//     while(n!=0){
//         if(ch[n%10]) return false;
//         n /= 10;
//     }
//     return true;
// }



// --------write my code!!!!!----------//


int main(){
    int a; cin >> a;
    string s; cin >> s;
    int red=0;
    int br=0;
    for(int i=0; i<a; i++){
        if(s[i]=='R') red++;
        else br++;
    }
    if(red>br) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> tii;
typedef vector<pii> vii;

#define pb push_back
#define mp make_pair
#define sq(a) (a)*(a)
#define rep(i,a,b) for (int i = a; i < b; i++)
#define mod 1e9+7
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	IOS

	int n;
	cin >> n;
	unordered_set<string> s;
	for (int i = 0; i < n; i++)
	{
		string t;
		cin >> t;
		s.insert(t);
	}

	cout << s.size() << endl;

	return 0;
}

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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

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

ll f(ll& a, ll& b) {
	ll ret = min(a, b);

	if(a > b) {
		a -= b;
		b = 0;
	} else {
		b -= a;
		a = 0;
	}

	return ret;
}

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;
	vector<ll> a(n+1), b(n);
	rep(i, n+1) cin >> a[i];
	rep(i, n  ) cin >> b[i];

	ll ret = 0;
	rep(i, n) {
		ret += f(a[i]  , b[i]);
		ret += f(a[i+1], b[i]);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CDiceAndCoin {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            double n = in.nextInt();
            double k = in.nextInt();
            double ans = (n - k + 1) / n;
            if (ans < 0) {
                ans = 0;
            }

            for (int i = 1; i <= k - 1 && i <= n; i++) {
                long temp = i;
                double tt = 0.5;
                while (temp * 2 <= k - 1) {
                    tt /= 2;
                    temp *= 2;
                }
                ans += tt / n;
            }
            out.printf("%.9f", ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define R(a) int a;cin>>a;
#define deb(x) cout<<#x<<" "<<x<<endl;
#define mod 1000000007
#define f_arr(n) for(int i=0;i<n;i++)
#define r_arr(n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define all(x) x.begin(),x.end()
#define inf 1e18
// #define int long long int
using namespace std;

#ifndef ONLINE_JUDGE
template<typename T>    
void __p(T a) {
  cerr<<a;
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cerr<<"[";
  __p(a.first);
  cerr<<",";
  __p(a.second);
  cerr<<"]";
}
template<typename T>
void __p(std::vector<T> a) {
  cerr<<"[";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cerr<<",]"[it+1==a.end()];
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr<<name<<" : ";
  __p(arg1);
  cerr<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cerr.write(names,comma-names)<<" : ";
  __p(arg1);
  cerr<<" | ";
  __f(comma+1,args...);
}
#define trace(...) cerr<<"Line:"<<__LINE__<<" ", __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...)
#endif

void test_case()
{
  R(n);
  vector<int> h(n),dp(n);
  for(int &x : h){
    cin>>x;
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[n-1];
  /*
  #define int long long int
  */
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int t=1;
    // cin>>t;
    while(t--)
    {
        test_case();
    }

    cerr<<endl<<"Time : "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";

    return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using lld=long double;
#define rep( i, a, n ) for( ll i=a; i<n; i++)
#define mp make_pair
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define pii pair<int,int> 
#define pb push_back
#define per( i, a, n ) for( ll i=n-1; i>=a; i--)
#define repp( i, a, n, p ) for( ll i=a; i<n; i+=p)
#define all(c) (c).begin(), (c).end()
#define accu accumulate 

template <typename t> 
inline void print ( const t & v ){
    cout << "Printing the container: " << endl;
    for ( auto i: v) {
        cout << i << " ";
    }
    cout << endl;
}

int main () { 
    string s;
    cin >> s;

    ll count=0;
    ll Max=0;
    rep ( i, 0, s.size() ) {
        if ( s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T') {
            count++;
        }

        else { 
            Max = max ( Max, count);
            count=0;
        }
    }
    Max = max ( Max, count);

    cout << Max << endl;
} 


Measured memory_bytes: 256
from collections import deque

N, K = [int(a) for a in input().split()]
S = input()

L = deque()

n_zero = 0  # 通過した0の塊の数
r = 0 # 連続する0の塊がK個含まれるSの連続部分列の右端の位置
l = 0
# rの値を探す
while r < N and n_zero < K:
    if S[r] == "0": n_zero += 1
    while r < N and S[r] == "0":
        r += 1
    if 0 < r < N and S[r] == "1":
        L.append(r)
    while r < N and S[r] == "1":
        r += 1

ans = r

while len(L) > 0 and r < N:
    l = L.popleft()
    while r < N and S[r] == "0":
        r += 1
    if r < N and S[r] == "1":
        L.append(r)
    while r < N and S[r] == "1":
        r += 1
    ans = max(ans, r - l)

print(ans)

Measured memory_bytes: 4468
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanInt()
	a := make([]bool, 1e6+1)
	a[s] = true

	for i := 0; i < 1e6; i++ {
		if s&1 == 0 {
			s = s / 2
		} else {
			s = 3*s + 1
		}
		if a[s] {
			fmt.Fprintln(wr, i+2)
			return
		}
		a[s] = true
	}
}


Measured memory_bytes: 1820
package main

import "fmt"

// UnionFind is union find structure
type UnionFind struct {
	Par   []int
	Ranks []int
	Sizes []int
}

// NewUnionFind generates a new union find
func NewUnionFind(n int) UnionFind {
	uf := UnionFind{make([]int, n), make([]int, n), make([]int, n)}
	for i := range uf.Par {
		uf.Par[i] = i
		uf.Ranks[i] = 0
		uf.Sizes[i] = 1
	}
	return uf
}

// Root searches the root of the arguement
func (uf UnionFind) Root(x int) int {
	if x == uf.Par[x] {
		return x
	}
	uf.Par[x] = uf.Root(uf.Par[x]) // 経路圧縮
	return uf.Par[x]
}

// Unite unites two trees by adding one root to another
func (uf UnionFind) Unite(x, y int) {
	rx := uf.Root(x)
	ry := uf.Root(y)
	if rx == ry {
		return
	}
	if uf.Ranks[rx] < uf.Ranks[ry] {
		uf.Par[rx] = ry
		uf.Sizes[ry] += uf.Sizes[rx]
	} else {
		uf.Par[ry] = rx
		uf.Sizes[rx] += uf.Sizes[ry]
		if uf.Ranks[rx] == uf.Ranks[ry] {
			uf.Ranks[rx]++
		}
	}
}

// Same returns true when the two are in the same group
func (uf UnionFind) Same(x, y int) bool {
	return uf.Root(x) == uf.Root(y)
}

// Size returns size of a group where x belongs
func (uf UnionFind) Size(x int) int {
	return uf.Sizes[uf.Root(x)]
}

func main() {
	var n, m, k int
	fmt.Scan(&n, &m, &k)
	uf := NewUnionFind(n)

	friends := make(map[int]int)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		uf.Unite(a-1, b-1)
		friends[a-1]++
		friends[b-1]++
	}

	blocks := make([]int, n)
	for i := 0; i < k; i++ {
		var c, d int
		fmt.Scan(&c, &d)
		if uf.Same(c-1, d-1) {
			blocks[c-1]++
			blocks[d-1]++
		}
	}

	for i := 0; i < n; i++ {
		ans := uf.Size(i) - friends[i] - blocks[i] - 1
		fmt.Printf("%v ", ans)
	}
	fmt.Println()
}


Measured memory_bytes: 13316
#include <stdio.h>
#include <stdlib.h>
int main()
{
   int a,b,k;
   scanf("%d%d%d",&a,&b,&k);
   int i;i=a;
   int l=k,h=b-k+1;
     while(k--)
     {
         if(i<=b)
         printf("%d\n",i++);
     }
     if(h<=i)
        h=i;
         while(l--)
         {
             if(h<=b)
            printf("%d\n",h++);
         }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    ll N,M;cin>>N>>M;
    ll ans=1;
    for(ll i=1;i*i<=M;++i){
        if(M%i==0){
            if(i*N<=M) ans=max(ans,i);
            if(N*(M/i)<=M) ans=max(ans,M/i);
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repr(i, n) for (int i = n; i >= 0; --i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int INT_INF = 999999999;
const static llong INF = 1LL << 60;
const static double eps = 1e-6;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

const int MAX = 510000;

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

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

    int h, w, a, b;
    cin >> h >> w >> a >> b;
    COMinit();
    llong res = 0;
    rep(i, h - a) {
        res += COM(b-1+i,b-1)*COM(w-b-1+(h-1-i),w-b-1);
		res%=MOD;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 12160