akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let k = sc.read();
    let q: usize = sc.read();
    let d: Vec<usize> = sc.vec(k);
    for _ in 0..q {
        let n: usize = sc.read::<usize>();
        let x: usize = sc.read();
        let m: usize = sc.read();
        let d: Vec<_> = d.iter().map(|&d| d % m).collect();
        let mut sum = vec![0; k + 1];
        let mut zero = vec![0; k + 1];
        for i in 0..k {
            sum[i + 1] = sum[i] + d[i];
            zero[i + 1] = zero[i] + if d[i] == 0 { 1 } else { 0 };
        }

        let first = x;
        let last = (n - 1) / k * sum[k] + sum[(n - 1) % k] + x;
        let t = last / m - first / m;
        let zero = (n - 1) / k * zero[k] + zero[(n - 1) % k];
        println!("{}", n - 1 - t - zero);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = ll(1e18)+5;

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll l = -1; ll r = N;
    ll ans =0;
    while(l<r){
        l++;
        --r;
        while(l<N && S[l] =='R'){
            l++;
        }
        while(r>=0 && S[r] == 'W'){
            --r;
        }
        ans++;
    }
    cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 3624
def main():
	a,b,c,d=map(int,input().split())
	mod=998244353
	dp=[[0 for _ in range(d)]for _ in range(c)]
	dp[a-1][b-1]=1
	for i in range(a-1,c):
		for j in range(b-1,d):
			if i!=a-1:
				dp[i][j]+=dp[i-1][j]*(j+1)%mod
			if j!=b-1:
				dp[i][j]+=dp[i][j-1]*(i+1)%mod
			if i!=a-1 and j!=b-1:
				dp[i][j]-=dp[i-1][j-1]*i*j%mod
			dp[i][j]%=mod
	print(dp[-1][-1])

if __name__ == '__main__':
	main()

Measured memory_bytes: 153100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    ll ans = 0;
    multiset<ll> mt;
    rep(i,0,N){
        auto iter = mt.lower_bound(A[i]);
        if(iter == mt.begin()){
            ans++;
            mt.insert(A[i]);
        }else{
            iter--;
            auto it_tmp = iter;
            mt.erase(iter);
            iter = it_tmp;
            mt.insert(A[i]);
        }
    }
    print(ans);

    
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
using namespace std;
int tree[100001],ans,N,K;
int main()
{
	cin >> N >> K;
	
	for(int i=0; i<N; i++)
	{
		cin >> tree[i];
	}
	
	sort(tree,tree+N);
	
	ans=tree[K-1]-tree[0];

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

Measured memory_bytes: 640
import sys
input=sys.stdin.readline

import collections

def main():
    A = input().strip()
    n = len(A)
    ans = 1 + n*(n-1)//2
    for k in collections.Counter(A).values():
        ans -= k*(k-1)//2
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3752
N, W = map(int, input().split())
max_val = N * 1000 + 1
dp = [[float("inf") for _ in range(max_val)] for _ in range(N+1)]
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int,input().split())

dp[0][0] = 0
ans = 0
for i in range(1, N+1):
    for sum_v in range(max_val):
        if sum_v - v[i-1] >= 0: 
            dp[i][sum_v] = min(dp[i-1][sum_v], dp[i-1][sum_v - v[i-1]] + w[i-1])
        else:
            dp[i][sum_v] = dp[i-1][sum_v]
    for val, weight in enumerate(dp[i]):
        if weight <= W:
            ans = max(ans, val)

print(ans)

Measured memory_bytes: 266044
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  int n, a, c = 0;
  cin >> n;
  rep(i,n)
  {
    cin >> a;
    if (i % 2 == 0 && a % 2 == 1) {
      c++;
    }
  }
  cout << c;
  return 0;
}


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

int main() {
    int n, k;
    vector<int> h(200100);
    long ans=0;

    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> h[i];

    sort(h.begin(), h.begin()+n);

    if(n-k <= 0){
        cout << 0 << endl;
        return 0;
    }

    for (int i = 0; i < n-k; i++) {
        ans += h[i];
    }

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

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
a.sort()
dup=0
uniq=1
last=a[0]
for i in range(1,len(a)):
    if a[i] == last:
        dup+=1
    else:
        uniq+=1
    last=a[i]

if dup%2==0:
    print(uniq)
else:
    print(uniq-1)

Measured memory_bytes: 14388
#include<stdio.h>
#include<string.h>
int main()
{
	char ss[10];
	int t,time=0,i;
	gets(ss);
	t=strlen(ss);
	for(i=0;i<t;i++)
	{
		if(ss[i]=='1')
		time++;
	}
	printf("%d",time);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;



int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    char c;
    cin>>c;
    if(c>='a')
        cout<<'a';
    else
        cout<<"A";

    return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
vl a;
vl accum;
ll getsum(int r,int l){//lからrまでの和
  if(l>0){
    return accum[r]-accum[l-1];
  }else{
    return accum[r];
  }
}
int searchborder(int r,int l){//二分探索で「左側の右端」のindexを求める
  if(l>r){
    cout<<"error"<<endl;
    return -1;
  }
  int tmpl=l;
  int tmpr=r;
  int mid=(l+r)/2;
  while(tmpl!=mid){
    //cout<<" l "<<l << " r "<<r<<" mid "<<mid<<endl;
    if(getsum(mid,l)<=getsum(r,mid+1)){
      tmpl=mid;
    }else{
      tmpr=mid;
    }
    mid=(tmpr+tmpl)/2;
  }
  return mid;
}
int main(void){
  int n;
  cin>>n;
  a=vl(n);
  rep(i,n){
    cin>>a[i];
  }
  accum = vl(n);
  accum[0]=a[0];
  rep(i,n-1){
    accum[i+1]=accum[i]+a[i+1];
  }
  ll ans=llMAX;
  for(int i=1;i<n-2;i++){//全体を二分したときの左側の右端がi
  //cout<<"r";
    int lborder=searchborder(i,0);//四分したときの一番左の区間の右端のindex
    int rborder=searchborder(n-1,i+1);//四分したときの右から3番目の区間の右端のindex
 
    vl nums;//4つの区間の和を入れる
 
    nums.pb(getsum(lborder,0));
    nums.pb(getsum(i,lborder+1));
    nums.pb(getsum(rborder,i+1));
    nums.pb(getsum(n-1,rborder+1));
    ll tmpmax=0;
    ll tmpmin=llMAX;
    for(auto j:nums){
      tmpmax=max(j,tmpmax);
      tmpmin=min(j,tmpmin);
    }
    ans=min(ans,tmpmax-tmpmin);
    nums.clear();
    //cout<<"e";
 
    //一つずらしたときの場合を考える
 
 
    if(lborder+1<i){
      nums.pb(getsum(lborder+1,0));
      nums.pb(getsum(i,lborder+2));
      nums.pb(getsum(rborder,i+1));
      nums.pb(getsum(n-1,rborder+1));
      tmpmax=0;
      tmpmin=llMAX;
      for(auto j:nums){
        tmpmax=max(j,tmpmax);
        tmpmin=min(j,tmpmin);
      }
      ans=min(ans,tmpmax-tmpmin);
      nums.clear();
    //cout<<"i";
    }
    if(rborder+1<n-1){
      nums.pb(getsum(rborder+1,i+1));
      nums.pb(getsum(n-1,rborder+2));
      nums.pb(getsum(lborder,0));
      nums.pb(getsum(i,lborder+1));
      tmpmax=0;
      tmpmin=llMAX;
      for(auto j:nums){
        tmpmax=max(j,tmpmax);
        tmpmin=min(j,tmpmin);
      }
      ans=min(ans,tmpmax-tmpmin);
      nums.clear();
    //cout<<"a";
    }
    if(rborder+1<n-1 && lborder+1<i){
      nums.pb(getsum(rborder+1,i+1));
      nums.pb(getsum(n-1,rborder+2));
      nums.pb(getsum(lborder+1,0));
      nums.pb(getsum(i,lborder+2));
      tmpmax=0;
      tmpmin=llMAX;
      for(auto j:nums){
        tmpmax=max(j,tmpmax);
        tmpmin=min(j,tmpmin);
      }
      ans=min(ans,tmpmax-tmpmin);
      nums.clear();
    //cout<<"s";
    }
    //cout<<"now "<<tmpmax-tmpmin<<" max "<<tmpmax<<" min "<<tmpmin<<endl;
    //ans=min(ans,tmpmax-tmpmin);
    //cout<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

void solve(){
    ll A, B, K;
    cin >> A >> B >> K;

    for (int i = 0; i < K; i++) {
        if (i % 2 == 0){
            if (A & 1) {
                A -= 1;
            }
            B += A/2;
            A /= 2;
        }else{
            if (B & 1) {
                B -= 1;
            }
            A += B/2;
            B /= 2;
        }
    }

    cout << A << " " << B << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vll a(3*n),front(3*n),rear(3*n);//front:前から数えてそこまでの中ででかいやつn個の和 rear:後から数えてでかいやつn個の和
    priority_queue<ll,vector<ll>,greater<ll>> pqf;
    ll sum=(ll)0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
        pqf.push(a[i]);
    }
    front[n-1]=sum;
    rep2(i,n,2*n){
        cin>>a[i];
        pqf.push(a[i]);
        sum+=a[i];
        sum-=pqf.top();pqf.pop();
        front[i]=sum;
    }
    sum=(ll)0;
    priority_queue<ll> pqr;
    rep2(i,2*n,3*n){
        cin>>a[i];
        sum+=a[i];
        pqr.push(a[i]);
    }
    rear[2*n]=sum;
    for(int i=2*n-1;i>n-1;i--){
        pqr.push(a[i]);
        sum+=a[i];
        sum-=pqr.top();pqr.pop();
        rear[i]=sum;
    }
    ll ans=-INF;
    rep2(i,n-1,2*n)ans=max(ans,front[i]-rear[i+1]);
    cout<<ans<<endl;
}

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

def zehnpaard():
    from itertools import product

    n = int(input())
    fs = [[int(x) for x in input().split()] for _ in range(n)]
    ps = [[int(x) for x in input().split()] for _ in range(n)]

    xs = product((0, 1), repeat=10)
    next(xs)
    print(max(sum(p[sum(a==b==1 for a, b in zip(f, x))] for f, p in zip(fs, ps)) for x in xs))

def solver():
    import itertools
    N = int(input())

    # implements
    Fs = [list(map(int, input().split())) for n in range(N)]
    Ps = [list(map(int, input().split())) for n in range(N)]

    # joisino姉がお店を開く全組み合わせ
    Xs = itertools.product([0,1], repeat=10)
    next(Xs) # すべて0を除く

    ans = (-10**7)*N
    for x in Xs:
        profit = 0
        for n in range(N):
            c = 0
            for a, b in zip(x, Fs[n]):
                if a==b==1:
                    c += 1
            profit += Ps[n][c]
        ans = max(ans, profit)
    print(ans)


if __name__ == "__main__":
    solver()


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int n,i,cnt;
	char s[100001];
	i=0;
	cnt=0;
	scanf("%d",&n);
	scanf("%s",s);
	while(i<=n){
		if(s[i]=='O'&&s[i+1]=='X'||s[i+1]=='O'&&s[i]=='X'){
			i=i+2;
			cnt++;
		}
		else i++;
	}
	printf("%d\n",cnt);
	return 0;
}


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

bool comp(int a, int b) {
  return (a + 9) % 10 > (b + 9) % 10;
}

int main() {
  vector<int> a(5);
  REP(i, 5)
    cin >> a.at(i);
  sort(a.begin(), a.end(), comp);
  
  int time = 0;
  REP(i, 4)
    time += (a.at(i) + 9) / 10 * 10;
  time += a.at(4);
  
  cout << time << endl;
  
  return 0;
}

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

struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
              return x>a.x;
    }

};

vector<int> v[1];
//bitset<4001000> b;
int a,c,i,b,n,m,k,d;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int o[332111];
int l[833331];
int j[855551];
int e;
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long x,y,mod=998244353,mod2=1000000009,mod3=2017;
long long z;
double pi=3.14159265;
P u[1];
stack<int> s;

//set<long long> s;
queue<int> q,q1;

//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//list<int> l;

string r,r1;
//char r[111331];
//deque<int> de;

bool as(P a,P b)
{
    
        return a.x<b.x;
    
}

long long f(int n,int m)
{
    long long x=0;
    for(;n<m;)
    {
        if(n%2) x+=j[n],n++;
        else if(m%2==0) x+=j[m],m--;
        else n/=2,m/=2;
    }
    return x+j[n];
}

int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;m=max(m,o[t]),t++)
        scanf("%d",&o[t]);
    n=1;
    for(i=1;i<200001;i*=2);
    for(;n<m;)
    {
        memset(l,0,sizeof(l));
        memset(j,0,sizeof(j));
        x=0;
        int h=(n+m)/2+1;
        l[0]=100001;
        j[100000+i]=1;
        for(int u=(100000+i)/2;u;u/=2)
            j[u]=j[u*2]+j[u*2+1];
        for(int t=1;t<=a;t++)
        {
            if(o[t]>=h) l[t]=l[t-1]+1;
            else l[t]=l[t-1]-1;

           
            x+=f(i,l[t]+i-1);
            j[l[t]+i-1]++;
            for(int u=(l[t]+i-1)/2;u;u/=2)
                j[u]=j[u*2]+j[u*2+1];

        }

        if(x>=(long long)a*(a+1)/2-((long long)a*(a+1))/4) n=h;
        else m=h-1;
    }
    printf("%d",n);
}



Measured memory_bytes: 7296
program MAIN
  implicit none
  character(len=6) :: input
  logical :: result
  read (*,*) input
  result = (input(3:3) == input(4:4)) .and. (input(5:5) == input(6:6))
  if (result) then
    print *, "Yes"
  else
    print *, "No"
  end if
end program MAIN

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

int main() {
  char a;
  cin >> a;
  if (a <= 90) cout << 'A' << endl;
  else cout << 'a' << endl;

  return 0;
}

/*
*/


Measured memory_bytes: 3628
while 1:
    try:
        i=float(raw_input())
        if i<=48.00:
            print "light fly"
        elif i<=51.00:
            print "fly"
        elif i<=54.00:
            print "bantam"
        elif i<=57.00:
            print "feather"
        elif i<=60.00:
            print "light"
        elif i<=64.00:
            print "light welter"
        elif i<=69.00:
            print "welter"
        elif i<=75.00:
            print "light middle"
        elif i<=81.00:
            print "middle"
        elif i<=91.00:
            print "light heavy"
        else:
            print "heavy"
    except:
        break

Measured memory_bytes: 6316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	ll n; cin >> n;
	vector<ll> hash(n);
	ll zero = 0;
	for(auto &x : hash){
		cin >> x;
		if(x==0)
			zero++;
	}
	if(zero > 0){
		cout<<"0\n";
		return;
	}
	ll res = 1;
	for(auto x : hash){
		if(x <= 1000000000000000000/res){
			res*=x;
		}
		else{
			cout<<"-1\n";
			return;
		}
	}
	cout<<res;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


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

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

#define fr first
#define sc second
#define rep(i,x) for(int i = 0 ; i < x ; i ++)

int TO_int(string s){
	int ret = 0;
	for(int i = 0 ; i < 5 ; i ++){
		ret *= 27;
		if(i < s.size())ret += s[i]-'a'+1;
	}
	return ret;
}
string TO_string(int x){
	string ret = "";
	while(x > 0){
		int t = x%27;
		if(t > 0)ret += 'a'+t-1;
		x /= 27;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}

int main(){
	string s;
	int k;
	cin >> s >> k;
	
	vector<int> vec;
	rep(i,s.size()){
		for(int j = 1 ; j <= k ; j ++){
			if(i+j > s.size())break;
			vec.push_back(TO_int(s.substr(i,j)));
		}
	}
	
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	cout << TO_string(vec[k-1]) << endl;
}



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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define qi queue<int>
#define si set<int>
#define inf LLONG_MAX


main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int x;
	cin>>x;
	if(x>=400&&x<600)
		cout<<8;
	else if(x>=600&&x<800)
		cout<<7;
	else if(x>=800&&x<1000)
		cout<<6;
	else if(x>=1000&&x<1200)
		cout<<5;
	else if(x>=1200&&x<1400)
		cout<<4;
	else if(x>=1400&&x<1600)
		cout<<3;
	else if(x>=1600&&x<1800)
		cout<<2;
	else
		cout<<1;
	return 0;
}


Measured memory_bytes: 3644
import java.math.BigInteger;
import java.util.Scanner;
import java.util.Vector;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();

		int K = scanner.nextInt();

//		int H = scanner.nextInt();

//		int[] scannerArray = new int[N];

		long ans = 0;

		int H = 0;

		for(int index = 0; index < N; index++) {
			H = scanner.nextInt();
			if (H >= K) {
				ans++;
			}
		}

		log(ans);

	}

	private static void dfs(int[] treeArray,int parrent, int children) {
		Vector<Vector> aa = new Vector<>();
		Vector<Integer> bb = new Vector<>();
		bb.add(1);
		aa.add(bb);
	}


	/**
	 * バブルソートの交換数を算出
	 * ※転倒数
	 * @param array
	 * @return
	 */
	private static long countSwapBabbleSort(int[] array, int N) {
		long ans = 0;
		int[] binary = new int[N + 1];

		for (int index = 0; index < array.length; index++) {
			ans = ans + (index - sum(binary, array[index]));
			add(binary, array[index], 1);
		}
		return ans;
	}

    //add value at idx on bit O(logN)
	private static void add(int[] bit,int idx,int value) {
        for(int i=idx;i<bit.length;i=i+(i&-i)) {
        	bit[i] += value;
        }
    }

    //return sum [1,idx] O(logN)
	private static long sum(int[] bit,int idx) {
        long ret = 0;
        for(int i=idx;i>0;i-=(i&-i)) {
        	ret += bit[i];
        }
        return ret;
    }

	private static void log(String str) {
		System.out.println(str);
	}

	private static void log(int str) {
		System.out.println(str);
	}

	private static void log(long str) {
		System.out.println(str);
	}

	private static void log(double str) {
		System.out.println(str);
	}

	private static void log(BigInteger str) {
		System.out.println(str);
	}

}



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

int main(){
  int n, k;
  std::cin >> n;
  std::vector<int> v(n);
  for (int i = 0; i < n; i++) {
    std::cin >> v.at(i);
  }
  int a = v.at(0);
  int count = 0;
  for (int i = 0; i < n; i++) {
    a = min(a, v.at(i));
    if (a == v.at(i)) {
      count++;
    }
  }
  std::cout << count << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;
 
//            < = = = = =    GCD     = = = = = >
 
ll gcd(ll a,ll b)
{
	if(a<b)	gcd(b,a);
	if(b==0)	return a;
	return gcd(b,a%b);
}
 
//            < = = = = =    LCM     = = = = = >
 
ll lcm(ll a,ll b) 
{ 
	ll x=(a/gcd(a,b))*b; 
	return x;
}
 
//            < = = = = =    power  x^n     = = = = = >
 
ll power(ll x , ll n , ll m=inf){
	if(x==0){
		return 0;
	}
	if(n==0){
		return 1;
	}
	ll ans;
	if(n%2==0){
		ll smallAns = power(x,n/2,m);
		ans = (smallAns*smallAns)%m;		
	} else {
		ll smallAns = power(x,n-1,m);
		ans = x;
		ans = (ans*smallAns)%m;
	}
	// for negative values also
	return (ans+m)%m;
	
}
 
//            < = = = = =    CHECK FOR PRIME     = = = = = >
 
bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
 
//            < = = = = =    SOLVE    = = = = = >
 
// bool cmp(pair<double,int> x, pair<double,int> y){
//     if(x.first==y.first){
//         return x.second<y.second;
//     }
//     return x.first>y.first;
// }

// void rec(int ){
//     if(){
        
//         return;
//     }

//     return;
// }
 
int solve() {fastio
    int n,m;
    cin>>n>>m;
    long long int h[n];
    for (long long int i = 0; i < n; i++) {
        /* code */
        cin>>h[i];
    }
    vector<int>v[n];
    for (int i = 0; i < m; i++) {
        int e,f;
        cin>>e>>f;
        v[e-1].push_back(f-1);
        v[f-1].push_back(e-1);
    }
    int ans = 0;
    f(i,0,n-1,1){
        if(v[i].size()==0){
            ans++;
        } else {
            bool vbn=0;
        for (auto e : v[i]) {
            if(h[e]>=h[i]){
                vbn=1;
                break;
            }
        }
        if(vbn==0){
        ans++;
        }
        }
    }
    cout<<ans;
    return 0;
}

//            < = = = = =    MAIN     = = = = = >
 
int main() {fastio
    
 	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    
    int t=1;
     // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 9576
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

ll powa(ll a, ll b, ll c)
{
    a%=c;
    if(a<0)
	a+=c;
    ll res = 1;
    while(b>0)
    {
        if(b&1)
            res*=a, res%=c;
        a*=a, a%=c;
        b>>=1;
    }
    return res;
}

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   
   string s;
   cin>>s;
   
   ll cnt = 0;
   rep(n)
        if(s[i] == '1')
            cnt++;
               
   ll ma[200005];
   memset(ma,0,sizeof(ma));
   if(cnt == 0)
   {
       rep(n)
            cout<<1<<"\n";
       return 0;
   }
   
   if(cnt == 1)
   {
       ll id = -1;
       rep(n)
       {   
           if(s[i] == '1')
                id = i;
       }
       
       rep(n)
       {
           if(i == id)
                cout<<0<<"\n";
           else
           {
               ll temp = powa(2,n-1-i,2) + powa(2,n-1-id,2);
               temp%=2;
               if(temp == 1)
                    cout<<2<<"\n";
               else cout<<1<<"\n";        
           }
       }
       return 0;
   }
   
   rep(n)
   {
       if(s[i] == '1'){
       ma[cnt-1]+=powa(2,n-1-i,cnt-1), ma[cnt-1]%=(cnt-1);
       ma[cnt]+=powa(2,n-1-i,cnt), ma[cnt]%=(cnt);
       ma[cnt+1]+=powa(2,n-1-i,cnt+1), ma[cnt+1]%=(cnt+1);
       }
   }
   
   //cout<<ma[12]<<" "<<ma[13]<<" "<<ma[14]<<"\n";
   
   rep(n)
   {
       ll now = cnt;
       if(s[i] == '1')
            now--;
       else now++;
      // cout<<"now = "<<now<<" ";
       ll sum = ma[now];
      // cout<<"sum = "<<sum<<" ";
       if(s[i] == '1')
           sum = (sum - powa(2,n-1-i,now) + now)%now;
       else 
           sum = (sum + powa(2,n-1-i,now) + now)%now;
       //cout<<sum<<" ";
       ll tot = 1;
       while(sum>0)
       {
           sum = (sum%bpc(sum));
           tot++;
       }
       cout<<tot<<"\n";
   }
   
   return 0;        
}  
  
          
   

Measured memory_bytes: 5328
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
int H,W;
cin >> H>>W;
vector<vector<char>> v(H);
vector<pair<int,int>> K;
for ( int i = 0 ; i < H ; i++ )
   v[i].resize(W);
   
   for(int i=0;i< H;i++)
      for(int j=0;j<W;j++){
                  char x;
                  cin >> x;
                  v[i][j]=x;
                  if(x=='#')
                    K.push_back(make_pair(i,j));
      }
      int count=0;
     int prevn=0;
     
      while(1){
          int n=K.size();
          int c=0;
            int OK=0;
          for(int l=prevn;l<n;l++){
              int i=K[l].first;
              int j=K[l].second;
            
              if(i>0)
                 if(v[i-1][j]=='.'){
                     v[i-1][j]='#';
                     K.push_back(make_pair(i-1,j));
                     c++;
                  //   cout << "Jos";
                 }
                     
            if(i<(H-1)) 
                 if(v[i+1][j]=='.'){
                    v[i+1][j]='#';
                    K.push_back(make_pair(i+1,j));
                    c++;
                  //  cout << "Sus";
                 }
               if(j>0)
                 if(v[i][j-1]=='.'){
                     v[i][j-1]='#';
                     K.push_back(make_pair(i,j-1));
                     c++;
                   //  cout << "Stanga";
                 }
                     
            if(j<(W-1)) 
                 if(v[i][j+1]=='.'){
                     v[i][j+1]='#';
                     K.push_back(make_pair(i,j+1));
                     c++;
                  //   cout <<  "Dreapta";
                     
                 }
               //  cout << endl;
                 if(c!=0)
                   OK=1;
                /*   cout << c << endl << endl;
                   for(int f=0;f<H;f++){
                        for(int g=0;g<W;g++)
                           cout << v[f][g];
                           cout << endl;
                   }
                   cout << endl << endl;*/
                 
          }
         // cout << "asddddddddd" << endl << endl << endl << endl << endl << endl;
          if(!OK)
             break;
          count++;
          prevn=n;
          
          
      }
      cout << count;
   
               
}


Measured memory_bytes: 11376
#include <iostream>
#include <string>
#include <vector>
//#include <math.h>
#include <algorithm>
#include <map>

using namespace std;

class Puzzle 
{
public:
	int D, G;
	vector<int> ps;
	vector<int> cs;
	vector<int> all_ps;
	vector<int> use;
	int min_point;

	void input()
	{
		cin >> D >> G;

		int p, c;
		for (int li = 0; li < D; li++) {
			cin >> p >> c;
			ps.push_back(p);
			cs.push_back(c);
			all_ps.push_back(p * 100*(li + 1) + c);
			use.push_back(0);
		}
		min_point = 999999;
	}

	void play()
	{
		int ans = try_code(0);
		printf("%d", ans);

	}

	int try_code(int pi)
	{
		//printf("pi=%d,use[0]=%d,use[1]=%d\n",pi,use[0],use[1]);
		int now_pt;
		if (calc_sc() >= G) {
			now_pt = calc_pt();
			if (now_pt < min_point) {
				min_point = now_pt;
				//printf("min_point = %d\n", min_point);
			}
			return min_point;
		}
		else if (pi >= D) {
			now_pt = calc_end();
			if (now_pt > 0) {
				if (now_pt < min_point) {
					min_point = now_pt;
					//printf("min_point = %d\n", min_point);
				}
			}
			return min_point;
		}
		else {
			try_code(pi + 1);

			use[pi] = 1;
			try_code(pi + 1);
			use[pi] = 0;
		}

		return min_point;
	}

	int calc_sc()
	{
		int sc = 0;
		for (int pi = 0; pi < D; pi++) {
			if (use[pi] == 1) {
				sc += all_ps[pi];
			}
		}

		return sc;
	}

	int calc_pt()
	{
		int pt = 0;
		for (int pi = 0; pi < D; pi++) {
			if (use[pi] == 1) {
				pt += ps[pi];
			}
		}

		return pt;
	}


	int calc_end() 
	{
		int remain = G - calc_sc();
		for (int pi = D - 1; pi >= 0; pi--) {
			if (use[pi] == 0) {
				int re_sc = ceil(remain,  100 * (pi + 1));
				if (re_sc < ps[pi]) {
					return re_sc + calc_pt();
				}
				else {
					return -1;
				}
			}
		}

		return -1;
	}

	int ceil(int a, int b)
	{
		if (a % b == 0) {
			return a / b;
		}else{
			return a / b + 1;
		}
	}

};


int main()
{

	Puzzle puz;

	puz.input();
	puz.play();

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

typedef struct UnionFindTree{
    vector<int> par, cnt;

    UnionFindTree(int n){
        par.resize(n, -1);
        cnt.resize(n, 0);
    }

    bool is_root(int x){
        return par[x]<0;
    }

    int find(int x){
        if(is_root(x)) return x;
        return par[x] = find(par[x]);
    }

    int size(int x){
        return -par[find(x)];
    }

    int get_cnt(int x){
        return cnt[find(x)];
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        cnt[x] += cnt[y];
        par[y] = x;
        return true;
    }

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

struct edge{
    int from, to, id;
    edge(int from, int to, int id): from(from), to(to), id(id){}
};

int n, m, X[MAX];
pii p[MAX];
vector<edge> G[MAX];
bool used[MAX];
vector<int> ans;

void dfs(int v, edge pe){
    used[v] = true;
    for(auto &e: G[v])if(!used[e.to]) dfs(e.to, e);
    if(X[v]){
        X[v] ^= 1;
        X[pe.from] ^= 1;
        ans.push_back(pe.id);
    }
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, n) scanf("%d%d", &p[i].fi, &p[i].se);
    p[n] = {mod, 0};
    sort(p, p+n+1);
    X[0] = p[0].se;
    For(i, 1, n+1) X[i] = p[i-1].se ^ p[i].se;
    UF uf(n+1);
    rep(i, n+1) uf.cnt[i] = X[i];

    rep(i, m){
        int L, R;
        scanf("%d%d", &L, &R);
        int l = lower_bound(p, p+n+1, make_pair(L, 0)) - p;
        int r = upper_bound(p, p+n+1, make_pair(R, 1)) - p;
        if(l == r) continue;
        uf.unite(l, r);
        G[l].emplace_back(l, r, i);
        G[r].emplace_back(r, l, i);
    }

    memset(used, false, sizeof(used));
    rep(i, n+1)if(uf.is_root(i)){
        if(uf.get_cnt(i) % 2 == 1){
            puts("-1");
            return 0;
        }
        dfs(i, {-1, i, -1});
    }

    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for(int i: ans) printf("%d ", i+1);
}

Measured memory_bytes: 16896
#include<stdio.h>

int main(void){
int x[3000],y[3000],i,k,ch;

 for(i=1;i<3000;i++){
 scanf("%d %d",&x[i],&y[i]);
  if(x[i]==0 && y[i]==0) break;
 }

 for(k=1;k<i;k++){
   if(x[k]>y[k]){
   ch=x[k];
   x[k]=y[k];
   y[k]=ch;
   }
 printf("%d %d\n",x[k],y[k]);
 }


return 0;
}

Measured memory_bytes: 1716
#!/usr/bin/env python3
# coding=utf-8

import sys

s = sys.stdin.readline().strip()
check = [_s is "1" for _s in list(s)]
index = 0
for i, (curr, next) in enumerate(zip(check[:len(s) // 2], check[1:len(s) // 2 + 1])):
    if curr != next:
        index = i + 1
check = check[::-1]
for i, (curr, next) in enumerate(zip(check[:len(s) // 2], check[1:len(s) // 2 + 1])):
    if curr != next:
        index = max(index, i + 1)
print(len(s) - index)

Measured memory_bytes: 4852
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int N = 1e1+5;

int n;
int g;
int mem[11][101][100001];
int s[N] , c[N];

int go(int idx , int bot , int has){
    if(has >= g)
        return 0;
    if(idx > n)
        return 1e8;
    if(mem[idx][bot][has] != -1)
        return mem[idx][bot][has];
    int best = go(idx + 1 , 0 , has);
    if(bot + 1 <= s[idx]){
        int must = idx;
        if(bot + 1 == s[idx]){
            must += c[idx];
        }
        best = min(best , 1 + go(idx , bot + 1 , has + must));
    }
    return mem[idx][bot][has] = best;
}

int main(){
    scanf("%d %d" , &n , &g);
    for(int i = 1; i <= n; i++){
        scanf("%d %d" , &s[i] , &c[i]);
        c[i] /= 100;
    }
    g /= 100;
    memset(mem , -1 , sizeof mem);
    printf("%d\n" , go(1 , 0 , 0));
    return 0;
}


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

int main(){
  ll x,k,d;
  cin >> x >> k >> d;
  x=abs(x);
  if(x/d>=k){
    cout << x-k*d << endl;
    return 0;
  }
  if((k-(x/d))%2 == 0) cout << x%d << endl;
  else cout << abs(d-x%d) << endl;
}

Measured memory_bytes: 3576
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

// 制約: 0 <= a <= 10^5
static int
digits_sum(int a)
{
  return (a / 100000
          + a / 10000 % 10
          + a / 1000 % 10
          + a / 100 % 10
          + a / 10 % 10
          + a % 10);
}

static int
solve(int N)
{
  int ret = N;
  // 後半は前半と同じ結果なので半分まで調べればよい。
  int half = N / 2;
  // 例2より、A = 0 の場合は除外。
  for (int A = 1; A <= half; A++)
  {
    int sum = digits_sum(A) + digits_sum(N - A);
    if (sum < ret)
    {
      ret = sum;
    }
  }
  return ret;
}

int
main()
{
  int N;
  cin >> N;
  cout << solve(N) << endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc129d()
}

fun abc129d() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val wall = (1..h).map { readLine()!!.map { it == '#' }.toBooleanArray() }

    // down,up,right,left
    val cSumD = Array(h) { IntArray(w) { 0 } }
    val cSumU = Array(h) { IntArray(w) { 0 } }
    val cSumR = Array(h) { IntArray(w) { 0 } }
    val cSumL = Array(h) { IntArray(w) { 0 } }

    for (x in 0 until w) {
        for (y in 0 until h) {
            cSumD[y][x] = if (wall[y][x]) 0 else if (y == 0) 1 else cSumD[y - 1][x] + 1
            cSumR[y][x] = if (wall[y][x]) 0 else if (x == 0) 1 else cSumR[y][x - 1] + 1
        }
    }
    for (x in w - 1 downTo 0) {
        for (y in h - 1 downTo 0) {
            cSumU[y][x] = if (wall[y][x]) 0 else if (y == h - 1) 1 else cSumU[y + 1][x] + 1
            cSumL[y][x] = if (wall[y][x]) 0 else if (x == w - 1) 1 else cSumL[y][x + 1] + 1
        }
    }

    val answer = (0 until h).map { y ->
        (0 until w).map { x -> cSumD[y][x] + cSumU[y][x] + cSumR[y][x] + cSumL[y][x] }.max()!!
    }.max()!! - 3

    println(answer)
}


Measured memory_bytes: 177200
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N,K;
  cin>>N>>K;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  for(int i=K;i<N;i++){
    if(A[i-K]<A[i]) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
  }

  return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	register int number_read=0,if_ok_read=1;
	char ch_read=getchar();
	while(ch_read<'0'||ch_read>'9')
	{
		if(ch_read=='-')
			if_ok_read=-1;
		ch_read=getchar();
	}
	while(ch_read>='0'&&ch_read<='9')
	{
		number_read=number_read*10+ch_read-'0';
		ch_read=getchar();
	}
	return number_read*if_ok_read;
}
inline void write(register int x_write)
{
    if(x_write<0)
	{
    	putchar('-');
		x_write=-x_write;
	}
    if(x_write>9)
		write(x_write/10);
    putchar(x_write%10+'0');
    return ;
}
inline void stO()
{
	printf("Yes\n");
	exit(0);
}
inline void Orz()
{
	printf("No\n");
	exit(0);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s;
	cin>>s;
	int len=s.length(),t;
	bool flag=false;
	for(int i=0;i<len;i++)
		if(s[i]=='C')
		{
			flag=true;
			t=i+1;
		}
	if(!flag)
		Orz();
	for(int i=t;i<len;i++)
		if(s[i]=='F')
			stO();
	Orz();
	putchar('\n');
	return 0;
}


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 x, y;
	cin >> x >> y;
	cout << x+y/2 << endl;
    return 0;
}

Measured memory_bytes: 256
def bar(a,b,c):
  x=(a+b+c)/3
  return x
while True:
  n=int(input())
  if n==0:
    break
  for i in range(n):
    m,e,j=map(int, input().split())
    y=(m+e)/2
    x =bar(m,e,j)
    if (m==100 or e==100 or j==100) or y>=90 or x>=80:
      print("A")
    elif x>=70:
      print("B")
    elif x>=50:
      if m>=80 or e>=80:
        print("B")
      else:
        print("C")
    else:
      print("C")


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



int main () {
    string s;
    int a,i,y,x,W,H,N,num=0;
    cin >> s;
    for (i=0;i<s.size()-1;i++)
        if (s[i]!=s[i+1]) num++;
    cout << num << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>

using namespace std;


int main(void) {

	string s, p,s2;
	int cnt = 0, j, k ;
	bool judge = false;
	cin >> s;
	cin >> p;
	s2 = s + s;

	for (int i = 0;i < s2.length();i++) {
		if (p[0] == s2[i]) {
			k = i + 1;
			j = 1;
			cnt++;

			while (1) {
				if (cnt == p.length()) {
					judge = true;
					break;
				}
				if (p[j] != s2[k])
					break;
				
				cnt++;
				j++;
				k++;
			}
	
		}		
		if (cnt == p.length()) {
			break;
		}
		cnt = 0;
	}

	if (judge)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

		return 0;
}

Measured memory_bytes: 3204
#include <iostream>

using namespace std;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int atual = 0;
    if(a<b){
        int temp=a;
        a=b;
        b=temp;
    }
    for(int i=b;i>0;i--){
        if(atual==k){
            cout << i << endl;
            break;
        }
        if(a%i==0 and b%i==0){
            atual++;
        }
        if(atual==k){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define endl "\n"
    #define fastio ios_base::sync_with_stdio(0);  cin.tie(0) ; cout.tie(0);
    #define debug(x) cout << #x << " : " << x << endl;
    #define pi 3.14159265359
    #define pb push_back
    #define eb emplace_back
    #define mp make_pair
    #define F first
    #define S second
    using ll = long long int;
    using db = double;
    typedef pair<ll,ll> pll;
    typedef pair<int,int> pii;
    typedef vector<ll> vl;
    typedef vector<int> vi;
    typedef vector<bool> vb;
    const int MOD = 1e9+9;

    void solve()
    {
        string s,t;
        cin>> s >> t;
        int s_sz = s.size() , t_sz = t.size() , ans = INT_MAX;
        for(int i = 0 ; i + t_sz <= s_sz ; i++)
        {
            // cout << "s[" << i << "] = " << s[i] <<endl;
            int s_pos = i , t_pos = 0 , diff = 0;
            while(s_pos < s_sz && t_pos < t_sz)
                if(s[s_pos++] != t[t_pos++])
                    diff++;
            ans = min(diff , ans);
        }
        cout << ans << endl;
    }

    int main()
    {
    //  #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin); 
    //     freopen("output.txt", "w", stdout);
    //  #endif
        fastio;

        ll t = 1;
        while(t--)
        solve();
        return 0;
    }

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}


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

#define F first
#define S second
#define pb push_back
#define ld  double
#define ll long long
#define int long long


using namespace std;

const int MAXN = 301 * 1001  , MOD = 1e9 + 7 , sq = 333  ;


string s[30] ;

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);
   int n, m ;
   cin >> n >> m ;
   for(int i = 0 ; i < n ; i ++ )
   {
       string s;
       for(int j = 0 ; j < m ; j ++ )
       {
           cin >> s ;
           if(s=="snuke")
        {
             cout<<(char)(j+'A')<<i+1;

        }
       }
   }


}


Measured memory_bytes: 256
// Submission #11550407

#include <bits/stdc++.h>
 
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
 
vector<ll> a;
void dfs(int len,ll x){
    if(len>10) return;
    a.pb(x);
    int a=x%10;
    if(a>0) dfs(len+1,x*10+a-1);
    dfs(len+1,x*10+a);
    if(a<9) dfs(len+1,x*10+a+1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int K;
    cin>>K;
    for1(i,9) dfs(1,i);
    sort(all(a));
    unique(all(a));
    cout<<a[K-1];
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N,C;cin >> N >> C;
    vector<LL> x(N);
    vector<LL> v(N);
    rep(i,N)cin >> x[i] >> v[i];

    vector<LL> a(N);
    vector<LL> b(N);
    vector<LL> DPa(N);
    vector<LL> DPb(N);
    vector<LL> rui(N);
    vector<LL> Rrui(N);
    rep(i,N){
        if(i == 0){
            rui[0] = v[i];
            Rrui[N-1] = v[N-1];
            continue;
        }
        rui[i] = rui[i-1] + v[i];
        Rrui[N-1-i] = Rrui[N-i] + v[N-1-i];
    }


    rep(i,N){
        a[i] = rui[i] - 2*x[i];
        b[i] = Rrui[i] - (C - x[i]);
        DPa[i] = a[i];
        DPb[i] = b[i];
    }
    for(int i = 1;i <= N-1;++i)chmax(DPa[i],DPa[i-1]);            // i番目までの時計回りのスコアの最大値
    for(int i = N-2;i >= 0;--i)chmax(DPb[i],DPb[i+1]);  // i番目以降の反時計回りのスコアの最大値

    LL ans_1 = 0;
    rep(i,N){
        if(i != N-1)chmax(ans_1,DPa[i] + DPb[i+1]);           // 時計と反時計のDP同士の和のmax
        else chmax(ans_1,DPa[i]);
    }
    rep(i,N)chmax(ans_1,rui[i]-x[i]);                     // 時計回りで片道だけ
    rep(i,N)chmax(ans_1,Rrui[i]-(C-x[i]));            // 反時計周りで片道だけ       これらはどっちか片っぽやっとけばいいぞ
    



///// ここから反時計


    vector<LL> c(N);
    vector<LL> d(N);
    vector<LL> DPc(N);
    vector<LL> DPd(N);
    rep(i,N){
        c[i] = rui[i] - x[i];
        d[i] = Rrui[i] - 2*(C - x[i]);
        DPc[i] = c[i];
        DPd[i] = d[i];
    }
    for(int i = 1;i <= N-1;++i)chmax(DPc[i],DPc[i-1]);
    for(int i = N-2;i >= 0;--i)chmax(DPd[i],DPd[i+1]);

    LL ans_2 = 0;
    rep(i,N){
        if(i != 0)chmax(ans_2,DPc[i-1] + DPd[i]);
        else chmax(ans_2,DPd[i]);
    }
    LL ans = max(ans_1,ans_2);
    cout << ans << endl;

}



Measured memory_bytes: 9600