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

#define forn(i, n) for(int i = 0; i < (int)n; ++i)

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

	vector<ll> v(n);
	forn(i, n) cin >> v[i];

	map<ll, ll> mp;
	vector<ll> sum(n+1, 0);

	// sum
	forn(i, n) sum[i+1] = sum[i] + v[i];
	forn(i, n+1) ++mp[sum[i]];

	ll ans = 0;
	for(auto item : mp) {
		ll num = item.second;
		ans += num * (num - 1) / 2;
	}

	cout << ans << "\n";


	return 0;
}

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

using namespace std;

int n;
string s;
vector<int> v[11];

int main() {
    cin >> n >> s;
    
    for (int i = 0; i < n; ++i) 
        v[s[i] - '0'].push_back(i);
    
    int ans = 0;
    for (int i = 0; i < 100; ++i) {
        string x = to_string(i);
        while(x.size() < 2) x = "0" + x;
        int a = 0, b = 0;

        while(a < n and b < (int)x.size()) {
            if(s[a] == x[b]) a++, b++;
            else a++;
        }

        if(a == n) continue;
        
        for (int i = 0; i < 10; ++i) {
            if(!v[i].size()) continue;
            int l = -1, r = v[i].size();
            while(r - l > 1) {
                int mid = (l + r) / 2;
                if(v[i][mid] >= a) r = mid;
                else l = mid;
            }
            ans += (r < (int)v[i].size());
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
N = int(input())

s = input()


def fnc(x1, x2):
    pre = x1  # s[-1] の仮定
    curr = x2  # s[0] の仮定
    ans = []
    for i in range(N):
        if curr == 1:  # 羊
            if s[i] == 'o':
                nv = pre
            else:
                nv = (pre + 1) % 2
        else:  # 狼
            if s[i] == 'x':
                nv = pre
            else:
                nv = (pre + 1) % 2
        pre = curr
        curr = nv
        ans.append(pre)

    if pre == x1 and curr == x2:
        return ans
    else:
        return None


def solve():
    for i in [1, 0]:
        for j in [1, 0]:
            ans = fnc(i, j)
            if ans:
                return ans
    return None


if __name__ == '__main__':
    ans = solve()
    if not ans:
        print(-1)
        exit()

    for a in ans:
        print('S' if a else 'W', end='')
    print()


Measured memory_bytes: 66800
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  int sum = 0;
  REP(i,N){
    sum+=a.at(i)-1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;

    cout << (a-1)*(b-1);
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

typedef pair<int, int> P;

int H, W, N;
P ab[100000];
set<P> vted;
bool img[5][5];
ll res[10];

int main(int argc, char **argv) {
	cin >> H >> W >> N;
	REP(i, N) {
		cin >> ab[i].first >> ab[i].second;
		--ab[i].first; --ab[i].second;
	}
	sort(ab, ab + N);
	CLEAR(res);
	REP(i, N) {
		CLEAR(img);
		P &p = ab[i];
		REP(a, 5) {
			auto top = lower_bound(ab, ab + N, P(p.first - 2 + a, p.second), [&](const P &a, const P &b) { return a.first < b.first; });
			auto btm = upper_bound(ab, ab + N, P(p.first - 2 + a, p.second), [&](const P &a, const P &b) { return a.first < b.first; });
			REP(b, 5) {
				if (binary_search(top, btm, P(p.first - 2 + a, p.second - 2 + b), [&](const P &a, const P &b) { return a.second < b.second; })) img[a][b] = true;
			}
		}
		REP(a, 3) REP(b, 3) {
			int c = p.first - 2 + a, d = p.second - 2 + b;
			if (c < 0 || d < 0 || c >= H - 2 || d >= W - 2 || vted.find(P(c, d)) != vted.end()) continue;
			vted.insert(P(c, d));
			int cnt = 0;
			REP(i, 3) REP(j, 3) if (img[a + i][b + j]) ++cnt;
			++res[cnt];
		}
	}
	res[0] = ll(W - 2) * (H - 2);
	REP(i, 9) res[0] -= res[i + 1];
	REP(i, 10) cout << res[i] << endl;
	return 0;
}


Measured memory_bytes: 43264
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int P[] = new int[N];
		int min = 0;
		int count = 0;
		for(int i = 0; i < N; i++) {
			P[i] = sc.nextInt();
			if(i > 0) {
				if(min >= P[i]) {
					min = P[i];
					count++;
				}
			}else {
				min = P[i];
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 50356
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
int n;
int a[10000];
double wa;
int main()
{
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    wa=a[0];
    rep2(i,1,n)
    {
        wa=(wa+(double)a[i])/2.00000000;
    }    
    cout<<wa<<endl;
    return 0;
}

Measured memory_bytes: 256
S = str(input())

sum = 0
S_mae = ""
S_horyu = ""

for i in range(len(S)):

    if i == 0:
        S_mae = S[i]
        sum += 1
    elif S_mae != (S[i] + S_horyu):
        S_mae = S[i] + S_horyu
        S_horyu = ""
        sum += 1
    else:
        S_horyu = S_horyu + S[i]

print(sum)

Measured memory_bytes: 41948
# -*- coding: utf-8 -*-

from sys import stdin

n,x = [int(i) for i in stdin.readline().split()]
limit = int(x ** (1.0/n)) + 1

def factorize(x):
    ans = 1

    p = 2
    if x % p == 0:
        count = 1
        x /= p
        while x % p == 0:
            count += 1
            x /= p
        if count >= n:
            ans = ans * (p ** (count // n))

    for p in range(3, limit, 2):
        if x % p == 0:
            count = 1
            x /= p
            while x % p == 0:
                count += 1
                x /= p
            if count >= n:
                ans = ans * (p ** (count // n))
        if x < p * p:
            break
    return ans

if x == 1:
    print(1)
elif n == 1:
    print(x)
else:
    ans = factorize(x)
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;


int main() {
	int i, j, k;
	long long n, m, sum=0;

	cin >> n >> m;

	
	if (n * 2 <= m) {
		sum += n;
		m -= (n * 2);
		sum += (m / 4);
	}
	else if (n * 2 > m) {
		if (n >= m / 2) {
			sum += (m / 2);
		}
		else {
			m -= n * 2;
			sum += n;
			sum += (m / 4);
		}
	}


	cout << sum << endl;






	getchar();
	getchar();
	return 0;
}

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

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	int x, y;
	switch(a) {
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12: x = 1; break;
	case 4:
	case 6:
	case 9:
	case 11: x = 2; break;
	case 2: x = 3; break;
	}
	switch(b) {
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12: y = 1; break;
	case 4:
	case 6:
	case 9:
	case 11: y = 2; break; break;
	case 2: y = 3; break;
	}
	if(x == y) printf("Yes\n");
	else printf("No\n");
}


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

int64_t f(int64_t K){
  if(K%4==0){return K;}
  if(K%4==1){return 1;}
  if(K%4==2){return K+1;}
  if(K%4==3){return 0;}
}

int main(){
  int64_t A,B;
  cin>>A>>B;
  bitset<60> s(f(A-1)),t(f(B));
  int64_t ans=(s^t).to_ullong();
  cout<<ans<<endl;
}

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

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


void Main() {
  string s, t;
  cin >> s >> t;
  bool ok = true;
  auto f = [&]() { 
    vector<int> M[26];
    rep(i, s.size()) M[s[i]-'a'].push_back(i);
    rep(i, 26) {
      if (M[i].size() <= 1) continue;
      rep(j, M[i].size()-1) if (t[M[i][j]] != t[M[i][j+1]]) ok = false;
    }
  };
  f();
  swap(s,t);
  f();
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

const ll mod=1e9+7;
ll ans,cnt[100005],n,k;

ll fp(ll x,ll y)
{
    ll ret=1;
    while(y)
    {
        if(y&1) ret=ret*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return ret;
}

int main()
{
    scanf("%lld%lld",&n,&k);
    for(int i=k;i>=1;i--)
    { 
        cnt[i]=fp(k/i,n);
        for(int j=2*i;j<=k;j+=i) 
        {
            cnt[i]-=cnt[j];
            if(cnt[i]<0) cnt[i]+=mod;
        }
        ans=(ans+i*cnt[i])%mod;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 4564
#include <stdio.h>
#define N 101

int main() {
    int n, g;
    int list[N][N];
    int i, j, v, u;

    // 初期化
    for(i = 0; i < N; i++){
        for(j = 0; j < N; j++){
            list[i][j] = 0;
        }
    }

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &u);
        scanf("%d", &v);
        for(j = 0; j < v; j++){
            scanf("%d", &g);
            list[i][g-1] = 1;
        }
    }

    for(i = 0; i < n; i++){
        for(j = 0; j < n-1; j++){
            printf("%d ", list[i][j]);
        }
        printf("%d\n", list[i][n-1]);
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  int ans = 1000000;
  for(int i = -100; i <= 100; i++){
    int sub = 0;
    for(int j = 0; j < N; j++){
      sub += (i-vec.at(j))*(i-vec.at(j));
    }
    if(sub < ans){
      ans = sub;
    }
  }
  cout << ans << endl;
}

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

int main(){
    string S;
    cin >> S;
    vector<char> ch(4);
    for (int i = 0; i < 4;i++)
        ch[i] = S[i];

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

    if(ch[0] == ch[1] && ch[2] == ch[3] && ch[1] != ch[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
moves = input()

easy = True
for i in range(len(moves)):
  if i % 2 == 0 and not moves[i] in "RUD":
    easy = False
    break
  if i % 2 == 1 and not moves[i] in "LUD":
    easy = False
    break

print("Yes" if easy else "No")


Measured memory_bytes: 2940
fun main() {
    readInt()
    val a = readInts().sorted()
    val seen = mutableSetOf<Int>()
    var ans = 0
    for ((index, i) in a.withIndex()) {
        if (i !in seen) {
            if (index == a.size - 1 || a[index + 1] != i) ans++
            seen.add(i)
            for (j in i..(1e6).toInt() step i) seen.add(j)
        }
    }

    println(ans)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 137516
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int N;

    scanf("%d", &N);
    printf("%d\n", (N-1)/2);

    return 0;
}


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

int main()
{
    int a, b;
    std::string op;
    
    while (std::cin >> a >> op >> b) {
        if (op == "?") {
            break;
        }

        if (op == "+") {
            std::cout << a + b << std::endl;
        } else if (op == "-") {
            std::cout << a - b << std::endl;
        } else if (op == "*") {
            std::cout << a * b << std::endl;
        } else if (op == "/") {
            std::cout << a / b << std::endl;
        }                    
    }
    
    return 0;
}


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

int ctoi(char x){
  return x - '0';
}

int main() {
  string s; cin >> s;
  int N = stoi(s);
  
  int H=0;
  for(int i=0; i<s.size(); i++){
    H += ctoi(s[i]);
  }
  
  if(N%H==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

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

ll extgcd(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1; y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
}

int main(){
    ll n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    ll d = gcd(a, b);
    if(n > 2){
        ll c;
        cin >> c;
        d = gcd(d, c);
    }
    vll ans;
    for(ll i=1; i*i <= d; i++){
        if(d % i == 0){
            ans.push_back(i);
            if(i != d/i){
                ans.push_back(d/i);
            }
        }
            
    }
    sort(ans.begin(), ans.end());
    rep(i, ans.size())
        cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String s;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.s = sc.next();
    }
    
    //解答処理
    private String solve() {
        String answer = null;
        String[] S = s.split("");
        int A = Integer.valueOf(S[0]);
        int B = Integer.valueOf(S[1]);
        int C = Integer.valueOf(S[2]);
        int D = Integer.valueOf(S[3]);
        
        if (A + B + C + D == 7) {
        	answer = A + "+" + B + "+" + C + "+" + D + "=7";
        } else if (A + B + C - D == 7) {
        	answer = A + "+" + B + "+" + C + "-" + D + "=7";
        } else if (A + B - C + D == 7) {
        	answer = A + "+" + B + "-" + C + "+" + D + "=7";
        } else if (A - B + C + D == 7) {
        	answer = A + "-" + B + "+" + C + "+" + D + "=7";
        } else if (A - B - C + D == 7) {
        	answer = A + "-" + B + "-" + C + "+" + D + "=7";
        } else if (A + B - C - D == 7) {
        	answer = A + "+" + B + "-" + C + "-" + D + "=7";
        } else if (A - B + C - D == 7) {
        	answer = A + "-" + B + "+" + C + "-" + D + "=7";
        } else if (A - B - C - D == 7) {
        	answer = A + "-" + B + "-" + C + "-" + D + "=7";
        }
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 39408
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>

int main(void)
{
    int64_t N;
    std::cin >> N;

    int64_t prev;
    int64_t flag = true;
    std::cin >> prev;
    for (int64_t i=1; i < N; ++i) {
        int64_t h;
        std::cin >> h;
        if (prev > h) {
            flag = false;
            break;
        }
        if (prev == h) {
            continue;
        }
        prev = h - 1;
    }

    std::cout << (flag ? "Yes" : "No") << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline void rdi(int &x){
	int f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	if(f) x=-x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
int n;
ll a[17][17];
ll dp[1<<17];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	int i,j,k;
	for(i=0;i<n;++i) for(j=0;j<n;++j) cin>>a[i][j];
	for(i=0;i<(1<<n);++i){
		ll res(0);
		for(j=0;j<n;++j) for(k=0;k<j;++k) if((i>>j)&(i>>k)&1) res+=a[j][k];
		for(j=i;j;j=(j-1)&i) res=max(res,dp[j]+dp[i^j]);
		dp[i]=res;
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

Measured memory_bytes: 768
INF = 10 ** 20
def get_dist(r1, r2):
  c = r1 + r2
  b = abs(r1 - r2)
  return (c ** 2 - b ** 2) ** (1 / 2)

def minimum_width(rest, r, dic):
  if (rest, r) in dic:
    return dic[(rest, r)]
  if rest == ():
    return r

  ret = INF
  lenr = len(rest)
  for i, c in enumerate(rest):
    ret = min(ret, minimum_width(tuple(rest[j] for j in range(lenr) if i != j), rest[i], dic) + get_dist(r, rest[i]))
  dic[(rest, r)] = ret
  return ret


while True:
  try:
    lst = list(map(int, input().split()))
    w = lst[0]
    cakes = lst[1:]
    cakes.sort()
    lenc = len(cakes)
    dic = {}
    ans = INF
    for i in range(lenc):
      ans = min(ans, minimum_width(tuple(cakes[j] for j in range(lenc) if i != j), cakes[i], dic) + cakes[i])
    if w >= ans:
      print("OK")
    else:
      print("NA")
  except EOFError:
    break


Measured memory_bytes: 8872
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	long long s = 1;
	for (; s * s <= n; ++s) {
	}

	cout << (s - 1) * (s - 1) << "\n";

	return 0;

}

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

int main() {
  int N, Y;
  cin >> N >> Y;
  bool can = true;
  for (int i = 0; i <= N; i++) {
    bool can2 = false;
    for (int j = 0; j <= N - i; j++) {
      if ((Y - i * 10000 - j * 5000) / 1000 == N - i -j) {
        cout << i << " " << j << " " << N - i - j << endl;
        can = false;
        can2 = true;
        break;
      }
    }
    if (can2) break;
  }
  if (can) cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int an[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k; cin >> k;
	cout << an[k - 1] << endl;
}

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

ans = 0
M = 10**9+7
for i in range(60):
    x = 0
    for j in range(N):     
        if A[j]>>i & 1:
            x += 1
    now = x * (N - x) % M
    for j in range(i):
        now = now * 2 % M
    ans += now
    ans %= M
print(ans)

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

int main() {
    double w,h;
    int x,y;
    cin >> w>> h >> x>> y;
    double a;
    a=(w*h)/2;
    cout << fixed << setprecision(9)<< a << endl;
    if( x==(w/2) && y==(h/2)){   
        cout << 1 << endl; 
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
int n,m,h,w,i,j,flag;
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	n=read();m=read();h=read();w=read();
   	if(n%h==0&&m%w==0)
   		printf("No\n");
   	else{
   		flag=(1000000000-1)/(h*w-1);
   		printf("Yes\n");
   		for(i=1;i<=n;i++,cout<<endl)
   			for(j=1;j<=m;j++)
   				if(i%h==0&&j%w==0)
   					pus(-flag*(h*w-1)-1,1);
   				else
   					pus(flag,1);
	}
    return 0;
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,a,m;
    cin>>h>>a;
    m=h/a;
    if(h%a!=0)m++;
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	
	int m,f,r,mf;
	cin>>m>>f>>r;
	while(m!=-1||f!=-1||r!=-1){
		mf=m+f;
		if(m==-1||f==-1){
			cout<<"F"<<endl;
		}
		if(m!=-1&&f!=-1){
			if(mf>=80){
				cout<<"A"<<endl;
			}
			if(mf<80&&mf>=65){
				cout<<"B"<<endl;
			}
			if(mf<65&&mf>=50){
				cout<<"C"<<endl;
			}
			if(mf<50&&mf>=30){
				if(r>=50){
					cout<<"C"<<endl;
				}
				else{
					cout<<"D"<<endl;
				}
			}
			if(mf<30){
				cout<<"F"<<endl;
			}
		}
			cin>>m>>f>>r;
	}	
	return 0;
}

Measured memory_bytes: 3080
import java.util.*;
import java.lang.*;




public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A<10 && B<10) System.out.println(A*B);
        else System.out.println(-1);


    }
}


Measured memory_bytes: 23764
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int taro=0 ,hanako=0,x;
        int n=sc.nextInt();
        
        for(int i=0;i<n;i++){
            x=sc.next().compareTo(sc.next());
            if(x<0)hanako+=3;
            else if (x==0){hanako++;taro++;}
            else taro+=3;
        }
        
        System.out.printf("%d %d\n",taro,hanako);
    }
}



Measured memory_bytes: 30088
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

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

    vector<pair<int, int>> xy(n);
    for (int i = 0; i < n; i++) {
        cin >> xy[i].first >> xy[i].second;
    }

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

    double r1 = 0;
    int r2 = 0;
    do {
        for (int i = 1; i < n; i++) {
            r1 += sqrt((xy[i - 1].first - xy[i].first) * (xy[i - 1].first - xy[i].first)
                    + (xy[i - 1].second - xy[i].second) * (xy[i - 1].second - xy[i].second));
        }
        r2++;
    } while (next_permutation(xy.begin(), xy.end()));

    cout << setprecision(12) << fixed << r1 / r2 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] a = Read.Ints();
        for (int i = 0; i < a[0]; i++)
        {
            string[] s = Read.Strs();
            for (int k = 0; k < a[1]; k++)
            {
                if (s[k] == "snuke")
                {
                    Console.WriteLine((char)(k+'A')+""+(i+1));
                    break;
                }
            }
        }Console.ReadLine();
    }
}
public static class Read
{
    public static string read() { return Console.ReadLine(); }
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (int i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] Ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
ll sum;
int main(){
  cin >> N;
  rep(i,N+1){
    sum += i;
    if(sum >= N){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int ans =1;
		if(n>=2000) {
			
		}else {
			for(int i=0;i<20;i++) {
				if(n>i*105&&(i+1)*100>n) {
					ans=0;
					break;
				}
			}
		}
		System.out.println(ans);
	}
}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 21844
#include <stdlib.h> 
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>

using namespace std; 

int main()
{
  int n;

  cin>>n;

    if( n % 2 == 0) cout<< n / 2;
    else cout<<(n/2) + 1;

}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
LL ahako[100010];
LL bhako[100010];
int main(){
  LL n;
  LL a = 0;
  LL res = 0;
  cin >> n;
  rep(i,0,n+1){
    cin >> ahako[i];
  }
  rep(i,0,n){
    cin >> bhako[i];
  }
  rep(i,0,n){
    if(a > ahako[i]){
      res += ahako[i];
      a = bhako[i];
    }else{
      if((ahako[i] - a) > bhako[i]){
        res += bhako[i] + a;
        a = 0;
      }else{
        res += ahako[i];
        a = bhako[i] + a - ahako[i];
      }
    }
  }
  res += min(a,ahako[n]);
  cout << res << endl;
	return 0;
}


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

int main() {
  long long H, N; cin >> H >> N;
  long long A;
  for (int i=0; i<N; i++) {
    cin >> A;
    H -= A;
  }
  string ans ="Yes";
  if (H > 0) ans = "No";

  cout << ans << endl;

  return 0;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    ll t[100];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> t[i];

    ll tmp = t[0];
    for (int i = 1; i < n; i++)
    {
        int r = __gcd(t[i], tmp);
        tmp = (tmp / r) * t[i];
    }
    cout << tmp << endl;
}


Measured memory_bytes: 256
s = input()
t = input()
l0 = len(s)
l1 = len(t)
ans = 10**9
for i in range(l0 - l1 + 1):
  x = 0
  for j in range(l1):
    if s[i + j] != t[j]:
      x += 1
  ans = min(ans, x)
print(ans)


Measured memory_bytes: 9048
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		int n = ni();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nl();
		}

		long ans = 0;
		long tmp = a[0];
		for (int i = 1; i < n; i++) {
			if (tmp > a[i]) {
				ans += tmp - a[i];
				a[i] = tmp;
			}
			tmp = a[i];
		}

		out(ans);

	}

	/*
	 * 以下メソッド集
	 */

	public static void permutation(String q, String ans) {
		// Base Case
		if (q.length() <= 1) {
			System.out.println(ans + q);
		}
		// General Case
		else {
			for (int i = 0; i < q.length(); i++) {
				permutation(q.substring(0, i) + q.substring(i + 1),
						ans + q.charAt(i));
			}
		}
	}

	static char[][] same(char[][] c, int h, int w) {

		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				a[i][j] = c[i][j];
			}
		}
		return a;

	}

	static int countkuro(char[][] c) {

		int count = 0;
		for (char[] cc : c) {
			for (char ccc : cc) {
				if ('#' == ccc) {
					count++;
				}
			}
		}
		return count;
	}

	static void debug() {

		out("---");
	}

	static void debug(Object a) {

		out("-------");
		out(a);
		out("-------");
	}

	static int ketasuu(int n) {

		String str = "" + n;
		return str.length();
	}

	static int account(String str) {

		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {

		return sc.nextInt();
	}

	static long nl() {

		return sc.nextLong();
	}

	static double nd() {

		return sc.nextDouble();
	}

	static String n() {

		return sc.next();
	}

	static char[] nc() {

		return sc.next().toCharArray();
	}

	static int kaijo(int n) {

		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {

		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {

		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(Object obj) {
		System.out.println(obj);
	}

	static void outn(Object obj) {
		System.out.print(obj);
	}

	static double max(double d, double e) {

		return Math.max(d, e);
	}

	static long max(long a, long b) {

		return Math.max(a, b);
	}

	static long min(long d, long e) {

		return Math.min(d, e);
	}

	static int min(int a, int b) {

		return Math.min(a, b);
	}
}

class XY {

	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 62552
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

struct edge {
	int to,  cost;
};
vector<int> G[100010];
int color[100010];

bool visited[100010];

void dfs(int n) {
	for (auto x : G[n]) {
		if (!visited[x]) {
			visited[x] = true;
			dfs(x);
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M; cin >> N >> M;
	REP(i, M) {
		int x, y, z; cin >> x >> y >> z;
		x--, y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	int ans = 0;
	m0(visited);
	REP(i, N) {
		if (!visited[i]) {
			ans++;
			dfs(i);
		}
	}
	print(ans);
}

Measured memory_bytes: 8960
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {

	string s;
	scans(s);
	int n = s.length();
	bool b = true;
	string t = "", k = "";
	rep(i, (n - 1) / 2)t += s[i];
	for (int i = (n + 3) / 2 - 1; i < n; ++i)k += s[i];
	for (int i = 0; i < t.length() / 2; ++i) {
		if (t[i] != t[t.length() - 1 - i])b = false;
	}
	for (int i = 0; i < k.length() / 2; ++i) {
		if (k[i] != k[k.length() - 1 - i])b = false;
	}
	reverse(all(k));
	if (t != k)b = false;

	printyn(b);

	Please AC;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	//💡そうか!
	//QとRの切れ目を全探索する
	//するとPQもRSも真ん中で切った方がいい気持ちになれる(意味深)
	llint n,i,ans=big;cin>>n;
	vector<llint>wa(n+1);
	for(i=1;i<=n;i++){cin>>wa[i];wa[i]+=wa[i-1];}
	for(i=2;i<=n-2;i++){
		llint Lba=LBI(wa,wa[i]/2);
		llint Lsyo=max(wa[Lba-1],wa[i]-wa[Lba]),Ldai=wa[i]-Lsyo;
		llint Rba=LBI(wa,(wa[n]-wa[i])/2+wa[i]);
		llint Rsyo=max(wa[Rba-1]-wa[i],wa[n]-wa[Rba]),Rdai=(wa[n]-wa[i])-Rsyo;
		mineq(ans,max(Ldai,Rdai)-min(Lsyo,Rsyo));
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

bool binarySearch(vector<int> vi, int t) {
    int right = vi.size() - 1;
    int left = 0;
    bool flg = true;
    while (flg) {
        if(right == left) flg = false;
        int center = (left + right) / 2;
        if (vi[center] < t) {
            left = center + 1;
        } else if (vi[center] > t) {
            right = center;
        } else {
            return true;
        }
    }
    return false;
}

int main() {
    vector<int> vi;
    int n, q;
    int count = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int s;
        cin >> s;
        vi.push_back(s);
    }
    sort(vi.begin(), vi.end());
    cin >> q;
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        count += binarySearch(vi, t);
    }
    cout << count << endl;
    return 0;
};


Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int n,l=1,r=1;
ll a[200005],s[200005],x[200005],ans=0;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i],x[i]=x[i-1]^a[i];
	while(r<=n){
		while(s[r]-s[l-1]!=(x[r]^x[l-1])) l++;
		ans+=r-l+1;
		r++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4992
*RBG, n = map(int, input().split())
RBG.sort()
a, b, c = RBG
ans = 0
for i in range(n//c + 1):
    t = n - c*i
    for j in range(t//b + 1):
        ans += (t - j*b) % a == 0
print(ans)

Measured memory_bytes: 9096
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x);
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x);
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

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

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i) cin >> vec[i];
}

int main() {
  ll K, A, B;
  cin >> K >> A >> B;
  if (A >= K) {
    print(1);
  } else {
    if (A <= B) {
      print(-1);
    } else {
      print((K - A + A - B - 1) / (A - B) * 2 + 1);
    }
  }
  return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> nums(N);
    ll hiNum = 0;
    for (int i = 0; i < N; i++)
    {
        ll A;
        cin >> A;
        nums.at(i) = A;
        hiNum = max(hiNum, A);
    }
    ll answer = 0;
    if(K == 0)
    {
        for(int i = 0; i < N; i++)
        {
            answer += nums.at(i);
        }
        cout << answer << endl;
        return 0;
    }
    int aKeta = 0;
    ll tmpHiNum = hiNum;
    while (tmpHiNum)
    {
        tmpHiNum /= 2;
        aKeta++;
    }
    int kKeta = 0;
    ll tmp = K;
    while (tmp)
    {
        tmp /= 2;
        kKeta++;
    }
    //aKetaからkKetaまでをそのまま加算する処理
    ll checkBit = 1LL << (aKeta - 1);
    for (int i = 0; i < aKeta - kKeta; i++)
    {
        for (ll num : nums)
        {
            answer += num & checkBit;
        }
        checkBit = checkBit >> 1;
    }
    //kKetaからのaの各桁のbitを算出
    vector<ll> bitCounts(kKeta); // Kの最大桁の左(大きい順)から0, 1 ,2で1が経っている数(0はN - bitCountで取得)
    checkBit = 1LL << (kKeta - 1);
    for (int i = 0; i < kKeta; i++)
    {
        for (ll num : nums)
        {
            if (num & checkBit)
            {
                bitCounts.at(i)++;
            }
        }
        checkBit = checkBit >> 1;
    }
    vector<vector<ll>> dp(2, vector<ll>(kKeta + 1)); //0が境界、1がそれよりsmallerでの左からi桁まででXORした時の最大値
    checkBit = 1LL << (kKeta - 1);
    //必ず最初はbitが立っている
    dp.at(0).at(1) = (N - bitCounts.at(0)) * checkBit;
    dp.at(1).at(1) = bitCounts.at(0) * checkBit;
    checkBit = checkBit >> 1;
    for (int i = 1; i < kKeta; i++)
    {
        ll bitCount = bitCounts.at(i);
        ll zeroCount = N - bitCount;

        ll hiCount = max(zeroCount, bitCount);
        ll hiSum = hiCount * checkBit;
        if (K & checkBit)
        {
            //1が境界
            dp.at(0).at(i + 1) = dp.at(0).at(i) + zeroCount * checkBit;
            //smallerの方はsmallerのうち、最大の結果を格納
            //(今まで境界から0になったものと、既に境界未満のものから最大で取ったものの大きい方)
            dp.at(1).at(i + 1) = max(dp.at(0).at(i) + bitCount * checkBit, dp.at(1).at(i) + hiSum);
        }
        else
        {
            //0が境界
            dp.at(0).at(i + 1) = dp.at(0).at(i) + bitCount * checkBit;
            //smallerの方はsmallerのうち、最大の結果を格納
            dp.at(1).at(i + 1) = dp.at(1).at(i) + hiSum;
        }
        checkBit = checkBit >> 1;
    }
    answer += max(dp.at(0).at(kKeta), dp.at(1).at(kKeta));
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 1024
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(['#']+input().split()+['#'])
ans1 = ['#'] * (w+2)
print(''.join(ans1))
for i in range(h):
    print(''.join(a[i]))
print(''.join(ans1))

Measured memory_bytes: 3060