akhauriyash/Code-Regression huggingface dataset:
/*
Author : N_o_o_B
Created : April 22 2020 21:44:54 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#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 ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    int k;
    cin >> k;
    vi a(n,k);
    int q;
    cin >> q;
    int sub = q;
    while(q--){
        int x;
        cin >> x;
        --x;
        a[x] += 1;
    }

    fori(i,n){
        if(a[i] > sub){
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }

    time_taken();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>

using namespace std;

const int MAX_N = 805;
const int INF = 1e9 + 5;

char grid [MAX_N][MAX_N];
int dist [MAX_N][MAX_N];
int ni [4] = {1, 0, -1, 0};
int nj [4] = {0, 1, 0, -1};

int main () {
  ios::sync_with_stdio(false);
  
  int h, w, K;
  cin >> h >> w >> K;

  for (int i = 0; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      grid[i][j] = '#';
      dist[i][j] = INF;
    }
  }

  queue<pair<int, int>> Q;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> grid[i][j];
      if (grid[i][j] == 'S') {
        grid[i][j] = '.';
        dist[i][j] = 0;
        Q.push(make_pair(i, j));
      }
    }
  }

  int ans = INF;
  while (!Q.empty()) {
    auto cur = Q.front();
    Q.pop();

    int d = dist[cur.first][cur.second];
    if (d <= K) {
      int rest = min(min(cur.first - 1, cur.second - 1),
                     min(h - cur.first, w - cur.second));
      ans = min(ans, 1 + (rest + K - 1) / K);
    }

    int x = cur.first;
    int y = cur.second;
    
    for (int k = 0; k < 4; k++) {
      if (grid[x + ni[k]][y + nj[k]] != '#' &&
          dist[x + ni[k]][y + nj[k]] == INF) {
        dist[x + ni[k]][y + nj[k]] = dist[x][y] + 1;
        Q.push(make_pair(x + ni[k], y + nj[k]));
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6756
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        
        while(true){
        int a = scan.nextInt();
        String op = scan.next();
        int b = scan.nextInt();
        
        if(op.equals("?"))break;
        
        int ans = 0;
        
            switch(op){
            case "*":
                ans = a * b;
                break;
                
            case "/":
                ans = a / b;
            break;
            
            case "+":
                ans = a + b;
                break;
                
            case "-":
              ans = a - b;
                break;
        }
          System.out.println(ans);
        }
        
    }
}


Measured memory_bytes: 26368
s = input()

import re
output ="NO"
s = re.sub('dreameraser', 'A', s)
s = re.sub('dreamerase', 'A', s)
s = re.sub('dreamer', 'A', s)
s = re.sub('eraser', 'A', s)
s = re.sub('erase', 'A', s)
s = re.sub('dream', 'A', s)
if s.isupper() :
    output = "YES"
print(output)

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

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

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

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

int n;
ll a[100010],imos[100010];

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

	cin>>n;
	REP(i,n) {
		cin>>a[i+1];
		imos[i+1]+=imos[i]+abs(a[i+1]-a[i]);
	}
	imos[n+1]+=imos[n]+abs(a[n]);
	REP(i,n) {
		cout<<imos[i]+(imos[n+1]-imos[i+2])+abs(a[i+2]-a[i])<<endl;
	}

	return 0;
}


Measured memory_bytes: 2816
N=int(input())
T=[[int(j) for j in input().split()] for i in range(N)]
m=0
T.reverse()
T.append([0,0,0])
T.reverse()
for i in range(N):
    l_i=T[i][1]+T[i][2]
    l_iadd=T[i+1][1]+T[i+1][2]
    t_iadd_i=T[i+1][0]-T[i][0]
    l=t_iadd_i-l_iadd+l_i
    mod=l%2
    if l>=0:
        if mod==0:
            m+=1
        else:
            break
    else:
        break
if m==N:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21156
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int comp(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

int main()
{
	int n, i, d[3];

	scanf("%u", &n);
	for(i=0; i<n; i++){
		scanf("%u %u %u", &d[0], &d[1], &d[2]);

		qsort(d, 3, sizeof(int), comp);

		if( (d[2]*d[2]) == (d[0]*d[0]) + (d[1]*d[1]) ){ puts("YES"); }
		else puts("NO");
	}
    return 0;
}

Measured memory_bytes: 588
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i <= n; i ++)
    for (int j = 0; j <= m; j ++)
      if (i * (m - j) + j * (n - i) == k) return puts("Yes"), 0;
  return puts("No"), 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll A, B, C, K; cin >> A >> B >> C >> K;
    if(A>=K){
        cout << K;
    }else if(A + B >= K){
        cout << A;
    }else{
        cout << A - (K - A - B);
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n, m;
	cin >> n >> m;
	vi a(n), b(n), c(m), d(m);
	vi ans(n);
	rep(i, n) cin >> a[i] >> b[i];
	rep(i, m) cin >> c[i] >> d[i];
	rep(i, n) {
		rep(j, m) {
			if(abs(a[i] - c[j]) + abs(b[i] - d[j]) < abs(a[i] - c[ans[i]]) + abs(b[i] - d[ans[i]])) ans[i] = j;
		}
	}
	rep(i, n) cout << ans[i] + 1 << endl;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while (A > 0) {
    C -= B;
    A -= D;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
  }
  if ( C > 0) {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
	int c1, c5, c10, c50, c100, c500;
	
	scanf("%d%d%d%d%d%d", &c1, &c5, &c10, &c50, &c100, &c500);

	if ((c1       + c5   * 5   + c10  * 10 +
	     c50 * 50 + c100 * 100 + c500 * 500) < 1000){
		printf("0\n");
	   
	}
	else {
		printf("1\n");
	}
	
	return (0);
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll h, w;
	cin >> h >> w;
	vector<string> a(h);
	vector<bool> badh(h, false), badw(w, false);
	for (ll i = 0; i < h; i++) cin >> a[i];
	for (ll i = 0; i < h; i++) {
		for (ll j = 0; j < w; j++) {
			if (a[i][j] == '#') break;
			if (j == w - 1) badh[i] = true;
		}
	}
	for (ll j = 0; j < w; j++) {
		for (ll i = 0; i < h; i++) {
			if (a[i][j] == '#') break;
			if (i == h - 1) badw[j] = true;
		}
	}
	for (ll i = 0; i < h; i++) {
		if (badh[i]) continue;
		for (ll j = 0; j < w; j++) {
			if (badw[j]) continue;
			cout << a[i][j];
		}cout << endl;
	}
}

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

struct edge {
	int to, cap, rev;
};

vector<edge>X[100009]; bool used[100009];

void add_edge(int u, int v, int w) {
	X[u].push_back(edge{ v, w, (int)X[v].size() });
	X[v].push_back(edge{ u, 0, (int)X[u].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t) return f;
	used[v] = true;
	for (int i = 0; i < X[v].size(); i++) {
		if (used[X[v][i].to] == true || X[v][i].cap <= 0) continue;
		int D = dfs(X[v][i].to, t, min(X[v][i].cap, f));
		if (D > 0) {
			X[v][i].cap -= D;
			X[X[v][i].to][X[v][i].rev].cap += D;
			return D;
		}
	}
	return 0;
}
int max_flow(int u, int v) {
	int ret = 0;
	while (true) {
		for (int i = 0; i < 20009; i++) used[i] = false;
		int T = dfs(u, v, 1000000007);
		if (T == 0) break;
		ret += T;
	}
	return ret;
}

int H, W; string S[100]; bool flag = false;

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i >= 1 && i < H - 1 && j >= 1 && j < W - 1) continue;
			if (S[i][j] == 'X') flag = true;
		}
	}
	if (flag == true) { cout << "-1" << endl; return 0; }
	int cnts = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] != 'X') { add_edge(H*W + cnts, cnts, 1); }
			if (S[i][j] == 'X') { add_edge(H*W + cnts, cnts, 1000000007); }
			cnts++;
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
			for (int k = 0; k < 4; k++) {
				int cx = i + dx[k], cy = j + dy[k];
				if (cx < 0 || cy < 0 || cx >= H || cy >= W) continue;
				add_edge(i*W + j, H*W + cx*W + cy, 1000000007);
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == 'X') add_edge(2 * H*W, H*W + i*W + j, 1000000007);
			if (i >= 1 && i < H - 1 && j >= 1 && j < W - 1) continue;
			add_edge(i*W + j, 2 * H*W + 1, 1000000007);
		}
	}
	cout << max_flow(2 * H*W, 2 * H*W + 1) << endl;
	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
const ll inf=10000000000;
int n,m,v,p;
int a[max_n];
ll b[max_n];
bool ok(int x){
    ll res=0;
    for(int i=1;i<=n;i++)res+=min(x*1ll,b[i]);
    return res>=1ll*x*v;
}
bool check(int x){
    int tot=p-1;
    for(int i=1;i<=n;i++){
        if(i==x){
            b[i]=a[i]+m;
            continue;
        }
        if(tot==0){
            b[i]=a[x]+m;
        }
        else{
            tot--;
            b[i]=inf;
        }
    }
    for(int i=1;i<=n;i++)if(b[i]<a[i])return false;
    /*
    for(int i=1;i<=n;i++)cout<<a[i]<<' ';
    cout<<endl;
    for(int i=1;i<=n;i++)cout<<b[i]<<' ';
    cout<<endl;
    */
    for(int i=1;i<=n;i++)b[i]-=a[i];
    int l=0,r=m;
    int mid,ans;
    while(l<=r){
        mid=l+r>>1;
        if(ok(mid))ans=mid,l=mid+1;
        else r=mid-1;
    }
    return ans>=m;
}
int main(){
    scanf("%d%d%d%d",&n,&m,&v,&p);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    sort(a+1,a+n+1,greater<int>());
    check(5);
    int ans=0;
    int l=1,r=n;
    int mid;
    while(l<=r){
        mid=l+r>>1;
        if(check(mid))ans=mid,l=mid+1;
        else r=mid-1;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	double a[n+1];
	string st[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i]>>st[i];
	}
	double jpy=0,btc=0;
	for(int i=1;i<=n;i++){
		if(st[i]=="JPY"){
			jpy+=a[i];
		}
		else{
			btc+=a[i];
		}
	}
	btc*=380000;
	jpy+=btc;
	cout<<jpy;
	return 0;
}


Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    use std::collections::VecDeque;
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut d: Vec<Vec<usize>> = vec![Vec::new(); n];
    let m: usize = scan(tokens);
    for _ in 0..m {
        let a: usize = scan(tokens);
        let b: usize = scan(tokens);
        d[a - 1].push(b - 1);
    }
    let mut ans = Vec::new();
    let mut prev = vec![0; n];
    let mut visited = vec![false; n];
    let mut que = VecDeque::new();
    'a: for s in 0..n {
        for i in 0..n {
            visited[i] = false;
        }
        que.clear();
        que.push_back(s);
        while let Some(i) = que.pop_front() {
            for j in d[i].clone() {
                if j == s {
                    let mut res = Vec::new();
                    let mut k = i;
                    while {
                        res.push(k);
                        k != s
                    } {
                        k = prev[k];
                    }
                    res.reverse();
                    ans.push((res.len(), res));
                    continue 'a;
                }
                if !visited[j] {
                    visited[j] = true;
                    prev[j] = i;
                    que.push_back(j);
                }
            }
        }
    }
    if ans.is_empty() {
        println!("-1");
    } else {
        ans.sort();
        println!("{}", ans[0].0);
        for &k in &ans[0].1 {
            println!("{}", k + 1);
        }
    }
}


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

ll gcd(ll x, ll y){
	if(y == 0) return x;
	return gcd(y, x%y);
}

int main(){
	ll n,X;
	cin >> n >> X;
	vector<ll> x(n);
	rep(i,n){
		cin >> x[i];
	}
	sort(x.begin(),x.end());
	vector<ll> temp;
	rep(i,n-1){
		temp.push_back(x[i+1] - x[i]);
	}
	ll val = 0;
	rep(i,n-1){
		val = __gcd(val, temp[i]);
	}
	ll ans = 0;
	rep(i,n){
		ans = max(ans, __gcd(val, abs(X-x[i])));
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
	priority_queue<pair<int, int> > PQ;
	int color[MAX], d[MAX];
	for(int i = 0; i < n; i++) {
		color[i] = WHITE;
		d[i] = INFTY;
	}
	
	d[0] = 0;
	PQ.push(make_pair(0, 0));
	color[0] = GRAY;
	
	while(!PQ.empty()) {
        pair<int, int> f = PQ.top();
		PQ.pop();
		int u = f.second;
		
		color[u] = BLACK;
		
		
		for(int j = 0; j < adj[u].size(); j++) {
			int v = adj[u][j].first;
			if(color[v] == BLACK) continue;
			if(d[v] > d[u] + adj[u][j].second) {
				d[v] = d[u] + adj[u][j].second;
				PQ.push(make_pair(d[v] * (-1), v));
				color[v] = GRAY;
			}
		}		
	}
	
	for(int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	} 
}


int main() {
	int u, k, v, c;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> u >> k;
		for(int j = 0; j < k; j++) {
			cin >> v >> c;
			adj[u].push_back( make_pair(v, c));
		}
	}
	
	dijkstra();
	
	return 0;
}

Measured memory_bytes: 3396
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var searchText = "ACGT"

func checkString(char rune) bool {
	return strings.Contains(searchText, string(char))
}

func main() {
	var input string
	if sc.Scan() {
		input = sc.Text()
	}

	count := 0
	maxCount := 0

	for i := range input {
		if checkString(rune(input[i])) {
			count++
			if count > maxCount {
				maxCount = count
			}
		} else {
			count = 0
		}
	}
	fmt.Println(maxCount)
}


Measured memory_bytes: 640
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        String str = sc.next();

        int count = 1;

        String s = str.substring(0,1);

        int i =1;
        while(i<str.length()){
            int j = i+1;
            if ((i==str.length()-1) && s.equals(str.substring(i, j))) break;
            while(s.equals(str.substring(i, j))){
                j++;
            }
            s = str.substring(i, j);
            i = j;
            count++;
        }

        System.out.println(count);

    }
}

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

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n = int.Parse(Console.ReadLine());
            //string[] str = Console.ReadLine().Split(' ');

            string[] str = Console.ReadLine().Split(' ');

            int n = int.Parse(str[0]);
            int m = int.Parse(str[1]);
            int x = int.Parse(str[2]);

            var a = new int[n , m + 1];

            var sum = new int[m + 1];

            for (int i = 0; i < n; i++)
            {
                str = Console.ReadLine().Split(' ');
                for (int j = 0; j < m + 1; j++)
                {
                    a[i, j] = int.Parse(str[j]);
                    sum[j] += a[i, j];
                }
            }

            int[] temp = sum.Skip(1).ToArray();
            if (temp.Min() < x)
            {
                Console.WriteLine(-1);
                return;
            }

            for (int i = 0; i < sum.Length; i++) { sum[i] = 0; }

            var tf = new int[n];

            int ans = 1200000;
            for(int i = 0; i < (int)Math.Pow(2, n); i++)
            {
                var add = new int[m + 1];
                for(int j = 0; j < n; j++)
                {
                    if (tf[j]==1) add = Buy(a, add, j);
                }

                ans = Min(ans, Judge(add, x));

                tf[0]++;
                for(int j = 0; j < n-1; j++)
                {
                    if (tf[j]>1)
                    {
                        tf[j + 1]++;
                        tf[j] = 0;
                    }
                }
            }

            Console.WriteLine(ans);

            //ここまで
        }

        

        static int Min(int a,int b)
        {
            if (a < b) return a;
            return b;
        }

        /*static int Compare(int[,] a, int[] sum, int place, int x, int n, bool boo)
        {
            if (place == n) return sum[0];

            if (boo) sum = Buy(a, sum, place);

            if (Judge(sum, x) < 12000000) return sum[0];
            
            return Min(Compare(a, sum, place + 1, x, n, true), Compare(a, sum, place + 1, x, n, false));


        }*/

        static int Judge(int[] sum, int x)
        {
            int[] temp = sum.Skip(1).ToArray();
            if (temp.Min() >= x) return sum[0];
            else return 12000000;
        }

        static int[] Buy(int[,]  a, int[] sum, int place)
        {
            for(int i = 0; i < sum.Length; i++)
            {
                sum[i] += a[place, i];
            }
            return sum;
        }
        

    }

}


Measured memory_bytes: 29488
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;

    return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

bool primes[N];
int cnt[N];

void prime()
{
  primes[0] = primes[1] = 1;
  for(int i=2; i*i <= N; i++)
  {
    if(primes[i] == 0)
    {
      for(int j=i*i; j<= N; j+=i)
      {
        primes[j] = 1;
      }
    }
  }
}

int main()
{
  int q;
  cin>>q;
  prime();
  int ct = 0;
  repn(i, 1, N)
  {
    if(primes[i] == 0 && i != 2)
    {
      if(primes[(i+1)/2] == 0)
      {
        ct++;
      }
    }
    cnt[i] = ct;
  }
  while(q--)
  {
    int l, r;
    cin>>l>>r;
    int ans = cnt[r] - cnt[l-1];
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
map<int, char> x;
char s[100010], t[100010];
int main(){
  ll n, m;
  cin>>n>>m;
  scanf("%s%s",s,t);
  ll tmp, g=__gcd(n, m);
  tmp=(n*m)/g;
  for(ll i=0; i<tmp; i+=tmp/n){
    x[i]=s[i/(tmp/n)];
  }
  bool l=1;
  for(ll i=0; i<tmp; i+=tmp/m){
    if(x.count(i) && x[i]!=t[i/(tmp/m)]){
        l=0;
        break;
    }
  }
  if(l)
    cout<<tmp<<endl;
  else
    cout<<-1<<endl;
  return 0;
}




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

using namespace std;

const int N = 100010;

int n, k;
int h[N];
int f[N];

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> h[i];
    memset(f, 0x3f, sizeof f);
    f[1] = 0;
    for (int i = 2; i <= n; i++) {
        for (int j = max(0, i - k); j < i; j++)
            f[i] = min(f[i], f[j] + abs(h[i] - h[j]));
            
    }
    cout << f[n] << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for(int i=(l);i<(r);i++)
#define forb(i,r,l) for(int i=(r);i>(l);i--)
#define log2i(x) 32 - __builtin_clz((x)) - 1
#define log2ll(x) 64 - __builtin_clzll((x)) - 1
#define Pi acos(-1.0)
#define sz(x) (int)x.size()
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int x,y,sl[3];
ll ans=0;
vi a[3], b;

int main() {
#ifndef ONLINE_JUDGE
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
#endif
    fastIO;
    cin >> x >> y >> sl[0] >> sl[1] >> sl[2];
    forw(i,0,3) {
        forw(j,0,sl[i]) {
            int tmp;
            cin >> tmp;
            a[i].pb(tmp);
        }
        sort(all(a[i]),greater<int>());
    }
    forw(i,0,x) b.pb(a[0][i]);
    forw(i,0,y) b.pb(a[1][i]);
    forw(i,0,sl[2]) b.pb(a[2][i]);
    sort(all(b),greater<int>());
    forw(i,0,x+y) ans+=b[i];
    cout << ans;
    return 0;
}


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

int main(){
	string n;
	int flag = 0;

	cin >> n;
	for(int i = 0;i < 3;i++){
		if(n.at(i) == '7'){
			flag = 1;
			break;
		}
	}
	if (flag == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
#define ll long long 
#define il inline
const int maxn=200010;
struct node{
    ll a,b;
    node(ll _a,ll _b):a(_a),b(_b){}
};
bool operator < (const node &na,const node &nb){
    return min(na.a,na.b)<min(nb.a,nb.b);
}
priority_queue<node> q;
ll a[maxn]; int n;
ll ans;
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;++i){
        scanf("%lld",&a[i]);
    }
    if (n==1){
        cout<<"0";
        exit(0);
    }
    if (n==2){
        cout<<max(a[1],a[2]);
        exit(0);
    }
    sort(a+1,a+1+n); ans+=a[n];
    q.push(node(a[n-1],a[n]));
    q.push(node(a[n-1],a[n]));
    for (int i=n-2;i>=1;--i){
        node tmp=q.top(); q.pop();
        //cout<<a[i]<<" "<<tmp.a<<" "<<tmp.b<<endl;
        ans+=min(tmp.a,tmp.b);
        q.push(node(tmp.a,a[i]));
        q.push(node(tmp.b,a[i]));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9056
#include <iostream>
using namespace std;
int getDiag(int, int);
int main(void){
    while(true){
        int h, w;
        cin >> h >> w;
        if(h == 0){
            break;
        }
        int minH = 150, minW = 150;
        for(int H = 1; H <= 151; H++){
            for(int W = H + 1; W <= 151; W++){
                if(getDiag(h, w) < getDiag(H, W) || (getDiag(h, w) == getDiag(H, W) && h < H)){
                    if(getDiag(minH, minW) > getDiag(H, W) || (getDiag(minH, minW) == getDiag(H, W) && minH > H)){
                        minH = H;
                        minW = W;
                    }
                }
            }
        }
        cout << minH << ' ' << minW << endl;
    }
}

int getDiag(int _h, int _w){
    return (_h*_h) + (_w*_w);
}



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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> tt, xx, yy;
  tt.push_back(0);
  xx.push_back(0);
  yy.push_back(0);

  for (int k = 0; k < n; k++) {
    int t, x, y;
    scanf("%d %d %d", &t, &x, &y);
    tt.push_back(t);
    xx.push_back(x);
    yy.push_back(y);
    t = tt[k+1] - tt[k];
    x = xx[k+1] - xx[k];
    y = yy[k+1] - yy[k];
    if (t < x + y || (t - (x + y)) % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

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

vector <int> from[200010];
int ans[200010];
int cnt[10];

void dfs(int x, int last) {
	cnt[ans[x]]++;
	for (int i = 0; i < from[x].size(); i++) {
		int v = from[x][i];
		if (v == last) continue;
		ans[v] = 3 - ans[x], dfs(v, x);
	}
}

int main () {
	int n; scanf("%d", &n);
	int a = n / 3, b = (n + 2) / 3, c = (n + 1) / 3;
	for (int i = 1; i < n; i++) {
		int x, y; scanf("%d%d", &x, &y);
		from[x].push_back(y);
		from[y].push_back(x);
	}
	ans[1] = 1, dfs(1, 1);
	if (cnt[1] < cnt[2]) {
		for (int i = 1; i <= n; i++) {
			ans[i] = 3 - ans[i];
		}
		swap(cnt[1], cnt[2]);
	}
	if (cnt[1] <= b + a) {
		int t1 = cnt[1] - b, t2 = cnt[2] - c;
		for (int i = 1; i <= n; i++) {
			if (ans[i] == 1) {
				if (t1) t1--, ans[i] = 0;
			} else {
				if (t2) t2--, ans[i] = 0;
			}
		}
		int now[3] = {3, 1, 2};
		for (int i = 1; i <= n; i++) {
			printf("%d ", now[ans[i]]);
			now[ans[i]] += 3;
		}
		printf("\n");
		return 0;
	}
	int T = c, T1 = a - cnt[2];
	for (int i = 1; i <= n; i++) {
		if (ans[i] == 2) {
			ans[i] = 0;
		} else if (ans[i] == 1) {
			if (T) T--, ans[i] = 2;
			else if (T1) T1--, ans[i] = 0;
		}
	}
	int now[3] = {3, 1, 2};
	for (int i = 1; i <= n; i++) {
		printf("%d ", now[ans[i]]);
		now[ans[i]] += 3;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 20864
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	int n = sc.nextInt();
      	long count = 0;
      	long max = 1;
      	String sstack1;
      	String sstack2;
      	boolean fst = true;
        List wList = new ArrayList<String>();
      	List aList = new ArrayList<String>();
      	Map<String,Integer> wMap = new HashMap<String,Integer>();
      
      	for(int i = 0;i < n;i++){
          wList.add(sc.next());
        }
      	Collections.sort(wList);
      	wList.add("AC祈願");
      	sstack1 = (String)wList.get(0);
      	count = 1;
      	max = 1;
      	for(int i = 1;i < wList.size();i++){
          	sstack2 = (String)wList.get(i);
        	if(sstack1.equals(sstack2)) count++;
          	else{
              if(fst){
              	max = count;
              	aList.add(sstack1);
              	count = 1;
                fst = false;
              } else if(count == max){
              	aList.add(sstack1);
                count = 1;
              } else if(count > max){
                aList.clear();
                aList.add(sstack1);
                max = count;
                count = 1;
              } else count = 1;
            }
          	sstack1 = sstack2;
          	
        }
   
      	for(int i = 0;i < aList.size();i++){
          	System.out.println(aList.get(i));
        }      	
        
	}
}


Measured memory_bytes: 74460
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
typedef long long ll ;
#define pll pair<ll , ll >
#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
using namespace std;
const int maxn = 2000*1000+5 ;
const ll inf = 9223372036854775807 ;
const ll mod = 998244353 ;
ll ps[maxn] , n , m , k  , a[maxn] , mark[maxn]  , dp[maxn] , l[maxn] , r[maxn];  vec<int> v ; 
int main()
{
	migmig ;
	cin>>n>>k;
	for(int i = 1 ; i<= k ; i ++) 
	{
		cin>>l[i]>>r[i] ; 
		a[l[i]] += 1 ; 
		a[r[i] + 1] -= 1; 
	}
	int cnt = 0 ; 
	for(int i = 1;  i<= n ; i ++)
	{
		cnt+=a[i] ; 
		if(cnt > 0) 
		{
			v.pb(i);
			dp[i] = 1 ; 
		 } 
	}
	//for(auto u : v) cout<<u <<" " ; 
	dp[0] = 0 ; 
	for(ll i = 1;  i < n ; i ++)
	{
		for(int j = 1 ; j <= k ; j ++)
		{
			dp[i] = (dp[i] + ps[max(0ll , i - l[j])] - ps[max(0ll , i - r[j] - 1)] ) % mod ; 
		}
		ps[i] = ps[i-1] + dp[i] ; 
	//	cout<<i <<" : " << dp[i] << endl ; 
	}
	cout<<dp[n-1] ; 
}








Measured memory_bytes: 7212
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int a, b, c, d;
	long n;
	scanf("%d%d%d%d%ld", &a, &b, &c, &d, &n);
	if(a*2<b) b=a*2;
	if(b*2<c) c=b*2;
	if(c*2<d) d=c*2;
	printf("%ld\n", n/2*d+n%2*c);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <bitset>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define PII pair <ll,ll>
#define N 100007
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

bool board[1001][1001];
int dp[1001][1001];

int main() {
    int h, w;
    char x;
    cin >> h >> w;
    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            cin >> x;
            board[i][j] = x == '.';
        }
    }
    dp[h][w] = 1;
    for(int i = h; i > 0; i--) {
        for(int j = w; j > 0; j--) {
            if(i == h && j == w) continue;
            dp[i][j] = 0;
            if(!board[i][j]) continue;
            if(i < h) {
                dp[i][j] += dp[i+1][j];
                dp[i][j] %= MOD;
            }
            if(j < w) {
                dp[i][j] += dp[i][j+1];
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[1][1];
    return 0;
}

Measured memory_bytes: 5120
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().ToCharArray();

            var x = 0;
            var max = x;
            for(var i = 0; i < n; i++){
                if(s[i] == 'I'){
                    x++;
                }else{
                    x--;
                }
                max = Math.Max(max, x);
            }
            Console.WriteLine(max);
        }
    }
}


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



public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(in.readLine());
		
		//Scanner sc = new Scanner(System.in);
		//String line1 = sc.nextLine();
		//int n = Integer.parseInt(line1);

		Deque<Integer> list = new ArrayDeque<Integer>();

		for (int i = 0; i < n; i++) {
			String kari = in.readLine();

			// if (kari.equals("deleteFirst")) {
			// list.remove(list.size() - 1);
			// } else if (kari.equals("deleteLast")) {
			// list.remove(0);
			// } else {
			// String[] kari2 = kari.split(" ");
			// int x = Integer.parseInt(kari2[1]);
			// if (kari2[0].equals("insert")) {
			// list.add(x);
			// } else if (kari2[0].equals("delete")) {
			// if (list.contains(x)) {
			// list.remove(list.lastIndexOf(x));
			// }
			// }
			// }

			if (kari.charAt(0) == 'i') {
				list.offerFirst(Integer.parseInt(kari.substring(7)));
			} else if (kari.charAt(6) == 'L') {
				list.removeLast();
			} else if (kari.charAt(6) == 'F') {
				list.removeFirst();
			} else {
				try {
					list.remove(Integer.valueOf(kari.substring(7)));
				} catch (Exception e) {

				}

			}
		}

		// while (list.size() > 1) {
		// System.out.print(list.pop());
		// System.out.print(" ");
		// }
		// System.out.println(list.get(0));

		StringBuilder answer = new StringBuilder();
		while (list.size() > 1) {
			answer.append(list.pop());
			answer.append(" ");
		}
		answer.append(list.pop());
		System.out.println(answer);
	}

}

Measured memory_bytes: 124512
import sys


def dfs(M, i, j, h, w):
    M[i][j] = 0
    for dy in range(-1, 2):
        for dx in range(-1, 2):
            ny, nx = i+dy, j+dx
            if 0 <= ny < h and 0 <= nx < w and M[ny][nx] == 1:
                dfs(M, ny, nx, h, w)


def search(M, w, h):
    count = 0
    for i in range(h):
        for j in range(w):
            if M[i][j] == 1:
                dfs(M, i, j, h, w)
                count += 1
    return count


if __name__ == "__main__":
    sys.setrecursionlimit(50*50)
    ans = []
    while True:
        w, h = map(int, input().split())
        if w == 0 and h == 0:
            break
        M = [[int(ipt) for ipt in input().split()] for _ in range(h)]
        ans.append(search(M, w, h))

    for a in ans:
        print(a)


Measured memory_bytes: 8156
#include "bits/stdc++.h"
using namespace std;

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

    int ans = A[0] + A[N - 2];
    for (int i = 1; i < N - 1; i++) {
        if (A[i] > A[i - 1]) ans += A[i - 1];
        else ans += A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
			var scanner = new Scanner();

			var a = scanner.Int();
			var b = scanner.Int();
			var h = scanner.Int();

			Console.WriteLine((a + b) * h / 2);
        }

		public class Scanner
		{
			private readonly char[] delimiter_ = new char[] { ' ' };
			private readonly string filePath_;
			private readonly Func<string> reader_;
			private string[] buf_;
			private int index_;

			public Scanner(string file = "")
			{
				if (string.IsNullOrWhiteSpace(file)) {
					reader_ = Console.ReadLine;
				} else {
					filePath_ = file;
					var fs = new StreamReader(file);
					reader_ = fs.ReadLine;
				}
				buf_ = new string[0];
				index_ = 0;
			}

			public string NextLine() => reader_();
			public string Next()
			{
				if (index_ < buf_.Length) {
					return buf_[index_++];
				}

				string st = reader_();
				while (st == "") {
					st = reader_();
				}

				buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
				if (buf_.Length == 0) {
					return Next();
				}

				index_ = 0;
				return buf_[index_++];
			}

			public int Int() => int.Parse(Next());
			public long Long() => long.Parse(Next());
			public double Double() => double.Parse(Next());

			public int[] ArrayInt(int N, int add = 0)
			{
				int[] Array = new int[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Int() + add;
				}
				return Array;
			}

			public long[] ArrayLong(int N, long add = 0)
			{
				long[] Array = new long[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Long() + add;
				}
				return Array;
			}

			public double[] ArrayDouble(int N, double add = 0)
			{
				double[] Array = new double[N];
				for (int i = 0; i < N; i++) {
					Array[i] = Double() + add;
				}
				return Array;
			}

			public (int, int) Int2(int add = 0)
			{
				var array = ArrayInt(2, add);
				return (array[0], array[1]);
			}

			public (int, int, int) Int3(int add = 0)
			{
				var array = ArrayInt(3, add);
				return (array[0], array[1], array[2]);
			}

			public (long, long) Long2(int add = 0)
			{
				var array = ArrayLong(2, add);
				return (array[0], array[1]);
			}

			public (long, long, long) Long3(int add = 0)
			{
				var array = ArrayLong(3, add);
				return (array[0], array[1], array[2]);
			}

			public (double, double) Double2(int add = 0)
			{
				var array = ArrayDouble(2, add);
				return (array[0], array[1]);
			}

			public (double, double, double) Double3(int add = 0)
			{
				var array = ArrayDouble(3, add);
				return (array[0], array[1], array[2]);
			}

			public void Save(string text)
			{
				if (string.IsNullOrWhiteSpace(filePath_)) {
					return;
				}

				File.WriteAllText(filePath_ + "_output.txt", text);
			}
		}
	}
}



Measured memory_bytes: 27344
N = int(input())
xybp = [list(map(int,input().split())) for _ in range(N)]
for X in xybp:
    x,y,b,p = X[0],X[1],X[2],X[3]
    kouho1 = x*b+y*p
    if b <= 5 and p <= 2:
        kouho2 = 0.8*x*5+0.8*y*2
    elif b > 5 and p <= 2:
        kouho2 = 0.8*x*b+0.8*y*2
    elif b <= 5 and p > 2:
        kouho2 = 0.8*x*5+0.8*y*p
    else:
        kouho2 = 0.8*x*b+0.8*y*p
    print(min(kouho1,int(kouho2)))


Measured memory_bytes: 5724
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] c = sc.next().toCharArray();
        int ans = 0;
        for (int i=0;i<n;i++){
            while (i<n-1&&c[i]==c[i+1])i++;
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 39644
n,m = map(int,input().split())
if n == m:
    p = 1
    for i in range(1,n+1):
        p *= i
        p %= 1000000007
    print((2*p*p)%1000000007)
elif abs(n-m) == 1:
    p = 1
    for i in range(1,min(n,m)+1):
        p *= i
        p %= 1000000007
    print((max(n,m)*p*p)%1000000007)
else:
    print(0)

Measured memory_bytes: 38640
#include <iostream>

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

using namespace std;

unsigned long long int gcd(unsigned long long int a, unsigned long long int b){
//	cout << "gcd " << a << "," << b << endl;
	if (b==0) return a;
	return gcd(b,a%b);
}

unsigned long long int lcm(unsigned long long int a, unsigned long long int b){
//	cout << "lcm " << a << "," << b << endl;
	return (a/gcd(a,b))*b;
}

int main(){
	
	int n;
	cin >> n;
	
	unsigned long long int t[102];
	REP(i,n) cin >> t[i];
	
	unsigned long long int ans=t[0];
	
	REP(i,n-1){
		ans = lcm(ans,t[i+1]);
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;



int main(){
    int n;
    cin>>n;
    // ll arr[n];
    ll ele=0;
    ll zero[61]{0},one[61]{0};
    pan(j,n){
        cin>>ele;
        pan(i,61){
            if(ele % 2 ==1) one[i]++;
            else zero[i]++;
            ele/=2;
        }
    }
    ll a = 0;
    ll b = 0;
    ll c = 1;
    pan(i, 61){
      b = zero[i] * one[i];
      if(b >= 1000000007) b %= 1000000007;
      b = b * c;
      if(b >= 1000000007) b %= 1000000007;
      a += b;
      if(a >= 1000000007) a %= 1000000007;
      c *= 2;
      if(c >= 1000000007) c %= 1000000007;
    }
	cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;


template <typename T>
T extGCD(T a, T b, T &x, T &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	T d = extGCD(b, a%b, y, x); // 再帰的に解く
	y -= a / b * x;
	return d;
}

// 負の数にも対応した mod 
template <typename T>
T modG(T a, T m) {
	return (a % m + m) % m;
}

// 逆元計算 
template <typename T>
T modinv(T a, T m) {
	T x, y;
	extGCD(a, m, x, y);
	return modG(x, m);
}
int main() {
	ll n;
	cin >> n;
	vector<vector<ll>> a(n);
	vector<ll> sum(60);
	for (ll i = 0; i < n; i++) {
		a[i].resize(60);
	}
	for (ll i = 0; i < n; i++) {
		ll tmp;
		cin >> tmp;
		for (ll j = 0; j < 60; j++) {
			a[i][j] = tmp % 2;
			sum[j] += a[i][j];
			tmp /= 2;
		}
	}
	ll ans = 0;
	
	for (ll i = 0; i < n; i++) {
		ll pow = 1;
		for (ll j = 0; j < 60; j++) {
			if (a[i][j] == 0) {
				ans += pow * sum[j];
			}
			else {
				ans += pow * (n - sum[j]);
			}
			ans %= mop;
			pow *= 2;
			pow %= mop;
		}
	}
	cout << (ans * modinv(2LL, mop)) % mop << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n;
    cin >> n;

    ll a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i], a[i] -= i + 1;
    
    sort(a, a + n);
    auto f = [&] (ll a[], int n, ll x) {
        ll res = 0;
        for (int i = 0; i < n; i++)
            res += abs(a[i] - x);
        return res;
    };

    ll ans = f(a, n, a[n/2]);
    if (n % 2 == 0)
        ans = min(ans, f(a, n, a[n/2] + 1));
    cout << ans << '\n';
    return 0;
}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "yes"
#define FALSE__ "no"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#define MOD (1000000007)

ll culc(ll x)
{
	if (x == 0) return 1;
	return (x * culc(x-1)) % MOD;
}

int main()
{
	ll N, M;
	cin >> N >> M;
	if (abs(N-M) > 1) {
		cout << 0 << endl;
		return 0;
	}
	ll res = (culc(N) * culc(M)) % MOD;
	if (N == M) res = (res * 2) % MOD;
	cout << res << endl;
}

Measured memory_bytes: 1792
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    string S,T,U;
    cin>>S>>T;

    int A=S.length();
    int B=T.length();

    for(int i=0;i<A;i++){
        U+=T[i];
    }

    if(U==S&&(A+1)==B){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 3628
from sys import stdin
n = int(stdin.readline())
l = list(map(int,stdin.readline().split()))
q = int(stdin.readline())

for i in range(q):
    inp_l = list(map(int,stdin.readline().split()))
    ans = l[inp_l[0]:inp_l[1]].count(inp_l[2])
    print(ans)


Measured memory_bytes: 5720