akhauriyash/Code-Regression huggingface dataset:
//Two Colors Card Game
//連想配列クラスstd::mapを使ってみよう．
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<(x)<<endl
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){//階乗の計算
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}
ll gcd(ll a ,ll b){return b ? gcd(b,a%b) : a;}//最大公約数
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}//最小公倍数
int num_digit(ll a){//桁数を求める
    int num_dig = 0;
    while(a!=0){
        a /= 10;
        ++num_dig;
    }
    return num_dig;
}
vector<ll> digit(ll a){//桁の数字を求める
    vector<ll> dig(num_digit(a));
    for(int i=num_digit(a)-1; i>=0; --i){
        dig[i] = a%10;
        a /= 10; 
    }
    return dig;
}

int main(){
    int n,m;
    map<string,int> blue_card,red_card;
    //青いカードの読み込み
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        if(blue_card.count(s)) blue_card[s] += 1;
        else blue_card[s] = 1;
    }
    //赤いカードの読み込み
    cin >> m;
    rep(i,m){
        string s;
        cin >> s;
        if(red_card.count(s)) red_card[s] += 1;
        else red_card[s] = 1;
    }

    map<string, int> total;
    for(pair<string, int> p : blue_card){
        string k = p.first;
        int v = p.second;
        total[k] = v; 
    }
    for(pair<string, int> p : red_card){
        string k = p.first;
        int v = p.second;
        if(total.count(k)) total[k] -= v; 
        else total[k] = -v; 
    }
    int ans=0;
    for(auto p : total){
        int v=0;
        v = p.second;
        if(v>ans) ans = p.second;
    }
    cout(ans);
    return 0;
}

Measured memory_bytes: 256
main :: IO()
main = do
    [a,b] <- map read . words <$> getLine
    print $ getsolve a b
    
getsolve :: Int -> Int -> Int
getsolve a b
    | b == 1			= 0
    | b <= a			= 1
    | otherwise			= div (b - a) (a-1) + 1 + if mod (b-a) (a-1) == 0 then 0 else 1

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

using namespace std;
const int MAXN = 1e5 + 7;

int dp[2][MAXN], a[101], n;

int solve(bool on, int k) {
  int &ans = dp[on][k];
  if (~ans) return ans;
  ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > k) continue;
    ans = ans | (!solve(!on, k - a[i]));
    if (ans) break;
  }
  return ans;
}

int main() {
  memset(dp, -1, sizeof(dp));
  int k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (solve(0, k)) {
    cout << "First\n";
  } else {
    cout << "Second\n";
  }
  return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n;
    cin >> n;
    vector<int> t(n), a(n);

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

    ll ans = 1;
    if(n == 1 and t[0] != a[0]) ans = 0;
    
    for(int i = 1; i < n-1; i++) {
        if(t[i-1] != t[i] and a[i] != a[i+1] and t[i] != a[i]) ans = 0;
        if(t[i-1] == t[i] and a[i] != a[i+1] and t[i] < a[i])  ans = 0;
        if(t[i-1] != t[i] and a[i] == a[i+1] and t[i] > a[i])  ans = 0;
        if(t[i-1] == t[i] and a[i] == a[i+1]) ans = ans * min(a[i], t[i]) % SMOD;

    }

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



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    string str[500];
    int d[128][128];
    int INF=1<<29;
    fill(d[0],d[128],INF);
    for(int i=0;i<128;i++){
      d[i][i]=0;
    }
    bool f=false;
    for(int i=0;i<n;i++){
      cin>>str[i];
      for(int j=0;j<i;j++){
	int mm=min(str[i].size(),str[j].size());
	if(str[i].compare(0,mm,str[j],0,mm)==0){
	  f|=str[i].size()<str[j].size();
	}else{
	  auto x=mismatch(begin(str[i]),end(str[i]),begin(str[j]));
	  d[*x.first][*x.second]=-1;
	}
      }
    }
    for(int i=0;i<128;i++){
      for(int j=0;j<128;j++){
	for(int k=0;k<128;k++){
	  if(d[j][i]!=INF&&d[i][k]!=INF){
	    d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
	  }
	}
      }
    }
    for(int i=0;i<128;i++){
      f|=d[i][i]<0;
    }
    cout<<(f?"no":"yes")<<endl;
  }
}

	   

Measured memory_bytes: 1312
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, N) for(int i = 0; i < N; i++)

int main() {
    string s, t;
    map<char, char> maps, mapt;

    cin >> s;
    cin >> t;
    rep(i, s.size()) {
        if(maps.count(s[i]) == 0) maps[s[i]] = t[i];
        if(mapt.count(t[i]) == 0) mapt[t[i]] = s[i];
        if(maps[s[i]] != t[i] || mapt[t[i]] != s[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
import std.stdio, std.algorithm, std.conv, std.array, std.string;

int[500] CS;
int[500] SS;
int[500] FS;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (i; 0..N-1) {
        auto csf = readln.split.to!(int[]);
        CS[i] = csf[0];
        SS[i] = csf[1];
        FS[i] = csf[2];
    }

    foreach (s; 0..N-1) {
        int t = 0;
        foreach (i; s..N-1) {
            if (t <= SS[i]) {
                t = SS[i] + CS[i];
            } else {
                auto d = t % FS[i];
                t += (FS[i] - t % FS[i]) % FS[i] + CS[i];
            }
        }
        writeln(t);
    }
    writeln(0);
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n, d; cin >> n >> d;
  ll cnt = 0;
  REP(i, n) {
    ll x, y; cin >> x >> y;
    if(d * d >= x * x + y * y) cnt++;
  }
  cout << cnt << endl;
}








Measured memory_bytes: 3612
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

use std::collections::HashMap;

fn main() {
    input!{
      n: usize,
      k: usize,
      aa: [usize; n],
    }
    let mut map: HashMap<usize, usize> = HashMap::new();
    for i in 0..aa.len() {
        let e = map.entry(aa[i]).or_insert(0);
        *e += 1;
    }
    if map.keys().len() <= k {
        println!("{}", 0);
        return;
    }
    let mut values = map.iter().map(|(_, &v)| v).collect::<Vec<usize>>();
    values.sort();
    let mut ans = 0;
    let values = &values[0..values.len()-k];
    for i in 0..values.len() {
        ans += values[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 17172
/*Author--Vishwas Agrawal*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define pb push_back
#define test ll t; cin>>t; while(t--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define M 1000000007LL
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define inc(i,a,n) for (ll i=a;i<n;i++)
#define dec(i,a,n) for (ll i=n-1;i>=a;i--)
long long binpow(long long base, long long exp, int mod) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) % mod;
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}
long long mod(long long x){
return ((x%M+M)%M);
}

long long add(long long a, long long b){
return mod(mod(a)+mod(b));
}

long long mul(long long a, long long b){
return mod(mod(a)*mod(b));
}

int main()
{
   double d,s,t;
   cin>>d>>s>>t;
   if(d/s<=t)
   {cout<<"Yes";}
   else
   {
      
      cout<<"No";
   }
   
  
   return 0;
}

Measured memory_bytes: 3720
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <set>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')

    #define I_int ll
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
        return x * f ;
    }
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int

}
using namespace io ;

using namespace std ;

#define N 100010

int m = read(), n = read();
int a[N], f[N];

bool cmp(int a, int b) {
	return a > b;
}

int main() {
	for(int i = 1; i <= n; ++i) a[i] = read();
	sort(a + 1, a + n + 1);
	if(m >= n) return puts("0"), 0;
	int cnt = 0;
	for(int i = 2; i <= n; ++i) {
		f[++cnt] = a[i] - a[i - 1];
	}
	sort(f + 1, f + n + 1, cmp);
	ll ans = 0;
	for(int i = m; i <= n; ++i) ans += f[i];
	printf("%lld\n", ans);
} 

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 2000000000
#define INFTY (1<<30)

void maxHeapify(int);
void insert(int);
void increaseKey(int, int);
int heapExtractMax(void);

int H, A[MAX];

void maxHeapify(int i){
  int l, r, largest,keep;
  l = 2*i;
  r = 2*i+1;
  if( l <= H && A[l] > A[i] ) largest = l;
  else largest = i;
  if( r <= H && A[r] > A[largest] ) largest = r;
  if( largest != i){
    keep = A[i];
    A[i] = A[largest];
    A[largest] = keep;
    maxHeapify(largest);
  }
}

void insert(int key){
  H++;
  A[H] = -INFTY;
  increaseKey(H, key);
}

void increaseKey(int i, int key){
  int c;
  if(key < A[i]) return;
  A[i] = key;
  while (i > 1 && A[i/2] < A[i]) {
    c = A[i/2];
    A[i/2] = A[i];
    A[i] = c;
    i = i/2;
  }
}

int heapExtractMax(){
  int max;
  if( H < 1 ) return -INFTY;
  max = A[1];
  A[1] = A[H];
  H--;
  maxHeapify(1);
  return max;
}

int main(){
  int key;
  A[H] = -INFTY;
  char com[10];

  while(1){
    scanf("%s", com);
    if(com[0] == 'e' && com[1] == 'n' ) break;
    if(com[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }
    else{
      printf("%d\n", heapExtractMax());
    }
  }

  return 0;
}



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

using namespace std;

int main()
{
    const char groundtruth[] = "CODEFESTIVAL2016";

    string str;
    cin >> str;

    int count = 0;
    for (string::size_type i = 0; i < str.size(); ++i) {
        if (str[i] != groundtruth[i]) ++count;
    }

    cout << count << endl;
    return 0;
}

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

using namespace std;

class SegmentTree {
  public:
    SegmentTree(int size, int value):
        m_size(size),
        m_data(size * 2, value) {}

    void update(int position, int value) {
        for (position += m_size; position; position /= 2)
            m_data[position] = min(m_data[position], value);
    }

    int query(int from, int to) {
        int answer = numeric_limits<int>::max();
        for (from += m_size, to += m_size; from < to; from /= 2, to /= 2) {
            if (from & 1)
                answer = min(answer, m_data[from++]);
            if (to & 1)
                answer = min(answer, m_data[--to]);
        }
        return answer;
    }

  private:
    int m_size;
    vector<int> m_data;
};

int main() {
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> B(N + 1, 0);
    for (int i = 1; i <= N; ++i)
        cin >> B[i];

    vector<int> partial(N + 1, 0);
    for (int i = 1; i <= N; ++i)
        partial[i] = partial[i - 1] + B[i];

    int Q; cin >> Q;
    vector< vector<int> > rights(N + 1);
    for (int i = 0; i < Q; ++i) {
        int x, y; cin >> x >> y;
        rights[x].emplace_back(y);
    }

    SegmentTree S(N + 1, N);
    vector<int> dp(N + 1, N);
    dp[0] = 0;
    for (int i = 1; i <= N; ++i) {
        dp[i] = min(dp[i], dp[i - 1] + B[i]);
        S.update(i - 1, dp[i - 1] - (i - 1) + partial[i - 1]);
        // dp[i] = min(dp[j] + (i - j) - (partial[i] - partial[j]))
        //       = i - partial[i] + min(dp[j] - j + partial[j])
        for (auto &right : rights[i]) {
            int best = right - partial[right] + S.query(i - 1, right);
            dp[right] = min(dp[right], best);
            S.update(right, best - right + partial[right]);
        }
    }

    cout << dp[N] << "\n";
}


Measured memory_bytes: 12800
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: i64 = iterator.next().unwrap().parse().unwrap();
    let a: i64 = iterator.next().unwrap().parse().unwrap();
    let b: i64 = iterator.next().unwrap().parse().unwrap();

    let mut ans: i64 = pow(2, n);
    ans = (ans - 1) % MOD;
    ans = (ans - comb(n, a)) % MOD;
    ans = (ans - comb(n, b)) % MOD;
    if ans < 0 {
        ans += MOD;
    }

    return format!("{}", ans);
}

const MOD: i64 = 1000000007;

fn pow(n: i64, x: i64) -> i64 {
    if x == 0 {
        return 1;
    }

    return if x % 2 == 0 {
        let t = pow(n, x / 2);
        t * t % MOD
    } else {
        n * pow(n, x - 1) % MOD
    }
}

fn comb(n: i64, k: i64) -> i64 {
    let mut numerator: i64 = 1;
    let mut denominator: i64 = 1;
    for i in 0..k {
        numerator = numerator * (n - i) % MOD;
        denominator = denominator * (k - i) % MOD;
    }
    numerator * pow(denominator, MOD - 2) % MOD
}


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 
/*CODE START HERE*/
int main() {
  int n , a , b;
  cin >> n >> a >> b;
  int r=0;
  forn(i,n+1){
    int c=0;
      int t =i;
    forn ( j , 5){
      c += t%10;
      t/=10 ;
    }
    if ( c>=a && c<=b ){
      r+=i ;
    }
  }
  cout << r << endl;
}

Measured memory_bytes: 3656
package main

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

func main() {
	N := getStdinInt64()
	A := getStdinIntArr64()
	Apush := make([]int64, 0)

	var i int64 = 0
	var ans int64 = 0

	sort.Slice(A, func(i, j int) bool { return A[i] > A[j] })

	Apush = append(Apush, A[0])
	for i = 1; i < N; i++ {
		Apush = append(Apush, A[i])
		Apush = append(Apush, A[i])
	}
	for i = 0; i < N-1; i++ {
		ans += Apush[i]
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

char a[101][101];
int main()
{
	int n,m,i,j,t;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	   for(j=1;j<=m;j++)
	   cin>>a[i][j];
	for(i=1;i<=n;i++)
	   for(j=1;j<=m;j++)
	   {
	   	if(j==1&&i!=1)cout<<endl;
	   	t=0;
	   	if(a[i][j]=='#')cout<<'#';
	   	    else  if(a[i][j]=='.')
			   {
	   	    	if(a[i-1][j]=='#')t++;
	   	    	if(a[i-1][j-1]=='#')t++;
	   	    	if(a[i-1][j+1]=='#')t++;
	   	    	if(a[i][j-1]=='#')t++;
	   	    	if(a[i][j+1]=='#')t++;
	   	    	if(a[i+1][j]=='#')t++;
	   	    	if(a[i+1][j-1]=='#')t++;
	   	    	if(a[i+1][j+1]=='#')t++;
	   	    	cout<<t;
			   }
	   }
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())

l = [0] * (n-1)
for i in range(1, n):
    for j in range(i+1, n+1):
        s = min(j-i, abs(x-i)+abs(j-y)+1)
        l[s-1] += 1
for i in l:
    print(i)

Measured memory_bytes: 9216
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 100001
#define INF   1000000000
#define p     1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll a[MAX_N];
ll b[MAX_N];
ll **col;
vector<ll> G[MAX_N];
ll cmax;

bool dfs (ll v, ll vp, ll cp) {

  vector<ll> c_list;
  ll cn = 1;
  
  for(ll i = 0; i < G[v].size(); i++) {
    ll vn = G[v][i];
    if (vn != vp) {
      if(cn != cp) c_list.push_back(cn++);
      else {c_list.push_back(++cn); cn++;};
    }
  }

  ll ci = 0;
  for(ll i = 0; i < G[v].size(); i++) {
    ll vn = G[v][i];
    if (vn != vp) {
      if (col[min(v, vn)][max(v, vn)] == 0) {
	cmax = max(c_list[ci], cmax);
	col[min(v, vn)][max(v, vn)] = c_list[ci];
	dfs(vn, v, c_list[ci]);
	ci++;
      }
    }
  }
  return true;
}


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

    ll N;
    cin >> N;

    col = (ll **)malloc(sizeof(ll*) * MAX_N);
    for(ll i = 0; i < MAX_N; i++) {      
      col[i] = (ll *)malloc(sizeof(ll) * MAX_N);
    }
    
    for(ll i = 0; i < N-1; i++) {
      cin >> a[i] >> b[i];
      G[ a[i] ].push_back( b[i] );
      G[ b[i] ].push_back( a[i] );
    }

    cmax = 0;
    dfs( a[0], 0, 0);

    cout << cmax << endl;
    for(ll i = 0; i < N-1; i++) cout << col[a[i]][b[i]] << endl;
    
    return 0;
}
    




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

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);

            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int one =0;
            int two =0;
            int three =0;
            for(int i =0;i<N;i++){
                if(input[i] <=A){
                    one++;
                }else if(A< input[i] && input[i]<=B){
                    two++;
                }else if(B<input[i]){
                    three++;
                }
            }
            int[] array = {one,two,three};
            Console.WriteLine(
                array.Min()
            );
        }
    }
}


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

int main(){
	int i = 0, j = 0;
	for(i = 1; i < 10; i++){
		for(j = 1; j < 10; j++){
			cout << i << "x" << j << "=" << i*j << "\n";
		}
	}
	return 0;
}

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

int main() {
    int n, t, a, ans;
    cin >> n >> t >> a;
    vector<double> vec(n), tall(n);

    for(int i = 0; i < n; i++) {
        cin >> vec.at(i);
        vec.at(i) = t - vec.at(i) * 0.006;
        if(vec.at(i) > a) vec.at(i) -= a;
        else vec.at(i) = a - vec.at(i); 
        tall.at(i) = vec.at(i);
    }

    sort(tall.begin(), tall.end());

    for(int i = 0; i < n; i++) {
        if(tall.at(0) == vec.at(i)) ans = i+1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=0,i=0;while(n/10>0){i++;d++;}return d;}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 sc(n);
 map<ll,ll>map;
 ll b;
 rep(i,0,n){
  sc(b);map[b]++;
 }

 ll m;
 sc(m);
 if(n<m){
  pN;return 0;
 }

 rep(i,0,m){
  sc(b);
  if(map[b]==0){
   pN;return 0;
  }
  else map[b]--;
 }
 pY;
 return 0;}

Measured memory_bytes: 16080
#include<iostream>
#include<algorithm>
using namespace std;
int N;
int x[3];
int main(){
	cin >> N;
	while (N>0){
		for (int i = 0; i<3; i++){
			cin >> x[i];
		}
		sort(x, x + 3);
		if (x[2] *x[2] == (x[1] *x[1]) + (x[0] *x[0])){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
		N--;
	}
	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

main()
{
  int n;
  int a[100000];

  cin >> n;
  Rep(i, n) cin >> a[i];
  /*
  int sum = a[i];
  int cnt = 0;
  int now;
  if( a[i] > 0 ) now = 1;
  else now = -1;
  for(int i=1; i<n; i++) {
    sum += a[i];
    if( now == 1 ) {
      if( sum > 0 ) {
	cnt += sum + 1;
	sum = -1;
      }
    } else {
      cnt += -sum + 1;
      sum = 1;
    }
    }*/

  int sum = 0;
  int ans = 0;
  
  Rep(i, n) {
    sum += a[i];
    if( i % 2 == 0 ) { // -
      if( sum >= 0 ) {
	ans += sum + 1;
	sum = -1;
      }
    } else {
      if( sum <= 0 ) {
	ans += -sum + 1;
	sum = 1;
      }
    }
  }

  //cout << ans << endl;
  int tmp = ans;
  sum = 0;
  ans = 0;
  Rep(i, n) {
    sum += a[i];
    if( i % 2 == 1 ) { // -
      if( sum >= 0 ) {
	ans += sum + 1;
	sum = -1;
      }
    } else {
      if( sum <= 0 ) {
	ans += -sum + 1;
	sum = 1;
      }
    }
  }

  cout << min( ans, tmp ) << endl;

  
}


Measured memory_bytes: 1024
from fractions import gcd
from functools import reduce

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = set(A)

M = max(A)


def mgcd(x):
    return reduce(gcd, x)


if M < K:
    print("IMPOSSIBLE")
elif K in A:
    print("POSSIBLE")
else:
    G = mgcd(A)
    if K % G == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


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

typedef pair<char,int> P;

signed main(){
  int n;cin>>n;
  vector<P> v(n),w(n),x(n);
  for(int i=0;i<n;i++){
    char c;int a;cin>>c>>a;
    v[i]=P(c,a);
  }
  for(int i=0;i<n;i++)w[i]=x[i]=v[i];
  for(int i=0;i<n;i++)
    for(int j=n-1;j>=i+1;j--)
      if(v[j].second<v[j-1].second)
        swap(v[j],v[j-1]);
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(w[j].second<w[minj].second){
        minj=j;
      }
    }
    swap(w[i],w[minj]);
  }
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<v[i].first<<v[i].second;
  }
  cout<<endl;
  bool stable=1;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(x[i].second!=x[j].second)continue;
      bool f=0;
      for(int k=0;k<n;k++){
        if(v[k]==x[i])f=1;
        if(v[k]==x[j])if(!f)stable=0;
      }
    }
  }
  if(stable)cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<w[i].first<<w[i].second;
  }
  cout<<endl;
  stable=1;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(x[i].second!=x[j].second)continue;
      bool f=0;
      for(int k=0;k<n;k++){
        if(w[k]==x[i])f=1;
        if(w[k]==x[j])if(!f)stable=0;
      }
    }
  }
  if(stable)cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
}



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

N = int(input())
H = list(map(int, input().split()))

count = 0
maxCount = 0

i = 0
while i < N - 1:
    if H[i] >= H[i+1]:
        count = count + 1
    else:
        maxCount = max(maxCount, count)
        count = 0

    i = i + 1

maxCount = max(maxCount, count)
print(maxCount)


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


#define int long long

int a[100010];
int b[100010];

signed main(){
	int an, bn, m;
	cin >> an >> bn >> m;
	
	int amin = INT_MAX;
	int bmin = INT_MAX;
	for(int i = 0;i < an;i++){
		cin >> a[i];
		amin = min(amin, a[i]);
	}

	for(int i = 0;i < bn;i++){
		cin >> b[i];
		bmin = min(bmin, b[i]);
	}

	int ans = amin + bmin;

	for(int i = 0;i < m;i++){
		int x, y, c;
		cin >> x >> y >> c;
		x--; y--;
		ans = min(ans, a[x] + b[y] - c);
	}

	cout << ans << endl;

	return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;


void solve()
{
    string s; cin >> s;
    int count = 0;
    char last = s[0];
    FOR(i, 1, s.length())
    {
        if(s[i] != last)
        {
            count++;
            last = s[i];
        }
    }
    cout << count << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s; cin >> s;
    int n=s.size();
    int num[n+1][30];
    rep(i,n+1)rep(j,30)num[i][j]=0;
    
    rep(i,30)num[0][30]=0;
    rep(i,n){
        int x=s[i]-'a';
        rep(j,30){
            if(j==x)num[i+1][j]=num[i][j]+1;
            else num[i+1][j]=num[i][j];
        }
    }
    rep(j,30){
        vector<int> v(n+1);
        rep(i,n+1){
            v[i]=2*num[i][j]-i;
        }
        int pre=0,premin=0;
        for(int i=2;i<=n;i++){
            if(v[i]>premin){
                cout << pre+1 << " " << i << endl;
                return 0;
            }
            if(premin>v[i-1]){
                premin=v[i-1];
                pre=i-1;
            }
        }
        
    }
    cout << -1 << " " << -1 << endl;
}



Measured memory_bytes: 15936
#include<bits/stdc++.h>
    using namespace std;
     
    string n;
    int main(){
      cin >> n;
      if(n[3] == n[2] || n[2] == n[1] || n[1] == n[0]){
        cout << "Bad\n";
      }else cout << "Good\n";
    }


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

int main() {
  string S,T;
  cin >> S >> T;
  int N = S.size();
  bool flag = true;
  for(int i = 0 ; i < N ; i++){
  	if(S.at(i)!=T.at(i)){
    	flag = false;
    }
  }
  if(flag){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}


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

int main() { 
    int n;
    cin>>n;
    double d;
    cin>>d;
    int c=0;
    while(n--){
        double a,b;
        cin>>a>>b;
        double n = pow(a,2);
        n+=pow(b,2);
        n=sqrt(n);
       
        if(n<=d){
            c++;
        }
    }
    cout<<c;
    
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

void Main(){
    int h, w, k;
    cin >> h >> w >> k;
    VS cv(h);
    REP(i, h) cin >> cv[i];
    int n = h + w;
    int ans = 0;
    for (int bit = 0; bit < (1<<n); ++bit) {
        int count = 0;
        REP(i, h) {
            REP(j, w) {
                char s = cv[i][j];
                if(s == '#' && bit & (1 << i) && bit & (1 << (h + j))) {
                    count++;
                }
            }
        }
        if (count == k) ans++;
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

vector<ll> enum_div(ll n) {
  vector<ll> ret;
  for(ll i = 2; i*i <= n; i++) {
    if(n%i == 0) {
      ret.push_back(i);
      if(i*i != n) {
        ret.push_back(n/i);
      }
    }
  }
  ret.push_back(n);
  sort(ret.begin(), ret.end());
  return ret;
}

int main() {
  ll n;
  cin >> n;
  ll c = n;
  vll v = enum_div(c);
  ll ans = 0;
  rep(i,v.size()) {
    ll m = n;
    ll k = v[i];
    while(m%k==0) {
      m /= k;
    }
    if(m==1) {
      ans++;
      continue;
    }
    m %= k;
    if(m==1) {
      ans++;
      continue;
    }
  }
  if(n!=2) {
    ll a = n-1;
    vll v2 = enum_div(a);
    ll b = v2.size();
    ans += b;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var N string
	fmt.Scan(&N)

	if N[0] == N[1] {
		if N[1] == N[2] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		if N[1] == N[2] {
			if N[2] == N[3] {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
typedef long long ll;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

int atoz(){
    int frnt,bck,nibo,present,i;string s;
        frnt = abs(s[i]-present);
        bck = 26-frnt;
        nibo = min(frnt,bck);
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
int main()
{
    IOS;
    ll p,n,i;
    cin>>p>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    if(n==2){
        ll k = a[n-1]-a[0];
        ll l = a[0] + p-a[n-1];
        cout<<min(k,l)<<endl;
        return 0;
    }
    ll ans =INT_MAX;
    ll k = a[n-1]-a[0];ll l = a[0]+ p-a[1];ans = min(k,l);
    //cout<<ans<<endl;
    for(i=1;i<n;i++)
    {
        if(i==n-1){
            k = p-a[i];
            l = k+a[i-1]-a[0];
            ans = min(ans,l);
            cout<<ans<<endl;
            return 0;
        }
        //s=0;
        k = a[i] + p - a[i+1];
        ans = min(ans,k);
        //cout<<ans<<endl;
    }




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



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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    string S;
    cin >> S;


    // Y = 89, N = 13, Y + N=> 102
    // 102 - 90 = 12
    // 'A' = 65, 'Z' = 90
    int ascii_num;
    for (int i = 0; i < S.length(); i++)
    {
        ascii_num = (int)S.at(i);
        // Y = 89, N = 13, Y + N=> 102
        // 102 - 90 = 12
        // 'A' = 65, 'Z' = 90
        if (ascii_num + N > 90)
        {
            S.at(i) = ((ascii_num + N) - 'Z') + 'A' - 1;

        }
        else
        {
            S.at(i) += N;
        }
    }

    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,a):
    if (not 1 in a):return -1
    res = 0
    idx = 1
    for i in a:
        if i != idx:
            res += 1
        else:
            idx += 1
    return res
    
n = ii()
a = mi()
print(main(n,a))

Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n; i++)
#define all(v) (v).begin(), (v).end()
#define decimal fixed << setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int a, b;
    cin >> a >> b;
    if((a*b)%2 == 1) cout << "Odd" << endl;
    else cout << "Even" << endl;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>

#define INF 1010000000
#define rep(i,n) for(int i=0;i<int(n);i++)
#define sint(i) scanf("%d",&i)
#define sintt(i,j) scanf("%d%d",&i,&j)
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k)

using namespace std;

int main(){
	while(1){
		int xx,yy;
		sintt(xx,yy);
		if(xx==0)break;
		int n;
		sint(n);
		int masu[18][18];
		int ura[18][18];
		rep(i,18)rep(j,18)ura[i][j]=masu[i][j]=0;
		
		
		rep(k,n){
			int a,b;
			sintt(a,b);
			ura[a][b]=1;
		}
		
		masu[1][1]=1;
		rep(i,xx+1)rep(j,yy+1){
			if(ura[i+1][j+1]==1)continue;
			masu[i+1][j+1]+=masu[i][j+1]+masu[i+1][j];
		}
		
		printf("%d\n",masu[xx][yy]);
	}
}

Measured memory_bytes: 0
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
  s=0
  a=list(map(int,input().split()))
  for j in range(m):
    s+=a[j]*b[j]
  if s+c>0:
    ans+=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 998244353
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;
ll power(ll x, ll y) { 
    ll temp, f; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2)%mod; 
    if (y%2 == 0) 
        return (temp * temp) % mod; 
    else{   
        f = (x * temp) % mod;
        f = (f * temp) % mod;
        return f; 
    }
}  
ll gcdExtended(ll a, ll b, ll *x, ll *y) { 
    // Base Case 
    if (a == 0) { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; // To store results of recursive call 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll modInverse(ll a, ll m) { 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        assert(0);
    else{ 
         
        ll res = (x%m + m) % m; 
        return res; 
    } 
}
vector<ll> ways(3010);
int main(){
	IOS;
	ll n, s;
	cin >>  n >> s;
	ll a[n + 1];
	loop(i, 1, n + 1)
		cin >> a[i];

	ways[0] = power(2, n);
	//debug(ways);
	loop(i, 1, n + 1){
		vector<ll> new_ways(3010);
		new_ways = ways;
		loop(value, 0, 3010){
			if(value + a[i] <= 3000)
				new_ways[value + a[i]] = (new_ways[value + a[i]] + ways[value] * modInverse(2, mod)) % mod; 
		
		}

		//debug(new_ways);
		swap(new_ways, ways);
	}
	cout << ways[s] << endl;
}

Measured memory_bytes: 3696
def aaa(x,y):
    if (y <= a) or (x <=c) :
        print(0)
    elif a < y and y < x :
        print(y-a)
    elif a < c and c < x :
        print(x-c)
    else :
        print(x-a)

a,b,c,d = map(int,input().split())
if (d-c) < (b-a) :
    aaa(d,b)
else :
    aaa(b,d)

Measured memory_bytes: 3060
A,B,K=map(int,input().split(" "))
#print(A)
#print(B)
#print(C)
count=1
i=max(A,B)+1

while i>0:
  i=i-1
  if A%i==0 and B%i==0:
    count=count+1
    #print(i)
  if count>K:
    print(i)
    exit()

Measured memory_bytes: 3060