akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
template<class T> T gcd(T a,  T b) {return b ? gcd(b, a % b) : a;}
template<class U> U lcm( U m, U n ){if((0 == m )||( 0 == n ))return 0; return ((m / gcd(m, n)) * n); }
bool j = false;
int n;
void dfs(int v,int d,vector<vector<int>>&edge){
    if(d == 2){
        if(v == n - 1) j = true;
        return;
    }
    for(auto nv : edge[v]){
        if(nv == v) continue;
        dfs(nv,d + 1, edge);
    }
}
signed main(){
    fast_io();
    int m; cin >> n >> m;
    vector<vector<int>>edge(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        --a,--b; edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dfs(0,0,edge);
    cout << (j ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 12776
#include <algorithm>
#include <iostream>
#include <cstdio>

int main()
{
    double r = 0;
    std::cin >> r;
    printf("%.7f %.7f\n", 3.14159265358979323846 * r * r, 3.14159265358979323846 * 2 * r);
    return 0;
}


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

int main()
{
	int n;
	cin>>n;
	string s[n+1];
	map<string,int> m;
	
	for(int i=1; i<=n; i++)
	{
		cin>>s[i];
		m[s[i]]++;
	}
	
	cout<<m.size()<< endl;
	return 0;
}


Measured memory_bytes: 25436
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc131/tasks/abc131_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 食べるべきリンゴは味の絶対値が最も小さいリンゴでいい
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,L; cin >> N >> L;
    vector<ll> apple(N);
    iota(apple.begin(),apple.end(),L);
    ll sum = accumulate(apple.begin(),apple.end(),0LL);
    sort(apple.begin(),apple.end(),[](const ll& l,const ll& r){ return abs(l) < abs(r); });
    res = sum - apple.front();
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;


int main(void) {

  int n, m, k;
  cin >> n >> m >> k;
  bool f = false;
  for(int i=0; i<=n; i++){
    for(int j=0; j<=m; j++){
      int cnt = i * m;
      cnt -= i * j;
      cnt += j * (n - i);
      // cerr << i << " " << j << " " << cnt << endl;
      if( cnt == k ) f = true;
    }
  }

  cout << ( f ? "Yes" : "No" ) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A = [0] + A + [0]
s = 0
for i in range(N+1):
    s += abs(A[i]-A[i+1])
for i in range(1,N+1):
    ans = s - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i+1]-A[i-1])
    print(ans)

Measured memory_bytes: 14048
#include <cstdio>
#define int long long
int read()
{
	int x=0,flag=1;char c;
	while((c=getchar())<'0' || c>'9') if(c=='-') flag=-1;
	while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*flag;
}
int x,t;
signed main()
{
    x=read();t=100;
    for(int i=1;i<=3760;i++)
    {
        t=t+t/100;
        if(t>=x)
        {
            printf("%lld\n",i);
            return 0;
        }
    }
}


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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i <N; i++) cin >> A[i];
    A.push_back(-1);
    ll  ans = 0;
    sort(A.begin(), A.end(), greater<int>());
    ll cnt = 1, max = 0, submax = 0;
    for(int i = 0; i <= N; i++){
        if(A[i] != A[i-1]){
            if(cnt >= 4){
                if(max == 0){
                    max = A[i-1];
                    submax = A[i-1];
                    break;
                }else if(submax == 0){
                    submax = A[i-1];
                    break;
                }
            }else if(cnt >= 2){
                if(max == 0){
                    max = A[i-1];
                }else if(submax == 0){
                    submax = A[i-1];
                    break;
                }
            }
            cnt = 1;
        }
        else cnt++;
    }
    cout << max * submax << endl;

}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int a[9],ans,used[10];
 
void dfs(int p){
  if(p==9){
    if(a[0]+a[2]+a[5]-a[8]+10*(a[1]+a[4]-a[7])+100*(a[3]-a[6])==0)ans++;
    return;
  }
  if(a[p]!=-1){dfs(p+1);return;}
  for(int i=1;i<=9;i++){
    if(used[i])continue;
    used[i]=1,a[p]=i;
    dfs(p+1);
    used[i]=0,a[p]=-1;
  }
}
 
int main(){
  for(int i=0;i<9;i++){
    cin>>a[i];
    if(a[i]!=-1)used[a[i]]=1;
  }
  dfs(0);
  cout<<ans<<endl;
  return 0;
}

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

int main(void){
    int X;
    cin >> X;
    
    if(X >= 400 && X < 600) cout << "8" << endl;
    else if(X >= 600 && X < 800) cout << "7" << endl;
    else if(X >= 800 && X < 1000) cout << "6" << endl;
    else if(X >= 1000 && X < 1200) cout << "5" << endl;
    else if(X >= 1200 && X < 1400) cout << "4" << endl;
    else if(X >= 1400 && X < 1600) cout << "3" << endl;
    else if(X >= 1600 && X < 1800) cout << "2" << endl;
    else if(X >= 1800 && X < 2000) cout << "1" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int INF = 1e8;

struct edge { int to, cost; };
using ve = vector<edge>;

int N, M;

vector<ve> G(1010, ve());
vector<vi> dist(1010, vi(1010, INF));

void dijkstra(int s){
    // first:最短距離 second:頂点番号
    priority_queue<pii, vector<pii>, greater<pii>> q;
    dist[s][s] = 0;
    q.push(pii(0, s));

    while (!q.empty()){
        int cur_d = q.top().first;
        int cur_v = q.top().second;
        //cout << cur_v << endl;
        q.pop();

        if (cur_d > dist[s][cur_v]) continue;

        for (int i = 0; i < G[cur_v].size(); i++){
            edge e = G[cur_v][i];
            if (dist[s][cur_v] + e.cost < dist[s][e.to]){
                dist[s][e.to] = dist[s][cur_v] + e.cost;
                q.push(pii(dist[s][e.to], e.to));
            }
        }
    }
}

int main(){
    cin >> N >> M;

    rep(i,N) dist[i][i] = 0;

    rep(i,M){
        int a, b, c; cin >> a >> b >> c; a--; b--;
        G[a].push_back(edge{b,c});
        G[b].push_back(edge{a,c});
    }

    rep(i,N) dijkstra(i);

    int ans = 2*M;
    rep(i,N) rep(j, G[i].size()){
        bool flag = false;
        //cout << i << " " << j << endl;
        rep(s,N){
            rep(t,N){
                if(dist[s][i] + G[i][j].cost + dist[G[i][j].to][t] == dist[s][t]){
                    ans--; flag = true;
                    break;
                }
            }
            if(flag) break;
        }
    }

    cout << ans/2 << endl;
}



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
char S[5050];

ll ln[5050];
ll i, j, k, ans;

ll calc(ll b){
    ll i = 1;
    ll j = 0;
    ll ret = 0;
    ll k = 0;
    while(i+b<N){
        //printf("%lld%lld\n", b,i);
        if(i+ln[i-j]<j+ln[j]){
            ln[i] = ln[i - j];
        }else{
            k = j + ln[i] - i > 0 ? j + ln[i] - i : 0;
            while(i+k+b<N&&S[k+b]==S[i+k+b])
                k++;
            ln[i] = k;
            j = i;
        }
        ll a = min(i, ln[i]);
        if(ret<a){
            ret = a;
        }
        i++;
    }
    return ret;
}
int main(){
    scanf("%lld%s", &N, S);
    fornum(i,0,N){
        ll a = calc(i);
        //printf("%lld:%lld\n", i, a);
        if(ans<a)
            ans = a;
            /*
        fornum(j,0,N){
            ln[j] = 0;
        }*/
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{

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

    void run(){
      Scanner sc=new Scanner(System.in);
      int N=sc.nextInt();
      long[] H=new long[N];
      for(int i=0;i<N;++i){
          H[i]=sc.nextLong();
      }
      long[] cost=new long[N];
      Arrays.fill(cost,1L<<60);
      cost[0]=0;
      for(int i=0;i<N;++i){
          for(int j=1;j<=2&&i+j<N;++j){
	          cost[i+j]=Math.min(cost[i+j],cost[i]+Math.abs(H[i]-H[i+j]));
          }
      }
      System.out.println(cost[N-1]);
    }
}


Measured memory_bytes: 50076
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
    int n,c = 0;
    cin >> n;
    vector<int>v(n);
    for(int i= 1; i<=n; i++){
        cin >> v[i];
        if(i%2 != 0&&v[i]%2!=0){
            c++;
        }
    }
    cout << c;
}


Measured memory_bytes: 3624
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [b]
    else
      match str.[ct] with
        ' ' -> b::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let _ = read_line ()
  and s = read_line () in
  let l = split s in
  let result =
    match l with
      h::t -> List.fold_left (fun x y -> y^" "^x ) h t
    | _ -> ""
  in
  Printf.printf "%s\n" result;;

Measured memory_bytes: 2640
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll, ll>
#define pb push_back
#define ll long long
#define ld long double	
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18
// double power(double num, double g) {
// 	if (g == 0)return 1;
// 	if (g % 2 == 1)return (num * power((num * num), g / 2));
// 	return power( (num * num) , g / 2);
// }

int main(){
	int n, k, x, d;
	cin >> n >> k;
	int a[n+1];
	mst0(a);
	FOR0(i, k){
		cin >> d;
		FOR0(i, d) cin >> x, a[x]++;
	}
	int cnt = 0;
	FOR1(i, n) if (a[i]==0) cnt++;
	cout << cnt;
}



Measured memory_bytes: 3632
import scala.io.StdIn._
object Main extends App {
  val input1 = readLine().split(" ").map(_.toInt)
  val input2 = readLine().split(" ").map(_.toInt).sorted.toList.reverse
  val n = input1(0)
  val k = input1(1)
  println(input2.take(k).sum)
}

Measured memory_bytes: 27452
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int min = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                min = a[i];
                max = a[i];
                continue;
            }
            if (a[i] < min) {
                min = a[i];
            }
            if (a[i] > max) {
                max = a[i];
            }
        }
        System.out.println(max - min);
    }

}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define lng long long
#define D(x) cout << #x " is " << x << endl

int n;
int rows[105];
int cols[105];
lng mem[105][105];

lng solve(int s, int e){
	if(s == e) return 0;
	
	lng &ret = mem[s][e];
	if(~ret) return ret;
	
	lng res = LLONG_MAX;
	lng curRes, cost;
	for(int i = s; i<e; i++){
		cost = 1LL*rows[s]*cols[i]*cols[e];
		curRes = cost + solve(s,i) + solve(i+1,e);
		res = min(res, curRes);
	}
	
	return ret = res;
}

int main(){
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	// cout.tie(NULL);
	
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &rows[i], &cols[i]);
	}

	memset(mem, -1, sizeof mem);
	
	lng ans = solve(0, n-1);
	printf("%lld\n", ans);
	
	return 0;
}



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool flag = false;
  for (int i=0;i<s.size();++i){
    for (int j=0;j<s.size();++j){
      if(i!=j && s[i]==s[j]) flag=true;
    }
  }
  if(flag) cout << "no" << endl;
  else cout << "yes" << endl;
         
}

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

int main(){
    int K;
    cin >> K;
    int A[32] = 
    {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};
    cout << A[K - 1] << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read <T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

pub fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let a: u32 = read(&mut stdin).unwrap();
    let b: u32 = read(&mut stdin).unwrap();

    if a % 2 != 0 && b % 2 != 0 {
        println!("Odd");
    } else {
        println!("Even");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = (s); i <= (int)(n); i++)
int b[1000010];
int d[1000010];

int main() {
	int n,a;
	int p,ans;

	cin >> n ;

	ans=0;
	rep(i,1000010) b[i]=0;
	for(int i = 1000005; i > 1; i--) {
		for(int j = i; j<1000005; j+=i) d[j]=i;
	}
	rep(k,n) {
		cin >> a ;
		p=0;
		while (a>1) {
			if(d[a]>p) {
				p=d[a];
				b[p]++;
				if(b[p]>ans) ans=b[p];
			}
			a/=p;
		}
	}
	if (ans==n) {
		cout << "not coprime" << endl;
		return 0;
	}else if (ans>1){
		cout << "setwise coprime" << endl;
		return 0;
	}else{
		cout << "pairwise coprime" << endl;
		return 0;
	}
}

Measured memory_bytes: 11328
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int inner, display;
	cin >> inner >> display;
	if(inner < 10){
		int rat = display + 100 *(10- inner);
		cout << rat;
	}else{
		cout << display;
	}
	return 0;
}

Measured memory_bytes: 3632
/*************************************************************************
  >         File: C.cc
  >       Author: Yuan Lei
  >         Mail: yuanlei@indeed.com
  > Created Time: Sun 22 Oct 2017 09:10:10 PM JST
*************************************************************************/
#include <vector>
#include <cstdio>
#include <bitset>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <fstream>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <string>
#include <iostream>
#include <algorithm>
#include <functional>

const int N = 1e5 + 5;
int ind[N];

int main() {
  std::ios::sync_with_stdio(0);
  std::string s;
  std::cin >> s;
  std::string r;
  for (int i = 0; i < (int) s.size(); ++i) {
    if (s[i] != 'x') ind[r.size()] = i, r += s[i];
  }
  if (r == "") {
    std::cout << 0 << std::endl;
    return 0;
  }
  int i = 0, j = r.size() - 1;
  for (; i < j; ++i, --j) {
    if (r[i] != r[j]) {
      std::cout << -1 << std::endl;
      return 0;
    }
  }
  int ans = 0;
  while (i > 0) {
    ans += std::abs((ind[i] - ind[i - 1]) - (ind[j + 1] - ind[j]));
    --i, ++j;
  }
  ans += std::abs((ind[0] + 1) - ((int) s.size() - ind[j]));
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <chrono>
using namespace std;
using ll = long long;


ll maxd(vector<ll> &v, ll maxa, ll k) {
	ll a = 1;
	while(maxa >= a) {
		a <<= 1;
	}
	a >>= 1;
	while (a > 0) {
		a >>= 1;
		ll count = 0;
		for (auto i : v) {
			if ((i & a) >= a) {
				++count;
				if (count == k) {
					return a;
				}
			}
		}
	}
	return a;
}

vector<ll> cut(vector<ll> &v, ll a) {
	vector<ll> vv(0);
	for (auto i : v) {
		if ((i & a) >= a) {
			vv.push_back(i);
		}
	}
	return vv;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	ll N, K;
	cin >> N >> K;
	ll s[1002][1002];
	for (ll i = 0; i != N; ++i) {
		for (ll j = 0; j <= N; ++j) {
			s[i][j] = 0;
		}
	}
	vector<ll> vs;
	for (ll i = 0; i != N; ++i) {
		ll a;
		cin >> a;
		for (ll j = 0; j <= i; ++j) {
			s[i + 1][j] = s[i][j] + a;
			vs.push_back(s[i + 1][j]);
		}
	}
	ll out = 0;
	ll a = 1e14;
	while (a > 0) {
		a = maxd(vs, a, K);
		out += a;
		vs = cut(vs, a);
		// for (auto i : vs) {
		// 	cout << i << endl;
		// }
		// cout << endl;
	}
	cout << out << endl;
}


Measured memory_bytes: 14320
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;string s;
	cin >> N>>s;
	ll count = 0;
	REP(i,N){
		if (s[i]=='R') count++;
	}
	
	//出力
	if (count>N/2) printf("Yes\n");
	else printf("No\n");
}


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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  a.push_back(a[0]+k);
  int l = 0;
  rep(i,n) {
    l = max(l, a[i+1]-a[i]);
  }
  int ans = k-l;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
N,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(N-1):
    s=a[i]+a[i+1]
    if s>x:
        if s-x<=a[i+1]:
            a[i+1]-=s-x
        else:
            a[i]-=s-x-a[i+1]
            a[i+1]=0
        ans+=s-x
print(ans)

Measured memory_bytes: 63856
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    int n,m;
    cin >> n >> m;
    int k[m];
    int s[m][n];
    rep(i,m){
        rep(j,n){
            s[i][j] = 0;
        }
    }
    rep(i,m){
        cin >> k[i];
        rep(j,k[i]){
            int x;
            cin >> x;
            s[i][x-1] = 1;
        }
    }

    int p[m];
    rep(i,m){
        cin >> p[i];
    }


    int ans = 0;

    rep(i,pow(2,n)){
        int swi[m] = {};
        int ii = i;
        rep(j,n){
            int x = ii%2;
            ii /= 2;
            rep(l,m){
                if(x==1&&s[l][j]==1){
                    swi[l]++;
                }
            }
        }
        int flag = 0;
        rep(j,m){
            if(swi[j]%2!=p[j]){
                flag = 1;
            }
        }
        if(flag==0){
            ans++;
        }
    }

    
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 512
#include <stdio.h>

int main()
{
  int i;
  int n, q;
  int m, date;
  int candidate[100];
  int max, date_of_meeting;
  
  while (1) {
    scanf("%d %d", &n, &q);
    if (n == 0 && q == 0) break;

    for (i = 0; i < sizeof(candidate)/sizeof(int); i++) {
      candidate[i] = 0;
    }

    while (n--) {
      scanf("%d", &m);
      while(m--) {
        scanf("%d", &date);
        candidate[date]++;
      }
    }

    max = 0;
    date_of_meeting = 0;
    for (i = 1; i < sizeof(candidate)/sizeof(int); i++) {
      if (candidate[i] > max && candidate[i] >= q) {
        max = candidate[i];
        date_of_meeting = i;
      }
    }

    printf("%d\n", date_of_meeting);
  }
  return 0;
}



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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

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

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }


  int main(){
    string x;
    cin >> x;
    for(int i = 0; i < (1 << x.length() - 1); i++){
      string target = "";
      int sum = x.at(0) - '0';
      for(int j = 0; j < x.length() - 1; j++){
        if(i & 1 << j) {
          target += '+';
          sum += x.at(j + 1) - '0';
        }
        else {
          target += '-';
          sum -= x.at(j + 1) - '0';
        }
      }
        if(sum == 7){
          REP(i, x.length()){
            cout << x.at(i);
            if(i < x.length() - 1) cout << target.at(i);
          }
        cout << "=7";
        cout << endl;
        return 0;
        
        }
      }


  }

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func reverseString(s string) string {
	n := len(s)
	bytes := []byte(s)
	for i := 0; i < n/2; i++ {
		bytes[i], bytes[n-1-i] = bytes[n-1-i], bytes[i]
	}
	return string(bytes)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	s := ""
	for n > 0 {
		r := (n - 1) % 26
		s += string(byte('a' + byte(r)))
		if n <= 26 {
			break
		}
		n = (n - 1) / 26
	}

	puts(reverseString(s))
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector <int>  p(m+1);
    vector <int> y(m+1); 
    vector <int> id[n+1];
    for(int i=0;i<m;i++){
        cin >> p[i] >> y[i];
        id[p[i]].push_back(y[i]);
    }
    for(int i=0;i<n;i++){
        sort(id[i+1].begin(),id[i+1].end());
    }
    for(int i=0;i<m;i++){
        printf("%012lld\n",(long long)(p[i])*1000000 + (long long)(lower_bound(id[p[i]].begin(),id[p[i]].end(),y[i])-id[p[i]].begin()+1));
    }
    return 0;
}

Measured memory_bytes: 7808
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long S; cin >> S;
    long long x1 = 1000000000, y1 = 1;
    long long y2 = (S+x1-1)/x1;
    long long x2 = x1*y2 - S;
    print(0, 0, x1, y1, x2, y2);
}

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

    solve();

    return 0;
}

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

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

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int N; cin >> N;
    vector<int> h( N );
    REP( i, N ) cin >> h[i];

    int t = h[0], ans = 1;
    REP( i, N - 1 ){
        if( h[i + 1] >= t ) ans++;
        chmax( t, h[i + 1] );
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        abcd: [(usize, usize, usize, usize); q],
    }

    let mut ans = 0;

    for x in (1..=m).combinations_with_replacement(n) {
        let mut s = 0;
        for (a, b, c, d) in abcd.iter() {
            if x[b - 1] - x[a - 1] == *c {
                s += d;
            }
        }
        ans = ans.max(s);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            string read = Console.ReadLine();
            int A = int.Parse(read.Split(' ')[0]);
            int B = int.Parse(read.Split(' ')[1]);
            string[] field = new string[100];
            for (int i = 0; i < 50; i++)
            {

                field[i] = "....................................................................................................";
            }
            for (int i = 50; i < 100; i++)
            {
                field[i] = "####################################################################################################";
            }
            string kougo = ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#";

            int first_kougo = (B-1)/ 50;
            int first_lastline = (B-1) % 50;
            for (int i = 0; i < first_kougo; i++)
            {
                field[2 * i] = kougo;
            }
            string lastline = "";
            for (int i = 0; i < 50; i++)
            {
                if (i < first_lastline) lastline += ".#";
                else lastline += "..";
            }
            field[48] = lastline;


            int second_kougo = (A - 1) / 50;
            int second_lastline = (A - 1) % 50;
            for (int i = 0; i < second_kougo; i++)
            {
                field[2 * i + 52] = kougo;
            }
            lastline = "";
            for (int i = 0; i < 50; i++)
            {
                if (i < second_lastline) lastline += ".#";
                else lastline += "##";
            }
            field[96] = lastline;
            Console.WriteLine("100 100");
            for (int i = 0; i < 100; i++)
            {
                Console.WriteLine( field[i]);
            };
            ;
        }
    }
}


Measured memory_bytes: 13268
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){

  int K, N; cin >> K >> N;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  int ans = A[N - 1] - A[0];
  for (int i = 0; i < N - 1; i++){
    ans = min(ans, K - A[i + 1] + A[i]);
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Simple {
    int X, Y;
    void Solve() {
        //input
        X = io.Char;
        Y = io.Char;
        //ret
        if(X<Y){
            Console.WriteLine("<");
        }else if (X>Y){
            Console.WriteLine(">");
        }else{
            Console.WriteLine("=");
        }
    }


    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() { Solve(); io.writeFlush(); }
}

class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

int n,k,a[1006];

int main()
{
    cin >> n >> k;
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    int ans=0;
    for (int i=0;i<k;i++)
    {
        ans+=a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
A, B = list(map(int, input().split(' ')))

ans = -1
for i in range(1001):
    moneyA = int(i * 1.08)
    taxA = moneyA - i
    moneyB = int(i * 1.10)
    taxB = moneyB - i
    if A == taxA and B == taxB:
        ans = i
        break
print(ans)

Measured memory_bytes: 3060
N,M = map(int, input().split())
AB = [ [int(j) for j in input().split()] for _ in range(M)]


data = [-1]*(N+1)
rank = [1]*(N+1)
con  = [1] * (N+1)
def find(a):
    while data[a] != -1:
        a = data[a]
    return a
def unite(a,b):
    a=find(a); b=find(b)
    if a != b:
        if rank[a] < rank[b]:
            b,a = a,b
        if rank[a] == rank[b]:
            rank[a] += 1
        rank[b] += rank[a]
        data[b] =  a
        con[a]  += con[b]


con = [ [] for _ in range(N+1)]

def is_edge(a):
    if len(con[a]) == 1:
        return True
    return False


conF = [ [False] * (N+1) for _ in range(N+1)]
for a,b in AB:
    # if find(a) != find(b):
    #     ans += 1
    #     unite(a,b)
    con[a].append(b)
    con[b].append(a)
    conF[a][b] = True
    conF[b][a] = True

def dfs(cnt, n, par,  target, visited):
    # print("dfs({}, {}, {}, {}, {}".format(cnt, n, par, target, visited))
    if cnt != 0 and n == target:
        return True

    found = False
    visited[n] = True
    for ch in con[n]:
        if ch == par: continue
        if visited[ch]: continue
        if not conF[ch][n] : continue

        found = dfs(cnt+1, ch, n, target, visited[:])
        if found:
            # print("\tFound!")
            break
    if found:
        return True
    else:
        return False

ans = 0
for a,b in AB:
    conF[a][b] = False
    conF[b][a] = False

    found = False
    for ch in con[a]:
        if ch == b: continue
        visited = [False] * (N+1)
        visited[a] = True
        
        found = dfs(0, ch ,a, b, visited[:])
        if found:
            break
    if not found:
        # print("a: ", a, "b: ", b, "+1! ")
        ans += 1
    # ---- 
    conF[a][b] = True
    conF[b][a] = True

print(ans)



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

int main(){
  int N;
  string S;
  cin >> N;
  for (int i=0;i<N;i++){
    cin >>S;
    if (S=="Y"){
      cout<<"Four"<<endl;
      break;
      }
    if (i==(N-1)){
      cout << "Three"<<endl;
      }
    }
  }

Measured memory_bytes: 3608
n, m = map(int, input().split())
c = [int(i) for i in input().split()]
inf = 10**10

dp = [[inf] * (n+1) for i in range(m+1)]
dp[0][0] = 0

for i in range(m):
  for j in range(n+1):
        if j>=c[i]:
            dp[i+1][j] = min(dp[i][j], dp[i][j-c[i]]+1, dp[i+1][j-c[i]]+1)
        else:
            dp[i+1][j] = dp[i][j]

print(dp[m][n])


Measured memory_bytes: 43776
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long n = sc.nextLong();
      	long k = sc.nextLong();
		long i;
        long ans = k;
        if(n == 1){
          System.out.println(k);
          System.exit(0);
        }
        for(i = 1;i < n;i++){
          ans *= k - 1;
        }
            System.out.println(ans);   
    }
}

Measured memory_bytes: 35676
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll dp[105][2][4];

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

	string S;
	int K;
	cin >> S >> K;
	int N = S.size();
	dp[0][0][0] = 1;
	REP(i, N) {
		dp[i + 1][0][0] = dp[i][0][0] * (S[i] == '0');
		dp[i + 1][1][0] = dp[i][0][0] * (S[i] > '0') + dp[i][1][0];
		REP(j, K) {
			dp[i + 1][0][j + 1] = dp[i][0][j] * (S[i] > '0') + dp[i][0][j + 1] * (S[i] == '0');
			dp[i + 1][1][j + 1] = dp[i][0][j] * (max(0, S[i] - '1')) + dp[i][0][j + 1] * (S[i] > '0')
				+ dp[i][1][j] * 9 + dp[i][1][j + 1];
		}
	}

	cout << dp[N][0][K] + dp[N][1][K] << endl;

	return 0;
}


Measured memory_bytes: 256
C =  [ list(map(int, input().split())) for _ in range(3) ]
for i in range(3):
  temp = C[i][0]
  C[i] = [ j-temp for j in C[i] ]
if C[0]==C[1] and C[1]==C[2]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define fi first
#define se second
#define mp make_pair
#define PII pair<int,int>
#define PIV pair<PII,PII>
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 2e5 + 5 ;
using namespace std ;

PIV q[N] ;
int n, a[N], mx[2][N][21], top, LOG[N] ;

bool cmp(PIV x, PIV y) {
	return a[x.se.fi] < a[y.se.fi] ;
}

void push(PIV x) {
	q[top ++] = x ;
	push_heap(q, q + top, cmp) ;
}

void pop() {
	pop_heap(q, q + top, cmp) ;
	-- top ;
}

int getmx(int l, int r, int c) {
	int i = LOG[r - l + 1] ;
	return a[mx[c][l][i]] > a[mx[c][r - (1 << i) + 1][i]] ? mx[c][l][i] : mx[c][r - (1 << i) + 1][i] ;
}

PII calc(PII x) {
	int l = x.fi, r = x.se ; PII ret ;
	if (l & 1) ret.fi = getmx(l, r, 1), ret.se = getmx(ret.fi + 1, r, 0) ; else
	  ret.fi = getmx(l, r, 0), ret.se = getmx(ret.fi + 1, r, 1) ;
	return ret ;
}

void inq(int l, int r) {
	if (l >= r) return ;
	push(mp(mp(l, r), calc(mp(l, r)))) ;
}

int main() {
	scanf("%d", &n) ;
	rep(i, 1, n) scanf("%d", &a[i]), a[i] = n + 1 - a[i] ;
	rep(i, 1, n) {
		mx[0][i][0] = mx[1][i][0] = 0 ;
		mx[i & 1][i][0] = i ;
		LOG[i] = (int) floor(log(i) / log(2)) ;
	}
	rep(j, 1, 20) rep(i, 1, n - (1 << j) + 1) {
		mx[0][i][j] = a[mx[0][i][j - 1]] > a[mx[0][i + (1 << (j - 1))][j - 1]] ? mx[0][i][j - 1] : mx[0][i + (1 << (j - 1))][j - 1] ;
		mx[1][i][j] = a[mx[1][i][j - 1]] > a[mx[1][i + (1 << (j - 1))][j - 1]] ? mx[1][i][j - 1] : mx[1][i + (1 << (j - 1))][j - 1] ;
	}
	top = 0 ;
	push(mp(mp(1, n), calc(mp(1, n)))) ;
	rep(i, 1, n / 2) {
		PIV u = q[0] ; pop() ;
		PII A = u.fi ;
		printf("%d %d ", n + 1 - a[u.se.fi], n + 1 - a[u.se.se]) ;
		int l = A.fi, r = A.se, midl = u.se.fi, midr = u.se.se ;
		inq(l, midl - 1), inq(midl + 1, midr - 1), inq(midr + 1, r) ;
	}
	return 0 ; 
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<int> a(n + 1);
  rep(i, n) cin >> a[i + 1];
  vector<int> b(n + 1);
  for (int i = n; i >= 1; --i) {
    int sum = 0;
    for (int j = i + i; j <= n; j += i) {
      sum += b[j];
    }
    if (sum % 2 != a[i]) {
      b[i] = 1;
    }
  }
  out(accumulate(all(b), 0));
  rep(i, n) if (b[i + 1] == 1) out(i + 1);
}


Measured memory_bytes: 4764
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    string s;
    cin >> s;
    string t = s.erase(s.sz - 8);
    cout << t << endl;
}



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

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  int p[N + 1];
  for (int i = 1; i <= N; i++) {
    cin >> p[i];
  }

  int sum = 0;
  bool f;
  for (int i = 1; i <= N; i++) {
    if (p[i] == i) {
      sum++;
      if(i < N && p[i + 1] == i + 1) {
        i++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}

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

#define M_W  10e5
int main() {
	vector<bool> D(M_W + 1, false);
	vector<long long> W(M_W + 1, INT64_MAX);
	D[0] = true;
	W[0] = 0;
	int N, V;
	cin >> N >> V;
	while (N--) {
		int w, v;
		cin >> w >> v;
		for (int i = M_W; i >= 0; i--) {
			if (D[i] && W[i] + w < W[i + v]) {
				W[i + v] = W[i] + w;
				D[i + v] = true;
			}
		}
	}

	for (int i = M_W; i >= 0; i--) {
		if (D[i] && W[i] <= V) {
			cout << i << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  ll A, B;
  cin >> A >> B;
  ll d = B - A + 1;
  ll ans;
  if (A % 2 == 0) { // Aが偶数
    if (B % 2 == 1) {
      if ((d / 2) % 2 == 0) ans = 0;
      else ans = 1;
    } else {
      d--;
      if ((d / 2) % 2 == 0) ans = B;
      else ans = B ^ 1;
    }
  } else {
    if (B % 2 == 1) {
      d--;
      if ((d / 2) % 2 == 0) ans = A;
      else ans = A ^ 1;
    } else {
      d -= 2;
      if ((d / 2) % 2 == 0) ans = A ^ B;
      else ans = A ^ B ^ 1;
    }
  }
  cout << ans << '\n';
}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n, S; cin >> n >> S;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    int res = inf;
    int s = 0, t = 0, sum = 0;
    while (true) {
        while (t < n && sum < S) sum += a[t++];
        if (sum < S) break;
        res = min(res, t - s);
        sum -= a[s++];
    }
    cout << (res <= n ? res : 0) << endl;
    return 0;
}


Measured memory_bytes: 3368
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

ll n, k;
string s;
vvv dp = vvvl(105, 200, 2, -1);

ll calc(ll t, ll K, ll f){
  if(t==-1) return (K==k?1:0);
  if(dp[t][K][f]!=-1) return dp[t][K][f];

  ll ret = 0;
  ll to = s[104 - t] - '0';
  if(f==1){
    for(int i=0;i<=9;i++){
      ret += calc(t-1, (i==0?K:K+1), f);
    }
  }else{
    for(int i=0;i<to;i++) ret += calc(t-1, (i==0?K:K+1), 1);
    ret += calc(t-1, (to==0?K:K+1), 0);
  }
  return dp[t][K][f] = ret;
}

int main(int argc, char const *argv[]) {
  std::cin >> s;
  std::cin >> k;
  while(s.size()!=105) s = '0' + s;
  std::cout << calc(104, 0, 0) << '\n';
  return 0;
}


Measured memory_bytes: 2040
#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);
	printf("%d\n",c1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000?1:0);
	return 0;
}

Measured memory_bytes: 600