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

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

#endif


#define mod 1000000007
typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int L;
    cin >> L;
    double r = (double)L/3.0;
    
    cout << r*r*r << endl;

}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#define Re register int
#define LL long long
#define INF 4611686018427387903

int N,K,H[100105];
LL f[100105];

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	var=w?-x:x;
}
inline int abs(int x) {return x<0?-x:x;}
inline LL min(LL a,LL b) {return a<b?a:b;}
int main(int argc, char const *argv[])
{
	read(N),read(K);
	for (Re i=1; i<=N; ++i) read(H[i]),f[i]=INF; f[1]=0;
	for (Re i=1; i<=N; ++i)
		for (Re j=1; j<=K; ++j)
			f[i+j]=min(f[i+j],f[i]+abs(H[i]-H[i+j]));
	printf("%lld\n",f[N]);
	return 0;
}

Measured memory_bytes: 1408
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer[] a = new Integer[9];
        for (int i = 0; i < 9; i++) {
            a[i] = Integer.parseInt(sc.next());
        }
        int n = Integer.parseInt(sc.next());
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        List<Integer> list = Arrays.asList(a);
        for (int i = 0; i < b.length; i++) {
            int index = list.indexOf(b[i]);
            if (0 <= list.indexOf(b[i])) {
                a[index] = 0; 
            }
        }

        String result = isBingo(a) ? "Yes" : "No";

        // 出力
        System.out.println(result);
        sc.close();
    }

    public static boolean isBingo(Integer[] a) {
        boolean isBingoLine = (a[0] == 0 && a[1] == 0 && a[2] == 0) || (a[3] == 0 && a[4] == 0 && a[5] == 0) || (a[6] == 0 && a[7] == 0 && a[8] == 0);
        boolean isBingoColumn = (a[0] == 0 && a[3] == 0 && a[6] == 0) || (a[1] == 0 && a[4] == 0 && a[8] == 0) || (a[2] == 0 && a[5] == 0 && a[8] == 0);
        boolean isBingoSlash = (a[0] == 0 && a[4] == 0 && a[8] == 0) || (a[2] == 0 && a[4] == 0 && a[6] == 0);
        return isBingoLine || isBingoColumn || isBingoSlash;
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define MAX 2000010
#define MOD 1000000007
using namespace std;

int factorial[MAX];
int inverse[MAX];
int invFact[MAX];

inline int add(int a, int b)
{
	return (a + b) % MOD;
}

inline int sub(int a, int b)
{
	return (MOD + a - b) % MOD;
}

inline int prod(int a, int b)
{
	return 1LL * a * b % MOD;
}

void init()
{
	factorial[0] = 1;
	invFact[0] = 1;
	factorial[1] = 1;
	invFact[1] = 1;
	inverse[1] = 1;
	for (int i = 2; i < MAX; i++)
	{
		factorial[i] = prod(factorial[i - 1], i);
		inverse[i] = prod(inverse[MOD % i], MOD - MOD / i);
		invFact[i] = prod(invFact[i - 1], inverse[i]);
	}
}

int main(void)
{
	init();
	int r1, r2, c1, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = 0;
	for (int i = r1; i <= r2; i++)
	{
		ans = add(ans, prod(factorial[i + c2 + 1], prod(invFact[c2], invFact[i + 1])));
		ans = sub(ans, prod(factorial[i + c1], prod(invFact[c1 - 1], invFact[i + 1])));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 23808
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

typedef pair<long long, long long> pl;

long long N, M, k, a, b, c, d, e, H, W,X;
long long A[200001] = {};
long long B[200002] = {};
long long tt[20000] = {};
bool f;
bool ff;
string S, SS;
set <long long>sll;
pl buf;
vector <long long>vpl;



int main() {
	cin >> a>>b>>c;
	d = 0;

	for (long i = a + b; i > 0; i--) {
		if (a%i == 0 && b%i == 0) {
			d++;
		}
		if (d == c) {
			cout << i << endl;
			break;
		}
	}

	

	return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())

K = 1
while K * (K-1) // 2 < N:
  K += 1

if K * (K-1) // 2 != N:
  print("No")
  sys.exit(0)

vs = [ [] for _ in range(K) ]
k = 0
for i in range(K):
  for j in range(K):
    if i <= j: continue
    vs[i].append(k)
    vs[j].append(k)
    k += 1

print('Yes')
print(K)
for v in vs:
  print(len(v), end="")
  print(" ", end="")
  print(" ".join([str(x+1) for x in v]))


Measured memory_bytes: 8948
import sys
input = sys.stdin.readline

S = input()

alphabets = set(chr(ord('a')+x) for x in range(26))

def F(S,alphabets):
    if len(S) == 0:
        return -1
    T = F(S[1:],alphabets-set([S[0]]))
    if T == -1:
        larger = [x for x in alphabets if x > S[0]]
        if not larger:
            return -1
        return min(larger)
    return S[0] + T

answer = F(S,alphabets)
print(answer)


Measured memory_bytes: 3064
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
  ans += B[A[i]-1]
  if i != N-1 and A[i]+1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)

Measured memory_bytes: 3064
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }

    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();

        double ans = 0.0;
        for (int i = 1; i <= n; i++) {
            int tmp = i;
            int p = 0;
            while (tmp < k) {
                tmp *= 2;
                p++;
            }

            ans += Math.pow(0.5, p);
        }
        out.println(ans / n);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

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

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());

    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  string a, b; cin >> a >> b;
  if (a.size() < b.size()) swap(a, b);
  vector<vector<int> > dp(a.size()+1, vector<int>(b.size()+1, 0));
  for (int i = 1; i <= a.size(); i++) {
    for (int j = 1; j <= b.size(); j++) {
      if (a[i-1] == b[j-1]) { 
        dp[i][j] = dp[i-1][j-1] + 1;
      }
      else {
        if (dp[i-1][j] > dp[i][j-1]) dp[i][j] = dp[i-1][j];
        else dp[i][j] = dp[i][j-1];
      }
    }
  }
  int ap=a.size(), bp=b.size();
  string out =  "";
  while (ap > 0 && bp > 0) {
    int up = dp[ap-1][bp], left = dp[ap][bp-1];
    if (a[ap-1] == b[bp-1]) {
      out = a[ap-1]+out;
      ap--; bp--;
    }
    else if (up > left) ap--;
    else bp--;
  }

  cout << out << endl;

  return 0;
}

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

int main()
{
    string str,p1 ,p2;
    cin >> str;
    p1 = str.substr(0, 2);
    p2 = str.substr(2, 2);
    if(stoi(p1)<=12&&stoi(p2)<=12&&stoi(p1)>0&&stoi(p2)>0)
    {
        cout << "AMBIGUOUS";
    }
    else if((stoi(p1)>12||!stoi(p1))&&stoi(p2)>0&&stoi(p2)<=12)
    {
        cout << "YYMM";
    }
    else if((stoi(p2)>12||!stoi(p2))&&stoi(p1)>0&&stoi(p1)<=12)
    {
        cout << "MMYY";
    }
    else
    {
        cout << "NA";
    }
    return 0;
}

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


const int MOD=1e9+7;

inline int add(int a,int b){return (a+=b)>=MOD?(a-MOD):a;}
inline int minus(int a,int b){return (a-=b)<0?(a+MOD):a;}

inline int Pow(int x,int p){
        int ans=1;
        for (;p;p>>=1,x=1LL*x*x%MOD)
                if (p&1)
                        ans=1LL*ans*x%MOD;
        return ans;
}

const int maxn=2e5+10;

int n,ans;
int a[maxn];
int b[maxn];
int F[4010][4010];

int Fac[maxn];
int Facinv[maxn];
inline int C(int n,int m){
        if (n==m||m==0)return 1;
        if (n<m||n<0||m<0)return 0;
        return 1LL*Fac[n]*Facinv[m]%MOD*Facinv[n-m]%MOD;
}

int main (){
#ifdef LOCAL
        freopen("input","r",stdin);
#endif
        Fac[0]=1;
        for (int i=1;i<=2e5;i++)Fac[i]=1LL*Fac[i-1]*i%MOD;
        Facinv[0]=1;
        Facinv[200000]=Pow(Fac[200000],MOD-2);
        for (int i=2e5-1;i>=1;i--)Facinv[i]=1LL*Facinv[i+1]*(i+1)%MOD;
        std::cin >> n;
        for (int i=1;i<=n;i++){
                std::cin >> a[i] >> b[i];
                ++F[2005-a[i]][2005-b[i]];
        }
        for (int i=-2000;i<=2000;i++)
                for (int j=-2000;j<=2000;j++){
                        F[2005+i][2005+j]=add(F[2005+i][2005+j],F[2005+i-1][2005+j]);
                        F[2005+i][2005+j]=add(F[2005+i][2005+j],F[2005+i][2005+j-1]);
                }
        for (int i=1;i<=n;i++){
                ans=add(ans,F[2005+a[i]][2005+b[i]]);
                ans=minus(ans,C((a[i]+b[i])<<1,a[i]<<1));
        }
        ans=1LL*ans*((MOD+1)>>1)%MOD;
        std::cout << ans << '\n';
        return 0;
}



Measured memory_bytes: 69396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    int da=abs(x-a);
    int db=abs(x-b);
    if(da<db)
    {
        printf("A\n");
    }
    else
    {
        printf("B\n");
    }
}



Measured memory_bytes: 256
n, x = [int(item) for item in input().split()]

p_num = []
pb_num = []
for i in range(n+1):
  if i == 0:
    p_num.append(1)
    pb_num.append(1)
  else:  
    p_num.append(p_num[-1] * 2 + 1)
    pb_num.append(pb_num[-1] * 2 + 3)
    
def get_p_num(n, x):
  if n == 0 and x == 1:
    return 1
  
  if x == 1:
    return 0
  elif x < (pb_num[n] + 1)//2:
    return get_p_num(n-1, x-1)
  elif x == (pb_num[n] + 1)//2:
    return p_num[n-1] + 1
  elif x < pb_num[n]:
    return p_num[n-1] + 1 + get_p_num(n-1, x - pb_num[n-1] - 2)
  else:
    return p_num[n-1] * 2 + 1
                 
print(get_p_num(n, x))


Measured memory_bytes: 3064
use std::ascii::AsciiExt;
use std::io::{BufRead, StdinLock};
use std::str::FromStr;

fn read<T: FromStr>(stdin_lock: &mut StdinLock, buf: &mut Vec<u8>, delimiter: u8) -> T {
    buf.clear();
    let l = stdin_lock.read_until(delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n = read(&mut stdin_lock, &mut buf, b' ');
    let k = read(&mut stdin_lock, &mut buf, b'\n');
    let s = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", solve(n, k, s));
}

fn solve(_: u8, k: usize, s: String) -> String {
    let mut chars: Vec<char> = s.chars().collect();
    chars[k - 1] = chars[k - 1].to_ascii_lowercase();
    chars.into_iter().collect()
}

#[test]
fn example1() {
    assert_eq!("aBC", solve(3, 1, "ABC".to_owned()))
}

#[test]
fn example2() {
    assert_eq!("CAbA", solve(4, 3, "CABA".to_owned()));
}


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

using namespace std;

int main() {
  string s;
  cin >> s;
  int a = 0;
  for (int i = 0; i < 4; i++) {
    if (s[i] == '+')
      a++;
    else
      a--;
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc138/tasks/abc138_d
import sys
sys.setrecursionlimit(2*2*10**5)

def dfs(i,p,edges,num):
    
    for j in edges[i]:
        if(j!=p):
            
            num[j] += num[i]
            
            dfs(j,i,edges,num)
    
def input():
    return sys.stdin.readline()[:-1]

N,Q = map(int,input().split())


#隣接リスト
edges = [ [] for i in range(N)]
num = [0]*N


for i in range(N-1):
    a0,b0 = map(int,input().split())

    edges[a0-1].append(b0-1)
    edges[b0-1].append(a0-1)
    
for i in range(Q):
    p0,x0 = map(int,input().split())

    num[p0-1] += x0
    
dfs(0,-1, edges, num)
    
for i in range(N):
    print(num[i], end=" ")


Measured memory_bytes: 231432
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

int N,A[1005];
void solve1(){
	int mx=-inf,idx;
	rep(i,N)if(chmax(mx,A[i]))idx=i;
	cout<<mx<<endl<<N-1<<endl;
	rep(i,idx)cout<<1<<endl;
	for(int i=N-idx;i>=2;i--)cout<<i<<endl;
}
void solve2(){
	int even=0,odd=0;
	rep(i,N){
		if(i&1)odd+=max(0ll,A[i]);
		else even+=max(0ll,A[i]);
	}
	vector<bool>v;
	vector<int>ope;
	rep(i,N){
		if((i&1)&&odd>=even&&A[i]>=0)v.pb(true);
		else if(!(i&1)&&odd<even&&A[i]>=0)v.pb(true);
		else v.pb(false);
	}
	while(v.size()&&!v[0]){
		v.erase(v.begin());ope.pb(1);
	}
	while(v.size()&&!v.back()){
		ope.pb(v.size());v.erase(v.end()-1);
	}
	while(v.size()>1){
		if(v[2]){
			ope.pb(2);v.erase(v.begin());v.erase(v.begin());
		}else {
			ope.pb(3);v.erase(v.begin()+1);v.erase(v.begin()+1);
		}
	}
	cout<<max(even,odd)<<endl<<len(ope)<<endl;
	for(int i:ope)cout<<i<<endl;
}
signed main(){
	cin>>N;
	bool flag=false;
	rep(i,N){
		cin>>A[i];
		flag|=A[i]>=0;
	}
	if(!flag)solve1();
	else solve2();
}


Measured memory_bytes: 3620
class BIT: #0-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0]*(n+1)
        self.depth = n.bit_length()
        self.n0 = 1<<self.depth
#        self.element = [0]*(n+1)
    def get_sum(self, i): #a_0 + ... + a_{i} #閉区間
        s = 0; i += 1
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    def query(self,l,r): #a_l + ... + a_r 閉区間
        return self.get_sum(r) - self.get_sum(l-1) 
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        # self.element[i] += x
    #def get(self,i): return element[i]        
    def bisect_left(self,w):
        #和が w 以上になる最小の index
        #w が存在しない場合 self.size を返す
        if w <= 0: return 0
        x,k = 0,self.n0
        for _ in range(self.depth):
            k >>= 1
            if x+k <= self.size and self.tree[x+k] < w:
                w -= self.tree[x+k]
                x += k
        return x


# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())


n,s,q,*query = read().split()
n = int(n)
q = int(q)

B = [BIT(n) for _ in range(26)]

SS = list(map(lambda x: ord(x)-97,s))
for i,c in enumerate(SS):
    B[c].add(i,1)

for I in range(q):
    l,r,c = query[3*I:3*(I+1)]
    l = int(l)
    r = int(r)-1
    
    if l == 1:
        z = ord(c)-97
        B[SS[r]].add(r,-1)
        B[z].add(r,1)
        SS[r] = z
    else:
        c = int(c)-1
        res = 0
        for i in range(26):
            if B[i].query(r,c):
                res += 1
        print(res)
        








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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll N=in<ll>();
	if(N%2LL) out(0);
	else{
		ll V=N/2LL;
		ll sum=0;
		while(V){
			sum += V/5LL;
			V/=5LL;
		}
		out(sum);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll MOD = 1e9+7;
ll expo(ll a, ll b){
    if(b == 0) 
		return 1;
    ll x = expo(a, b/2);
    return (b & 1 ? ((x*x)%MOD*a)%MOD : (x*x) % MOD);
}

ll fat(int x) {
	ll res = 1;
	for(int i = 1; i <= x; i++)
		res = (res*i)%MOD;
	return res;
}

int main() {
	int x,y;
	cin >> x >> y;
	pii at = {0, 0};
	int t1 = 0, t2 = 0;
	//t1 = (2*x-y)/3;
	//t2 = (y-t1)/2;
	while(at.f != x or at.s != y) {
		if(x-at.f > y-at.s) {
			at.f += 2;
			at.s++;
			t1++;
		}
		else {
			at.s += 2;
			at.f++;
			t2++;
		}
		if(at.f > x or at.s > y) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << (((fat(t1+t2) * expo(fat(t1), MOD-2))%MOD) * expo(fat(t2), MOD-2))%MOD << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

max_l = 1
min_r = N

for i in range(M):
    l, r = map(int, input().split())
    max_l = max(max_l, l)
    min_r = min(min_r, r)
    if max_l > min_r:
        print(0)
        exit()

print(min_r - max_l + 1)

Measured memory_bytes: 45544
a,b,c=map(int, input().split())
k=int(input())
co=0
while not (a<b and b<c):
  if co == k:
    print('No')
    break
  if not a<b:
    b*=2
  else:
    c*=2
  co+=1
  
else:
  print('Yes')
  

Measured memory_bytes: 9168
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()
s=ss()
t=ss()
if len(s) < len(t):
    s,t=t,s
    n,m=m,n

p=n*m//gcd(n,m)
q=gcd(n,m)
if s[0]==t[0]:

    x,y=n//gcd(n,m),m//gcd(n,m)
    cnt=1

    for i in range(gcd(n,m)-1):
        if s[i*x]==t[i*y]:
            cnt+=1
    if cnt==q:
        print(p)
    else:
        print(-1)

else:
    print(-1)
#print(cnt,y)

Measured memory_bytes: 64748
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

    int k;
    int a, b;
    cin >> k;
    cin >> a >> b;
    bool f = false;
    for (int i = a; i <= b; ++i) {
        if (i % k == 0)
            f = true;
    }
    if (f)
        cout << "OK";
    else
        cout << "NG";
    return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		
		int cx[][]=new int[3][3];
		
		int sum=0;
		for(int a=0;a<3;a++) {
			for(int b=0;b<3;b++) {
				cx[a][b]=sc.nextInt();
				sum+=cx[a][b];
			}
		}
		sum/=3;
		int a=cx[0][0]+cx[1][1]+cx[2][2];
		int b=cx[0][1]+cx[1][2]+cx[2][0];
		int c=cx[0][2]+cx[1][0]+cx[2][1];
		
		if(a==sum&&b==sum&&c==sum) {
			p("Yes");
		}else {
			p("No");
		}
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23124
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define badi_val 1000000007
int n;
int pd[1100];
const int mo=1e9+7;
int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;i++)
		for (int j=i+i;j<=n;j+=i) pd[j]=1;
	int ans=1;
	for (int i=2;i<=n;i++)
		if (pd[i]==0){
			int tot=0;
			for (int j=i;j<=n;j*=i) tot+=n/j;
			ans=1ll*ans*(tot+1)%mo;
		}
	cout<<ans<<endl;
}

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

using namespace std;

#define SZ(x) ((int) (x).size())
typedef long long ll;

const int N = 123456;

int n;
vector<int> e[N];

ll grundy(int u, int p = -1) {
    ll g = 0;
    for (int v: e[u]) {
        if (v == p) continue;
        g ^= grundy(v, u);
    }
    return g + (p != -1);
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }

    ll g = grundy(1);
    puts(g ? "Alice" : "Bob");
}


Measured memory_bytes: 11008
#include <iostream>
#include <bits/stdc++.h>
#define loop(N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
using namespace std ;
void ps(string i){
    cout << i << endl;
}

template <class T>
void pt(T s){
    cout << s << endl;
}

void pi(int i){
    cout << i << endl;
}

template <class T>
void pv(vector<T> v){
    loop(v.size()){
        pt<T>(v[i]);
    }
}



/*********************************asserting****************************/

template <class T>
void asserty(T in,T out){

    if(in != out){
        ps("Test not passed:");
        pt<T>(in);
        ps("expected :");
        pt<T>(out);
    }
}

void assertv(vi in,vi out){
    bool equals = true;
    if( in.size()!=out.size()){
        equals = false;
    }else{
        loop(in.size()){
            if(in[i]!=out[i]){
                equals = false;
                break;
            }

        }

    }

    if(!equals){
        ps("Test not passed:");
        pv<int>(in);
        ps("expected :");
        pv<int>(in);
    }
}

/*********************************reused****************************/
string s;
int t[4];
bool op[3];
bool dp(int k=0,int r=0){
    //cout<<k<<"  "<<r<<endl;
    if(k==0)
        return dp(1,t[0]);
    if(k==4){
       return r==7;
    }
    op[k]=true;
    if(dp(k+1,r+t[k]))
        return true;
    op[k]=false;
    if(dp(k+1,r-t[k]))
        return true;
    return false;
}
int main()
{
    cin>>s;
    loop(4){
        t[i]=s[i]-'0';
    }
    dp();
    cout<<t[0];
    loop(3){
        cout<<(op[i+1]?'+':'-')<<t[i+1];
    }
    cout<<"=7"<<endl;
    return 0;
}



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

bool isok(int n, int *arr, int maxTillNow, int k) {
	int count = 0;
	for(int i = 0; i < n; i++) {
		if(arr[i] > maxTillNow) {
			count += (arr[i]-1) / maxTillNow;
			// count --;
		}
		if(count > k) return false;
	}
	return true;
}

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

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

	// int low = INT_MAX;
	int low = 1;
	int high = INT_MIN;

	for(int i = 0; i < n; i++) {
		// low = min(low, arr[i]);
		high = max(high, arr[i]);
	}

	int ans;
	while(low <= high) {
		int mid = (low+high) / 2;

		if(isok(n, arr, mid, k)) {
			high = mid - 1;
			ans = mid;
		} else {
			low = mid + 1;
		}
	}
	cout << ans;


	return 0;
}

Measured memory_bytes: 5060
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll=long long;
using ld=long double; 
using namespace std;
//const int INF = 7+(1e+9);
ll GCD(ll x, ll y)
{
    if (y == 0)
    {
        return x;
    }
    else
    {
        return GCD(y, x % y);
    }
}
ll LCM(ll x, ll y)
{
    return x / GCD(x, y) * y;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll MOD=1e9+7;

int main(){
    string s;
    cin>>s;
    vector<bool> vec(26,false);
    for(int i=0;i<s.size();i++){
        if(!vec[s[i]-'a']){
            vec[s[i]-'a']=true;
        }else{
            cout<<"no"<<endl;
            return 0;
        }
    }
    cout<<"yes"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int n,r ;
    cin >> n >> r ;
    if (n <10)
    {
        r += 100*(10-n) ;
    }
    cout << r << endl ;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a,b,c;

    cin >> a >> b >> c;

    if(a == b  && b == c){
        printf("No\n");
        return 0;
    }else if(a == b || b == c || c == a){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  const int N = 1e4 + 42;
  const int n = 105;
  array<int, N> ans{};
  for (int x = 1; x < n; ++x) {
    for (int y = 1; y < n; ++y) {
      for (int z = 1; z < n; ++z) {
        int v = x * x + y * y + z * z + x * y + y * z + z * x;
        if (v < N) ans[v]++;
      }
    }
  }
  int u; cin >> u;
  for (int i = 1; i <= u; ++i) {
    cout << ans[i] << '\n';
  }
}


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

void next(int *x,int n);

int main(void){
    int H,W,K,ans=0;
    cin >> H >> W >> K;
    char c[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) cin >> c[i][j];
    }
    int x[H]={0},y[W]={0};
    bool jx=true;
    while(jx){
        bool jy=true;
        while(jy){
            char d[H][W];
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++) d[i][j]=c[i][j];
            }
            for(int i=0;i<H;i++){
                if(x[i]==1){
                    for(int j=0;j<W;j++) d[i][j]='r';
                }
            }
            for(int j=0;j<W;j++){
                if(y[j]==1){
                    for(int i=0;i<H;i++) d[i][j]='r';
                }
            }
            int count=0;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(d[i][j]=='#') count++;
                }
            }
            if(count==K) ans++;
            int jugy=0;
            for(int i=0;i<W;i++) jugy+=y[i];
            if(jugy==W) jy=false;
            next(y,W);
        }
        int jugx=0;
        for(int i=0;i<H;i++) jugx+=x[i];
        if(jugx==H) jx=false;
        next(x,H);
    }
    cout << ans << endl;
    return 0;
}

void next(int *x,int n){
    int j;
    j=n-1;
    do{
        x[j]=1-x[j];
        j--;
    }while(x[j+1]==0);
    return;
}

Measured memory_bytes: 3632
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;


int main(){ 
    vector<int> nums(120, 0);

    int n, b, f, r, v;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> b >> f >> r >> v;

        int index = (b-1) * 30 + (f-1) * 10 + (r-1);
        nums[index] += v;
    }

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

        for(int f = 0; f < 3; ++f){
            int offset_f  = f * 10;

            for(int r = 0; r < 10; ++r){
                int index = offset_b + offset_f + r;
                cout << " " << nums[index];
            }
            cout << endl;
        }
        if(i != 3){
            cout << "####################" << endl;
        }
    }
}




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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int D;
    cin >> D;
    if(D==22) cout << "Christmas Eve Eve Eve" << endl;
    else if(D==23) cout << "Christmas Eve Eve" << endl;
    else if(D==24) cout << "Christmas Eve" << endl;
    else cout << "Christmas" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   int x,y; cin >> x >> y;
   int b = y - 2*x;
   if(b >= 0 and b%2 == 0) {
      b/=2;
      int a = x - b;
      if(a >= 0) {
         cout << "Yes\n";
         return 0;
      }
   }  
   cout << "No\n";
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(s) s.begin(),s.end()
#define sz(s) (int)s.size()
#define clr(v, d) memset(v, d, sizeof(v))
#define fi first
#define se second
#define pp push_back
#define pb pop_back
#define pi 3.141592654
#define MOD 1000000007 
#define cons1 1e12
#define cons2 1e6
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pa;
typedef unsigned long long int ull;
typedef double long dl;
const int N = 1e5+9;
int n;
int v[N], ans[N];
int sol(int i) {
	if (ans[i] == -1) {
		if (i == n - 1)
			ans[i] = 0;
		else if (i == n - 2)
			ans[i] = abs(v[i] - v[i + 1]);
		else 
			ans[i] = min(abs(v[i] - v[i + 1])+sol(i + 1)
				, abs(v[i] - v[i + 2]) + sol(i + 2));
		
	}
	return ans[i];
	
}
void solve() {
	clr(ans, -1);
	cin >> n;
	rep(i, 0, n)
		cin >> v[i];
	cout << sol(0) << endl;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
	//cin >> t;
	while (t--)
		solve();

#ifndef ONLINE_JUDGE
	- system("pause");
#endif

}

Measured memory_bytes: 2808
require 'pp'
require 'set'
N,K = readline.chomp.split.map(&:to_i)

all_sushi = N.times.each.map {|i| readline.chomp.split.map(&:to_i) }.sort_by {|t,d| -d}
#pp all_sushi

selected = (0...K).to_a.reverse

tmax = all_sushi.map {|t,d| t}.uniq.size
#pp tmax

selected_types = Hash.new { 0 }
selected.each do |i|
  t = all_sushi[i][0]
  selected_types[t] += 1
end
#pp selected, selected_types

dscore = selected.map {|i| all_sushi[i][1] }.inject(:+)
tscore = selected_types.size * selected_types.size

max_score = dscore + tscore

not_selected_top_idx = K
selected_top_idx = 0
#pp max_score
while selected_types.size < [K,tmax].min
  rmv_idx = (selected_top_idx...selected.size).find do |i|
    t = all_sushi[ selected[i] ][0]
    selected_types[t] > 1
  end
  selected_top_idx = rmv_idx + 1

  rmv = selected[rmv_idx]
  removed_type = all_sushi[rmv][0]
  selected_types[removed_type] -= 1
  dscore -= all_sushi[rmv][1]

  aidx = (not_selected_top_idx...N).find do |i|
    t = all_sushi[i][0]
    selected_types[t] == 0
  end
  #pp "aidx : #{aidx}"
  not_selected_top_idx = aidx + 1
  selected[rmv_idx] = aidx
  selected_types[ all_sushi[aidx][0] ] += 1
  dscore += all_sushi[aidx][1]
  tscore = selected_types.size * selected_types.size

  if dscore + tscore > max_score
    max_score = dscore + tscore
  end
  #pp "dscore: #{dscore}, tscore : #{tscore}, selected_types : #{selected_types.inspect}"
end

puts max_score

# pp score( all_sushi[0..(K-1)] )



Measured memory_bytes: 21492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
long double EPS=1E-8;
////////////////////////////////////////

int main(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll dp[n+1][5];
    rep(j,0,4)dp[0][j]=0;
    rep(i,1,n)rep(j,0,4)dp[i][j]=inf;
    rep(i,1,n){
        rep(j,0,4){
            rep(k,0,j){
                Min(dp[i][j],dp[i-1][k]);
            }
        }
        if(a[i-1]==0){
            dp[i][1]+=2;
            dp[i][2]+=1;
            dp[i][3]+=2;
        }else if(a[i-1]%2==1){
            
            dp[i][0]+=a[i-1];
            dp[i][1]+=1;
            dp[i][3]+=1;
            dp[i][4]+=a[i-1];
        }else{
            
            dp[i][0]+=a[i-1];
            dp[i][2]+=1;
            dp[i][4]+=a[i-1];
        }
    }
    /*rep(i,0,n){
        rep(j,0,4){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    ll ans=inf;rep(j,0,4)Min(ans,dp[n][j]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.nextLine().split("");
		String[] p = sc.nextLine().split("");
		
		for(int i=0; i<s.length; i++){
			boolean flag = true;
			for(int j=0; j<p.length; j++){
				if(!s[(i+j)%s.length].equals(p[j])){
					flag = false;
					break;
				}
			}
			
			if(flag){
				System.out.println("Yes");
				return;
			}
		}
		
		System.out.println("No");
	}

}

Measured memory_bytes: 26348
#include <bits/stdc++.h>
#include <set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define mod 1000000007
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
void fastio()
{					
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

}
ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}


ll int dp[2001]={0};
void solve()
{
	
	ll int s,i,j;
	cin>>s;
	ll int n=2000;
	dp[0]=1,dp[1]=0,dp[2]=0;
	for(i=1;i<=s;i++)
	{
		for(j=3;j<=n;j++)
		{
			if (j<=i)
			{
				dp[i]=(dp[i]+dp[i-j])%mod;
			}
			else
			{
				dp[i]+=0;
			}
		}
	}
	
	cout<<dp[s]<<endl;



	
	
		
}
int  main()
{
	fastio();
	ll int t;
	t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	

}




Measured memory_bytes: 3644
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	int womb = 0;
	for (int i = 0;i < s.length();++i) {
		if (s[i] == '(')cnt++;
		else cnt--;
		womb = min(womb, cnt);
	}
	cnt += abs(womb);
	for (int i = 0;i < abs(womb);++i) {
		cout << "(";
	}
	cout << s;
	for (int i = 0;i < cnt;++i) {
		cout << ")";
	}
	cout << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n, m;
  cin >> n >> m;

  vector<ll> h(n);
  REP(i, n) { cin >> h[i]; }

  vector<ll> A(n);
  REP(i, n) { A[i] = 1; }

  REP(i, m) {
    ll a, b;
    cin >> a >> b;

    if (h[a - 1] > h[b - 1]) {
      A[b - 1] = 0;
    } else if (h[a - 1] < h[b - 1]) {
      A[a - 1] = 0;
    } else {
      A[a - 1] = 0;
      A[b - 1] = 0;
      continue;
    }
  }
  ll ans = 0;
  REP(i, n) {
    if (A[i] == 1) {
      ans++;
    }
  }
  cout << ans << "\n";
}

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

typedef long long ll;
ll p = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> A(N), c(111111,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
        c[A[i]]++;
    }
    bool F=true;
    if(N%2==0){
        for(int i=0; i<N; i++){
            if(i%2==0){
                if(c[i]!=0) F=false;
            }
            else {
                if(c[i]!=2) F=false;
            }
        }
    }
    else {
        for(int i=0; i<N; i++){
            if(i==0){
                if(c[i]!=1) F=false;
            }
            else if(i%2!=0){
                if(c[i]!=0) F=false;
            }
            else {
                if(c[i]!=2) F=false;
            }
        }
    }
    ll ans=1;
    if(F){
        if(N%2==0){
            for(int i=0; i<N/2; i++){
                ans *= 2;
                ans = ans%p;
            }
        }
        else {
            for(int i=0; i<N/2; i++){
                ans *= 2;
                ans = ans%p;
            }
        }
        cout << ans << endl;
    }
    else
        cout << 0 << endl;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    int a[n];
    f1(i,0,n)
    cin>>a[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    f1(i,2,n)
    {
    	dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string hitachiString = "hi";
  string checkString = hitachiString;
  bool isHi = false;
  for(int i = 0; i < 5; i++){
    if (checkString == s) {
      cout << "Yes" << endl;
      isHi = true;
      break;
    }
    checkString = hitachiString + checkString;
  }
  if(isHi == false){
      cout << "No" << endl;
  }
}

Measured memory_bytes: 256
h, w=gets.split.map(&:to_i)
s=Array.new(h)
h.times{|i| s[i]=gets.chomp}

dir=[[1, 0], [-1, 0], [0, 1], [0, -1]]
ng=false
h.times do |i|
  w.times do |j|
    next if s[i][j]=='.'
    at_least=false
    dir.each do |dd|
      ni, nj=i+dd[0], j+dd[1]
      next if ni<0 or ni>=h or nj<0 or nj>=w
      at_least=true if s[ni][nj]=='#'
    end
    ng=true unless at_least
  end
end

if ng
  puts 'No'
else
  puts 'Yes'
end

Measured memory_bytes: 1788