akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,temp,flag=0,sum=0;
	cin>>n;
	unordered_set<int> s;
	map<int,int> ma;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		s.emplace(a[i]);
		ma[a[i]]++;
	}
	for(int i=0;i<n;i++){
		if(ma[a[i]]>1)
		continue;
		flag=0;
		for(int j=1;j<=sqrt(a[i]);j++){
			if(a[i]%j==0){
				if(j!=a[i]){
					if(s.find(j)!=s.end()){
						flag=1;
						break;
					} 					
				}
				if((a[i]/j)!=a[i]){
					if(s.find(a[i]/j)!=s.end()){
						flag=1;
						break;
					}					
				}
			}
		}
		if(!flag) {
			//cout<<a[i]<<endl;
			sum++;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 21408
N = int(input())
b = list(map(int,input().split()))
answer = []

def check(series):
    L = len(series)
    if L == 0:
        return(True)
    matching = [False for _ in range(L)]
    maxMatchIndex = -1
    for i in range(L):
        num = series[i]
        match = num == i+1
        if match:
            matching[i] = True
            maxMatchIndex = i
    if maxMatchIndex == -1:
        return(False)
    answer.append(maxMatchIndex + 1)
    del series[maxMatchIndex]
    return(check(series))

res = check(b)
if res:
    answer.reverse()
    for ans in answer:
        print(ans)
else:
    print(-1)

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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define FORR(v, c) for (auto &v : c)
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define dbg(x) cerr<<#x<<" = " << (x) << endl
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

struct Arrete { int v, c;};
struct Point {int x, y; double distance(Point other) const {return sqrt(SQ(x-other.x)+SQ(y-other.y));}};

typedef	vector<int>	vi;
typedef pair<int,int>	ii;
typedef vector<string>	vs;
typedef vector<ii>	vii;
typedef vector<Arrete>	vg;
typedef vector<long long>	vl;
typedef	long long ll;

const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int A, B;
	read2(A, B);

	if (A > 9 or B > 9)
		pnl(-1);
	else
		pnl(A*B);
}



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

struct data {
  long long a, b;
};

bool operator<(const data &l, const data &r) {
  if(l.a != r.a) return l.a < r.a;
  return l.b > r.b;
}

long long n, m;
vector<data> v;
priority_queue<long long> pq;

long long solve();

int main() {
  cin >> n >> m;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i].a >> v[i].b;
  sort(v.begin(), v.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long now = 0, ans = 0;
  for(int i = 1; i <= m; ++i) {
    while(now < n && v[now].a <= i) pq.push(v[now++].b);
    if(!pq.empty()) {
      ans += pq.top();
      pq.pop();
    }
  }
  return ans;
}


Measured memory_bytes: 2936
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int g[100010];
bool a[100010];

int f(int v) {
	//cout << v << endl;
	if(a[v]) return v;
	return f(g[v]);
}

signed main(void)
{
	while(true) {
		int n, q;
		cin >> n >> q;
		if(!n && !q) break;
		REP(i, n-1) {
			int a;
			cin >> a;
			g[i+2] = a;
		}
		memset(a, false, sizeof(a));
		a[1] = true;
		ll su = 0;
		REP(i, q) {
			char c;
			int t;
			cin >> c >> t;
			if(c == 'Q') su += f(t);
			else a[t] = true;
		}
		cout << su << endl;
	}

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	for (int& i : d) {
		cin >> i;
		i /= 10;
	}
	int a = d.front(), i;
	for (i = 1; i < N; ++i) {
		if (0 == a) break;
		a = max(a - 1, d[i]);
	}
	if (N == i) {
		a = d.back();
		for (i = N - 2; i >= 0; --i) {
			if (0 == a) break;
			a = max(a - 1, d[i]);
		}
		if (-1 == i) cout << "yes";
		else cout << "no";
	}
	else cout << "no";
	cout << endl;
}


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

def find_min(lst):
    tmp = lst[0]
    idx = 0
    for i, item in enumerate(lst):
        if item < tmp:
            tmp = item
            idx = i

    return idx


def main():
    n, k = map(int, input().split())
    price = list(map(int, input().split()))

    price_sum = 0

    for i in range(k):
        idx = find_min(price)
        price_sum = price_sum + price.pop(idx)

    print(price_sum)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9108
n = int(input())
ans = []
def dfs(line, mx):
    if len(line) == n:
        ans.append(line)
    else:
        for i in range(mx+1):
            line_copy = line.copy()
            line_copy.append(i)
            dfs(line_copy, mx)
        line_copy = line.copy()
        line_copy.append(mx+1)
        dfs(line_copy, mx+1)

dfs([0], 0)

figures = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

for a in ans:
    for i in a:
        print(figures[i], end="")
    print()

Measured memory_bytes: 30128
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!
    if (isValid(a, b, s)) {
        println("Yes")
    } else {
        println("No")
    }
}

fun isValid(a: Int, b: Int, s: String): Boolean {
    for ((i, c) in s.withIndex()) {
        if (i == a) {
            if (c != '-') return false
        } else {
            if (!('0'..'9').contains(c)) return false
        }
    }
    return true
}

Measured memory_bytes: 37996
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    long long a, b;
    cin >> a >> b;
    if (a * b <= 2) {
      cout << 0 << endl;
      continue;
    }
    long long c = sqrt(a * b);
    long long ans = 0;
    if (a == b) {
      ans += (a - 1) * 2;
    } else if (c * c >= a * b) {
      ans += c * 2 - 3;
    } else if (c * (c + 1) >= a * b) {
      ans += c * 2 - 2;
    } else {
      ans += c * 2 - 1;
    }
    cout << ans << endl;
  }
  return 0;
}

// 1 5
// 3 1
// 2 2
//


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n, c, k;
    cin >> n >> c >> k;
    vector <int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(all(a));

    int ptr = 0, ans = 0;
    while (ptr < n) {
        int l = ptr;
        int r = l;
        while (r + 1 < n && r - l + 1 < c && a[r + 1] <= a[l] + k)
            ++r;
        ptr = r + 1;
        ++ans;                
    }   
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int m = sc.nextInt();
			if(m == 0) break;
			double a = 0;
			int r = 360;
			for(int i = 0; i < m-1; i++) {
				int x = sc.nextInt();
				a += Math.sin(Math.PI * x / 180);
				r -= x;
			}
			a += Math.sin(Math.PI * r / 180);
			
			int n = sc.nextInt();
			double b = 0;
			
			r = 360;
			for(int i = 0; i < n-1; i++) {
				int x = sc.nextInt();
				b+= Math.sin(Math.PI * x / 180);
				r -= x;
			}
			b += Math.sin(Math.PI * r / 180);
			
			
			if(Math.abs(a - b) < 1.0e-7) {
				System.out.println(0);
			}
			else if(a < b) {
				System.out.println(2);
			}
			else {
				System.out.println(1);
			}
			
			
		}
	}
	

}

Measured memory_bytes: 20956
N,*as=$<.read.split.map(&:to_i)

h=Hash.new(0)
as.each do |a|
    h[a] += 1
end

ret = 0
h.each do |k,v|
    if v != k
        if k < v
            ret += v-k
        else
            ret += v
        end
    end
end

puts ret

Measured memory_bytes: 15228
#include<cstdio>
#include<cmath>
int main(void){
	
	int i,n;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	int m=a[0];
	int p=a[1]-a[0];
	for(i=1;i<n;i++){
		if(a[i]-m>p){
			p=a[i]-m;
		}
		if(a[i]<m){
			m=a[i];
		}
	}
	printf("%d\n",p);
	return 0;
}

Measured memory_bytes: 3476
#include <cstring>
#include <algorithm>
#include <iostream>
#include <sstream>

std::string eq_less(const std::string& lhs, const std::string& rhs)
{
    if (std::strcmp(lhs.c_str(), rhs.c_str()) < 0)
        return lhs;

    return rhs;
}

int main() 
{
    int a = 0;
    int b = 0;

    std::cin >> a >> b;

    std::ostringstream a_oss;
    std::ostringstream b_oss;
    
    for (int i = 0; i < b; ++i)
    {
        a_oss << a;
    }

    for (int i = 0; i < a; ++i)
    {
        b_oss << b;
    }

    std::cout << eq_less(a_oss.str().c_str(), b_oss.str().c_str());

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		Main instance = new Main();
		instance.execute();
	}
	
	private void execute() throws IOException {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		
		String line;
		int[] currentLine = toIntArray(sc.readLine());
		int[] nextLine;
		while(true) {
			line = sc.readLine();
			if(line == null || "".equals(line)){break;}
			nextLine = toIntArray(line);
			currentLine = (currentLine.length > nextLine.length) ? narrowLine(currentLine, nextLine) : wideLine(currentLine, nextLine);
		}
		System.out.println(currentLine[0]);
	}
	private int[] toIntArray(String str) {
		String[] tmp = str.split(",");
		int[] intArray = new int[tmp.length];
		for(int i = 0 ; i < tmp.length ; i++) {
			intArray[i] = Integer.parseInt(tmp[i]);
		}
		return intArray;
	}
	private int[] wideLine(int[] currentLine, int[] nextLine) {
		for(int i = 1 ; i < nextLine.length - 1 ; i++) {
			nextLine[i] += (currentLine[i] > currentLine[i - 1]) ? currentLine[i] : currentLine[i - 1];
		}
		nextLine[0] += currentLine[0];
		nextLine[nextLine.length - 1] += currentLine[currentLine.length - 1];
		return nextLine;
	}
	private int[] narrowLine(int[] currentLine, int[] nextLine) {
		for(int i = 0 ; i < nextLine.length ; i++) {
			nextLine[i] += (currentLine[i] > currentLine[i + 1]) ? currentLine[i] : currentLine[i + 1];
		}
		return nextLine;
	}
}

Measured memory_bytes: 19424
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
#include<utility>
using namespace std;
using ll = long long;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll t1 = n/(a+b);
  ll t2 = n%(a+b);
  cout << t1*a + min(a,t2);
  return 0;
}

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

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

    string ans="No";
    for(int i=0; i<(int)s.length(); i++){
        bool flag=true;
        for(int j=0; j<(int)p.length(); j++){
            if(s[(i+j)%(int)s.length()]!=p[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3200
/**
 *   @FileName	d.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.16 18:39:30
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

vector< ll > q;
vector< ll > a;
int x, y;
 
void dfs(int v, int c = -1, int p = -1) {
    if (q[v] != -1) {
        x = v;
        y = p;
        return;
    }
    q[v] = c + 1;
    dfs(a[v], c + 1, v);
}
 
int main() {
    int n;
    cin >> n;
    ll k;
    cin >> k;
    q.resize(n, -1);
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    dfs(0);
    if (q[x] >= k) {
        for (int i = 0; i < n; i++) {
            if (q[i] == k) {
                cout << i + 1 << endl;
                return 0;
            }
        }
    }
    else {
        k -= q[x];
        k %= q[y] - q[x] + 1;
        for (int i = 0; i < n; i++) {
            if (q[i] - q[x] == k) {
                cout << i + 1 << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 6364
#include<iostream>
using namespace std;
int main(){
  int n,t,ans,i;
  cin >> n >> t;
  ans = n*t;
  int x[n];
  for(i=0;i<n;i++){
    cin >> x[i];
    if (i != 0){
      if (x[i]-x[i-1] < t){
        ans -= t-(x[i]-x[i-1]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstring>

using namespace std;

int main() {
	char target[10],s[10];
	int n;
	int cnt = 0;

	cin >> target;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> s;
		strcat(s, s);	//strcat(s1,s2)でs1にs2を連結
		if (strstr(s, target) != NULL)cnt++;  //sの中でtargetを探索
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
set<int> st;
int a,b,k;
vi answers;
int main(int argc,char const* argv[])
{
  cin >> a >> b >> k;
  for(int i=0;i<k;i++)
    {
      if(a+i>b) continue;
      st.insert(a+i);
      cout << a+i << endl;
    }
  for(int i=k-1;i>=0;i--)
    {
      if(b-i<a) continue;
      auto judge=st.insert(b-i);
      if(judge.second==false) continue;
      else cout << b-i << endl; 
    }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int i=0;
  string S;
  bool A=true;
  cin>>S;
  while(i<S.size())
  {
    if(S.at(i)=='U'||S.at(i)=='D')A&=true;
    else if(i%2==0&&S.at(i)=='R')A&=true;
    else if(i%2!=0&&S.at(i)=='L')A&=true;
    else A=false;
    i++;
  }
  A?cout<<"Yes\n":cout<<"No\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String str=scn.next();
		int cnt0=0,cnt1=0;
		char alt0='0',alt1='1';
		for(int i=0;i<str.length();i++) {
			if(str.charAt(i)==alt0) {
				cnt1++;
			}else {
				cnt0++;
			}
			if(alt0=='0') {
				alt0='1';
				alt1='0';
			}else {
				alt0='0';
				alt1='1';
			}
		}
		System.out.println(Math.min(cnt0, cnt1));
	}

}


Measured memory_bytes: 24544
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
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;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

ll g1(ll n, int p){
  if (n==0) return 0;
  return n/p + g1(n/p,p);
}

ll g2(ll n, int p){
  if (n%2 == 1){
    return g1(n,p) - g2(n-1,p);
  }
  ll res = g1(n/2,p);
  if (p==2) res += n/2;
  return res;
}


int main(){
  ll n; cin >> n;
  ll ans = min(g2(n,2),g2(n,5));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }

int main(){
    string S;
    cin >> S;
    if(S.size() % 2){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < S.size(); i += 2){
        if(S.substr(i, 2) != "hi"){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  LL A,B,C;
  cin >> A >> B >> C;
  cout << min(B / A, C) << endl;
}


Measured memory_bytes: 888
import sys
input = sys.stdin.readline
INF = 2**31 - 1

class StarrySkyTree:
    def __init__(self, n):
        LV = (n-1).bit_length()
        self.N0 = 2 ** LV
        self.data = [0] * (2*self.N0)
        self.lazy = [0] * (2*self.N0)
    
    def gindex(self, l, r):
        L = l + self.N0; R = r + self.N0
        lm = (L // (L & -L)) >> 1
        rm = (R // (R & -R)) >> 1
        
        while L < R:
            if R <= rm:
                yield R
                
            if L <= lm:
                yield L
                
            L >>= 1; R >>= 1
            
        while L:
            yield L
            L >>= 1

    def propagates(self, *ids):
        for i in reversed(ids):
            v = self.lazy[i-1]
            
            if not v:
                continue
            
            self.lazy[2*i-1] += v; self.lazy[2*i] += v
            self.data[2*i-1] += v; self.data[2*i] += v
            self.lazy[i-1] = 0

    def update(self, l, r, x):
        L = self.N0 + l; R = self.N0 + r
        
        while L < R:
            if R & 1:
                R -= 1
                self.lazy[R-1] += x; self.data[R-1] += x
                
            if L & 1:
                self.lazy[L-1] += x; self.data[L-1] += x
                L += 1
                
            L >>= 1; R >>= 1
            
        for i in self.gindex(l, r):
            self.data[i-1] = min(self.data[2*i-1], self.data[2*i]) + self.lazy[i-1]

    def query(self, l, r):
        self.propagates(*self.gindex(l, r))
        L = self.N0 + l; R = self.N0 + r
        s = INF
        
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])
                
            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
                
            L >>= 1; R >>= 1
            
        return s

n, q = map(int, input().split())
sst = StarrySkyTree(n)

for _ in range(q):
    que = list(map(int, input().split()))
    
    if que[0] == 0:
        s, t, x = que[1], que[2], que[3]
        sst.update(s, t+1, x)
    elif que[0] == 1:
        s, t = que[1], que[2]
        print(sst.query(s, t+1))


Measured memory_bytes: 21028
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int a;
    ld b;
    cin >> a >> b ;
    ld ans = b * a; 
    ans = floor(ans);
    cout << fixed << setprecision(0) << ans ;
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,K,X,Y,s;
    cin>>N>>K>>X>>Y;
    if(N>K){
    s=K*X;
    s+=(N-K)*Y;
    }
    else
        s=N*X;
    cout<<s<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 1000002
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

string s ;

int main()
{
    int i , j , k , l , m , n , f ;

    scanf("%d",&n) ;

    printf("0\n") ;

    fflush(stdout) ;

    char str[100];
    scanf("%s",str) ;
    if(str[0]=='V') return 0 ;

    if(str[0]=='M')
    {
        m = 0 ; f = 1 ;
    }

    if(str[0]=='F')
    {
        m = 1 ; f = 0 ;
    }


    int lo = 1 , hi = n-1 ;

    while(true)
    {
        int mid = (lo+hi)/2 ;

        printf("%d\n",mid) ;
        fflush(stdout) ;

        scanf("%s",str) ;
        if(str[0]=='V') return 0 ;

        if( (str[0]=='M' && m==mid%2) || (str[0]=='F' && f==mid%2) )
        {
    //        printf("here\n") ;
            lo = mid+1 ;
        }
        else hi = mid ;
    }

    return 0 ;
}


Measured memory_bytes: 852
from collections import deque

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

G = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

visited = [False] * N

ans = 1
for i in range(N):
    if visited[i]:
        continue
    visited[i] = True
    d = deque(G[i])
    tmp = 1
    while d:
        v = d.pop()
        if not visited[v]:
            visited[v] = True
            tmp += 1
            for j in G[v]:
                if not visited[j]:
                    d.append(j)
    if tmp > ans:
        ans = tmp

print(ans)


Measured memory_bytes: 45096
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int ans[]={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 main(){
	int a;scanf("%d",&a);
	printf("%d\n",ans[a-1]);
}

Measured memory_bytes: 128
D, N = map(int, input().split())

if N <= 99:
    print(N, end = "")
    for _ in range(D):
        print("00", end = "")
    print("")
else:
    if D == 0:
        print(101)
    elif D == 1:
        print(10100)
    else:
        print(1010000)

Measured memory_bytes: 38384
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp.reverse
N=S.size
i=0
flag=true
while i<N
    case
    when S[i..i+4].join("")=="maerd"
        i+=5
    when S[i..i+6].join("")=="remaerd"
        i+=7
    when S[i..i+4].join("")=="esare"
        i+=5
    when S[i..i+5].join("")=="resare"
        i+=6
    else
      flag=false
      break
    end
end
puts yn_judge(flag,"YES","NO")

Measured memory_bytes: 22544
import operator as op
from io import StringIO
from collections import *
from functools import *
from fractions import gcd
import sys


def main(inputs):
    # n = int(next(inputs))
    # xs = list(map(int, next(inputs).split()))
    xs = list(map(int, next(inputs).split()))
    y = reduce(gcd, xs)
    r, g, b, n = map(op.floordiv, xs, [y]*4)
    ans = 0
    for i in range(1 + (n // r)):
        n_r = n - r*i
        for j in range(1 + (n_r // g)):
            if (n_r - g*j) % b == 0:
                #print("{}".format((i, j)))
                ans += 1
                pass
            pass
        pass
    return ans


def gen_inputs(str_=None):
    inputs = StringIO(str_) if str_ else sys.stdin
    while True:
        a = inputs.readline().rstrip()
        yield a
        pass
    pass


if __name__ == "__main__":
    print(main(gen_inputs()))
    pass


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

int main()
{
	int i, n, t;

	while (1) {
		std::cin >> n;

		if (n == 0) break;

		std::vector<int> data;

		for (i = 0; i < n; i++) {
			std::cin >> t;
			data.push_back(t);
		}

		std::sort(data.begin(), data.end());
		
		long long sum, result;
		for (i = 0, sum = 0, result = 0; i < n; i++) {
			result += sum;
			sum += (long long)data[i];
		}

		std::cout << result << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1320
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int X[8], Y[8];
	double goukei = 0;
	rep(i, N) cin >> X[i] >> Y[i];

	rep(i, N) rep(j, i) {
		goukei += sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]));
	}
	cout << setprecision(12) << (goukei* (N - 1) / (N * (N - 1) / 2)) << endl;

	Would you please return 0;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;cin>>n;
    if(n%2==0)
        cout<<n<<endl;
    else
        cout<<2*n<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

def check(a,b,c):
	if((a<b)and(b<c))or((a>b)and(b>c)):
		return 1
	return 0

import sys
n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

sum=0
for i in range(n-2):
	sum += check(hoge[i],hoge[i+1],hoge[i+2])

print(sum)


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

int main()
{
  char s[201], p[101];
  cin >> s >> p;
  char t[101];
  strcpy(t, s);
  strcat(s, t);
  if (strstr(s, p)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3092
H, W = input().split(' ')
H = int(H)
W = int(W)
if H==1 or W ==1:
  print(1)
elif (H%2)==0 and (W%2)==0:
  print(int((H/2) * W))
elif (H%2)==1  and (W%2)==0:
  print(int((W/2) * H))
elif (H%2)==0 and (W%2)==1:
  print(int((H/2) * W))
elif (H%2)==1 and (W%2)==1:
  print(int((H*W//2)+1))

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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N, x, cont;
int ans = 1, m = 1;

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

	cin >> N;

	for(int i = 1; i <= N; i++){
		x = i;
		cont = 0;
		while(x % 2 == 0){
			x /= 2;
			cont++;
		}

		if(cont >= m){
			m = cont;
			ans = i;
		}
	}

	cout << ans << "\n";


	return 0;		
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
PS = [line.split() for line in readlines()]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)

penal = 0
for p,s in PS:
    p = int(p)
    if AC[p]:
        continue
    if s == b'WA':
        WA_cnt[p] += 1
    else:
        AC[p] = True
        penal += WA_cnt[p]

ac = sum(AC)
print(ac, penal)

Measured memory_bytes: 34468
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    //input
    String input1 = sc.next();
    char input = input1.charAt(0);

    //output
    if( Character.isUpperCase(input) ){
      System.out.println("A");
    }else{
      System.out.println("a");
    }

  }
}


Measured memory_bytes: 26900
#include<stdio.h>
#include<math.h>
int N,H,M;
double s,t,a;
int main()
{
	scanf("%d",&N);
	for(;N--;)
	{
		scanf("%d:%d",&H,&M);
		s=0.5*M+H*30;
		t=M*6;
		a=s-t<0?t-s:s-t;
		a=a<360-a?a:360-a;
		//printf("%lf\n",a);
		puts(a>=90?"safe":a<30?"alert":"warning");
	}
	return 0;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define mp make_pair
#define P pair<int,int>
#define ri register int
#define rb register bool
#define rc register char
#define t(i) edge[i].to
#define w(i) edge[i].wei
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt)

const int N=2*1e5+10;
int w[N],d[N],cnt[20],res,n,st,sxr[N];
bool book[N];

il int read()
{
	rc ch=gc;ri x=0;rb y=1;
	while(ch!='-' && (ch<'0' || ch>'9'))ch=gc;
	if(ch=='-')ch=gc,y=0;
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
	return y?x:-x;
}

int main()
{
	n=read();rp(i,1,n-1){ri u=read()+1,v=read()+1,va=read();w[u]^=va;w[v]^=va;}rp(i,1,n)cnt[w[i]]++;
	rp(i,1,15)res+=cnt[i]/2,st|=(cnt[i]&1)<<(i-1);
	n=1<<15;
	for(int i=1;i<(1<<15);i++)d[i]=d[i>>1]+(i&1);
	for(int i=1;i<(1<<15);i++)d[i]-=1;
	for(int i=1;i<(1<<15);i++)
		for(int j=0;j<15;j++)if((i>>j)&1)sxr[i]^=(j+1);
	for(int i=1;i<(1<<15);i++)
	{
		if(sxr[i]!=0)continue;
		for(int k=(i-1)&i;k;k=(k-1)&i)
			if(sxr[k]==0)d[i]=min(d[i],d[k]+d[i^k]);
	}printf("%d",res+d[st]);return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <map>

using namespace std;
typedef long long LL;

const int maxn = 200005;
map<int,int> h;
int n,a[maxn],b[maxn],c[maxn],d[maxn],tot,ans,p[maxn]; 
int findp(int t) {return p[t]?p[t]=findp(p[t]):t;}
void merge(int u,int v) {u=findp(u);v=findp(v);u!=v?p[u]=v:0;}
int main()
{
	#ifdef Amberframe
		freopen("agc016d.in","r",stdin);
		freopen("agc016d.out","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),a[0]^=a[i];
	for (int i=1;i<=n;i++) scanf("%d",&b[i]),b[0]^=b[i];
	for (int i=0;i<=n;i++) c[i]=a[i],d[i]=b[i];
	sort(c,c+n+1);sort(d,d+n+1);
	for (int i=0;i<=n;i++) if (c[i]!=d[i]) {puts("-1");return 0;}
	for (int i=1;i<=n;i++)
	if (a[i]!=b[i]) {
		(!h[a[i]])?h[a[i]]=++tot:0;
		(!h[b[i]])?h[b[i]]=++tot:0;
		merge(h[a[i]],h[b[i]]);++ans;
	}
	!h[a[0]]?++ans:0;
	for (int i=1;i<=tot;i++) ans+=(p[i]==0);
	printf("%d",ans?ans-1:ans);
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<int> B(N, 0), W(N, 0);
    for (int i = 0; i < N; i++) {
        if (S[i] == '#') {
            B[i]++;
        } else {
            W[i]++;
        }
    }
    vector<int> b(B.size() + 1, 0);
    partial_sum(B.begin(), B.end(), b.begin() + 1);
    vector<int> w(W.size() + 1, 0);
    partial_sum(W.begin(), W.end(), w.begin() + 1);

    int ans = N;
    for (int i = 0; i <= N; i++) {
        int count = b[i] + (w[N] - w[i]);
        ans = min(ans, count);
    }
    cout << ans << endl;
}

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

int main() {
	
	long N,ans=0;
	cin >> N;
	for (size_t i = 0; i < N; i++)
	{
		ans += i;
	}
	cout << ans;
	//NとN-1は互いに素。P1=2,P2=3,…P(N-1)=N,P(N)=1ととる。
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
string s[200005];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>s[i];
    sort(s+1,s+n+1);
    int sum=1,maxn=1;
    for(int i=2;i<=n;i++)
    {
        if(s[i]==s[i-1]) sum++;
        else sum=1;
        maxn=max(sum,maxn);
    }
    sum=1;
    if(maxn==1) cout<<s[1]<<endl;
    for(int i=2;i<=n;i++)
    {
        if(s[i]==s[i-1]) sum++;
        else sum=1;
        if(sum==maxn) cout<<s[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 14208
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<functional>

using namespace std;

#define REP(i,n) for(int i = 0;i < n ;i++)
	
struct boad
{
	int high,a,b;
	
	bool operator<(const boad& a)const
	{
		return this->high > a.high;
	}
};



int main()
{
	int n,m,a;
	while(cin >> n >> m >> a,n)
	{
		vector<boad> v;
		REP(i,m)
		{
			boad tmp;
			cin >> tmp.high >> tmp.a >> tmp.b;
			v.push_back(tmp);
		}
		sort(v.begin(),v.end());
		REP(i,v.size())
		{
			if(a == v[i].a)
			{
				a = v[i].b;
				continue;
			}
			if(a == v[i].b)
			{
				a = v[i].a;
			}
		}
		
		cout << a << endl;
		
	}
	
	return 0;
	
}

Measured memory_bytes: 2992
import itertools

N = int(input())
l = [i for i in range(1, N+1)]
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
A = [v for v in itertools.permutations(l)]
a = 0
b = 0
A = sorted(A)
for i in range(len(A)):
  if A[i] == P:
    a = i+1
  if A[i] == Q:
    b = i+1
print(abs(a-b))

Measured memory_bytes: 45424
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ; cin >> n ;
	int mx = 0 ;
	for(int  i = 1 ; i*i <= n ;++i ){
		mx = max(mx,i*i);
	}
	cout << mx << endl;
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main()
{
	int A, B;

	cin >> A >> B;

	int num1 = A + B;
	int num2 = A - B;
	int num3 = A * B;

	int ans;

	if (num1 >= num2)
	{
		ans = num1;
	}
	else
	{
		ans = num2;
	}
	
	if (num3 >= ans)
	{
		ans = num3;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();
        char[]a = A.toCharArray();
        char[]b = B.toCharArray();
        char[]c = C.toCharArray();

        if(a[A.length()-1]==b[0] && b[B.length()-1]==c[0]){
            System.out.println("YES");    
        }else{
            System.out.println("NO");
    }
}
}

Measured memory_bytes: 35744
#include <stdio.h>

typedef long long ll;

int main() {

	int Q;

	scanf("%d",&Q);

	ll A,B;

	int i,j,x;

	for(j=0;j<Q;j++){
		scanf("%lld %lld",&A,&B);

		if(A>B){
			ll tmp=B; 
			B=A;
			A=tmp;
		}

		ll ans=2ll*(A-1ll);

		int num=0;

		for(i=29;i>=0;i--){
			num+=1<<i;
			if(A+num>B){
				num-=1<<i;
				continue;
			}

			int ng=0;
			for(x=(num/2)-2;x<=(num/2)+2;x++){
				if(x<=0||x>num){continue;}
				if((A+x)*(A+num-x)>=A*B){ng=1;}
			}
			if(ng==1){num-=1<<i;}
		}
		ans+=(ll)num;
		printf("%lld\n",ans);
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;

int main()
{
    int n,m;
    while (~scanf("%d %d",&n,&m)) {
        printf("%d\n", max(0, n-m+1));
    }
    return 0;
}





Measured memory_bytes: 256
### INPUT
# array = [*1..q].map { |_| gets.split.map(&:to_i) }
# n = gets.split.map(&:to_i)
### SNIPPET
# [].all?(&:even?)
# a = [*1..m].repeated_combination(n).to_a
# 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
# 3.upto(6) do |i|, 6.downto(3) do |i|
# 公約数125.gcd(100)、公倍数125.lcm(100)
# PI = Math::PI
# 高さh = a * Math.sin(w / 180.0 * Math::PI)
# 底辺 = a * Math.cos(w / 180.0 * Math::PI)
INF = Float::INFINITY
### DP
def chmin(a, b) a < b ? a : b end
# def chmax(a, b) a > b ? a : b end

n = gets.to_i
h = gets.split.map(&:to_i)

dp = [INF] * n

dp[0] = 0
(n-1).times do |i|
  if i == 0
    dp[i+1] = (h[1] - h[0]).abs
  else
    dp[i+1] = chmin(
      dp[i] + (h[i+1] - h[i]).abs,
      dp[i-1] + (h[i+1] - h[i-1]).abs
    )
  end
end

puts dp[n-1]

Measured memory_bytes: 8844
<?php
     
    	$data = explode(" ", trim(fgets(STDIN)));
    	$n = $data[0];
    	$k = $data[1];
    	
    	$x = (int)floor($n/$k);
    	$y = 1 + (int)floor(($n - $k/2)/$k);
    	
    	if($k%2 == 1){
    		echo $x**3;
    	}else{
    		echo $x**3 + $y**3;
    	}
    	
     
?>

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

namespace _ {
	bool rEOF = 1;//为0表示文件结尾
	inline char nc() {
		static char buf[100000], *p1 = buf, *p2 = buf;
		return p1 == p2 && rEOF && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? (rEOF = 0, EOF) : *p1++;
	}
	template<class _T>
	inline bool read(_T &num) {
		char c = nc(), f = 1; num = 0;
		while (c<'0' || c>'9')c == '-' && (f = -1), c = nc();
		while (c >= '0'&&c <= '9')num = num * 10 + c - '0', c = nc();
		return (bool)(num *= f);
	}
	inline bool need(char &c) { return c >= 'a'&&c <= 'z' || c >= '0'&&c <= '9' || c >= 'A'&&c <= 'Z'; }//读入的字符范围
	inline bool read_str(char *a) {
		while ((*a = nc()) && need(*a) && rEOF)++a;
		*a = '\0'; return rEOF;
	}
}using namespace _;

const int mod = 1e9 + 7;
int dp[2][14];
string str;
int main()
{
	cin >> str;
	int len = str.length();
	dp[1][0] = 1;
	for (int i = 0; i < len; i++)
	{
		int now = i & 1,pre=now^1;
		for (int j = 0; j < 13; j++)dp[now][j] = 0;
		if ('0' <= str[i] && str[i] <= '9')
		{
			for (int j = 0; j < 13; j++)
				(dp[now][(j*10 + str[i] - '0') % 13] += dp[pre][j]) %= mod;
		}
		else
		{
			for (int j = 0; j < 13; j++)
				for (int k = 0; k <= 9;k++)
					(dp[now][(j*10 + k) % 13] += dp[pre][j])%=mod;
		}
	}
	printf("%lld\n", dp[(len-1) & 1][5]);
	return 0;
}


Measured memory_bytes: 512