akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define mkp make_pair
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;
/*
ll bin(ll i,ll j){
	ll mid=(i+j)/2;
	if(a[mid]==x)reutrn mid;
	else if(ans>x)return bin(i,mid-1);
	else return bin(mid+1,j);
}/*
ll power(ll base,ll power){
    ll res=1;
    base=base%mod;
    while(power>0){
    	if(power&1){
    		res=(res*base)%mod;
		}
		power=power>>1;
		base=(base*base)%mod;
	}
	return res;
}
*/
/*
int nCr(int x, int y){
	if(y>x)return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}
*/
/*bool prime[n+1];
void SieveOfEratosthenes(int n){
	rep(i,0,n+1)prime[i]=true
    for (int p=2;p*p<=n;p++)
        if (prime[p])
            for (int i=p*p;i<=n;i+=p)prime[i]=false;
}*/
/*
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
*/
int solve(){
    int n,k;
    cin>>n>>k;
	string s;
	cin>>s;
	vector<int> vec;
	rep(i,0,n){
		if(k==0)break;
		int j=i+1;
		while(j<n&&s[i]==s[j])j++;
		if(j==n)break;
		int p=j+1;
		s[j]=s[i];
		while(p<n&&s[j]!=s[p]){
			s[p]=s[j];
			p++;
		}
		k--;
	}
	int cnt=0;
	rep(i,0,n-1){
		if(s[i+1]==s[i])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 512
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut h: Vec<usize> = sc.vec(N);
    let mut ans = 0;
    loop {
        let mut cur = 0;
        while cur < N {
            while cur < N && h[cur] == 0 {
                cur += 1;
            }
            if cur >= N {
                break;
            }
            let mut d = h[cur];
            let mut end = cur + 1;
            while end < N && h[end] != 0 {
                d = min(d, h[end]);
                end += 1;
            }
            for i in cur..end {
                h[i] -= d;
            }
            ans += d;
        }
        for &hi in &h {
            if hi != 0 {
                continue;
            }
        }
        break;
    }
    println!("{}", ans);
}


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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> rest(n, 1);
  vector<bool> state(n, false);
  state[0]=true;
  
  for(int i=0;i<m;++i) {
    int fr,to; cin>>fr>>to;
    --fr; --to;
    --rest[fr];
    ++rest[to];
    state[to] = state[to] or state[fr];
    if(rest[fr]==0){
      state[fr] = false;
    }
  }

  int ans=0;
  for(int i=0;i<n;++i)
    if(state[i]) ++ans;
  cout << ans << endl;
}

Measured memory_bytes: 640
maxNum, brokenCount= map(int, input().split())
brokenIndexSet= set([int(input()) for i in range(brokenCount)])

ans = [0]*(maxNum+2)

ans[maxNum] = 1

for i in reversed(range(maxNum)):
    if i in brokenIndexSet:
        ans[i] = 0
    else:
        ans[i] = (ans[i+1] + ans[i+2]) % 1000000007 

print(ans[0])

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

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

  int N;
  cin>>N;
  for(int i=1;i<=N;i++){
    ll ans=0;
    for(int j=1;j*j<=N;j++){
      for(int k=1;k*k<=N;k++){
        int l=0,r=102,m;
        while(r-l>1){
          m=(l+r)/2;
          if(m*m+(j+k)*m<=i-j*j-k*k-j*k)l=m;
          else r=m;
        }
        if(1<=l&&l<=100&&l*l+(j+k)*l==i-j*j-k*k-j*k)ans++;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3648
n,k = list(map(int, input().split()))
ans = 0
for i in range(1,n+1):
  tmp = i
  cnt = 0
  while tmp < k:
    tmp *= 2
    cnt +=1
  #print(n,tmp, cnt)
  ans = ans + ((1/(n*(2**cnt))))
print(ans)

Measured memory_bytes: 3060
// JOI14-quest1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <stdio.h>


int main(void)
{
	int x_money, y_standard, y_max, y_money, joi_use;

	scanf("%d", &x_money);
	scanf("%d", &y_standard);
	scanf("%d", &y_max);
	scanf("%d", &y_money);
	scanf("%d", &joi_use);

	int x_total = 0, y_total = 0;

	x_total = x_money * joi_use;

	if (joi_use <= y_max) {
		y_total = y_standard;
	}
	else {
		y_total = y_standard + (y_money * (joi_use - y_max));
	}

	int small = 0;

	if (x_total <= y_total) {
		small = x_total;
	}
	else {
		small = y_total;
	}

	printf("%d\n", small);

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define fi first
#define se second
#define endl "\n"
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=61; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} typedef pair<int,int> pii;
const int mod=(999983); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;}
//#define int ll
struct vec{
	lf x,y;
	explicit vec(lf x=0,lf y=0):x(x),y(y){}
	vec operator-(const vec &b){return vec(x-b.x,y-b.y);}
	vec operator+(const vec &b){return vec(x+b.x,y+b.y);}
	vec operator*(lf k){return vec(k*x,k*y);}
	lf len(){return hypot(x,y);}
	lf sqr(){return x*x+y*y;}
	vec trunc(lf k=1){return *this*(k/len());}
	vec rotate(double th){lf c=cos(th),s=sin(th); return vec(x*c-y*s,x*s+y*c);}
}a[N];
ostream &operator<<(ostream &o,const vec &v){return o<<'('<<v.x<<','<<v.y<<')';}
int n,k; lf c[N],s[N];

lf E(vec v){
	repeat(i,0,n)s[i]=(a[i]-v).len()*c[i];
	nth_element(s,s+k,s+n);
	return s[k];
}

lf rndf(){return rnd()*1.0/rnd.max();}
vec rndvec(){return vec(rndf()*2-1,rndf()*2-1);}
struct state{
	vec v; lf e;
	state(vec v=vec()):v(v),e(E(v)){}
	operator lf(){
		return e;
	}
};
state solve(){
	state X; lf T=1000;
	auto work=[&](){
		state Y=X.v+rndvec()*T;
		if(Y<X){X=Y; return 1;}
		return 0;
	};
	while(T>1e-9){
		if(work()){
			work(); work();
			T*=1.1;
		}
		T*=0.99992;
	}
	return X;
}

void Solve(){
	n=read(),k=read()-1;
	repeat(i,0,n)a[i].x=read(),a[i].y=read(),c[i]=read();
	state X=solve();
	repeat(i,0,5){
		state Y=solve();
		if(X>Y)X=Y;
	}
	printf("%.10f\n",lf(X));
}
signed main(){
	int T=1; //T=read();
	while(T--)Solve();
	return 0;
}

Measured memory_bytes: 3892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x, y;cin>>x>>y;bool f = -abs(y)<x&&x<=abs(y);
  cout<<abs(abs(x)-abs(y))+(abs(y)<x)+(-abs(y)<x&&x<0)+(f&&y<0)+(!f&&y>0)<<endl;
}


Measured memory_bytes: 256
<?php
// Your code here!
$inp = fgets(STDIN);
$inp = explode(" ",$inp);
list($n,$a,$b) = array_map(function($a){return (int)$a;},$inp);
$s = trim(fgets(STDIN));
$ca = 0;
$co = 0;
$ss = str_split($s) ;
$ans = "";
foreach ($ss as $c)
{
    
    if($c == "a")
    {
        
        if($ca < $a + $b)
        {
            $ans .= ("Yes".PHP_EOL);
            $ca += 1;
        }
        else
        {
            $ans .=("No".PHP_EOL);
        }
    }
    else if($c == "b")
    {
        
        
        if($co < $b and $ca < $a + $b)
        {
            $ans .=("Yes".PHP_EOL);
            $ca += 1;
            $co += 1;
        }
        else
        {
            $ans .=("No".PHP_EOL);
        }
        
    }
    else
    {
        $ans .=("No".PHP_EOL);
    }
}
echo($ans);
?>


Measured memory_bytes: 22284
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 120000;
int cnt[N], ans;
bool can[N];
int main() {
	int n, m;
	cin >> n >> m;
	can[1] = 1;
	for(int i = 1; i <= n; i ++ ) cnt[i] = 1; 
	for(int i = 1; i <= m; i ++ ) {
		int x, y;
		cin >> x >> y;
		cnt[x]--, cnt[y]++;
		if(can[x]) can[y]=1;
		if(cnt[x] == 0) can[x] = 0;
	}
	for(int i = 1;i <= n; i ++ ) {
		cnt[0]+=can[i];
	}
	cout << cnt[0] << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <set>
#include <utility>
#include <algorithm>
using namespace std;
pair<int,pair<int,int>> p[200010];
set<pair<int,int>> s;
int ans[200010];
int main(){
	int i,n,q;
	cin >> n >> q;
	for(i=0;i<n;i++){
		int l,r,x;
		cin >> l >> r >> x;
		p[i] = {x,{l,r}};
	}
	sort(p,p + n);
	for(i=0;i<q;i++){
		int d; cin >> d;
		s.insert({d,i}); ans[i] = -1;
	}
	for(i=0;i<n;i++){
		int x = p[i].first;
		int l = p[i].second.first - x,r = p[i].second.second - x;
		auto it = s.lower_bound({l,-1});
		while(it!=s.end()){
			if(it->first>=r) break;
			ans[it->second] = x;
			s.erase(it++);
		}
	}
	for(i=0;i<q;i++){
		cout << ans[i] << "\n";
	}
}

Measured memory_bytes: 14336
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <random>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

template <typename T> struct BIT { // 1-indexed
private:
    vector<T> array;
    const int n;

public:
    // 初期化
    BIT(int _n) : array(_n + 1, 0), n(_n) {}

    // 1番目からi番目までの累積和を求める
    T sum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i; // LSB減算
        }

        return s;
    }

    // [i, j]の要素の総和
    T sum(int i, int j) {
        T ret_i = sum(i - 1);
        T ret_j = sum(j);

        return ret_j - ret_i;
    }

    // i番目に要素xを追加
    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i; // LSB加算
        }
    }
};

template <typename T> struct BIT2 { // 1-indexed
private:
    vector<vector<T> > array;
    const int n;
    const int m;

public:
    // 初期化
    BIT2(int _n, int _m) : array(_n + 1, vector<T>(_m + 1, 0)), n(_n), m(_m) {}

    // (1, 1)から(x, y)までの累積和を求める
    T sum(int x, int y) {
        T s = 0;
        for (int i = x; i > 0; i -= i & (-i)) {
            for (int j = y; j > 0; j -= j & (-j)) {
                s += array[i][j];
            }
        }

        return s;
    }

    // [(x1, y1), (x2, y2)]の要素の総和
    T sum(int x1, int y1, int x2, int y2) {
        return sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) + sum(x1 - 1, y1 - 1);
    }

    // (x, y)に要素kを追加
    void add(int x, int y, T k) {
        for (int i = x; i <= n; i += i & (-i)) {
            for (int j = y; j <= m; j += j & (-j)) {
                array[i][j] += k;
            }
        }
    }
};

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}

int main() {
    int N, M, Q, l, r, p, q;
    cin >> N >> M >> Q;
    BIT2<int> bit(N, N);

    for (int i = 0; i < M; ++i) {
        cin >> l >> r;
        bit.add(l, r, 1);
    }

    for (int i = 0; i < Q; ++i) {
        cin >> p >> q;
        cout << bit.sum(min(p, q), min(p, q), max(p, q), max(p, q)) << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#define x first
#define y second

namespace jm
{
	typedef std::pair<int,int> pii;
	const int N=101000;
	std::queue<pii> Q;
	std::set<int> G0[N],G1[N];
	int n;
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,u,v;i<n;i++)
		{
			scanf("%d%d",&u,&v);
			G0[u].insert(v);
			G0[v].insert(u);
		}

		for(int i=1,u,v;i<n;i++)
		{
			scanf("%d%d",&u,&v);
			G1[u].insert(v);
			G1[v].insert(u);

			if(G0[u].find(v)!=G0[u].end())
				Q.push(pii(u,v));
		}
	}

	bool done[N];

	void combine(int u,int v)
	{
		if(G0[u].size()+G1[u].size()<G0[v].size()+G1[v].size())std::swap(u,v);

		for(auto x:G0[v])if(x!=v)G0[x].erase(v);
		for(auto x:G1[v])if(x!=v)G1[x].erase(v);

		for(auto x:G0[v])
		{
			if(x==u || x==v)continue;

			G0[u].insert(x);
			G0[x].insert(u);
			if(G1[u].count(x))
				Q.push(pii(u,x));
		}

		for(auto x:G1[v])
		{
			if(x==u || x==v)continue;

			G1[u].insert(x);
			G1[x].insert(u);
			if(G0[u].count(x))
				Q.push(pii(u,x));
		}
		G0[v].clear(),G1[v].clear();

		done[v]=1;
	}

	void solve()
	{
		initialize();
//		printf("?\n");
		while(!Q.empty())
		{
			pii A=Q.front();Q.pop();
			int x=A.x,y=A.y;
			if(x==y || done[x] || done[y])continue;

//			printf("%d -- %d\n",x,y);

			combine(x,y),n--;
//			if(n%100==0)printf("%d\n",n);
		}
		printf("%s\n",n>1?"NO":"YES");
	}
}

int main()
{
//	freopen("E.in","r",stdin);
	jm::solve();
	return 0;
}


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

int main(void){
    int c[3][3]={0};
    for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>c[i][j];
    for(int i=0;i<=100;i++){
        int b1=c[0][0]-i;
        int b2=c[0][1]-i;
        int b3=c[0][2]-i;
        if((c[1][0]-b1==c[1][1]-b2)&&(c[1][1]-b2==c[1][2]-b3)&&(c[2][0]-b1==c[2][1]-b2)&&(c[2][1]-b2==c[2][2]-b3)){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

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

typedef long long ll;

int main()
{
	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 };
	int k;
	cin >> k;
	cout << a[k - 1];
	return 0;
}

Measured memory_bytes: 256
n,m,l=map(int,input().split())
INF=1001001001
dist=[[INF for i in range(n)] for j in range(n)]
dist2=[[INF for i in range(n)] for j in range(n)]
for i in range(n):
  dist[i][i]=0
  dist2[i][i]=0
for i in range(m):
  a,b,c=map(int,input().split())
  a-=1
  b-=1
  dist[a][b]=c
  dist[b][a]=c
#print("dist",dist)
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
for i in range(n):
  for j in range(n):
    if dist[i][j]<=l:
      dist2[i][j]=1
#print("dist2 pre",dist2)
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist2[i][j]=min(dist2[i][j],dist2[i][k]+dist2[k][j])
#print("dist2",dist2)
q=int(input())
for i in range(q):
  s,t=map(int,input().split())
  if dist2[s-1][t-1]==INF:
    print(-1)
  else:
    print(dist2[s-1][t-1]-1)

Measured memory_bytes: 60504
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n;

int main(){
	cin >> n;
	
	ll pos=(n/11+!!(n%11));
	if(11*pos-5>=n) pos=2*pos-1;
	else pos*=2;
	cout << pos << endl;
	return 0;
}


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

int main() {
   string n;
   cin >> n;
   if ((n[0] == '7') || (n[1] == '7') || (n[2] == '7')) {
      cout << "Yes" << endl;
   }
   else cout << "No" << endl;
   return 0;
}

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

using namespace std;

int arr[12];

int main(){
	for(int i = 0;i < 10;i++)
	    cin>>arr[i];
	sort(arr,arr+10);
	for(int j = 9;j>=7;j--)
		cout<<arr[j]<<endl;
	return 0;
}

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

map<int,int> mp;
int main () {
    int n,f=1;
    cin>>n;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        if(mp.find(k)!=mp.end())
            f=0;
        mp[k]=1;
    }
    if(f)
        cout<<"YES";
    else
        cout<<"NO";
}

Measured memory_bytes: 9600
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
vector<string> ans;
map<string, ll> mp;

void dfs(ll num, ll ma, string co) {
  // Cout(co);
  if (num == n) {
    // mp[co] = 1;
    ans.p_b(co);
    return;
  }
  rep(i, num + 1) {
    string res = co;
    res += alph[i];
    if (ma + 1 < i) continue;
    dfs(num + 1, max(ma, i), res);
  }
}

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

  cin >> n;
  dfs(0LL, 0LL, "");
  // sort(all(ans));
  rep(i, Size(ans)) Cout(ans[i]);
  return 0;
}


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

using namespace std;

//#define _FILES
#define PB push_back
#define MP make_pair
#define X first
#define Y second
const int MAXN = 2005;

int f[MAXN][MAXN], h[MAXN][MAXN], v[MAXN][MAXN], c[MAXN][MAXN];

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n, m, q;
    cin >> n >> m >> q;
    for (int i=1;i<=n;i++)
    {
        string s;
        cin >> s;
        for (int j=0;j<m;j++)
        {
            if (s[j] == '1')
            {
                f[i][j+1] = 1;
            }
        }
    }

    for (int i=n;i>=1;i--)
    {
        for (int j=m;j>=1;j--)
        {
            c[i][j] = c[i+1][j] + c[i][j+1] - c[i+1][j+1];

            if (f[i][j])
            {
                c[i][j]++;
                if (f[i+1][j])
                {
                    c[i][j]--;
                }

                if (f[i][j+1])
                {
                    c[i][j]--;
                }
            }

            v[i][j] = v[i+1][j];
            if ((f[i][j]) && (f[i][j+1]))
            {
                v[i][j]++;
            }

            h[i][j] = h[i][j+1];
            if ((f[i][j]) && (f[i+1][j]))
            {
                h[i][j]++;
            }
        }
    }

    for (int i=0;i<q;i++)
    {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int ans = c[x1][y1] + h[x2][y1] - h[x2][y2+1] + v[x1][y2] - v[x2+1][y2] - c[x2+1][y1] - c[x1][y2+1] + c[x2+1][y2+1];
        cout << ans << "\n";
    }
    return 0;
}



Measured memory_bytes: 64640
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.nextLine();
		int count = 0;
		
		for (int i = 0; i < S.length(); i++) {
			if (S.charAt(i) == 'o')
				count++;
		}
		
		if (((15 - S.length())+count)>= 8)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
int main() {int a, b,x,y,z,o;
  cin >> a >> b>>x>>y>>z;
  
  if (a == 0) {
    cout << "1" << endl;
  }
   if (b == 0) {
    cout << "2" << endl;
  }
             if (x == 0) {
    cout << "3" << endl;
  }
             if (y == 0) {
    cout << "4" << endl;
  }
             if (z == 0) {
    cout << "5" << endl;
  }
           }

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

int insSrot(vector<int>& a) {
	int cnt = 0;
	for (int i = 0; i < a.size(); i++) {
		int minj = i;
		for (int j = i; j < a.size(); j++) {
			if (a[j] < a[minj]) minj = j;
		}
		if (i != minj) cnt++;
		swap(a[i], a[minj]);

	}
	for (int i  = 0; i < a.size(); i++) {
		if (!i) cout << a[i];
		else cout << " " << a[i];
	}
	cout << endl;
	return cnt;
}

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


	cout << insSrot(a) << endl;

	return 0; 
}



Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<iomanip>
#include<algorithm>
using namespace std;

int main(){
  int N;
  int L;
  cin >> N>>L;
  string S[110];
  for(int i=0; i<N; ++i){
    cin >>setw(L)>>  S[i] ;
  }
 sort(S,S+N);
  for(int i=0; i<N; ++i){
    cout << S[i] ;
  }
}

Measured memory_bytes: 256
function gcd(a,b)
    if b~=0 then
        return gcd(b,a%b)
    else
        return a
    end
end
a,b,c,d=io.read("*n","*n","*n","*n")
x=(b//c+b//d-b//((c*d)//gcd(c,d)))-((a-1)//c+(a-1)//d-(a-1)//((c*d)//gcd(c,d)))
print(b-a+1-x)

Measured memory_bytes: 376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  rep(i, 3) {
    rep(j, 3) {
      char c;
      cin >> c;
      if (i == j) cout << c;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
using namespace std;
 
#define int long long

const int MAX_V=1000;
int memo[1000001]={0};
int dist[MAX_V][MAX_V];


void warshall_floyd(int V){
    for(int k=0;k<V;k++){
        for(int i=0;i<V;i++){
            for(int j=0;j<V;j++){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
}

 

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化
    
    int h,w;
    cin>>h>>w;

    int dist[10][10];
    int wall[h][w];
    int ans=0;
    int tmp;

    REP(i,10){
        REP(j,10){
            cin>>dist[i][j];
        }
    }

    REP(k,10){
        REP(i,10){
            REP(j,10){
                if(dist[i][j]>dist[i][k]+dist[k][j])dist[i][j]=dist[i][k]+dist[k][j];
            }
        }
    }

    // for(int i=0;i<10;i++){
    //     for(int j=0;j<10;j++){
    //         cout<<dist[i][j]<<" ";
    //     }cout<<endl;
    // }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>tmp;
            if(tmp==1||tmp==-1)continue;
            else{
                ans+=dist[tmp][1];
            }
        }
    }

    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	var map = {};
	var submap = new Set();
	var sameSet = new Set();
	for(var i = 0; i < N; i++){
		if(submap.has(list[i])){
			sameSet.add(list[i]);
		}
		submap.add(list[i]);
		if(map[list[i]] == null){
			map[list[i]] = getDivisorList(list[i]);
		}
	}
	var output = 0;
	for(var i = 0; i < N; i++){
		if(sameSet.has(list[i])){
			continue;
		}
		var getDiv = map[list[i]];
		var isOK = true;
		for(var j = 0; j < getDiv.length; j++){
			if(getDiv[j] != list[i] && submap.has(getDiv[j])){
				isOK = false;
				break;
			}
		}
		if(isOK){
			output++;
		}
	}
	myout(output);
}
function getDivisorList(val){
  var list = [];
  for(var i = 1; i * i <= val; i++){
    if(val % i == 0){
      list.push(i);
      if(i * i != val){
        list.push(val / i);
      }
    }
  }
  list.sort(function(a,b){ return a - b; });
  return list;
}

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

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

using ll = long long;

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

int main() {
  ll L, R;
  cin >> L >> R;
  if((R/2019LL)-((L-1LL)/2019LL)>=1LL) cout<< 0 << endl;
  else{
    ll ans = 2020LL;
    for(ll i = L; i < R; i++) {
      for(ll j = i+1LL; j <= R; j++) {
        ll t = ((i%2019LL)*(j%2019LL))%2019LL;
        chmin(ans,t);
      }
    }
    cout<<ans<<endl;
  }
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  u64 n, k;

  cin >> n >> k;

  deque<u64> a(n);
  deque<u64> p(k);

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

  rep(i, k) {
    u64 ai = a.front();

    p[i] = ai;
    a.pop_front();
  }

  rep(i, n - k) {
    u64 ai = a.front();
    u64 pi = p.front();
    if (ai > pi) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    a.pop_front();
    p.pop_front();
    p.push_back(ai);
  }

  return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }

    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
string str;
ll sum[100009];
int  main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    cin>>str;
    char ch ='0';
    int cnt=0;
    vector<pair<ll,char> > v;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]==ch) cnt++;
        else
        {
            if(cnt)v.pb(mp(cnt,ch));
            if(ch=='1') ch='0';
            else ch='1';
            cnt=1;
        }
    }
    v.pb(mp(cnt,ch));
    sum[0]=v[0].first;
    for(int i=1;i<v.size();i++)
    {
        sum[i]=sum[i-1]+v[i].first;
    }
    int dif=2*k;
    ll ans=0;
    for(int i=0;i<v.size();i++)
    {
        ll temp=0;
        char  e=v[i].second;
        int last=0;
        if(e=='0') last=i+dif-1;
        else last=i+dif;
        int mini=min((int)v.size()-1,last);
         if(i==0) temp=sum[mini];
        else temp=sum[mini]-sum[i-1];
        ans=max(ans,temp);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 2928
h,w=map(int,input().split())
G=[["#"]*(w+2) for i in range(h+2)]
for i in range(1,h+1):
  G[i]=["#"]+list(input())+["#"]
for i in range(h+2):
  for j in range(w+2):
    if G[i][j]==".":
      G[i][j]=0
    else:
      G[i][j]=1
dp=[[1000]*(w+2) for i in range(h+2)]
dp[1][1]=0
for i in range(1,h+1):
  for j in range(1,w+1):
    if i==1 and j==1:
      continue
    dp[i][j]=min(dp[i-1][j]+(G[i-1][j]+G[i][j])%2,dp[i][j-1]+(G[i][j-1]+G[i][j])%2)
ans=dp[h][w]
if G[1][1]==1:
  ans=ans+1
print((ans+1)//2)

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

long long GCD(long long A, long long B)
{
  long long a = A, b = B;
  while (a * b != 0  &&  a != 1  &&  b != 1)
  {
    if (a < b) b %= a;
    else a %= b;
  }
  if (a * b == 0) return max(a, b);
  else return 1;
}

long long LCM(long long A, long long B)
{
  return A * B / GCD(A, B);
}

int main()
{
  long long N, M;
  string S, T;
  cin >> N >> M >> S >> T;
  
  long long G = GCD(N, M), L = LCM(N, M);
  long long n = N / G, m = M / G;
  long long ans = L;
  for (long long i = 0; i < G; i++)
  {
    if (S.at(n * i) != T.at(m * i))
    {
      ans = -1;
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int ip[100042]={0};
int main(void)
{
	int n,i;
	cin>>n;
	long long ans=0;
	int rem=0;
	for(i=0;i<n;i++)
	{
		cin>>ip[i];
	}
	for(i=0;i<n;i++)
	{
		ans+=(rem+ip[i])/2;
		rem=(rem+ip[i])%2;
		if(ip[i]==0)
		{
			rem=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let W = input[0]
	const alphabets = 'abcdefghijklmnopqrstuvwxyz'
	for(let i = 0 ; i < alphabets.length ; i++) {
		let match = W.match(new RegExp(alphabets[i], 'g'))
		if(match && match.length % 2 === 1) {
			console.log('No')
			return
		}
	}
	console.log('Yes')
}   
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
object Main {
  def main(args:Array[String]) {
    val read = readLine()
    var N = read.split(' ')(0).toLong
    var K = read.split(' ')(1).toInt

    var count = 0
    while(K <= N) {
      N = N / K
      count = count + 1
    }
    println(count + 1)
  }
}


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

int main() {// 単調非減少＝広義の単調増加。
  int N;
  cin >> N;
  if (N==1) puts("Hello World");
  else if (N==2){
    int A,B;
    cin >> A >> B;
    cout << A+B << endl;
  }
    
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll inf  = 1e7+5;

bool visited [inf];
int dist[inf];
int main() {
  int n,m; cin >> n >> m;
  double pop = m;
  double total = 0;
  vector<int> nums (n);
  for (int i = 0; i < n; i++){
        int a; cin >> a; nums[i] = a;
        total+= a;
  }
  sort(nums.begin(), nums.end());
  reverse(nums.begin(), nums.end());
  double d = 1.0/(pop*4.0);
  for (int i = 0; i < n; i++){
      if (d*total > nums[i]){
          break;
      }
      else{
          m--;
      }
  }
    if (m > 0){
        cout << "No";
    }
    else{
        cout << "Yes";
    }
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		StringTokenizer st = new StringTokenizer(line, " ");
		int n = Integer.parseInt(st.nextToken());
		int sum = Integer.parseInt(st.nextToken());
		int wt[] = new int[n];
		int val[] = new int[n];
		for (int i = 0; i < n; i++) {
			String lines = br.readLine();
			StringTokenizer sts = new StringTokenizer(lines, " ");
			wt[i] = Integer.parseInt(sts.nextToken());
			val[i] = Integer.parseInt(sts.nextToken());
		}
		System.out.println(KN(n, sum, wt, val));
	}

	static long KN(int n, int W, int wt[], int val[]) {
		long dp[][] = new long[n + 1][W + 1];

		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= W; j++) {
				if (i == 0 || j == 0) {
					dp[i][j] = 0;
				} else if (wt[i - 1] <= j) {
					dp[i][j] = Math.max(val[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]);
				} else {
					dp[i][j] = dp[i - 1][j];
				}
			}
		}
		return dp[n][W];
	}

}


Measured memory_bytes: 125396
import java.util.*;

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

		while(true){
			final String[] data = sc.nextLine().split(" ");
			final int n = Integer.parseInt(data[0]);
			final int x = Integer.parseInt(data[1]);
			if(n == 0 && x == 0) break;
			int count = 0;
			for(int i = 1; i <= n - 2; i++){
				for(int j = i + 1; j <= n - 1; j++){
					for(int k = j + 1; k <= n; k++){
						if((i + j + k) == x) count++;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 18984
N, Q = map(int, input().split())
S = input()
x = [0]*N
cnt = 0
for i in range(1, N):
    if S[i-1:i+1] == "AC":
        cnt += 1
    x[i] = cnt

lr = []
for _ in range(Q):
    lr.append(map(int, input().split()))

for l, r in lr:
    print(x[r-1]-x[l-1])

Measured memory_bytes: 52040
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 1; i <= n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
int n, h, k, c,t; string s;
ll ans = 1;
vector<int> d(1001,1);
void prime(int n) {
	if (n != 1) {
		while (n % 2 == 0) {
			d[2]++;
			n /= 2;
		}
		for (int i = 3; i <= n; i += 2) {
			while (n % i == 0) {
				d[i]++;
				n /= i;
			}
		}
	}
}
int main() {
    cin >> n;
    rep(i, n) {
		prime(i);
    }
	rep(i, n) {
		ans *= d[i];
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
ll dp[55][55][2505];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;cin>>n>>a;
    vector<int> k(n);
    rep(i,n)cin>>k[i];
    rep(i,n+1)rep(j,n+1)rep(l,n*a+1)dp[i][j][l]=0;
    dp[0][0][0]=1;
    rep(i,n)rep(j,n+1)rep(l,n*a+1){
        if(dp[i][j][l]==0)continue;
        dp[i+1][j][l]+=dp[i][j][l];
        dp[i+1][j+1][l+k[i]]+=dp[i][j][l];
    }
    ll ans=0;
    for(int j=1;j<=n;j++)ans+=dp[n][j][j*a];
    cout<<ans<<endl;
    return 0;
}


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

ll H, K, sum=0;
vector<ll> A;

signed main(){
    cin >> H >> K;
    for(int i=0;i<K;i++) {
        ll a;
        cin >> a;
        sum += a;
    }
    if(sum>=H) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

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

#define llint long long int

using namespace std;

int main(){
    int N, M, Q;

    cin >> N >> M >> Q;

    vector<int> a(Q), b(Q), c(Q), d(Q);

    for(int i = 0; i < Q; i ++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    vector<int> A(N, 1);

    int max_score = 0;

    while(A[0] <= M){
        int score = 0;

        for(int i = 0; i < Q; i ++){
            if(A[b[i] - 1] - A[a[i] - 1] == c[i]){
                score += d[i];
            }
        }
        if(score > max_score){
            max_score = score;
        }
        A[N - 1] ++;

        for(int i = N - 1; i >= 1; i --){
            if(A[i] == M + 1){
                A[i - 1] ++;
            }
        }
        for(int i = 1; i < N; i ++){
            if(A[i] == M + 1){
                A[i] = A[i - 1];
            }
        }
    }
    cout << max_score << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int a[200012];
int main()
{
    int n;
    cin>>n;
    for(int i =1;i<=n;++i)
        cin>>a[i];
    int ans = 0;
    int num = 0;
    int flag ;
    flag = a[1];
    for(int i =1;i<=n;i++)
    {
        
        if(a[i]<=flag)
        {
            ans++;
            flag = a[i];
        }
    }
    
    
    cout<<ans<<endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAX_N 100010
#define rank dfasoifd
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
P par[MAX_N];
int rank[MAX_N];

void init(int n){
  for(int i=0;i<n;i++)par[i]=P(i,0),rank[i]=0;
}

P find(int x){
  if(par[x].f==x)return par[x];
  P r=find(par[x].f);
  return  par[x]=P(r.f,r.s+par[x].s);
}

void unite(int x,int y,ll c){
  P X=find(x),Y=find(y);
  x=X.f,y=Y.f;
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=P(y,c+(-X.s+Y.s));
  else{
    par[y]=P(x,-c+(+X.s-Y.s));
    if(rank[x]==rank[y])rank[x]++;
  }
}

bool same(int x,int y){return find(x).f==find(y).f;}

int main(){
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n&&!m)break;
    init(n);  
    while(m--){
      char ch;
      int a,b,c;
      cin>>ch>>a>>b;a--,b--;
      if(ch=='!')cin>>c,unite(a,b,c);      
      else{
	if(same(a,b))printf("%lld\n",par[a].s-par[b].s);
	else printf("UNKNOWN\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 5168
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var x = Read();
            var list = new List<long>();
            list.Add(1);
            for (int i = 1; i<=x ; i++)
            {
                for (int j = 2; j*j <=i ; j++)
                {
                    var tmp = i;
                    while (tmp > 1 && tmp % j == 0)
                    {
                        tmp /= j;
                    }
                    if (tmp == 1)
                        list.Add(i);
                }
            }
            Console.WriteLine(list.Max());



 
           
            Console.Out.Flush();
        }
    }
}

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

using namespace std;

struct Process {
  string name;
  int time;
};

int main () {
  int n, q;
  Process P[1000000];

  cin >> n >> q;

  for (int i = 0; i < n; i++) {
    cin >> P[i].name >> P[i].time;
  }

  int count = 0;
  int origin = n;

  for (int i = 0; i < n; i++) {
    P[i].time -= q;
    if (P[i].time <= 0) {
      count += q + P[i].time;
      cout << P[i].name << " " << count << endl;
    } else {
      n++;
      P[n-1] = P[i];
      count += q;
    }
  }

}

Measured memory_bytes: 21104
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
        a[i] --;
    }
    for (int i = 0; i < n; ++ i) {
        cin >> b[i];
    }
    for (int i = 0; i < n - 1; ++ i) {
        cin >> c[i];
    }
    ll ans = b[a[0]], prev = a[0];
    for (int i = 1; i < n; ++ i) {
        ans += b[a[i]];
        if (a[i] - prev == 1) ans += c[prev];
        prev = a[i];
    }
    cout << ans;
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

	private static final long MOD = 1000000009;
	private static final int MAX = 62;

	@Override
	public void run() {
		Scanner sc = new Scanner(System.in);
		for (int c = 1; sc.hasNext(); c++) {
			final int W = sc.nextInt();
			final long H = sc.nextLong();
			final int N = sc.nextInt();
			if (H == 0 && W == 0 && N == 0)
				return;

			NavigableMap<Long, List<Integer>> obs = new TreeMap<Long, List<Integer>>();
			for (int i = 0; i < N; i++) {
				final int x = sc.nextInt() - 1;
				final long y = sc.nextLong() - 1;
				if (!obs.containsKey(y))
					obs.put(y, new ArrayList<Integer>());
				obs.get(y).add(x);
			}
			if (!obs.containsKey(H - 1))
				obs.put(H - 1, new ArrayList<Integer>());
			final long[][][] ms = new long[MAX][W][W];
			for (int i = 0; i < W; i++)
				for (int j = 0; j < W; j++)
					ms[0][i][j] = Math.abs(i - j) <= 1 ? 1 : 0;
			for (int p = 1; p < MAX; p++)
				for (int i = 0; i < W; i++)
					for (int j = 0; j < W; j++)
						for (int k = 0; k < W; k++) {
							ms[p][i][j] += ms[p - 1][i][k] * ms[p - 1][k][j];
							ms[p][i][j] %= MOD;
						}
			long[] v = new long[W];
			v[0] = 1l;
			for (long y = 0; !obs.isEmpty();) {
				Map.Entry<Long, List<Integer>> e = obs.pollFirstEntry();
				final long p = e.getKey() - y;
				for (int b = 0; b < MAX; b++)
					if ((p & (1L << b)) > 0) {
						long[] u = new long[W];
						for (int i = 0; i < W; i++)
							for (int j = 0; j < W; j++) {
								u[i] += ms[b][i][j] * v[j];
								u[i] %= MOD;
							}
						v = u;
					}
				for (final int x : e.getValue())
					v[x] = 0l;
				y += p;
			}
			System.out.println("Case " + c + ": " + v[W - 1]);
		}
	}

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

Measured memory_bytes: 17000
n,m = map(int, input().split())

abcsl = []
for _ in range(m):
    a,b = map(int, input().split())
    cl = list(map(int, input().split()))
    abcsl.append((a,b,cl))

# dp = [ [10**9]*(2**n) for _ in range(m) ]
dp = [10**9]*(2**n)
dp[0] = 0
for a,b,cl in abcsl:
    b_bit = 0
    for c in cl:
        b_bit += 2**(c-1)
    for i in range(2**n):
        dp[i|b_bit] = min(dp[i]+a, dp[i|b_bit])

if dp[2**n-1] == 10**9:
    print(-1)
else:
    print(dp[2**n-1])

Measured memory_bytes: 75012