akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::HashMap;

fn sieve_of_eratosthenes(n: usize) -> Vec<usize> {
    // spf:
    // store smallest prime factor of number
    // 最小の素因数を格納
    // is_prime:
    // 配列番号が素数であるかどうかを示す
    let mut spf = vec![None; n+1];
    let mut is_prime = vec![true; n+1];
    let mut primes = Vec::new();

    // 0 と 1 は素数ではない
    is_prime[0] = false;
    is_prime[1] = false;

    for i in 2..n+1 {
        // is_prime[i]:
        // それ以下の素数で割り切られていなければ True となる
        if is_prime[i] {

            // この if 文より i は素数なので
            primes.push(i);

            // 素数はそれ自身の最も小さい素因数であるから
            spf[i] = Some(i);
        }

        // 全ての prime の倍数(prime * i)を取り除く
        for prime in &primes {
            // prime が i の最も小さい因数よりも大きくなってしまったら探索終了
            if i * prime >= n + 1 || prime > &spf[i].unwrap() {
                break;
            }

            is_prime[i * prime] = false;

            // i * primes[j] の最も小さい素数は primes[j] 自身
            spf[i * prime] = Some(*prime);
        }
    }
    primes
}

// Prime Factorization using The Sieve of Eratosthenes
// エラストテネスの篩を用いた素因数分解
fn factorization_with_sieve_of_eratosthenes(mut n: usize) -> HashMap<usize, usize> {
    // primes:
    // ルートn までの素数
    // hm_primes:
    // ハッシュマップの素因数
    let mut primes = sieve_of_eratosthenes(f64::sqrt(n as f64) as usize);
    let mut hm_primes = HashMap::new();

    //  n を ルートn 以下の素数で割り切れるまで割っていく
    for prime in primes {
        while n % prime == 0 {
            n /= prime;
            if hm_primes.contains_key(&prime) {
                let mut x = hm_primes.get_mut(&prime).unwrap();
                *x += 1;
            } else {
                hm_primes.insert(prime, 1);
            }
        }
    }

    // 最後にnが素数になっている場合はそれ自身も素因数に含めて終了
    if n > 1 {
        if hm_primes.contains_key(&n) {
            let mut x = hm_primes.get_mut(&n).unwrap();
            *x += 1;
        } else {
            hm_primes.insert(n, 1);
        }
    }
    hm_primes
}

fn main() {
    let a = read::<usize>();
    let b = read::<usize>();


    println!("{:?}",factorization_with_sieve_of_eratosthenes(gcd(a, b)).len()+1);
}

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

Measured memory_bytes: 22780
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if(a+b < 2*c){
        cout << a*x+b*y << endl;
        return 0;
    }
    int ans = 0;
    ans += c*min(x,y)*2;
    if(a<2*c){
    ans += a*(x-min(x,y));
    }else{
        ans += 2*c*(x-min(x,y));
    }
    if(b<2*c){
    ans += b*(y-min(x,y));
    }else{
        ans += 2*c*(y-min(x,y));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>


using namespace std;

vector<pair<long, long>> prime_factorization(long n) {
    vector<pair<long, long>> res;

    for (long i = 2; i * i <= n; ++i) {
        if (n % i != 0) {
            continue;
        }

        long ex = 0;

        while (n % i == 0) {
            ex += 1;
            n = n / i;
        }

        res.emplace_back(i, ex);
    }

    if (n != 1) {
        res.emplace_back(n, 1);
    }

    return res;

}


int main() {

    long N;
    cin >> N;

    map<long, long> exp;

    for (long n = 1; n <= N; ++n) {
        vector<pair<long, long>> vs = prime_factorization(n);
        for (auto kv:vs) {
            exp[kv.first] += kv.second;
        }
    }
    long M = 1000000000 + 7;
    long result = 1;
    for (auto kv:exp) {
        result = (result * (kv.second + 1)) % M;
    }

    cout << result << endl;

    return 0;

}

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

int keta(int n){
    int re=0;
    while(n>0){
        re=re+n%10;
        n=n/10;
    }
    return re;
}

int main(){
    int a,b,n;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;i++){
        int t;
        t=keta(i);
        if(a<=t&&t<=b){ans+=i;}
    }
    cout<<ans<<endl;
    }


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("hard1.txt","r",stdin)
#define OUT freopen("hard1.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 1000005
#define FastIO  ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

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

#define maxn 200005
#define mod 998244353LL
#define lim 1000000000
#define INF 1000000000
#define Max(x,y,z) max(max(x,y),z)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int Right[2005] , Left[2005] ;

int f( string s1 , string s2 )
{
    int n = s2.size() ;

    for(int i=0 ; i<n ; i++)
    {
        for(int j=i , k=0 ; k<n ; k++, j = (j+1)%n )
        {
            if( s2[j]=='1' )
            {
                Right[i] = k ;
                break ;
            }
        }
        for(int j=i , k=0 ; k<n ; k++, j = (j+n-1)%n )
        {
            if( s2[j]=='1' )
            {
                Left[i] = k ;
                break ;
            }
        }
    }

    int ans = 2*n ;

    for(int l=0 ; l<n ; l++)
    {
        vector < pair<int,int> > vp ;
        int flip = 0 ;
        for(int i=0 ; i<n ; i++)
        {
            int j = (i+l)%n ;
            if( s1[i] != s2[j] ) flip++ ;
            if( s1[i]=='1' && s2[j]=='0' )
            {
                if(Right[i]<=l) continue ;
                vp.pb( mp(Right[j],Left[i]) ) ;
            }
        }
        if( vp.size()== 0 )
        {
            ans = min( ans , flip + l ) ;
            continue ;
        }
        sort( vp.begin() , vp.end() ) ;
        vector <pair<int,int> > temp = vp ;
        vp.clear() ;
        for(int i=0 ; i<temp.size() ; i++)
        {
            while( vp.size() > 0 && vp.back().yy <= temp[i].yy ) vp.pop_back() ;
            vp.pb(temp[i]) ;
        }
        ans = min( ans , flip + l + 2*min( vp[0].yy , vp.back().xx ) ) ;
        for(int i=1 ; i<vp.size() ; i++)
        {
            ans = min( ans , flip + l + 2*( vp[i-1].xx + vp[i].yy ) ) ;
        }
    }
    return ans ;
}


int main()
{
    int n ;
    string s1 , s2 ;
    cin>>s1 ;
    cin>>s2 ;

    n = s1.size() ;

    int fl1 = 0 , fl2 = 0 ;

    for(int i=0 ; i<n ; i++)
    {
        if( s1[i]=='1' ) fl1 = 1 ;
        if( s2[i]=='1' ) fl2 = 1 ;
    }

    if( fl2==0 )
    {
        if(fl1!=0) printf("-1\n") ;
        else printf("0\n") ;
        return 0 ;
    }

    int r1 = f(s1,s2) ;

    reverse( s1.begin() , s1.end() ) ;
    reverse( s2.begin() , s2.end() ) ;

    int r2 = f(s1,s2) ;

    printf("%d\n",min(r1,r2)) ;

    return 0 ;
}


Measured memory_bytes: 256
k,n = map(int, input().split())
A = list(map(int, input().split()))
ans = 10**6
for i in range(n-1):
  if ans > k - (A[i+1] - A[i]):
    ans = k - (A[i+1] - A[i])
if ans > A[-1] - A[0]:
  ans = A[-1] - A[0]
print(ans)

Measured memory_bytes: 32316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b;cin>>n;
  lvector A(n);rep(i,n) cin>>A[i];
  lvector B(A);sort(RALL(B));a=B[0],b=B[1];
  rep(i,n) {
    if(A[i]==a) print(b);
    else print(a);
  }
  return 0;
}

Measured memory_bytes: 4736
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b,c = readInts()
print(min(abs((a//2) * b*c - (a-a//2)*b*c), abs(a*(b//2)*c - a*(b-b//2)*c), abs(a*b*(c//2) - a*b*(c-c//2))))


Measured memory_bytes: 10352
//unti de gozaimasuwa
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h, w, a, b;
    cin >> h >> w >> b >> a;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int x = (i < a);
            int y = (j < b);
            cout << (x ^ y);
        }
        cout << endl;
    }
    return 0;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int md = (int)1e9+7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main(){
	int n;
	cin >>n;
	vector<ll> a(n);
	rep(i,n) cin >>a[i];
	
	VI sc(n);
	rep(i,n){
		ll w=a[i];
		while(w%2==0){ w/=2; sc[i]++;}
	}
	//for(auto x :sc) printf("%d, ",x); puts("");
	ll ans = accumulate(all(sc), 0LL);
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 384
using System;
 using System.Linq;

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
    int K=int.Parse(Console.ReadLine());    
    int X=int.Parse(Console.ReadLine()); 
	 int Y=int.Parse(Console.ReadLine());
      int ans=0;
      for(int i=0;i<N;i++){
        if(i<K){
          ans+=X;
        }else{
          ans+=Y;
        }
      }
      Console.WriteLine(ans);
    }
    
  }

}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
char s[100005];
int main() {
	scanf("%s",s);
	int len=strlen(s);
	int ans=len;
	for (int i=0;i<len-1;i++)
		if (s[i]+s[i+1]-96==1) ans=min(ans,max(i+1,len-i-1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    cout<<s.substr(0,3);
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
   int n;cin>>n;
   int a=n/1000;
   
    a=n-(a+1)*1000;
   a=abs(a);
   if(a==1000)a=0;
   cout<<a<<endl;
 }


Measured memory_bytes: 3628
#include "iostream"
#include "vector"
#include "queue"

using namespace std;
const int inf = (int)1e9;

int main() {
  int x, y, z, n, m, s, t;
  cin >> x >> y >> z >> n >> m >> s >> t;
  --s;
  --t;
  queue<int> vsando[x], vkatsu[y], vkare[z];
  vector<int> a(n + m), b(n + m);
  for (int i = 0; i < n; ++i) {
    //a->sando,b-katsu
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
    vsando[a[i]].push(i);
    vkatsu[b[i]].push(i);
  }
  for (int i = n; i < n + m; ++i) {
    //a-katsu,b->kare
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
    vkatsu[a[i]].push(i);
    vkare[b[i]].push(i);
  }
  queue<int> q;
  q.push(s);
  vector<int> d(n + m, inf);
  d[s] = 0;
  vector<bool> visited(n + m);
  visited[s] = true;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    if (p < n) {
      while (!vsando[a[p]].empty()) {
        int to = vsando[a[p]].front();
        vsando[a[p]].pop();
        if (visited[to]) continue;
        q.push(to);
        d[to] = d[p] + 1;
        visited[to] = true;
      }
      while (!vkatsu[b[p]].empty()) {
        int to = vkatsu[b[p]].front();
        vkatsu[b[p]].pop();
        if (visited[to]) continue;
        q.push(to);
        d[to] = d[p] + 1;
        visited[to] = true;
      }
    } else {
      while (!vkatsu[a[p]].empty()) {
        int to = vkatsu[a[p]].front();
        vkatsu[a[p]].pop();
        if (visited[to]) continue;
        q.push(to);
        d[to] = d[p] + 1;
        visited[to] = true;
      }
      while (!vkare[b[p]].empty()) {
        int to = vkare[b[p]].front();
        vkare[b[p]].pop();
        if (visited[to]) continue;
        q.push(to);
        d[to] = d[p] + 1;
        visited[to] = true;
      }
    }
  }
  cout << (d[n + t] == inf ? -1 : d[n + t]) << endl;
  return 0;
}


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

int main()
{
int n,k;
cin>>n>>k;
vector<int> v(n);
for(int i=0;i<n;i++)
cin>>v[i];
int dp[n];
dp[0]=0;
dp[1]=abs(v[1]-v[0]);
for(int i=2;i<n;i++)
{
    dp[i]=dp[i-1]+abs(v[i]-v[i-1]);
    for(int j=2;j<=k&&i-j>=0;j++)
    {
        dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
    }
}
//dp[i]=min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i]-v[i-1]));
cout<<dp[n-1]<<endl;
return 0;
}

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

using namespace std;

int main(){
	string s;
	cin>>s;
	int n=s.length();
	for(int i=0;i<n;i++){
		if(i%2){
			if(s[i]=='R'){
				printf("No\n");
				return 0;
			}
		}
		else{
			if(s[i]=='L'){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

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

const ll MAX = 2*100000;
const ll MOD = 1000000007;

ll power(ll a, ll n, ll m)
{
        ll ret = 1;
        for (; n > 0; n >>= 1, a = a * a % m)
        {
                if (n % 2 == 1)
                {
                        ret = ret * a % m;
                }
        }
        return ret;
}

ll COM(ll N, ll K) {
    ll X=1, Y=1;
    for (int i = 1; i <= K; i++){
        X = X*(N-i+1)%MOD; // *=にするとmodされた後に掛け算なのでダメ
        Y = Y*i%MOD;
    }
    ll Y_p = power(Y,MOD-2,MOD);
    // あまりのせいでYが大きくなるとX/Yがうまく計算されないため逆元を用いる
    // cout << X << " " << power(Y,MOD-2,MOD) << " " << Y_p << endl;
    return X*Y_p%MOD;
}

int main() {
  int N, a, b;
  cin >> N >> a >> b;

  ll ans = power(2, N, MOD) - 1;
  ll a_c = COM(N, a);
  ll b_c = COM(N, b);
  ans -= a_c%MOD;
  ans -= b_c%MOD;
  cout<<(ans%MOD+MOD)%MOD<<endl;

}


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

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


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

#define INF 10000000

int main() {
  int L, R;
  cin >> L >> R;
  if(R - L >= 2019) {
    cout << 0 << endl;
  } else {
    int ans = INF;
    for(int l=L; l<R; l++) {
      for(int r=l+1; r<=R; r++) {
        ans = min(ans, ((l%2019)*(r%2019))%2019);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 384
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	// A
	H1, M1 := getInt(), getInt()
	H2, M2 := getInt(), getInt()
	K := getInt()

	start := H1*60 + M1
	end := H2*60 + M2

	ans := end - start - K

	out(ans)
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  
  vector<int> p(N), m(N);
  map<int, int> pcount, mcount;
  rep(i, N){
    p[i] = a[i] + i+1;
    m[i] = -a[i] + i+1;
    if(pcount.count(p[i])) pcount[p[i]]++;
    else pcount[p[i]] = 1;
    if(mcount.count(m[i])) mcount[m[i]]++;
    else mcount[m[i]] = 1;
  }
  
  int64_t ans = 0;
  for(auto x: mcount) ans += (int64_t)x.second*pcount[x.first];
  
  cout << ans << endl;
  
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

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

string S;

int main() {
    cin >> S;
    int ans = INF;
    REP(i, S.length() - 2) {
        int t = stoi(S.substr(i, 3));
        ans = min(ans, abs(t - 753));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a = 0
b = 0
k = 0

for i in itertools.permutations(range(1,n+1)):
    k += 1
    if i == p:
        a = k
    if i == q:
        b = k
ans = abs(a-b)
print(ans)

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

int main(){
  string s;
  cin>>s;
  s='X'+s+'X';
  int n=s.size();
  ll ans=0;
  if(n<3){
    cout<<0<<endl;
    return 0;
  }
  for(int i=0;i<s.size()-2;i++){
    if(s[i]=='B'&&s[i+1]=='C'){
      s.insert(i+2,"D");
      s.erase(i,2);
    }
  }
  //cout<<s<<endl;
  int j,stop;
  ll vec[s.size()];
  vec[0]=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      vec[i]=vec[i-1]+1;
    }
    else{
      vec[i]=vec[i-1];
    }
  }
  for(int i=1;i<s.size();i++){
    if(s[i]=='B'||s[i]=='C'||s[i]=='X'){
      stop=i;
      continue;
    }
    if(s[i]=='D'){
      ans+=vec[i]-vec[stop];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define fint register int
using namespace std;
char s[500000];
int main()
{
	scanf("%s",s);
	int tot=0;
	for(fint i=0;i<strlen(s);i++)
	tot+=(s[i]-'0');
	std::cout<<(tot%9==0?"Yes":"No");
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n,k;
	cin >> n >> k;
	
	int a[n] , sum = 0;
	for(int i=0 ; i<n ; i++)
		cin >> a[i] , sum += a[i];
		
	sort(a,a+n,greater<int>());
	for(int i=0 ; i < min(n,k) ; i++)
		sum -= a[i];
	sum = max(sum, 0LL);
	cout << sum;	
	
}



Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f;

int n;
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
int main()
{
    scanf("%d",&n);
    ll number=1,now=1;
    for(int i=1;i<=n;i++){
    	ll t;
    	scanf("%lld",&t);
    	now=gcd(number,t);
    	number=number/now*t;
    }
    printf("%lld",number);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N, M;
  cin >> N >> M;
  vll A(M);
  ll b = 0;
  vll V(N + 1, 1);
  REP(i, 0, M) {
    cin >> A[i];
    V[A[i]] = 0;
    if (i > 0) {
      if (A[i] - b == 1) {
        cout << 0 << endl;
        return 0;
      }
    }
    b = A[i];
  }

  vll dp(N + 1, 0);
  dp[0] = 1;
  REP(i, 0, N) {
    REP(j, i + 1, min(N, i + 2) + 1) {
      if (V[j] == 1) {
        dp[j] += dp[i];
        dp[j] %= kMod;
      }
    }
  }
  cout << dp[N] << endl;

  return 0;
}


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

int main(){
	int temp;
	std::vector<int> pack; 

	for (int i = 0; i < 3; i++){
		std::cin >> temp;

		pack.push_back(temp);
	}

	std::sort(pack.begin(), pack.end()); //問よりsetは使えない(重なる場合がある)

	if (pack[0] + pack[1] == pack[2]){
		std::cout << "Yes" << std::endl;
	}
	else{
		std::cout << "No"<<std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

long long int N,A,B,C,D,E,T,S, ans=0;
cin >> N >> A >> B >> C >> D >> E;

T = min(B,A);
T = min(T,C);
T = min(T,D);
T = min(T,E);

if((N%T)==0){
  S = N/T;
}else{
  S = N/T + 1;
}
ans = S+4;
cout << ans << endl;
  return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    const i64 mod = 1'000'000'007;
    
    i64 N,M;
    cin >> N >> M;
    vector<i64> a(N);
    rep(i,0,M){
        cin >> a[i];
    }
    
    vector<i64> broken(N+1);
    rep(i,0,M){
        broken[a[i]]=true;
    }
    
    vector<i64> dp(N+1);
    dp[0]=1;
    rep(i,0,N){
        if(i+1<=N and !broken[i+1]){
            dp[i+1]+=dp[i];
            dp[i+1]%=mod;
        }
        if(i+1<=N and !broken[i+2]){
            dp[i+2]+=dp[i];
            dp[i+2]%=mod;
        }
    }
    
    cout << dp[N] << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int a, b, x;
    cin >> a >> b >> x;

    double PI = acos(-1);
    double h = (double)x / (a * a);

    double low = 0, high = 90;
    for (int i = 0; i < 100; ++i) {
        double mid = (low + high) / 2;

        double c = tan(mid * PI / 180) * a / 2;
        if (c < h) {
            if (h + c < b) low = mid;
            else high = mid;
        }
        else {
            double d = sqrt(2.0 * x / a * tan(mid * PI / 180));
            if (d < b) low = mid;
            else high = mid;
        }
    }

    write(low);
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
gcd = a[-1]
def Euclid(n1,n2):
    if n1 % n2 == 0:
        return n2
    return Euclid(n2,n1%n2)
for i in range(n-1):
    gcd = Euclid(gcd,a[(-1)*(i+2)])
print(gcd)


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

int main(){
	int n; cin >> n; int a[110];
	REP(i,0,n) cin >> a[i]; sort(a, a+n);
	
	int pos = 0, pot = 0;
	REP(i,0,n){
		if(i%2) pos += a[i];
		else pot += a[i];
	}
	
	cout << abs(pos - pot) << endl;
	return 0;
}


Measured memory_bytes: 256
h, w, n = map(int,input().split())
from collections import defaultdict
m3x3 =defaultdict(list)
for _ in range(n):
    a, b = map(int,input().split())
    for i in range(max(0, a - 3),min(h - 2, a)):
        for j in range(max(0, b - 3),min(w - 2, b)):
            if (i,j) in  m3x3:
                m3x3[(i,j)] +=1
            else:
                m3x3[(i,j)] =1
v = list(m3x3.values())
k = m3x3.keys()
print((w-2)*(h-2)-len(k))
for j in range(1,10):
    print(v.count(j))


Measured memory_bytes: 155020
from collections import deque

n, q = map(int, input().split(' '))
d = deque()
for _ in range(n):
    l = list(input().split(' '))
    l[1] = int(l[1])
    d.appendleft(l)

_q = q
s = 0
while len(d) > 0:
    e = d.pop()
    if e[1] - _q > 0:
        s += _q
        e[1] -= _q
        d.appendleft(e)
    else:
        s += e[1]
        print(e[0], s)
    _q = q



Measured memory_bytes: 14596
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int main(){
   string n;
   cin>>n;
   rep(i,n.size()) {
       if(n[i]=='7'){cout<<"Yes"<<endl;
       return 0;}
   }
   cout<<"No"<<endl;
}



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

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int top;
int s[1000010];
int c[1000010];
char z;

int F(char x){
	if(x=='J')return 0;
	if(x=='O')return 1;
	return 2;
}

int main(){
	cin>>z;
	c[0]=F(z),s[0]=1,top=1;
	while(cin>>z){
		if(c[top-1]==F(z))s[top-1]++;
		else{
			c[top]=F(z);
			s[top]=1;
			top++;
		}
	}
	int ans=0;
	for(int i=0;i<top-2;i++){
		if(c[i]==0&&c[i+1]==1&&c[i+2]==2){
			int m=min(s[i],min(s[i+1],s[i+2]));
			if(m==s[i+1])ans=max(ans,m);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

struct edge{int from,to,cost;};

int n,m,s;
vector<edge>v;
int d[100009];

void Bellman(){
	fill(d,d+100009,1e9);
	d[s]=0;
	for(int i=0;i<n;i++){
		int update=0;
		for(int j=0;j<m;j++){
			edge e=v[j];
			if(d[e.from]!=1e9&&d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				update=1;
				if(i==n-1){
					cout<<"NEGATIVE CYCLE"<<endl;
					return;
				}
			}
		}
		if(!update)break;
	}
	for(int i=0;i<n;i++){
		if(d[i]==1e9)cout<<"INF"<<endl;
		else cout<<d[i]<<endl;
	}
}
int main(){
	cin>>n>>m>>s;
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		v.push_back({a,b,c});
	}
	Bellman();
}


Measured memory_bytes: 3556
#include<iostream>

using namespace std;

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

long int abs1(long int x){
    if(x > 0) return x;
    else return -x;
}

int main(){
    long int mod = 1000000007;
    long int n, m;
    cin >> n >> m;
    long int ans = 1;
    if (abs1(n - m) >= 2){
        cout << 0 << endl;
        return 0;
    }else if(n == m){
        for (int i = 1; i <= n; i++){
            ans *= i;
            ans %= mod;
        }
        ans = ans * ans * 2;
        ans %= mod;
    }else{
        long int num1 = 1;
        long int num2 = 1;
        for (int i = 1; i <= n; i++){
            num1 *= i;
            num1 %= mod;
        }
        for (int i = 1; i <= m; i++){
            num2 *= i;
            num2 %= mod;
        }
        ans = num1 * num2;
        ans %= mod;    

    }
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  int n=0, w=0, s=0, e=0;
  rep(i,S.size()) {
      if(S.at(i)=='N') n++;
      else if(S.at(i)=='W') w++;
      else if(S.at(i)=='S') s++;
      else if(S.at(i)=='E') e++;
  }
  if(n==0&&s!=0) cout << "No" << endl;
  else if(n!=0&&s==0) cout << "No" << endl;
  else if(e!=0&&w==0) cout << "No" << endl;
  else if(e==0&&w!=0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
def substrings(str)
  output = []
  (0...str.length).each do |i|
    (i...str.length).each do |j|
      output << str[i..j]
    end
  end
  output
end

S = gets.chomp
K = gets.chomp.to_i

#puts substrings(S).uniq.sort[K-1]

alphabets = S.split('').uniq.sort
substrs = []

alphabets.each do |a|
  positions = (0..S.length).find_all {|i| S[i] == a }
  positions.each do |pos|
    substrs << S[pos,K]
  end
  break if substrs.size >= K
end

candidates = substrs.map {|substr|
  substrings(substr)
}.flatten.uniq.sort

puts candidates[K-1]


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

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

    int K, N; cin>>K>>N;
    int* A = new int[N];
    rep(i,N){
        int a; cin>>a;
        A[i]=a;
    }
    int ans = 0;
    rep(i,N-1){
        int dis = A[i+1]-A[i]; 
        ans = max(ans, dis);
    }
    ans = max(ans, A[0]+K-A[N-1]);
    cout << K-ans << endl;
}

Measured memory_bytes: 1024
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto n = readln.chomp.length;

  foreach(i; 0..n) write("x");
  writeln("");
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
inline i64 gcd(i64 a, i64 b) { if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x >= y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x <= y) return 0; x = y; return 1; }
template<class T> inline i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template<class T> inline i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

int main() {
  ioinit();
  char x, y;
  cin >> x >> y;
  if (x < y) cout << '<' << '\n';
  else if (x > y) cout << '>' << '\n';
  else cout << '=' << '\n';
  return 0;
}


Measured memory_bytes: 256
def main():
  # S = input()[-1:0:-1]
  S = input()[::-1]
  MOD = 2019

  # dp = [0]*(len(S)+1)
  # dp[0] = 0
  dic = [0]*2019
  dic[0] = 1

  ten = 1
  pre = 0
  for i, s in enumerate(S):
    # dp[i] = (dp[i-1] + ten*int(s)) % MOD
    pre = (pre + ten*int(s)) % MOD
    dic[pre] += 1
    ten *= 10
    ten %= MOD

  sum_ = 0
  # for sup in dp:
  #   dic[sup] += 1

  for v in dic:
    sum_ += v*(v-1)//2

  print(sum_)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 73864
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <queue>
using namespace std;
struct node
{
    int x,y;
    int bu;
};
int n,m;
char mp[55][55];
int vis[55][55];
int fx[4][2] = {1,0,0,1,-1,0,0,-1};
int bfs(int qx,int qy)
{
    memset(vis,0,sizeof(vis));
    vis[qx][qy] = 1;
    node kai,xia,xian;
    kai.x = qx;
    kai.y = qy;
    kai.bu = 1;
    queue<node>q;
    q.push(kai);
    while(!q.empty())
    {
        xian = q.front();
        q.pop();
        if(xian.x == (n-1)&&xian.y == (m-1))
            return xian.bu;
        for(int i=0; i<4; i++)
        {
            xia.x = xian.x + fx[i][0];
            xia.y = xian.y + fx[i][1];
            if(xia.x<0||xia.y<0||xia.x>=n||xia.y>=m||vis[xia.x][xia.y]||mp[xia.x][xia.y]=='#')
                continue;
            vis[xia.x][xia.y] = 1;
            xia.bu = xian.bu +1;
            q.push(xia);
        }
    }
    return -1;
}
int main()
{
    scanf("%d %d",&n,&m);
    int lz=0;
    for(int i=0; i<n; i++)
    {
        scanf("%s",mp[i]);
        for(int j=0; j<m; j++)
        {
            if(mp[i][j]=='.')
                lz++;
        }
    }
    int x = bfs(0,0);
    if(x==-1)
        puts("-1");
    else
    {
        printf("%d\n",lz-x);
    }

    return 0;
}

Measured memory_bytes: 256
while str = $stdin.gets
  sec = str.strip.to_i
  h = (sec / 3600).floor
#  puts "h = #{h}"
  sec -= h * 3600
  m = (sec / 60).floor
#  puts "m = #{m}"
  sec -= m * 60
#  puts "sec = #{sec}"

  puts "#{h}:#{m}:#{sec}"
end

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 1e6;	

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

int a[1000001];

bool isprime[1000001];
int prime[78500];

set<int> primeList;

void sieve(int n) {
	int i,j;
	isprime[0] = isprime[1] = false;
	for(i=2;i*i<=n;i++){
		if(isprime[i]){
			for(j=i*i;j<=n;j+=i){
				isprime[j] = false;
			}
		}
	}
}

bool allNewPrime(ll n) {
	ll pf_idx = 0, pf = prime[pf_idx];
	while(pf*pf <= n) {
		if(n % pf == 0){
			if(primeList.find(pf) != primeList.end()){
				return false;
			}
			primeList.insert(pf);
			while(n % pf == 0){
				n /= pf;
			}
		}
		pf = prime[++pf_idx];
	}

	if(n != 1){
		if(primeList.find(n) != primeList.end()){
			return false;
		}
		primeList.insert(n);
	}
	return true;
}

int main(){
	int n,i,j;
	memset(isprime, true, sizeof isprime);
	sieve(maxn);
	int cntPrime = 0;
	for(i=0;i<maxn;i++){
		if(isprime[i]){
			prime[cntPrime++] = i;
		}
	}
	
	scanf("%d",&n);
	int gcd1 = 0;
	bool isAllNew = true;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		isAllNew = isAllNew && allNewPrime(a[i]);
		gcd1 = gcd(gcd1, a[i]);
	}
	if(isAllNew){printf("pairwise coprime\n");}
	else{
		if(gcd1 == 1){printf("setwise coprime\n");}
		else{printf("not coprime\n");}
	}
	
	return 0;
};

Measured memory_bytes: 8940
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'

vector < int > preffix(vector < int > &a) {
	vector < int > pf(a.size(), 0);
	for(int i = 1; i < a.size(); i++) {
		int j = pf[i - 1];
		while(j > 0 && a[j] != a[i])
			j = pf[j - 1];
		if(a[j] == a[i])
			pf[i] = j + 1;
	}
	return pf;
}

vector < int > kmp(vector < int > &s, vector < int > &t) {
	vector < int > ans;
	auto pf = preffix(t);
	int j = 0;
	for(int i = 0; i < s.size(); i++) {
		while(j > 0 && s[i] != t[j])
			j = pf[j - 1];
		if(s[i] == t[j]) {
			j++;
			if(j == t.size()) {
				ans.push_back(i - j + 1);
				j = pf[j - 1];
			}
		}		
	}
	return ans;
}

int32_t main() {
	boost;
	int n;
	cin >> n;
	vector < int > a(n), b(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++) {
		cin >> b[i];
		a.push_back(a[i]);
	}
	vector < int > s, t;
	for(int i = 1; i < 2 * n - 1; i++)
		s.push_back(abs(a[i] ^ a[i - 1]));
	for(int i = 1; i < n; i++)
		t.push_back(abs(b[i] ^ b[i - 1]));
	auto ans = kmp(s, t);
	for(auto x : ans)
		cout << x << ' ' << (a[x] ^ b[0]) << endl;
} 

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

using namespace std;

int main() {
	long long n;
	cin >> n;
	vector<long long> arr(n);
	
	for(int i = 0; i < n; i++)
		cin >> arr[i];
		
	long long curr = arr[0];
	long long tot = 0;
		
	for (int i = 1; i < n; i++) {
		if (arr[i] < curr) {
			tot += (curr - arr[i]);
		}
		else
			curr = arr[i];
	}
	
	cout << tot << endl;
	
		
}

Measured memory_bytes: 4816
sx,sy,tx,ty=map(int,input().split());print("U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx)+"L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"+"R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U")

Measured memory_bytes: 3060
a,b = map(int,input().split())
l = list(map(int,input().split()))
t = l[0]
ans = max(0,t-b)
t = min(t,b)
for i in l[1:]:
    # print(ans,t)
    ans += max(0,(t+i)-b)
    t = max(0,i-max(0,(t+i)-b))
print(ans)

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


int main()
{
    //freopen("in.txt","r",stdin);
	string ss;
	int n;
	cin>>n;
	cin>>ss;
	int cnt=0;
	for(int i=0;i<n;i++)
    {
        cnt++;
        if(ss[i]==ss[i+1])
        {
            while(ss[i]==ss[i+1])
            {
                i++;
            }
            //i--;
        }
    }
    cout<<cnt;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;

int main() {
  int n;
  cin >> n; cin.ignore();
  
  while(n--) {
    string str;
    cin >> str;
    list<char> li;
    list<char>::iterator it;
    inserter( li, li.end() ) = str[0];
    for(int i=3; i<str.size(); i+=3) {
      if(find(li.begin(), li.end(), str[i]) != li.end())
	continue;
      it = find(li.begin(), li.end(), str[i-3]);
      if(str[i-1] == '>')
	inserter( li, ++it ) = str[i];
      else
	inserter( li, it ) = str[i];
    }
    
    for(it = li.begin(); it != li.end(); it++ ) {
      cout << *it;
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main{

    public static void main(String[] args){

        Scanner scan = new Scanner(System.in);
        String str = scan.next();

        if(str.charAt(0)==str.charAt(1) && str.charAt(1)==str.charAt(2)){
            System.out.println("No");
        }
        else System.out.println("Yes");
    }
}


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

int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int x = count(s.begin(), s.end(), 'A');
	int y = count(s.begin(), s.end(), 'B');
	cout << (x != 0 and y != 0 ? "Yes" : "No");
	return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int x;
    cin >> x;

    if (x < 1200) cout << "ABC";
    else cout << "ARC";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256