akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
p = gets.split.map(&:to_i)
count = 0
(n-2).times do |i|
  array = [p[i], p[i+1], p[i+2]]
  if array.max == p[i+1]
    next
  end

  if array.min == p[i+1]
    next
  end

  count += 1
end

puts count

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

int main() {
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007

ll gcd(ll A, ll B){
    if(A<B) swap(A,B);
    while(B){
        ll w = A%B;
        A = B;
        B = w;
    }
    return A;
}

ll lcm(ll A, ll B){return A*B/gcd(A,B);}

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

    // solution comes here

    ll N;
    cin >> N;
    cout << lcm(2, N) << nl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define ll long long

int main()
{
	int n;
	cin>>n;
	std::vector<ll> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>v[i];
	}
	ll t=1;
	for (int i = 0; i < n; ++i)
	{
	     t=lcm(v[i],t);
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
import math

n,m = map(int, input().split())

x=int(math.sqrt(m))

ans=1
for i in range(1,x+1):
  if m%i==0:
    if i*n<=m:
      ans=max(ans,i)
    if (m/i)*n<=m:
      ans=max(ans,m/i)
print(int(ans))






Measured memory_bytes: 3060
#include <iostream>
#include <vector>

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

    std::vector<int> p(n);
    for (int i = 0; i < n; i++) std::cin >> p[i];

    int cnt = 0;
    for (int i = 0; i < n - 2; i++) {
        bool g, l;
        g = p[i] > p[i + 1] || p[i + 2] > p[i + 1];
        l = p[i] < p[i + 1] || p[i + 2] < p[i + 1];
        if (g && l) cnt++;
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
 
using namespace std;
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n)
        cin >> a[i];
    sort(a, a + n);
    int sum = 0;
    rep(i, 0, n)
        sum += a[i];
    if (sum % 10)
    {
        cout << sum << endl;
        return 0;
    }
    rep(i, 0, n)
        if (a[i] % 10)
        {
            cout << sum - a[i] << endl;
            return 0;
        }
    cout << 0 << endl;
    return 0;
}

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

int main(){
  int ans=0;
  string S;
  cin >> S;
  for(int i=0; i<S.size()/2; i++){
    if(S.at(i) != S.at(S.size()-i-1))
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N,K;
    char S[51];
    char c;
    scanf("%d %d",&N,&K);
    scanf("%s",&S);
    c = S[K-1] + 0x20;
    S[K-1] = c;
    // printf("%c",c);
    printf("%s",S);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    float x1, x2, x3, y1, y2, y3;
    float px, py, r;
    int i,n;
    
    scanf("%d0.0", &n);
    for (i=0; i < n; i++) {
        scanf("%f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3);

        px = ((y1 - y3)*(y1*y1 - y2*y2 + x1*x1 - x2*x2) - (y1 - y2)*(y1*y1 - y3*y3 + x1*x1 - x3*x3))
            / (2*(y1 - y3)*(x1 - x2) - 2*(y1 - y2)*(x1 - x3));
        
        py = ((x1 - x3)*(x1*x1 - x2*x2 + y1*y1 - y2*y2) - (x1 - x2)*(x1*x1 - x3*x3 + y1*y1 - y3*y3))
            / (2*(x1 - x3)*(y1 - y2) - 2*(x1 - x2)*(y1 - y3));
        
        r = sqrt((px-x1)*(px-x1) + (py-y1)*(py-y1));
        
        printf("%.3f %.3f %.3f\n", px, py, r);
    }
    return 0;
}

Measured memory_bytes: 660
#include<iostream>
#include<vector>
#include<deque>
#include<algorithm>
#include<numeric>
using namespace std;
using ll = long long int;

ll n, h;
deque<ll> b;
ll amax = 0;
ll ret = 0;

int main(void) {
	cin >> n >> h;
	for (int i = 0; i < n; i++) {
		ll ai, bi;
		cin >> ai >> bi;
		b.push_back(bi);
		if (ai > amax) {
			amax = ai;
		}
	}
	sort(b.begin(), b.end(), greater<ll>());
	while (ret<n && b.front()>amax && h > 0) {
		h -= b.front();
		b.pop_front();
		ret++;
	}
	if (h > 0)
		ret += (h + amax - 1) / amax;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
n, m = gets.split.map(&:to_i)

patterns = []
(0...2**n).each do |x|
  patterns << x.to_s(2).rjust(n, "0")
end

ms = []
m.times do
  ms << gets.split.map(&:to_i)
end

ps = gets.split.map(&:to_i)

ans = 0
patterns.each do |p|
  # puts "p:#{p.inspect}"
  t = true
  ms.each_with_index do |mm, i|
    cnt = 0
    mm[1..-1].each do |mmm|
      # puts "mmm:#{mmm}"
      if p[-mmm] == "1"
        cnt += 1
      end
    end
    # if cnt == 0 || cnt%2 != ps[i]
    if cnt%2 != ps[i]
      # puts "cnt:#{cnt}"
      t = false
    end
  end
  ans += 1 if t
end
puts ans

Measured memory_bytes: 2044
implicit none

integer :: n
logical :: flg_a, flg_b, flg_c
integer :: tmp_a, tmp_b
integer :: a,b,c

read *,a,b,c

flg_a = (mod(a,2) == 1)
flg_b = (mod(b,2) == 1)
flg_c = (mod(c,2) == 1)
if (flg_a .or. flg_b .or. flg_c) then
   print '(i0)',0
   stop
endif

if (a == b .and. b == c .and. c == a) then
   print '(i0)',-1
   stop
endif

n = 0
do while (.true.)
   if (mod(a,2) == 1) exit
   if (mod(b,2) == 1) exit
   if (mod(c,2) == 1) exit
   n = n + 1
   tmp_a = a
   tmp_b = b
   a = (tmp_b+c)/2
   b = (c+tmp_a)/2
   c = (tmp_a+tmp_b)/2
enddo

write(6,'(i0)') n
stop
end

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rr
const int N=100010,INF=0x3f3f3f3f;
bool use[N];
int n;
int ans;
int k;
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	n=read(),k=read();
	while(k--){
		int sum=read();
		for(rr int i=1;i<=sum;++i){
			use[read()]=true;
		}
	}
	for(rr int i=1;i<=n;++i){
		ans+=!(use[i]);
	}
	std::cout<<ans;
	return 0;
}


Measured memory_bytes: 3632
-- String を Intにする
toInt :: (String -> Int)
toInt x = read x :: Int

-- 入力を受け取り、 [Int] にする
getInts = do
  x <- getLine
  let y = (map$toInt)$words x -- 半角スペースで分割してIntにする
  return y

compareInts :: [Int] -> String
compareInts inNums
  | a < b = "a < b"
  | a == b = "a == b"
  | otherwise = "a > b"
  where a = inNums !! 0
        b = inNums !! 1

main = do
  inNum <- getInts
  putStrLn $ compareInts inNum


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

public class Main {

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

	private void run() throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] T = new Node[n];

		for (int i = 0; i < n; i++) {
			T[i] = new Node();
		}
		int l = 0;
		for (int i = 0; i < n; i++) {
			StringTokenizer tokenizer = new StringTokenizer(reader.readLine());
			int v = Integer.parseInt(tokenizer.nextToken());
			T[v].id = v;
			int d = Integer.parseInt(tokenizer.nextToken());
			for (int j = 0; j < d; j++) {
				int c = Integer.parseInt(tokenizer.nextToken());
				if (j == 0) {
					T[v].l = c;
				} else {
					T[l].r = c;
				}
				l = c;
				T[c].p = v;
			}
		}
		int r = -1;
		for (int i = 0; i < n; i++) {
			if (T[i].p == -1) {
				r = i;
				break;
			}
		}
		int[] D = new int[n];
		rec(r, 0, D, T);
		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < n; i++) {
			print(i, T, D, builder);
		}
		System.out.print(builder);
	}

	private void print(int u, Node[] T, int[] D, StringBuilder builder) {
		builder.append("node ").append(u).append(": parent = ").append(T[u].p)
				.append(", depth = ").append(D[u]).append(", ");
		if (T[u].p == -1)
			builder.append("root, ");
		else if (T[u].l == -1)
			builder.append("leaf, ");
		else
			builder.append("internal node, ");
		builder.append("[");
		for (int i = 0, c = T[u].l; c != -1; i++, c = T[c].r) {
			if (i != 0)
				builder.append(", ");
			builder.append(c);
		}
		builder.append("]\n");
	}

	private void rec(int u, int p, int[] D, Node[] T) {
		Deque<Node> deque = new ArrayDeque<Node>();
		deque.offer(T[u]);
		while (!deque.isEmpty()) {
			int t = deque.size();
			for (int i = 0; i < t; i++) {
				Node node = deque.poll();
				D[node.id] = p;
				if (node.l != -1) {
					node = T[node.l];
					while (true) {
						deque.offer(T[node.id]);
						if (node.r != -1) {
							node = T[node.r];
						} else {
							break;
						}
					}
				}
			}
			p++;
		}
	}

	class Node {
		int id = -1;
		int p = -1;
		int l = -1;
		int r = -1;
	}
}

Measured memory_bytes: 90732
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstring>
using namespace std;

int main() {
  int N,i;
  cin >> N;
  long int a[N];
  for(i=0;i<N;i++)
    cin >> a[i];
  int c=0;
  for(i=0;i<N;i++)
      while(a[i]%2==0){
        a[i]=a[i]/2;
        c++;
      }
  
    cout << c;
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 100005;
const int P = 1000000007;
const int INF = 1000000007;
const double eps = 1e-6;
using namespace std;
inline int getint() {
    int r = 0; bool b = true; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') b = false; c = getchar(); }
    while (c >= '0' && c <= '9') { r = (r<<1)+(r<<3) + c - '0'; c = getchar(); }
    return b ? r : -r;
}

int n, a[MAXN], b[MAXN];
LL ans1, ans2;

int main() {
    n = getint();
    for (int i = 1; i <= n; ++i) a[i] = getint();
    sort(a + 1, a + n + 1);

    for (int i = 1; i <= n; ++i) b[i] = 0;
    for (int i = 1; i < n; ++i) {
        if (i & 1) { --b[i]; ++b[i+1]; }
        else { ++b[i]; --b[i+1]; }
    }
    sort(b + 1, b + n + 1);
    ans1 = 0;
    for (int i = 1; i <= n; ++i) ans1 += b[i] * a[i];

    for (int i = 1; i <= n; ++i) b[i] = 0;
    for (int i = 1; i < n; ++i) {
        if (i & 1) { ++b[i]; --b[i+1]; }
        else { --b[i]; ++b[i+1]; }
    }
    sort(b + 1, b + n + 1);
    ans2 = 0;
    for (int i = 1; i <= n; ++i) ans2 += b[i] * a[i];

    printf("%lld", max(ans1, ans2));
}

Measured memory_bytes: 1152
#include <algorithm>
#include <iostream>
#include <math.h>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n - 1];
    REP(i, n)
    cin >> a[i];
    REP(i, n)
    cin >> b[i];
    REP(i, n - 1)
    cin >> c[i];

    int ans = 0, before = 30;
    REP(i, n) {
        ans += b[a[i] - 1];
        if (before == a[i] - 1)
            ans += c[a[i] - 2];
        before = a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
answer = 0
for _ in range(N):
    x, u = sr().split()
    if u == 'JPY':
        answer += int(x)
    else:
        answer += float(x) * 380000
print(answer)


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



int main()
{
    string str;
    cin>>str;
    int i=0;
    bool c1=false;
    bool c2=false;
    if(str[2]==str[3])
    {
        c1=true;
    }
    if(str[4]==str[5])
    {
        c2=true;
    }
    if(c1 && c2)
    {
        cout<<"Yes"<<"\n";
    }
    else{
        cout<<"No"<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        int left = 0;
        int right = 0;
        int now = 0;
        long ans = 0;
        while(right < n && left < n){
            if(now + a[right] == (now^a[right])){
                now = now^a[right];
                ans += (right-left)+1;
                right++;
            }else{
                now = now^a[left];
                left++;
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 47740
x=input()
n=len(x)

res=[]

import numpy as np
import itertools

x753=[3,5,7]

pt=list(itertools.product(x753, repeat=n))

pt_n=len(pt)

for i in range(pt_n):
	y="".join(map(str, pt[i]))
	for j in range(n):
		z=y[j:]
		if int(z)<=int(x) and ('3' in z) and ('5' in z) and ('7' in z):
			res.append(z)
            
print(len(set(res)))

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{INF};
    lol n; cin >> n;
    VL a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    FOR(i, 1, 100)
    {
        lol sum{0};
        REP(j, n)
        {
            sum += pow((a[j]-i), 2);
        }
        result = min(result, sum);
    }
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3632
def solve(N, Xs):
    sorted_Xs = sorted(Xs)
    left = sorted_Xs[N // 2 - 1]
    right = sorted_Xs[N // 2]
    ans = []
    for x in Xs:
        if x <= left:
            ans.append(right)
        else:
            ans.append(left)
    return "\n".join(str(i) for i in ans)

if __name__ == "__main__":
    N = int(input())
    Xs = list(map(int, input().split(" ")))
    print(solve(N, Xs))

Measured memory_bytes: 31136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll x;cin>>x;
  if(x>=1800)
    cout<<1;
  else if(x>=1600 && x<=1799)
    cout<<2;
  else if(x>=1400 && x<=1599)
    cout<<3;
  else if(x>=1200 && x<=1399)
    cout<<4;
  else if(x>=1000 && x<=1199)
    cout<<5;
  else if(x>=800 && x<=999)
    cout<<6;
  else if(x>=600 && x<=799)
    cout<<7;
  else if(x<=599)
    cout<<8;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
#include <map> 
using namespace std;
long long int find(long long int a[],long long int val[],long long int w,long long int n)
{
    long long int i,j;
     long long int k[n+1][w+1];
     for(i=0;i<=n;i++)
     {
          for(j=0;j<=w;j++)
          {
               if(i==0 || j==0)
               {
               k[i][j]=0;
               }
               else if(j>=a[i-1])
               {
                    k[i][j]=max((val[i-1]+k[i-1][j-a[i-1]]),k[i-1][j]);
               }
               else
               {
                    k[i][j]=k[i-1][j];
               }
          }
     }
     /*for(i=0;i<=n;i++)
     {
          for(j=0;j<=w;j++)
          {
               cout<<k[i][j]<<" ";
          }
          cout<<endl;
     }*/
     return k[n][w];

}
int main()
{
    long long int n,ans=0,i,y,maxisum=0,w;
    cin>>n>>w;
     long long int a[n]={0},val[n]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>val[i];
    }
    maxisum=find(a , val, w, n);
    cout<<maxisum<<endl;
    return 0;
}

Measured memory_bytes: 79104
#include<iostream>
#include<vector>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int n;
    cin >> n;
    vector<int> a(n,0);
    F(i,0,n) cin >> a[i];
    F(i,0,n){
        cout << a[i];
        if(i!=n-1) cout << ' ';
    }
    cout << endl;
    F(i,1,n){
        int k=a[i];
        int j=i;
        while(j>0 && a[j-1]>k){
            a[j]=a[j-1];
            --j;
        }
        a[j]=k;
        F(i,0,n){
            cout << a[i];
            if(i!=n-1) cout << ' ';
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>

#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
	char str[512];
	int array[102][101] = {0};
	int count = 1;
	int i, j;
	
	while (scanf("%s", str) != EOF){
		int num;
		
		for (i = num = 0; str[i] != 0; i++, num++){
			while ('0' <= str[i] && str[i] <= '9'){
				array[count][num] *= 10;
				array[count][num] += str[i] - '0';
				i++;
			}
			if (str[i] == 0) i--;
		}
		count++;
	}
	for (i = 2; i < count / 2; i++){
		for (j = 0; j < i; j++){
			array[i][j] += max(array[i - 1][j - 1], array[i - 1][j]);
		}
	}
	for (i = 0; i < count / 2; i++){
		for (j = 0; j < count / 2 - i; j++){
			array[count / 2 +  i][j] += max(array[count / 2 + i - 1][j], array[count / 2 + i - 1][j + 1]);
		}
	}/*
	for (i = 2; i < count / 2; i++){
		for (j = 0; j < i; j++){
			printf("%d ", array[i][j]);
		}
		puts("");
	}
	for (i = 0; i < count / 2; i++){
		for (j = 0; j < count / 2 - i; j++){
			printf("%d ", array[count / 2 + i][j]);
		}
		puts("");
	}*/
	printf("%d\n", array[count - 1][0]);
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans=0;
  if(n>=64) ans=64;
  if(n<64 && n>=32) ans=32;
  if(n<32 && n>=16) ans=16;
  if(n<16 && n>=8) ans=8;
  if(n<8 && n>=4) ans=4;
  if(n<4 && n>=2) ans=2;
  if(n==1) ans=1;
  cout << ans << endl;
}
    
      
      
    

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

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

    vll a(n);
    rep(i,n)cin >> a[i];

    ll cnt=0;

    rep(i,n){
        while(a[i] % 2 == 0){
            a[i] /= 2;
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

int main() {
    string S;
    int K;
    cin >> K >> S;
    
    if (S.size() > K) {
        for (int i = 0; i < K; i++) {
            cout << S.at(i);
        }
        cout << "..." << endl;
    } else {
        cout << S << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
// ORZ YJZ
#include <bits/stdc++.h>
#include <unordered_map>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
int n, k, l;
struct dsu {
	int par[200005], rank[200005];
	int find(int x) {
		return (x==par[x]?x:par[x]=find(par[x]));
	}
	void unite(int x, int y) {
		x=find(x),y=find(y);
		if (rank[x]>rank[y]) {
			swap(x,y);
		}
		par[x]=y;
		rank[y]+=rank[x];
	}
	bool same(int x, int y) {
		return find(x)==find(y);
	}
	void init(int n) {
		rep(i,1,n) par[i]=i,rank[i]=1;
	}
}road, rail;
unordered_map<int,unordered_map<int,int> > cnt;
int main() {
	n=readint();
	road.init(n);
	rail.init(n);
	k=readint();l=readint();
	while (k--) {
		int p=readint(),q=readint();
		road.unite(p,q);
	}
	while (l--) {
		int p=readint(),q=readint();
		rail.unite(p,q);
	}
	rep(i,1,n) {
		cnt[road.find(i)][rail.find(i)]++;
	}
	rep(i,1,n) {
		printint(cnt[road.find(i)][rail.find(i)]);printchar(' ');
	}
	return 0;
}


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

using ll = long long;

template <typename T>
T gcd(T a, T b){
    while(b){
        T tmp = b;
        b = a % b;
        a = tmp;
    }
    return a;
}

int main(){
    ll a, b, c;
    cin >> a >> b >> c;
    ll g = gcd(gcd(a, b), c);
    cout << (gcd(a / g, b / g) == 1 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int a, b;
    cin >> a >> b;
    cout << (a * b) << " " << (2 * a + 2 * b) << "\n";
}


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

const ll INF = 100100100100;

int main() {
    int A, B, Q; cin >> A >> B >> Q;
    vector<ll> S(A);
    vector<ll> T(B);
    vector<ll> X(Q);
    rep(i, A){
        cin >> S[i];
    }
    rep(i, B){
        cin >> T[i];
    }
    rep(i, Q){
        cin >> X[i];
    }

    rep(i, Q){
        ll x = X[i];
        int ss = lower_bound(S.begin(), S.end(), x) - S.begin();
        int tt = lower_bound(T.begin(), T.end(), x) - T.begin();
        if(ss == 0){
            if(tt == 0){
                cout << max(S[0], T[0]) - x << endl;
                continue;
            } else {
                ll d1;
                if(tt != B){
                    d1 = max(T[tt], S[0]) - x;
                } else {
                    d1 = INF;
                }
                ll d2 = min((S[0]- x) * 2 + x - T[tt-1], (x - T[tt-1]) * 2 + S[0] - x);
                cout << min(d1, d2) << endl;
                continue;
            }
        }

        if(tt == 0){
            ll d1;
            if(ss != A){
                d1 = max(S[ss], T[0]) - x;
            } else {
                d1 = INF;
            }
            ll d2 = min((T[0]- x) * 2 + x - S[ss-1], (x - S[ss-1]) * 2 + T[0] - x);
            cout << min(d1, d2) << endl;
            continue;
        }

        if(ss == A){
            if(tt == B){
                cout << x - min(S[A-1], T[B-1]) << endl;
                continue;
            } else {
                ll d1 = x - min(T[tt-1], S[A-1]);
                ll d2 = min((T[tt]- x) * 2 + x - S[A-1], (x - S[A-1]) * 2 + T[tt] - x);
                cout << min(d1, d2) << endl;
                continue;
            }
        }

        if(tt == B){
            ll d1 = x - min(S[ss-1], T[B-1]);
            ll d2 = min((S[ss]- x) * 2 + x - T[B-1], (x - T[B-1]) * 2 + S[ss] - x);
            cout << min(d1, d2) << endl;
            continue;
        }

        ll ans1, ans2, ans3, ans4;
        ans1 = max(T[tt], S[ss]) - x;
        ans2 = x - min(T[tt-1], S[ss-1]);
        if(S[ss] < T[tt]){
            ans3 = (S[ss] - x) * 2 + x - T[tt-1];
        } else {
            ans3 = (T[tt] - x) * 2 + x - S[ss-1];
        }
        if(S[ss-1] < T[tt-1]){
            ans4 = (x - T[tt-1]) * 2 + S[ss] - x;
        } else {
            ans4 = (x - S[ss-1]) * 2 + T[tt] - x;
        }
        ans1 = min(ans1, ans2);
        ans1 = min(ans1, ans3);
        ans1 = min(ans1, ans4);

        cout << ans1 << endl;



    }

    return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;

using namespace std;


VLL a(52), b(52);
ll c, x;

ll solve(ll n, ll m) {
	if (n == 0) {
		if (m <= 0)return 0;
		else return 1;
	}
	else if (m <= 1 + a[n - 1]) return solve(n - 1, m - 1);
	else return b[n - 1] + 1 + solve(n - 1, m - 2 - a[n - 1]);
}

int main() {
	cin >> c >> x;
	
	a[0] = b[0] = 1;
	REP(i, 51) {
		a[i + 1] = a[i] * 2 + 3;
		b[i + 1] = b[i] * 2 + 1;
	}

	cout << solve(c, x) << endl;

	return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
ps = [0]*n
ps = list(map(lambda x: (int(x)+1) / 2,input().split()))

ans = 0
for i in range(k):
    ans += ps[i]
tmp = ans
for i in range(k,n):
        tmp = tmp - ps[i-k] + ps[i]
        if ans < tmp:
            ans = tmp
    
print(ans)


Measured memory_bytes: 24684
#include<map>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,sum,kk;
int main(){
	scanf("%d",&n);
	m=n;
	while(m!=0){
		kk=m%10;
		sum+=kk;
		m/=10;
	}
	if(n%sum!=0)printf("No");
	if(n%sum==0)printf("Yes");
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
	ll N;
	cin>>N;
	ll arr[N+1];
	arr[0]=0;
	for(ll i=0;i<N;i++)
	{
		cin>>arr[i+1];
	}
	
	ll dp[N];
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	
	for(ll i=3;i<=N;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[N]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase(unique(ALL(v)), v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 2e18;
const double PI = acos(-1);

vvi Map;
vvb visited;
ll ans;
int H, W;

typedef pair<int, int> P;

bool check(int y, int x)
{
	if (y < 0 || y >= H)
		return false;
	if (x < 0 || x >= W)
		return false;
	return true;
}

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

void bfs(int y, int x)
{
	queue<P> Q;
	ll cnt0 = 0, cnt1 = 0;
	Q.push(P(y, x));
	visited[y][x] = true;
	while (!Q.empty())
	{
		P p = Q.front();
		Q.pop();
		if (Map[p.first][p.second] == 0)
		{
			cnt0++;
		}
		else
		{
			cnt1++;
		}
		REP(k, 4)
		{
			int nx = p.second + dx[k];
			int ny = p.first + dy[k];
			if (!check(ny, nx))
				continue;
			if (visited[ny][nx])
				continue;
			if (Map[p.first][p.second] != Map[ny][nx])
			{
				visited[ny][nx] = true;
				Q.push(P(ny, nx));
			}
		}
	}
	ans += cnt0 * cnt1;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> H >> W;
	ans = 0;
	Map = vvi(H, vi(W, 0));
	REP(i, H)
	{
		REP(j, W)
		{
			char a;
			cin >> a;
			if (a == '#')
				Map[i][j] = 1;
		}
	}
	visited = vvb(H, vb(W));
	REP(i, H)
	{
		REP(j, W)
		{
			if (!visited[i][j])
				bfs(i, j);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

using R = double;
constexpr R pi = acos((R)-1);
using C = complex<R>;
C& operator*=(C& l, const C& r) {
    return l = {real(l) * real(r) - imag(l) * imag(r), real(l) * imag(r) + imag(l) * real(r)};
}
void fft(V<C>& a, bool inv = false) {
    int n = a.size();
    int j = 0;
    for (int i = 1; i < n; ++i) {
        int w = n >> 1;
        while (j >= w) j -= w, w >>= 1;
        j += w;
        if (i < j) swap(a[i], a[j]);
    }
    static VV<C> xi(30);
    for (int k = 0; 1 << k < n; ++k) if (xi[k].empty()) {
        xi[k].resize(1 << k);
        for (int i = 0; i < 1 << k; ++i) {
            xi[k][i] = polar<R>(1, i * pi / (1 << k));
        }
    }
    for (int k = 0; 1 << k < n; ++k) {
        const int w = 1 << k;
        for (int s = 0; s < n; s += 2 * w) {
            for (int i = s; i < s + w; ++i) {
                C p = a[i], q = a[i + w] * (inv ? conj(xi[k][i - s]) : xi[k][i - s]);
                a[i] = p + q, a[i + w] = p - q;
            }
        }
    }
}
template<class Z> void multiply(V<Z>& a, const V<Z>& b) {
    int n = 1 << __lg(2 * (a.size() + b.size() - 1) - 1);
    V<C> c(n);
    for (int i = 0; i < n; ++i) {
        if (i < (int)a.size()) c[i].real(a[i]);
        if (i < (int)b.size()) c[i].imag(b[i]);
    }
    fft(c);
    for (int i = 0; i <= n / 2; ++i) {
        c[i] *= c[i];
        if (i & n / 2 - 1) c[n - i] *= c[n - i];
        c[i] = C(0, -0.25) * (c[i] - conj(c[n - i & n - 1]));
        if (i & n / 2 - 1) c[n - i] = conj(c[i]);
    }
    fft(c, true);
    a.resize(a.size() + b.size() - 1);
    for (int i = 0; i < (int)a.size(); ++i) {
        a[i] = real(c[i]) / n + 0.5;
    }
}

constexpr lint mod = 65537;
lint tmod(lint a, lint p) { return (a %= p) < 0 ? a + p : a; }
lint mod_inv(lint a, lint p) {
    a = tmod(a, p);
    lint b = p, x = 1, u = 0;
    while (b) {
        lint q = a / b;
        swap(a -= q * b, b);
        swap(x -= q * u, u);
    }
    assert(a == 1);
    return tmod(x, p);
}

int main() {
    int T; cin >> T;
    while (T--) {
        lint n, K; cin >> n >> K;
        V<lint> c(n); for (auto&& e : c) cin >> e, e = tmod(e, mod);
        reverse(begin(c), end(c));
        V<lint> a(n, 1);
        for (int i = 1; i < n; ++i) {
            a[i] = a[i - 1] * tmod(-K, mod) % mod * mod_inv(i, mod);
            a[i] = tmod(a[i], mod);
        }
        lint inv = 1;
        for (int i = 1; i < n; ++i) {
            inv = tmod(inv * mod_inv(i, mod), mod);
            c[i] *= inv;
            c[i] = tmod(c[i], mod);
        }
        multiply(a, c);
        lint fact = 1;
        for (int i = 0; i < n; ++i) {
            if (i) {
                fact = tmod(fact * i, mod);
            }
            a[i] *= fact;
            cout << tmod(a[i], mod) << " \n"[i == n - 1];
        }
    }
}


Measured memory_bytes: 9152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a=new int[2];
            a=Console.ReadLine().Split().Select(int.Parse).ToArray();
            if(a[0]%3==0||a[1]%3==0||(a[0]+a[1])%3==0)
            Console.WriteLine("Possible");
            else Console.WriteLine("Impossible");
            }
        }
}



Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;



int main(void) {
    ll N, K;
    cin >> N >> K;
    ll a[MAX];
    ll i, j, k;
    
    for(i=0; i<N; i++) cin >> a[i];
    
    ll ans=0;
    for(i=-1; i<40; i++) {
        if(i!=-1 && !(1&K>>i)) continue;
        
        ll t=0;
        for(j=0; j<40; j++) {
            ll mask=1LL<<j;
            ll cnt=0;
            
            for(k=0; k<N; k++) if(a[k]&mask) cnt++;
            
            if(j>i) {
                if(K&mask) t+=mask*(N-cnt);
                else t+=mask*cnt;
            }else if(j==i) {
                t+=mask*cnt;
            }else {
                t+=mask*max(cnt, N-cnt);
            }
        }
        
        chmax(ans, t);
    }
    
    pt(ans);
    
}







Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	
	bool added[n];
	int a[n][n];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			int buf;
			scanf("%d", &buf);
			a[i][j] = buf==-1 ? INT_MAX : buf;
		}
		added[i] = false;
	}
	added[0] = true;
	
	long total = 0;
	for(;114514;){
		bool end = true;
		int minCost = INT_MAX, pi, pj;
		for(int i = 0; i < n; i++){
			if(!added[i]){
				end = false;
				continue;
			}
			for(int j = 0; j < n; j++){
				if(minCost > a[i][j]){
					minCost = a[pi = i][pj = j];
				}
			}
		}
		if(end) break;
		a[pj][pi] = a[pi][pj] = INT_MAX;
		if(!added[pi] || !added[pj]){
			added[pi] = added[pj] = true;
			total += minCost;
		}
	}
	
	printf("%ld\n", total);
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;

int main(){
    int N,D,A;
    cin >> N >> D >> A;
    vector <pair<int,int> >  xh(N);

    REP(i, N)
    {
        cin >> xh[i].first >> xh[i].second;
        //あらかじめ圧縮しておく
        xh[i].second = (xh[i].second+A-1)/A;
    }
    sort(xh.begin(),xh.end());
    vector<int>s(N+1);
    int r = 0;
    ll ans = 0;
    REP(i,N)
    {
        xh[i].second -= s[i];
        //rの位置を移動
        while(r < N && xh[r].first <= xh[i].first + 2 * D)++r;
        if(xh[i].second > 0)
        {

            int num =xh[i].second;
            ans += num;
            s[i] += num;
            s[r] -= num;
        }
        //rの範囲でなくても引き継いでよいのか?
        //-> rの範囲でなければ、s[r]がひかれているはず
        //s[i]を引き継ぐ
        s[i+1] += s[i];
    }

    cout << ans << endl;



    return 0;    
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  bitset<64> b(0);
  int q;
  cin >> q;
  REP(i,q){
    int a;
    cin >> a;
    if(0<=a&&a<=3){
      int s;
      cin >> s;
      if(a==0){
        cout << b.test(s) << endl;
      }else if(a==1){
        b.set(s);
      }else if(a==2){
        b.reset(s);
      }else if(a==3){
        b.flip(s);
      }
    }else if(a==4){
      cout << b.all() << endl;
    }else if(a==5){
      cout << b.any() << endl;
    }else if(a==6){
      cout << b.none() << endl;
    }else if(a==7){
      cout << b.count() << endl;
    }else{
      cout << b.to_ullong() << endl;
    }
  }
}



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

int main(){
  string s;
  cin >> s;
  bool ans=true;
  if(s=="AAA"||s=="BBB"){
    ans=false;
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;

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

  int A,B,C;
  cin >> A >> B >> C;

  if (A+B >= C) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fl(i,from,to) for(ll i=from;i<to;i++)
#define dd double 
#define inp(a) ll a;cin>>a;
int main()
{
	inp(n);inp(d);ll cnt=0;
	fl(i,0,n)
	{
		inp(x);inp(y);
		ll ans=((x*x)+(y*y));
		dd res=sqrt(ans);
		if(res<=d)cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int N, i, tmp;
  vector<int> a;
  // get input
  cin >> N;
  for(i = 0; i < N; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  tmp = 0;
  for(i = 0; i < N; i++) {
    tmp ^= a[i];
  }
  // print result
  if(tmp == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 892
#include <iostream>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll pow(ll x, ll n) {
  ll res = 1;

  while (n > 0) {
    if (n % 2 == 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }

  return res;
}

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

  cout << ((pow(10, n) - pow(9, n) * 2 + pow(8, n)) % MOD + MOD) % MOD << endl;
}


Measured memory_bytes: 3552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
   public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            br.readLine();
            String[] split = br.readLine().split(" ");
            int n = split.length;
            double[] prob = new double[n];
            for (int i = 0; i < n; i++) {
               prob[i] = Double.parseDouble(split[i]); 
            }
            double[] dp = new double[n + 1];
            dp[0] = 1.0;
            for (int i = 1; i <= n; i++) {
                for (int j = Math.min(i + 1, n); j >= 0; j--) {
                    dp[j] = (j == 0 ? 0 : dp[j - 1])*prob[i - 1] +  dp[j]*(1 - prob[i - 1]);
                }
            }
            double result = 0.0;
            for (int i = (n + 1) / 2 ; i <= n; i++) {
                result += dp[i];
            }
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 25044
// !Start && !End 
//  0 se divide
//https: //www.youtube.com/watch?v=6Nb-prB-4P0&list=RD6Nb-prB-4P0&start_radio=1

// https: //www.youtube.com/watch?v=eYDI8b5Nn5s
// Electrify my OOOoooooOOOoooOOOOOoooooOOOooo!
#pragma optimise GCC(-O2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll,ll>
#define ve(x) vector<x>
#define f(a,b,c) for(int a=b;a<c;a++)
#define foto(x,v) for(auto x:v)
#define read(t) ll t; cin>>t;
#define reads(t) string t; cin>>t;
#define readarr(arr,n) ll arr[n]; f(i,0,n) cin>>arr[i];
#define forstl(i,v) for(auto &i: v)
#define ln endl
#define Endl endl
#define dbg(x) cout<<#x<<" = "<<x<<ln;
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<ln;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it<<ln;} cout<<ln;
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; forstl(it,v) \
cout<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cout<<ln;
#define dbgarr(v,s,e) cout<<#v<<" = "; f(i,s,e) cout<<v[i]<<", "; cout<<ln;
#define addEdge(tr,k) f(i,0,k) { ll x,y; cin>>x>>y, tr[x].push_back(y), tr[y].push_back(x);}
#define all(v) v.begin(),v.end()

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }

//														GLOBAL VARS
ll INF =LLONG_MAX;
const ll M= 1000000007;

//														USEFUL FUNCTIONS
ll powm(ll ,ll);

// 														MAIN
int main()
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    //It gets easier day by day, but the hard part is to........
    read(a)
    char op;
    cin>>op;
    read(b)
    if(op == '+') cout<<a+b;
    else cout<<a -b;
}










//													FUNCTIONS DECLARATIONS
ll powm(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%M;
		a=(a*a)%M;
		b>>=1;
	}
	return res;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[26];
int main(){
	rep(i,0,3){
		char c;
		scanf("%c",&c);
		s[c-'a']++;
	}
	puts(s[0]&&s[1]&&s[2]?"Yes":"No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = a * x + b * y;
    ll z = 0;
    
    for(int i = 0; i <= max(x, y); i++) {
        ll tmp = c * (i * 2);
        ll AA = max(z, x - i);
        ll BB = max(z, y - i);
        tmp += AA * a + BB * b;
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
    int n , i , j , r[200001] ;
    
    scanf("%d" , &n) ;
    
    for(i = 0 ; i < n ; i++){
        scanf("%d" , &r[i]) ;
    }
    int maxv = r[1] - r[0] , min = r[0] ;
    
    for(i = 1 ; i < n ; i++){
        if(r[i] - min > maxv){
            maxv = r[i] - min ;
        }
        if(r[i] < min){
            min = r[i] ;
        }
    }
    printf("%d\n" , maxv) ; 
    return 0 ;
}


Measured memory_bytes: 2640
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll dp[3][111111];

int main(){
	
	int n;cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);
	REP(i,n)cin >> a[i] >> b[i] >> c[i];
	
	dp[0][0] = a[0];
	dp[1][0] = b[0];
	dp[2][0] = c[0];
	
	REP(i,n-1){
		REP(j,3){
			if(j != 0)dp[0][i+1] = max(dp[0][i+1], dp[j][i] + a[i+1]);
			if(j != 1)dp[1][i+1] = max(dp[1][i+1], dp[j][i] + b[i+1]);
			if(j != 2)dp[2][i+1] = max(dp[2][i+1], dp[j][i] + c[i+1]);
		}
	}
		
	cout << max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1])) << endl;
	
	return 0;
}


Measured memory_bytes: 4992
import numpy as np
N, W = map(int, input().split())
 
items = [tuple(map(int, input().split())) for _ in range(N)]
 
dp = np.full(N*1000 +1, W+1) #横軸を価値の値に変換する
dp[0] = 0
 
for i, (w, v) in enumerate(items):
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
 
print(np.max(np.where(dp <= W)))

Measured memory_bytes: 14916