akhauriyash/Code-Regression huggingface dataset:
import numpy as np
import math

a, b, h, m = map( int, input().split() )
#print( a, b, h, m )

t = 60 * h + m

sa = ( 2.0e0 * np.pi ) / ( 12 * 60 )
sb = ( 2.0e0 * np.pi ) / 60


arad = sa * t
brad = sb * t
delab = brad - arad
prod  = int( delab / ( 2.0e0 * np.pi ) )
delab = delab - 2.0e0 * np.pi * prod
#print( arad, brad )
#print( prod, math.degrees( delab ) )

l2 = a*a + b*b - 2.0e0*a*b*np.cos( delab )
l  = np.sqrt( l2 )
print( l )


Measured memory_bytes: 27204
package FenwickTree;
sub new{
	return bless[(0)x$_[1]],$_[0];
}
sub add{
	my$self=shift;
	my($p,$x)=@_;
	$p++;
	while($p<=@{$self}){
		$self->[$p-1]+=$x;
		$p+=$p&-$p;
	}
}
sub sum{
	my$self=shift;
	return$self->prefixsum($_[1])-$self->prefixsum($_[0]);
}
sub prefixsum{
	my$self=shift;
	my$r=shift;
	my$s=0;
	while($r>0){
		$s+=$self->[$r-1];
		$r-=$r&-$r;
	}
	return$s;
}
package main;
my($N,$Q)=split$",<>;
my$fenwicktree=FenwickTree->new($N);
my@a=split$",<>;
for$i(0..$#a){
	$fenwicktree->add($i,$a[$i]);
}
for(1..$Q){
	my($t,$a,$b)=split$",<>;
	if($t==0){
		$fenwicktree->add($a,$b);
	}
	else{
		print$fenwicktree->sum($a,$b),$/;
	}
}


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

 
int main(void) { 
    int n;
    int x;
    vector<int> lst(n);
    cin>>n;

    for (int i=0;i<n;i++){
        cin>>x;
        if (x %2==0){
            lst.push_back(x);
        }
    }
    for (int j =0;j<lst.size();j++){
        if (lst.at(j) %3!=0 && lst.at(j) % 5!=0){
            cout<<"DENIED"<<endl;
            return 0;
        }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}


Measured memory_bytes: 35072
import math
N, P = map(int, input().split())
A = list(map(int, input().split()))

# 全探索(奇数か偶数に全てを分ける)
evenL = []
oddL = []
for i in range(N):
    if (A[i] % 2 == 0):
        evenL.append(A[i])
    else:
        oddL.append(A[i])

even = len(evenL)
odd = len(oddL)

# 2で割った袋の枚数のあまりが1になるような組み合わせを数える
sum_odd = 0
numL = []
for i in range(odd):
    if ((i + 1) % 2 == 1):
        numL.append(i + 1)

for i in numL:
    sum_odd += (math.factorial(odd) //
                math.factorial(odd - i) // math.factorial(i))
# 全体から奇数になるような選び方を引いたら偶数になる選び方になる

# 2で割ったあまりが偶数こになる
numevenL = []
sum_even = 0
for i in range(odd):
    if ((i + 1) % 2 == 0):
        numevenL.append(i + 1)

for i in numevenL:
    sum_even += ((math.factorial(odd) //
                  math.factorial(odd - i) // math.factorial(i)))

if (P % 2 == 1):
    print(2 ** N - ((sum_even + 1) * (2 ** even)))
else:
    print((sum_even + 1) * (2 ** even))


Measured memory_bytes: 9180
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000
long long gcd(long long x, long long y) {
	if (x >= y)swap(x, y);
	if (y%x == 0)return x;
	return gcd(y%x, x);
}

int main() {
	long long n;
	scanf("%lld", &n);
	n = gcd(n, 360);
	n = 360 / n;
	printf("%lld\n", n);

	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int m, n;
    cin >> m >> n;
    if(n == 1) cout << 0 << endl;
    else cout << m - n  <<  endl;
    
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int K, T; cin >> K >> T;
    vec a(T);
    int sum = 0;
    int ma = 0;
    rep(i, T){
        cin >> a[i];
        sum += a[i];
        ma = max(ma, a[i]);
    }
    if(ma <= sum-ma-1){
        cout << 0 << endl;
    }else{
        cout << ma-(sum-ma)-1 << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

char s[32];int n;
bool h[32];

int main(){
	scanf("%s",s);n=strlen(s);
	for(int i=0;s[i];++i)h[s[i]-'a']=true;
	if(n<26){
		int k=0;
		while(h[k])k++;
		s[n++]='a'+k;
		puts(s);
	}
	else {
		if(string(s)=="zyxwvutsrqponmlkjihgfedcba")puts("-1");
		else {
			int k=n-1;
			while(1){
				int w=-1;
				fore(i,s[k]+1,'z'+1)if(!h[i-'a']){w=i;break;}
				if(w>=0){
					s[k]=w;
					s[k+1]=0;
					break;
				}
				h[s[k]-'a']=false;
				k--;
			}
			//next_permutation(s,s+n);
			//string ss(s);
			puts(s);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pi pair <ll,ll>
#define vi vector <ll>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define SQ(a) (a)*(a)
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>       //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll i,j,k,n,m,t,l=0,x,prev=0,max1=0,flag=0,cnt=0,y,min1,q;
    cin>>n>>m;
    ll h[n+1];
    ll ans[n+1]={0};
    ll deg[n+1]={0};
    for(i=1;i<=n;i++){
        cin>>h[i];
    }
    while(m--){
        cin>>i>>j;
        deg[i]++;
        deg[j]++;
        if(h[j]>h[i]){
            ans[j]++;
        }
        else if(h[i]>h[j]){
            ans[i]++;
        }
    }
    for(i=1;i<=n;i++){
        if(ans[i]==deg[i]){
            cnt++;
        }
    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 6000
#include<bits/stdc++.h>
#define ll long long
#define mod 838627288460106
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast_io
    ll n,a,b,i,j,sum=0,tmp;
    cin>>n>>a>>b;
   for(i=1;i<=n;i++)
   {
       ll x=0;
       tmp=i;
       while(tmp>0)
       {
            x+=tmp%10;
           tmp/=10;
       }
       if(x>=a&&x<=b)
        sum+=i;

   }
   cout<<sum<<endl;

    return 0;
}





Measured memory_bytes: 3584
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int[] a = new int[M];
    for (int i = 0; i < M; i++) a[i] = scanner.nextInt();

    int[] cost = new int[]{0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    int min = 8;
    for (int i = 0; i < M; i++) min = Math.min(min, cost[a[i]]);

    int K = N / min + 1;
    boolean[][] dp = new boolean[K + 1][N + 1];
    int[][] digits = new int[K + 1][N + 1];
    dp[0][0] = true;
    for (int i = 1; i <= K; i++) {
      for (int j = 0; j <= N; j++) {
        for (int k = 0; k < M; k++) {
          if (dp[i - 1][j] && j + cost[a[k]] <= N) {
            dp[i][j + cost[a[k]]] = true;
            digits[i][j + cost[a[k]]] = Math.max(digits[i][j + cost[a[k]]], a[k]);
          }
        }
      }
    }
    int KM = 0;
    for (int i = K; i >= 0; i--) {
      if (dp[i][N]) {
        KM = i;
        break;
      }
    }
    List<Integer> list = new ArrayList<>();
    while (KM > 0) {
      int d = digits[KM][N];
      list.add(d);
      KM--;
      N -= cost[d];
    }
    Collections.sort(list);
    StringBuilder sb = new StringBuilder();
    for (int i = list.size() - 1; i >= 0; i--) sb.append(list.get(i));
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 298448
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int h,w,n;
	cin>>h>>w>>n;
	int ma = max( h, w );
	int ans = n / ma;
	if( n % ma != 0 ) ans++;
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  char C; cin >> C;
  string s = "abcdefghijklmnopqrstuvwxyz";

  bool suc = false;
  for (int i = 0; i < s.length(); i++) {
    if (suc) {
      cout << s[i] << endl;
      break;
    } else if (s[i] == C) {
      suc = true;
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
 using namespace std;
 int main()
{
	int n;
	scanf("%d",&n);
	if(n<10)printf("%d",n);
	else if(n>=10&&n<100)printf("%d",9);
		else if(n>=100&&n<1000)printf("%d",n-90);
		 else if(n>=1000&&n<10000)printf("%d",909);
		  else if(n>=10000&&n<100000)printf("%d",n-9090);
		  	else printf("%d",99999-9090);
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solver();
	}

	@SuppressWarnings("unchecked")
	static void solver() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int w = sc.nextInt();
		int h = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		ArrayList<Integer>[] x_ord = new ArrayList[w];
		ArrayList<Integer>[] y_ord = new ArrayList[h];
		for (int i = 0; i < w; i++)
			x_ord[i] = new ArrayList<>();
		for (int i = 0; i < h; i++)
			y_ord[i] = new ArrayList<>();
		int x0 = 0, xw = 0, y0 = 0, yh = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt() - 1;
			y[i] = sc.nextInt() - 1;
			if (x[i] == 0 && x0 == 0)
				x0++;
			else if (x[i] == w - 1 && xw == 0)
				xw++;
			if (y[i] == 0 && y0 == 0)
				y0++;
			else if (y[i] == h - 1 && yh == 0)
				yh++;
			x_ord[x[i]].add(i);
			y_ord[y[i]].add(i);
		}
		int d = Math.max(Math.max(x0, xw), Math.max(y0, yh));

		DJSet ds = new DJSet(n);
		for (int i = 0; i < w; i++) {
			while (!x_ord[i].isEmpty()) {
				for (int j = 0; j < x_ord[i].size(); j++) {
					ds.setUnion(x_ord[i].get(0), x_ord[i].get(j));
				}
				x_ord[i].clear();
			}
		}
		for (int i = 0; i < h; i++) {
			while (!y_ord[i].isEmpty()) {
				for (int j = 0; j < y_ord[i].size(); j++) {
					ds.setUnion(y_ord[i].get(0), y_ord[i].get(j));
				}
				y_ord[i].clear();
			}
		}
		int sum = n - ds.count();
		if (ds.count() == 1) {
			System.out.println(sum);
		} else {
			sum +=2 * ds.count() - 1 - d;
			System.out.println(sum);
		}

	}

	public static class DJSet {
		int n;// the number of vertices
		int[] d;

		DJSet(int n) {
			this.n = n;
			d = new int[n];
			Arrays.fill(d, -1);
		}

		int root(int x) {
			return d[x] < 0 ? x : root(d[x]);
		}

		boolean setUnion(int x, int y) {
			x = root(x);
			y = root(y);
			if (x != y) {
				if (x < y) {
					int d = x;
					x = y;
					y = d;
				}
				// x>y
				d[y] += d[x];
				d[x] = y;
			}
			return x != y;
		}

		boolean equiv(int x, int y) {
			return root(x) == root(y);
		}

		// the number of nodes of which graph contains x
		int size(int x) {
			return d[root(x)] * (-1);
		}

		// the number of connected graphs
		int count() {
			int ct = 0;
			for (int u : d) {
				if (u < 0)
					ct++;
			}
			return ct;
		}
	}
}

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

template<class Abel> struct UnionFind {
    vector<int> par;            // 親ノード
    vector<int> rank;           // ランク
    vector<Abel> diff_weight;   // 親ノードとの値の差分

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    // 初期化
    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    // 経路圧縮
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind<int> uf(N);
    for(int i=0;i<M;i++){
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        if(uf.issame(l, r)){
            int diff = uf.diff(l, r);
            if(diff != d){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            uf.merge(l, r, d);
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int str1 = sc.nextInt();
		int str2 = sc.nextInt();
		if(str1 == 1 || str1 == 3|| str1 == 5|| str1 == 7|| str1 == 8|| str1 == 10|| str1 == 12){
			str1 = 100;
		}
		if(str1 == 4 ||str1 == 6 ||str1 == 9 ||str1 == 11) str1 = 200;
		if(str1 == 2) str1 = 300;
		
		if(str2 == 1 || str2 == 3|| str2 == 5|| str2 == 7|| str2 == 8|| str2 == 10|| str2 == 12){
			str2 = 100;
		}
		if(str2 == 4 ||str2 == 6 ||str2 == 9 ||str2 == 11) str2 = 200;
		if(str2 == 2) str2 = 300;
		
		if(str1 == str2) System.out.println("Yes");
		if(str1 != str2) System.out.println("No");
	  }
	}

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

int main()
{

        long long N;
        long long M;
        cin >> N >> M;
        int A[M];
        long long ans = 0;
        for(int i=0; i < M; ++i) {
                cin >> A[i];
                ans += A[i];
        }

        if (N < ans) {
                cout << "-1" << endl;
        }
        else {
                cout << N - ans << endl;
        }


}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

vector<pll> prime_factorize(ll n){
    vector<pll> res;
    for(ll p = 2; p * p <= n; ++p){
        if(n % p != 0) continue;
        ll num = 0;
        while(n % p == 0){
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if(n != 1) res.push_back(make_pair(n, 1));
    return res;   
}

int main() {
    ll N;
    cin >> N;
    auto pf = prime_factorize(N);
    ll ans = 0;
    for(auto p : pf){
        ll now = 1;
        while(p.second - now >= 0){
            p.second -= now;
            ans++;
            now++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include<math.h>
using namespace std;

int main()
{

 long long n;cin>>n;
    double x=sqrt(n);
    long long y=sqrt(n);
    if((x-y)==0)
    cout<<n<<endl;
    else {
        long long i=n;
        while(true){
            i--;
        double x=sqrt(i);
           long long y=sqrt(i);
            if((x-y)==0){
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[N + 1];
main() {
    int n = readInt(), L = readInt();
    int total = 0;
    for (int i = 1; i <= n; i++) {
        a[i] = L + i - 1;
        total += a[i];
    }
    sort(a + 1, a + n + 1);
    int ans = 0, diff = LLONG_MAX;
    for (int i = 1; i <= n; i++) {
        if (diff > abs(a[i])) {
            diff = abs(a[i]);
            ans = total - a[i];
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
import math
N, D = [int(x) for x in input().split()]
X = [[int(x) for x in input().split()] for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        dist = math.sqrt(sum([(X[i][k] - X[j][k])**2 for k in range(D)]))
        if math.floor(dist) == math.ceil(dist):
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if (a == 1) a = 15;
  if (b == 1) b = 15;
  
  if (a > b) 
    cout << "Alice" << endl;
  else if (b > a)
    cout << "Bob" << endl;
  else
    cout << "Draw" << endl;
}


Measured memory_bytes: 256
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.in(),r=new Array(e),n=0;n<e;n++)r[n]=t.in();for(var i=1,o=1;o<e;o++){for(var s=!0,u=0;u<o;u++)if(r[u]>r[o]){s=!1;break}s&&i++}console.log(i)}}]);


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C;
    cin >> A >> B >> C;
    ll hi = max({A, B, C});
    ll answer = 0;
    ll Aplus2 = (hi - A) / 2;
    answer += Aplus2;
    A += 2 * Aplus2;
    ll Bplus2 = (hi - B) / 2;
    answer += Bplus2;
    B += 2 * Bplus2;
    ll Cplus2 = (hi - C) / 2;
    answer += Cplus2;
    C += 2 * Cplus2;
    ll loCount = 0;
    if (hi > A)
    {
        loCount++;
    }
    if (hi > B)
    {
        loCount++;
    }
    if (hi > C)
    {
        loCount++;
    }
    if (loCount == 2)
    {
        answer += 1;
    }
    else if (loCount == 1)
    {
        answer += 2;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)

template <typename T> using duo = std::pair<T, T>;
template <typename T> using vec = std::vector<T>;
using ll = long long;
using pii = duo<int>;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE1(T)vec<std::pair<T,int>>zipi(const vec<T>&x,int s=0){int N=x.size();vec<std::pair<T,int>>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  string s;
  getline(cin, s);
  sort(ALL(s));
  if (s == "  557") {
    pr("YES");
  } else {
    pr("NO");
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

map<int, int> mp;

void primeFactorize(int n) {
    for (int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            ++mp[i];
            n /= i;
        }
    }
    if (n > 1) ++mp[n];
}

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

    int n;
    cin >> n;
    rep2(i, 1, n + 1) {
        primeFactorize(i);
    }

    int ans = 1;
    for (auto p : mp) {
        (ans *= (p.second + 1)) %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, x, atec, a, days, result;
    cin>>n;
    cin>>days>>x;
    result = x;
    for(int i = 0; i < n; i++)
    {
        cin>>a;
        for(int j = 0; ; j++)
        {
            int Ai = a * j + 1;
            if(Ai>days)
                break;
            result++;
        }
    }
    cout<<result<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n;
    vector<string> v;
    rep(i, n){
        string s;cin>>s;
        vint num(10);
        rep(j, 10){
            num[j] = s[j]-'a';
        }
        sort(all(num));
        rep(j, 10){
            s[j] = num[j] + 'a';
        }
        //cout << s << endl;
        v.push_back(s);
        //cout << s << endl;
        //cout << sort(all(s));
    }
    sort(all(v));
    ll streak = 0;
    ll ans = 0;
    string now = "";
    rep(i, n){
        //cout << v[i] << endl;
        if(v[i]!=now){
            ans += streak*(streak-1)/2;//COM(streak, 2);
            //cout << streak << endl;
            streak = 1;
            now = v[i];
        }else{
            streak++;
        }
    }
    ans += streak*(streak-1)/2;//COM(streak, 2);
    cout << ans << endl;
    //cout << COM(3, 2) << endl;
    return 0;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
int main()
{

    char s[10];int i,flag=0;
    scanf("%s",s);
    for(i=0;i<strlen(s)-1;i++)
    {
        if(s[i]==s[i+1])
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        printf("Bad\n");
    else
        printf("Good\n");
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const lines = input.trim().split("\n");
  const N = parseInt(lines[0]);
  const H = lines[1].split(" ").map(h => parseInt(h));
  let ans = 0;
  H.forEach((h, i) => {
    let canSeeOcean = true;
    for (let j = 0; j < i; j++) {
      if (h < H[j]) {
        canSeeOcean = false;
      }
    }
    if (canSeeOcean) {
      ans++;
    }
  });
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

typedef long long int ll;
typedef vector<int>   vi;
typedef vector<char>  vc;
typedef vector<ll>    vll;

#define rep(i,a,b) for(ll i=(a); i<=(b); i++)
#define vin(v,n)   for(ll i = 0; i <  n; i++) cin >> v[i];
#define pushi(v,a) for(ll i = 0; i < a.size(); i++) v.push_back(a[i]);
#define vout(v,n)  for(ll i = 0; i < n; i++) cout << v[i] << " ";
#define Boost      ios_base::sync_with_stdio(false);cin.tie(0);
#define stop(n)    return cout<<n,0;
#define all(v)     (v).begin(), (v).end()
#define rall(v)    (v).rbegin(),(v).rend()
#define sp(x,y)    fixed<<setprecision(y)<<x
#define sz(v)      (int)(v.size())
#define endl       '\n'
#define PI         3.141592653
#define fn         fill_n
#define pb         push_back
#define in(n)      cin>>n;

void solve()
{
    char c;
    cin>>c;
    if(c>='A' && c<='Z')
        cout<<"A"<<endl;
    else
        cout<<"a"<<endl;
}

int main()
{
    Boost;
    clock_t time_p=clock();

    int test;
    test=1;
    //in(test);
    while(test--)
    {
        solve();
    }
    cerr<<"\n\nTime Taken : "<<sp((float)(clock()-time_p),5)/CLOCKS_PER_SEC<<endl;
    return 0;
}


Measured memory_bytes: 3800
k=int(input())
a=[int(i) for i in input().split()]
l=2
r=3
for i in range(k-1,-1,-1):
    l=(l+a[i]-1)//a[i]*a[i]
    r=(r+a[i]-1)//a[i]*a[i]
if l==r:
    print(-1)
else:
    print(l,r-1)


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll n, a, b;

int main(){
    cin >> a >> b >> n;
    double ans=0;
    if(n<b)
    {
        ans=floor(a*n/b)-a*floor(n/b);
    }
    else{
        ans=floor(a*(b-1)/b)-a*floor((b-1)/b);
        double tmp=floor(a*b/b)-a*floor(b/b);
        FOR(i,b-1,n+1)
        {
            if(tmp<floor(a*i/b)-a*floor(i/b))
                tmp=floor(a*i/b)-a*floor(i/b);
            else
            {
                break;
            }
        }
        chmax(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;

inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}

int main(){
  int a = getint(), b = getint();
  a < b ? puts("0") : puts("10");
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::io::BufRead;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n: usize = sc.next().unwrap();

    let mut a: Vec<i64> = vec![];
    for i in 0..n {
        a.push(sc.next().unwrap());
    }
    let mut s: Vec<i64> = vec![0; n + 1];
    for i in 0..n {
        s[i + 1] = s[i] + a[i];
    }
    let mut res = 1_000_000_000_000_000_000;
    for i in 2..(n-1) {
        let i2 = f(&s, 0, i);
        let i3 = f(&s, i, n);
        // println!("{} {} {}", i, i2, i3);
        for j in i2..(i2+2) {
            for k in i3..(i3+2) {
                if 0 < j && j < i && i < k && k < n {
                    let mut v = vec![s[j]-s[0], s[i]-s[j], s[k]-s[i], s[n]-s[k]];
                    v.sort();
                    res = std::cmp::min(res, v[3] - v[0]);
                }
            }
        }
    }

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

fn f(s: &Vec<i64>, l: usize, r: usize) -> usize {
    let mut ll = l + 1;
    let mut rr = r;
    while rr - ll > 1 {
        let m = (ll + rr) / 2;
        let sl = s[m] - s[l];
        let sr = s[r] - s[m];
        if sl > sr {
            rr = m;
        } else {
            ll = m;
        }
    }
    ll
}

/// Scanner
///
/// # Example
/// ```
/// use contest::io::scanner;
/// let mut sc = scanner::Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>().unwrap());
/// assert_eq!(2, sc.next());
/// assert_eq!(3.5, sc.next());
/// assert_eq!(None, sc.next::<i32>());
/// ```

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

impl<R: io::Read> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> Option<T>
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: "))
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}


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

int main(){
	string s1, s2;
	cin >> s1 >> s2;
	if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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

#define ll long long int
#define ull unsigned long long int
#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using namespace std;

const int INF = 1e9 + 7;
const int N = 1e5+5;

int main() {

	IO;
	
	int x;
	cin >> x;
	if (x >= 30) 
		cout << "Yes";
	else
		cout << "No";
}	



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

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

    int n;
    cin >> n;

    if (n & 1)
        cout << n / 2 + 1 << '\n';
    else
        cout << n / 2 << '\n';
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		//文字列を読み込む
		int[] A1 = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int[] A2 = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		int[] A3 = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		
		int N = int.Parse(Console.ReadLine());
		
		for(int i=0; i<N; i++){
			int bi = int.Parse(Console.ReadLine());
			for(int j=0; j<3; j++){
					if(A1[j] == bi){
							A1[j] = 0;
					}
					if(A2[j] == bi){
							A2[j] = 0;
					}
					if(A3[j] == bi){
							A3[j] = 0;
					}
			}
		}
		
		int sumLine1 = A1.Sum();
		int sumLine2 = A2.Sum();
		int sumLine3 = A3.Sum();
		
		int sumColumn1 = A1[0] + A2[0] + A3[0];
		int sumColumn2 = A1[1] + A2[1] + A3[1];
		int sumColumn3 = A1[2] + A2[2] + A3[2];
		
		int sumR = A1[0] + A2[1] + A3[2];
		int sumL = A1[2] + A2[1] + A3[0];
		
        if(sumLine1 == 0 || sumLine2 == 0 || sumLine3 == 0 ||
        sumColumn1 == 0 || sumColumn2 == 0 || sumColumn3 == 0 ||
        sumR == 0 || sumL == 0)
		{
			Console.WriteLine("Yes");
		}else{
			Console.WriteLine("No");
		}
	}
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const ll mod = 998244353;
const int N = 3005;
ll dp[N][N];
int a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	memset(dp, 0, sizeof(dp));
	int n, s;
	cin>>n>>s;
	for(int i = 1; i <= n; i++){
		cin>>a[i];
	}
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= s; j++){
			dp[i][j] = 2*dp[i - 1][j];
			if(j >= a[i])dp[i][j] += dp[i - 1][j - a[i]];
			dp[i][j] %= mod;
		}
	}
	cout<<dp[n][s]<<'\n';

	return 0;
}

Measured memory_bytes: 74212
o = input()
e = input()
s = ""
if len(o) > len(e):
    for i in range(len(e)):
        s += o[i] + e[i]
    print(s+o[-1])
elif len(o) == len(e):
    for i in range(len(o)):
        s += o[i] + e[i]
    print(s)
else:
    for i in range(len(o)):
        s += o[i]  + e[i]
    print(s+e[-1])

Measured memory_bytes: 3064
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define pii pair < ll , ll >
#define fi first
#define se second
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define forn(i,a,b) for (ll i = a; i <= b; i ++ )
#define mod(n,k) (((n%k)+k)%k)
using namespace std;
typedef long long ll;

ll N, ans;
string s;
ll dp[2][2040];

/*
ll dp( ll x , ll m ) {
    if( x == N )
        return m == 0;
    if( vis[{ x , m }] )
        return mp[{x , m }];
    vis[{x , m}] = 1;
    return mp[{x , m}] = dp( x + 1 , ( 10 * m + s[x] - '0' ) % 2019 ) + ( m == 0 );
}
*/

int main()
{
    optimiza_io
    cin >> s;
    N = s.size();
    ll act = 0, nxt = 1;
    dp[act][0] = 1;
    for( ll x = N-1; x >= 0; x -- ) {
        swap( act , nxt );
        for( ll m = 0; m < 2019; m ++ )
            dp[act][m] = dp[nxt][( 10 * m + s[x] - '0' ) % 2019] + ( m == 0 );
        ans += dp[nxt][s[x] - '0'];
    }
    
    /* for( ll i = 0; i < N; i ++ )
        ans += dp( i + 1 , s[i] - '0' );
        */ 
    
    cout << ans;
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3772
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve();

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

int N, A, B;
vector<int> H;

bool is_valid(int cnt) {
  int num_use = 0;
  for (int h:H) {
    h -= B*cnt;
    if (h > 0) {
      int d = A-B;
      num_use += (h+d-1)/d;
    }
  }

  return cnt >= num_use;
}

void solve() {
  cin >> N >> A >> B;
  H.resize(N);
  int maxi = 0;
  for (int &h:H) {
    cin >> h;
    maxi = max(maxi, h);
  }

  int ng = 1;
  int ok = maxi;
  while (ok - ng > 1) {
    int piv = (ok-ng)/2 + ng;
    if (is_valid(piv)) {
      ok = piv;
    } else {
      ng = piv;
    }
  }
  cout << ok << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 100
#define INF 1e9 + 5
#define LINF 1e18 + 5

using namespace std;
using ll = long long;
string a, b;
ll memo[3003][3003], gp[3003][3003];
ll solve(int y, int x)
{
    if (memo[y][x] != -1)
        return memo[y][x];
    if (x == 0 || y == 0)
        return memo[y][x] = 0;
    ll best = -1;
    ll res = solve(y - 1, x);
    gp[y][x] = 1;
    ll g = solve(y, x - 1);
    if (res < g)
    {
        res = g;
        gp[y][x] = 2;
    }
    if (a[y] == b[x])
    {
        g = solve(y - 1, x - 1) + 1;
        if(res<g){
            res=g;
            gp[y][x]=3;
        }
    }

    return memo[y][x] = res;
}
/*
 abyxb
a10000 
x11122
y11222
b12223

*/
int main()
{
    cin >> a >> b;
    a = "$" + a;
    b = "$" + b;
    memset(memo, -1, sizeof(memo));
    //memo[0][0] = 0;
    ll maxlenth = solve(a.length() - 1, b.length() - 1);
    for (int y = 0; y < a.length(); y++)
    {
        for (int x = 0; x < b.length(); x++)
        {
            //cout << memo[y][x];
        }
        //cout << endl;
    }

    int x = b.length() - 1, y = a.length() - 1;
    string t = "";
    while (x > 0 && y > 0)
    {
       if(memo[y][x]!=memo[y-1][x]&&memo[y][x]!=memo[y][x-1]){
           t = a[y]+t;
           x--;y--;
       }else{
           if(memo[y][x]==memo[y-1][x]){
               y--;
           }else{
               x--;
           }
       }
    }
    // cout<<maxlenth<<endl;
    cout << t;
    return 0;
}

Measured memory_bytes: 141568
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define deb(x) cout << #x << ' ' << x << '\n'
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define per(i,ini) for(int i=ini;i>=0;i--)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 2e5+2;


int main()
{
    int n, k;
    cin >> n >> k;

    vector <int> used(n+1, 0);

    while(k --)
    {
        int d;
        scn(d);

        while(d --)
        {
            int a;
            scn(a);

            used[a] = 1;
        }
    }

    int cnt = 0;

    rep(i, 1, n+1)
    if(!used[i])
    cnt ++;

    prin(cnt);
    
    return 0;
}

Measured memory_bytes: 3752
//
// Created on 2020/04/24.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    string ans = "No";
    string s;
    cin>>s;
    map<char,int>mp;
    for (int i = 0; i < s.size(); ++i) {
        mp[s[i]] ++;
    }
    if(mp.size() == 2 && mp[s[0]] == 2){
        ans = "Yes";
    }

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


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n;
    std::string str;
    int wsum[300001], esum[300001];
    std::cin >> n >> str;
    wsum[0] = 0;
    esum[n + 1] = 0;
    for (int i = 1; (i <= n); ++i) {
        if (str[i - 1] == 'W') wsum[i] = wsum[i - 1] + 1;
        else wsum[i] = wsum[i - 1];
        int eindex = n + 1 - i;
        if (str[n - i] == 'E') esum[eindex] = esum[eindex + 1] + 1;
        else esum[eindex] = esum[eindex + 1];
    }
    int min = 300001;
    for (int i = 1; (i <= n); ++i) {
        min = std::min(min, wsum[i - 1] + esum[i + 1]);
    }
    std::cout << min << std::endl;
    return 0;
}


Measured memory_bytes: 3076
// atcoder/abc177/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

class UnionFind {
public:
  UnionFind(int n) {
    r.resize(n, 0);
    p.resize(n, -1);
  }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return ;
    if (r[a] > r[b]) {
      p[a] += p[b];
      p[b] = a;
    } else {
      p[b] += p[a];
      p[a] = b;
      if(r[a] == r[b]) r[b]++;
    }
    return ;
  }
  int find(int a) {
    return (p[a] < 0) ? a : p[a] = find(p[a]);
  }
  bool same(int a, int b) {
    return find(a) == find(b);
  }
  size_t size(int n) {
    return -p[find(n)];
  }
private:
  vector<int> r, p;
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n, m;
  while (cin >> n >> m) {
    vec<pair<int, int>> v(m);
    cin >> v;
    each (i, v) {
      --i.first;
      --i.second;
    }

    UnionFind uf(n);
    each (i, v) {
      uf.unite(i.first, i.second);
    }

    for (int i = 0; i < n; ++i) {
      uf.find(i);
    }

    int mx = 0;
    map<int, int> m;
    for (int i = 0; i < n; ++i) {
      setmax(mx, ++m[uf.find(i)]);
    }

    cout << mx << endl;
  }

  return 0;
}


Measured memory_bytes: 14288