akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;


int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll N, P; cin >> N >> P;
	string S; cin >> S;
	
	vll cumsum (N+1);
	ll base = 1;
	R0F(i, N) {
		cumsum[i] = (cumsum[i+1] + (S[i] - '0') * base) % P;
		base = (base * 10) % P;
	}

	map<ll, int> occ;
	ll ans = 0;
	F0R(i, N) {
		if (P == 2) {
			if ((S[i] - '0') % P == 0) {
				ans += i+1;
			}
		} else if (P == 5) {
			if ((S[i] - '0') % P == 0) {
				ans += i+1;
			}
		} else {
			occ[cumsum[i]]++;
			ans += occ[cumsum[i+1]];
		}
	}
	print(ans);
}

Measured memory_bytes: 2580
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll;
#define in(n) ll n;cin>>n;
#define fo(m,n) for(int i=m;i< n;i++)
#define rfo(m,n) for(ll i =n;i>=m;i--)
#define out(n) cout<<n<<endl;
#define max(a,b) ((a>b)?a:b)

int main ()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t;cin>>t;ll d;cin>>d;
    d*=d;
    int cnt=0;
    while(t--)
    {
        ll x;ll y;cin>>x;cin>>y;
        x*=x;y*=y;x+=y;
        if(d>=x)
        cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

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

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {
	ll H, N;
	cin >> H >> N;
	ll sum = 0;
	for (int i = 0; i < N;++i) {
		ll a;
		cin >> a;
		sum += a;
	}
	string ans = H <= sum ? "Yes" : "No";
	cout << ans << endl;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define Si size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define Em empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define Fi first
#define Se second
#define Pi acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>

void FAST();
LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);







int mark[100010];

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n,q,l,r;
    string s;
    cin >> n >> q;
    cin >> s;
    for(i=1;i<n;i++)
    {
        if(s[i] == 'C'  &&  s[i-1] == 'A')
        {
            mark[i+1]=mark[i]+1;
        }
        else
        {
            mark[i+1]=mark[i];
        }
    }
    while(q--)
    {
        cin >> l >> r;
        cout << mark[r]-mark[l] << '\n';
    }
    return 0;
}







void FAST()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


Measured memory_bytes: 1488
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        a: usize1,
        b: usize1,
        c: usize1,
        d: usize1,
        s: chars,
    }
    let mut ans = true;
    for i in 0..n {
        if a < i && (i < c || i < d) {
            if s[i] == '#' && s[i+1] == '#' {
                ans = false;
            }
        }
    }
    if d < c {
        let mut between = false;
        for i in b..d+1 {
            if s[i-1] == '.' && s[i] == '.' && s[i+1] == '.' {
                between = true;
            } 
        }
        if !between {
            ans = false;
        }
    }
    println!("{}", if ans {"Yes"} else {"No"})
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
char a[105][105];
int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
//    freopen(".in","r",stdin);
//    freopen(".out","w",stdout);
    char ch;
    int i,j,n,m;
    cin>>n>>m;
    for(i=1; i<=m+2; i++)
        a[1][i]=a[n+2][i]='#';
    for(i=1; i<=n+1; i++)
        a[i][1]=a[i][m+2]='#';

    for(i=1; i<=n; i++)
    {
        for(j=1; j<=m; j++)
        {
            cin>>ch;
            a[i+1][j+1]=ch;
        }
    }
    for(i=1; i<=n+2; i++)
    {
        for(j=1; j<=m+2; j++)
        {

            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {};
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
constexpr int MOD = 1000000007;
using mint = ModInt<MOD>;

const int MAX = 2000100;
long long fac[MAX], finv[MAX], inv[MAX];
void init_comb() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long comb(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init_comb();
  int n, m;
  cin >> n >> m;
  mint ans = 0;
  rep(i, n+1) {
    mint res = mint(1)*comb(n, i)*comb(m, i)*fac[i];
    res *= mint(1)*comb(m-i, n-i)*fac[n-i]*comb(m-i, n-i)*fac[n-i];
    if (i%2)
      ans -= res;
    else
      ans += res;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 50440
def diff(X,Y):
    l=len(X) 
    c=0 
    for i in range(l):
        if X[i]!=Y[i]:
            c+=1 
    return c
s=input() 
t=input() 
i=0 
ans=len(s)
for _ in range(len(s)-len(t)+1):
    ans=min(ans,(diff(s[_:_+len(t)],t))) 
print(ans)

Measured memory_bytes: 9068
#include <stdio.h>

long long min(long long a, long long b){
  return a<b ? a:b;
}

int main(){
  long long a,b,n,m;
  scanf("%lld %lld %lld",&n,&a,&b);
  if(a+b == 0){
    printf("0\n");
    return 0;
  }
  m = n/(a+b);
  printf("%lld\n",m*a+min(n-m*(a+b),a));
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0)

#define ll long long

int main()
{
    IOS;
    string s1, s2, ans;
    cin>>s1>>s2;
    ll n1 = s1.size(), n2 = s2.size(), i, j;
    vector<vector<ll>> dp(n1+1, vector<ll>(n2+1));
    for(i=1;i<=n1;i++)
        for(j=1;j<=n2;j++)
            if(s1[i-1]==s2[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);

    i=n1;
    j=n2;
    while(i>0 and j>0)
    {
        if(s1[i-1]==s2[j-1])
        {
            ans.push_back(s1[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<"\n";
}


Measured memory_bytes: 70784
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)

def main():
    K = int(input())
    count = 0
    for i in range(1, K + 1):
        for j in range(1, K + 1):
            for k in range(1, K + 1):
                count += gcd(i, j, k)
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69384
#include<iostream>
using namespace std;
int main(){
    int S,h,m,s;
	cin>>S;
	h=S/3600;
		m=(S-h*3600)/60;
		s=S-h*3600-m*60;
		cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

int main()
{   
	ll n;
	cin >> n;
	if (n%2==0||n%5==0) cout << -1;
	else {
		int ans=1, a=7;
		while (1) {
			if (a%n==0) break;
			ans++;
			a=(a*10+7)%n;
		}
		cout << ans;
	}
}

Measured memory_bytes: 3624
A, B, M = [int(i) for i in input().split()]
ref = [int(i) for i in input().split()]
mic = [int(i) for i in input().split()]
cheap = min(ref) + min(mic)
for i in range(M):
  cp = [int(j) for j in input().split()]
  cheap = min([cheap, ref[cp[0]-1] + mic[cp[1]-1] - cp[2]])
print(cheap)

Measured memory_bytes: 18488
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
vector<p>v;
for(ll i=0;i<n;i++)
{
    ll a,b;
    cin>>a>>b;
    v.pb({a,b});
}
ll ans=n;
sort(v.begin(),v.end());
ll e=-1e10;
for(ll i=0;i<n;i++)
{
    ll x=v[i].fi;
    ll y=v[i].se;
    if(x-y>=e)
    {
        e=x+y;
    }else
    {
        if(e>=x+y)
        {
            ans--;
            e=x+y;
        }else
        {
            ans--;
        }
    }
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 2420
input = raw_input
n, k = map(int, input().split(" "))
ps = map(int, input().split(" "))

means = [(1+p)/2. for p in ps]

for i in range(n-k+1):
    if i == 0:
        cur = sum(means[i:i+k])
        out = cur
    else:
        cur = cur - means[i-1] + means[i+k-1]
        out = max(cur, out)

print(out)

Measured memory_bytes: 45768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; ll m; cin >> n >> m;
    vector<pair<int, ll>> pd(n); cin >> pd;

    SORT(pd);
    ll ans = 0;
    FOR(i, 0, n) {
        if (pd[n - 1 - i].second == 0)ans -= m - i - pd[n - 1 - i].first;
        else ans += m - i - pd[n - 1 - i].first;
    }


    ll cap = m - n;
    int r = 0, l = 0;
    FOR(i, 0, n) {
        if (pd[i].second == 0)++l;
        else ++r;
        if (l > r) {
            ans += cap * (l - r);
            l = r = 0;
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 4316
#include<stdio.h>
#include<algorithm>
using namespace std;
double dp[100001][15];
double rj[15];
double ans[100001];
int main(){
	dp[0][0]=1;
	rj[0]=1;
	for(int i=1;i<15;i++)rj[i]=rj[i-1]*0.5;
	double now=0;
	for(int i=0;i<100000;i++){
		for(int j=0;j<14;j++){
			now+=rj[j]*dp[i][j];
			dp[i+1][j+1]+=dp[i][j]*rj[j];
			dp[i+1][0]+=dp[i][j]*(1.0-rj[j]);
		}
		ans[i]=now;
	}
	int a;
	while(scanf("%d",&a),a){
		printf("%.12f\n",ans[a-1]);
	}
}


//1
//3/2
//17/8
//177/64
//3457/1024

Measured memory_bytes: 0
import Control.Arrow (second)
import Data.List
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B

solve :: V.Vector Int -> Int
solve = V.foldl1 gcd

main = do
  Just n <- fmap fst . B.readInt <$> B.getLine
  xs <- V.unfoldrN n (fmap (second B.tail) . B.readInt) <$> B.getLine
  print $ solve xs



Measured memory_bytes: 2940
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define forit(it, st) for(auto it : st)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void solve(){
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, sz(s) / 2){
		cnt += (s[i] != s[sz(s) - 1 - i]);
	}
	cout << cnt;

}
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,k=map(int,input().split())
dp=[0]*n
sdp=[0]*(n+1)
sdp[1]=1
dp[0]=1
mod=998244353
lr=[list(map(int,input().split())) for _ in range(k)]
for i in range(1,n):
    for j in range(k):
        l,r=lr[j]
        left=max(0,i-r)
        right=max(0,i-l+1)
        dp[i]+=(sdp[right]-sdp[left])
        dp[i]%=mod
    sdp[i+1]=(sdp[i]+dp[i])%mod
print(dp[-1])
        


Measured memory_bytes: 81920
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n, k; cin >> n >> k;
	n++;
	ll ans=0;
	for(ll i=k;i<=n;i++){
		ll p=(n-i)*i+1;
		ans+=p;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;

int main(){
    while(true){
        int a;
        string x;
        int b;
        cin >> a >> x >> b;
        if(x =="?")break;
        if(x == "+"){
            cout << a + b << endl;
        }else if(x == "-"){
            cout << a - b << endl;
        }else if(x == "*"){
            cout << a * b << endl;
        }else{
            cout << a / b << endl;
        }
    }

    


}


Measured memory_bytes: 3156
<?php 
fscanf(STDIN,"%d%d",$n,$T);
$t_l = explode(" ",trim(fgets(STDIN)));

$sum_t = 0;
for($i=0;$i<$n-1;$i++){
  $dis = $t_l[$i+1]-$t_l[$i];
  if($dis>=$T){
    $sum_t += $T;
  }else{
    $sum_t += $dis;
  }
}

echo ($sum_t+$T);

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

int main(){
  string S;
  cin>>S;
  map<char,int> A;
  for(char c:S)
    A[c]++;
  if(A.count('N')==A.count('S') && A.count('E')==A.count('W'))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> As(N);
  for(int i = 0; i< N; i++){
    cin >> As.at(i);
  }
  
  sort(As.begin(), As.end());
  
  cout << As.at(As.size() -1 ) - As.at(0) << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <atcoder/scc>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    scc_graph g(n);

    for (int i = 0; i < m; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        g.add_edge(u, v);
    }

    auto scc = g.scc();

    printf("%d\n", int(scc.size()));
    for (auto v : scc) {
        printf("%d", int(v.size()));
        for (int x : v) {
            printf(" %d", x);
        }
        printf("\n");
    }

    return 0;
}


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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  vector<vector<bool>> A_bingo(3, vector<bool>(3, false));
  for (int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cin >> A.at(i).at(j); 
  int N, b;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> b;
    for(int j = 0; j < 3; j++) {
      for(int k = 0; k < 3; k++) {
        if (A.at(j).at(k) == b) A_bingo.at(j).at(k) = true;
      }
    }
  }
  
  // 結果表示
  bool YN_Flag = false;
  for(int i = 0; i < 3; i++) {
    if (A_bingo.at(i).at(0) && A_bingo.at(i).at(1) && A_bingo.at(i).at(2)) {
      YN_Flag = true;
      break;
    }
  }
  for(int i = 0; i < 3; i++) {
    if (A_bingo.at(0).at(i) && A_bingo.at(1).at(i) && A_bingo.at(2).at(i)) {
      YN_Flag = true;
      break;
    }
  }
  if (A_bingo.at(0).at(0) && A_bingo.at(1).at(1) && A_bingo.at(2).at(2) ||
     A_bingo.at(2).at(0) && A_bingo.at(1).at(1) && A_bingo.at(0).at(2)) YN_Flag = true;
  YN_Flag ? cout << "Yes" << endl : cout << "No" << endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  for(i=0;i<n;i++){
    if(s[i]=='(')buf1++;
    else if(buf1>0)buf1--;
  }
  reverse(ALL(s));
  for(i=0;i<n;i++){
    if(s[i]==')')buf2++;
    else if(buf2>0)buf2--;
  }
  reverse(ALL(s));
  for(i=0;i<buf1;i++){
      s+=')';
    }

  for(i=0;i<buf2;i++){
    s='('+s;
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python

from sys import stdin

def warshallfloyd(d):
  n = len(d)
  for k in range(n):
    for i in range(n):
      for j in range(n):
        d[i][j] = min(d[i][j], d[i][k] + d[k][j])

def solve(c, A):
  warshallfloyd(c)
  cost = 0
  for i in range(len(A)):
    for j in range(len(A[i])):
      if A[i][j] >= 0:
        cost += c[A[i][j]][1]
  return cost

def readints():
  return map(int, stdin.readline().split())

H, W = readints()
c = []
for i in range(10):
  c.append(readints())
A = []
for i in range(H):
  A.append(readints())
print(solve(c, A))


Measured memory_bytes: 2948
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

// 1分で進む角度
// 1分 6度
// 60分 30度
// 180 = PI
// 360 = 2PI
typedef long double ld;
int main() {
  cout.precision(15); cout << fixed;
  ld a, b, h, m;
  in(a),in(b),in(h),in(m);
  ld alpha = (0.5 * (h*60+m) * M_PI) / 180;
  ld beta = (6.0 * m * M_PI) / 180;
  ld theta = alpha-beta;
  print(sqrt(a*a + b*b - 2 * a * b * cos(theta)));
  return 0;
}


Measured memory_bytes: 4064
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

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

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll h, w;
	cin >> h >> w;
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll kosuu = a[0];
	ll res = 1;
	rep(i, h) {
		if (i % 2 == 0) {
			rep(j, w) {
				ans[i][j] = res;
				kosuu--;
				if (kosuu == 0) {
					res++;
					kosuu = a[res - 1];
				}
			}
		}
		else {
			for (ll j = w - 1;j >= 0;--j) {
				ans[i][j] = res;
				kosuu--;
				if (kosuu == 0) {
					res++;
					kosuu = a[res - 1];
				}
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			cout << ans[i][j];
			if (j != w - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3680
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();

int n;
int a[100100];
int flag[100100] = {};

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

  solve();

  return 0;
}

void solve() {
  int cnt = 1;

  flag[0] = 1;

  int i = a[0]-1;

  while(flag[i]!=1) {
    if(i==1) {
      cout << cnt << endl;
      return;
    }
    flag[i] = 1;
    i = a[i] - 1;
    cnt += 1;
  }

  cout << -1 << endl;
}

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

int main()
{
    int n, i, j;
    cin >> n;
    pair<int, int> a[n];
    for(i=0; i<n; i++)
        cin >> a[i].second >> a[i].first;
    long long sum=0;
    int flag=0, flag2=0;
    sort(a, a+n);
    for(i=0; i<n; i++){
        if(a[i].second > a[i].first){
            flag2=1;
            break;
        }
    }
    for(i=0; i<n; i++){
    sum+=a[i].second;
        if(sum > a[i].first){
            flag = 1;
            break;
        }
    }
    if(flag == 1 || flag2 == 1)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


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

typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 2000 + 5;

ll dp[N][N];

ll fadd(ll a, ll b)
{
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

void init()
{
  dp[0][0] = 1;
  for (int i = 1; i < N; ++ i) {
    for (int j = 1; j <= i; ++ j) {
      dp[i][j] = fadd(dp[i - 1][j], dp[i - 1][j - 1]);
    }
  }
}

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

  init();
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; ++ i) {
    cout << (dp[n - k][i - 1] + dp[n - k][i] * 2 + dp[n - k][i + 1]) * dp[k][i] % MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 30208
S = input()
T = input()

Slen = len(S)
Tlen = len(T)
diff = Slen - Tlen

maxRes = 0

if diff == 0:
  for j in range(Tlen):
    if S[j] == T[j]:
      maxRes += 1
else: 
  for i in range(diff):
    res = 0
    for j in range(Tlen):
      if S[i + j] == T[j]:
        res += 1
    maxRes = max(maxRes, res)

ans = Tlen - maxRes

print(ans)

Measured memory_bytes: 73084
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>

int main(void) {
  int n, a, b;
  while (std::cin >> n >> a >> b) {
    std::cout << std::min(a, b) << " " << (a + b < n ? 0 : a + b - n) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, t; readV(n, t);
  int[] w, v; readC(n, w, v);

  auto dp = new long[][](n+1, t+1);
  foreach (ref dpi; dp) dpi[] = -1;
  dp[0][0] = 0;

  foreach (i; 0..n)
    foreach (j; 0..t+1) {
      dp[i+1][j] = dp[i][j];
      if (j >= w[i] && dp[i][j-w[i]] >= 0)
        dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
    }

  writeln(dp[$-1].reduce!max);
}


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

bool isPrime(int n) {
    bool is_prime = true;
    for (int i=2; i*i<=n; i++) {
        if (n%i==0) {
            is_prime = false;
            break;
        }
    }
    return is_prime;
}

int main() {
    bool Prime[100000] = {};
    for (int i=2; i<100000; i+=1) {
        if (isPrime(i)) Prime[i] = true;
    }

    bool Prime2017[100000] = {};
    for (int i=3; i<100000; i+=2) {
        if (Prime[i] && Prime[(i+1)/2]) Prime2017[i] = true;
    }

    int accum2017[100000] = {};
    for (int i=1; i<100000; i++) {
        accum2017[i] = Prime2017[i] + accum2017[i-1];
    }

    int Q;
    cin >> Q;

    int L[Q], R[Q];
    rep(i, Q) cin >> L[i] >> R[i];

    rep(i, Q) cout << accum2017[R[i]] - accum2017[L[i]-1] << endl;

    return 0;
}



Measured memory_bytes: 2048
from bisect import *

n = int(input())
l = sorted(list(map(int, input().split())))

cnt = 0

for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        lower = max(j+1, bisect_right(l, b-a))
        upper = bisect_left(l, a+b)
        cnt += max(0, upper-lower)

print(cnt)

Measured memory_bytes: 48220
#include <stdio.h>
int main()
{
    int n,c,d,e;
    scanf("%d",&n);
    c=n%10;
    d=(n%100)/10;
    e=n/100;
    if(c==7||d==7||e==7)
    {
        printf("Yes");
    }

    else{printf("No");}
    return 0;
}


Measured memory_bytes: 1696
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
N, K = map(int, input().split())
D = [int(x) for x in input().split()]
# S = input()

ans = 0
for l in range(N + 1):
    if l > K:
        break

    for r in range(N - l + 1):
        if l + r > K:
            break

        l_list = sorted(D[0 : l])
        r_list = sorted(D[N - r : N])

        for discard_l in range(K - (l + r) + 1):
            for discard_r in range(K - (l + r + discard_l) + 1):
                value = sum(l_list[discard_l:])
                value += sum(r_list[discard_r:])

                ans = max(ans, value)
        
print(ans)


Measured memory_bytes: 49372
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
typedef long long int ll;
int main()
{
    char ch;
    cin>>ch;
    if(ch>='a'&&ch<='z')
        cout<<"a"<<endl;
    else
        cout<<"A\n";
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <functional>

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;

char stage[53][53];
ll route[53][53] = {0};

pair<int, int> dirs[] = {
    {1, 0},
    {0, 1},
    {-1, 0},
    {0, -1},
};

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

    int count = 0;
    int H, W;
    cin>>H>>W;
    for (int h = 0; h <= H+1; h++) stage[h][0] = stage[h][W+1] = '#';
    for (int w = 0; w <= W+1; w++) stage[0][w] = stage[H+1][w] = '#';
    for (int h = 1; h <= H; h++) {
        string s;
        cin>>s;
        for (int w = 1; w <= W; w++) {
            stage[h][w] = s[w-1];
            if (s[w-1] == '.') count++;
        }
    }

    for (int h = 0; h <= H+1; h++) 
        for (int w = 0; w <= W+1; w++) route[h][w] = inf;

    ll ans = 0;
    queue<pair<pair<int, int>, ll>> q;
    route[H][W] = 1;
    for (auto dir : dirs) {
        if (stage[H+dir.first][W+dir.second] != '#') q.push(make_pair(make_pair(H+dir.first, W+dir.second), 2));
    }
    while (!q.empty()) {
        auto p = q.front();
        q.pop();
        for (auto dir : dirs) {
            if (stage[p.first.first+dir.first][p.first.second+dir.second] != '#'
                && p.second+1 < route[p.first.first+dir.first][p.first.second+dir.second]) {
                route[p.first.first+dir.first][p.first.second+dir.second] = p.second+1;

                q.push(make_pair(make_pair(p.first.first+dir.first, p.first.second+dir.second), p.second+1));
            }
        }
    }
    ans = (route[1][1] == inf) ? -1 : route[1][1];
    if (ans != -1) ans = count - ans;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
bool isprime(int m){
    if(m==2)
        return true;
     
    if(m<2 || m%2==0)
        return false;
     
    for(int i=3; i<=sqrt(m); i+=2){
        if(m%i==0)
            return false;
    }
     
    return true;
}
 
int main(){
    int n;
    cin >> n;
     
    int sum = 0;
     
    for(int i=0; i<n; i++){
        int m;
        cin >> m;
     
        if(isprime(m)) sum++;
    }
 
    cout << sum << endl;
 
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <queue>
#define F first
#define S second
#define PI pair<int, int>
using namespace std;

int n, d[100005];
PI t;
priority_queue<PI> qu;
void f(int p, int q) {
	if (d[p] == 0 || d[p] < q) {
		qu.push(PI(q, p));
		d[p] = q;
	}
}
int main()
{
	cin >> n;
	f(1, -1);
	while (!qu.empty()) {
		t = qu.top(); qu.pop();
		if (d[t.S] == t.F) {
			f((t.S * 10) % n, t.F);
			f((t.S + 1) % n, t.F - 1);
		}
	}
	cout << -d[0];
    return 0;
}

Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int numN = in.nextInt();
		int numM = in.nextInt();
		int numC = in.nextInt();

		int[] arrayB = new int[numM];
		
		for(int i = 0; i< numM; i++){
			arrayB[i] = in.nextInt();
		}
		

		int result = 0;
		int numForcheck = 0;
		for(int k = 0; k < numN ; k++ ){
			
			for(int j = 0; j< numM; j++){
				numForcheck += in.nextInt() * arrayB[j];
			}
			
			if(numForcheck + numC > 0){
				result ++;
			}
			numForcheck = 0;
		}
		System.out.println(result);
		
		in.close();
	}

}

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

int main(void){
   int N;
   cin>>N;
   vector<long long> A(N);
   for(int i=0;i<N;i++){
      cin>>A[i];
   }
   long long ans=1000;
   long long stock;
   for(int i=0;i<N-1;i++){
      if(A[i]<A[i+1]){
         stock=ans/A[i];
         ans+=(A[i+1]-A[i])*stock;
      }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

	 
int main()
{
	fastio;
	
	int n,a;
	cin>>n;
	int A[n+1];
	for(int i=0;i<=n;i++)
	A[i]=0;
	for(int i=2;i<=n;i++)
	{
		cin>>a;
		A[a]++;
	}
	for(int i=1;i<=n;i++)
	cout<<A[i]<<"\n";
	
	
	return 0;
	
	
}

Measured memory_bytes: 4440
import sys

#縦k、横kのマスに移動させて考える
n, k = map(int, sys.stdin.readline().strip().split())
x = []
y = []
mx = []
my = []
for _ in range(n):
    xx, yy, c = sys.stdin.readline().strip().split()
    xx = int(xx)
    yy = int(yy)
    if c == 'W':
        xx += k
    xx %= 2 * k
    yy %= 2 * k
    if xx >= k:
        if yy >= k:
            x.append(xx - k)
            y.append(yy - k)
        else:
            mx.append(xx - k)
            my.append(yy)
    else:
        if yy >= k:
            mx.append(xx)
            my.append(yy - k)
        else:
            x.append(xx)
            y.append(yy)

graph = [[0 for _ in range(k)] for __ in range(k)]

#累積和
#lx + lmx = n
lx = len(x)
graph[0][0] += lx
for i in range(lx):
    graph[x[i]][0] -= 1
    graph[0][y[i]] -= 1
    graph[x[i]][y[i]] += 2

lmx = len(mx)
graph[0][0] -= lmx
for i in range(lmx):
    graph[mx[i]][0] += 1
    graph[0][my[i]] += 1
    graph[mx[i]][my[i]] -= 2

for i in graph:
    for j in range(k-1):
        i[j+1] += i[j]

for i in range(k):
    for j in range(k-1):
        graph[j+1][i] += graph[j][i]

#最大値、最小値を取得
big = max([max(i) for i in graph]) + lmx
small = min([min(i) for i in graph]) - lx

if big + small >= 0:
    print(big)
else:
    print(-small)

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

int main(){
  int N;
  cin >> N;
  int X[N];
  int sum=0;
  int Xmin=100,Xmax=0;
  for(int i=0;i<N;i++){
    cin >> X[i];
    sum+=X[i];
    if(Xmin>X[i]){
      Xmin=X[i];
    }
    if(Xmax<X[i]){
      Xmax=X[i];
    }
  }
  int HP[Xmax-Xmin+1]={0};
  for(int i=Xmin;i<Xmax+1;i++){
    for(int j=0;j<N;j++){
      HP[i-Xmin]+=(abs(X[j]-i))*(abs(X[j]-i));
    }
  }
  int result=HP[0];
  for(int i=0;i<Xmax-Xmin+1;i++){
    //cout << HP[i] << endl;
    if(result>HP[i]){
      result=HP[i];
    }
  }
  cout << result;
  cout << endl;
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n;
  while (scanf("%d", &n) != EOF)
  {
    lli a[n], total = 0;
    for (int i = 0; i < n; i++)
    {
      scanf("%lld", &a[i]);
      total ^= a[i];
    }

    for (int i = 0; i < n; i++)
      printf("%lld%c", total ^ a[i], i < n - 1 ? ' ' : '\n');
  }
  return 0;
}

Measured memory_bytes: 5280
n, m = map(int, input().split())
a = list(map(int, input().split()))
c = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]  # マッチ棒の本数との変換
f = [0] + [-1] * 10000  # DP

# マッチ棒の本数分だけ回す
for i in range(n):
    # 入力の1番目(k)は不必要
    i += 1
    for x in a:
        # 数字が大きいほうが良いから全探索
        # ソートしても出来るけれど作るの面倒

        o = c[x]  # マッチ棒の本数に変換

        if i - o >= 0:  # マッチ棒の上限を超えないように判定
            # マッチ棒の本数分だけ減らして桁を繰り上げて足す
            f[i] = max(f[i], f[i - o] * 10 + x)

print(f[n])


Measured memory_bytes: 14388
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

def main():
    n, a, b, c, d = map(int, input().split())
    s = input()

    ans = 'Yes'
    if '##' in s[a - 1:c] or '##' in s[b - 1:d]:
        ans = 'No'

    if ans == 'Yes':
        if c < d:
            pass
        else:
            if '...' in s[b - 2:d + 1]:
                pass
            else:
                ans = 'No'

    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=0,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr; string str,ttr,ntr;

        priority_queue<long long>pq;

        scanf("%lld %lld",&n,&m);

        for(i=1;i<=n;i++)
        {
            scanf("%lld",&a);  pq.push(a);
        }

        while(1)
        {

            fr=pq.top(); pq.pop();
            fr=fr >> 1; pq.push(fr);

            x++; if(x==m)break;


        }

        while(!pq.empty())
        {
            fr=pq.top(); ans=ans+fr; pq.pop();
        }

        printf("%lld\n",ans);











    return 0;
}





Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int> vec){
  int64_t N = vec.size();
  for(int i=0; i<N-1; i++) cout << vec.at(i) << " ";
  cout << vec.at(N-1) << endl;
}

int main(){
  string S; cin >> S;
  string T; cin >> T;
  int N = S.size();
  int M = T.size();
  int ans = 0;
  for(int i=0; i<N; i++){
    if(S.at(i)!=T.at(i))ans++;
  }
  if(M==N+1){}
  else ans++;
  if(ans>0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

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

int main(){
	string S;
	cin >> S;
	int a[3] = {0,0,0};
	rep(i,S.size()){
		a[S[i]-'a']++;
	}
	sort(a,a+3);
	a[1] -= a[0];
	a[2] -= a[0];
	
	if(a[1]<=1 && a[2]<=1) cout << "YES" << endl;
	else cout << "NO" << endl;
return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
typedef long long ll;
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++)
	{
		if(s[i] == '1')
			s[i] = '9';
		else if(s[i] == '9')
			s[i] = '1';
	}
	cout << s << endl;
}

Measured memory_bytes: 256