akhauriyash/Code-Regression huggingface dataset:
//People only find me interesting because they can't tell whether I'm serious or not
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
typedef __int128 s128;
typedef __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define P 998244353
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 100005
#define PI 3.14159265359
#define inf LLONG_MAX
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
u64 binpower(u64 base, u64 e, u64 mod) {
    u64 result = 1;
    base %= mod;
    while (e) {
        if (e & 1)
            result = (u128)result * base % mod;
        base = (u128)base * base % mod;
        e >>= 1;
    }
    return result;
}
 
bool check_composite(u64 n, u64 a, u64 d, int s) {
    u64 x = binpower(a, d, n);
    if (x == 1 || x == n - 1)
        return false;
    for (int r = 1; r < s; r++) {
        x = (u128)x * x % n;
        if (x == n - 1)
            return false;
    }
    return true;
};
 
bool MillerRabin(u64 n, int iter=5) { // returns true if n is probably prime, else returns false.
    if (n < 4)
        return n == 2 || n == 3;
 
    int s = 0;
    u64 d = n - 1;
    while ((d & 1) == 0) {
        d >>= 1;
        s++;
    }
 
    for (int i = 0; i < iter; i++) {
        int a = 2 + rand() % (n - 3);
        if (check_composite(n, a, d, s))
            return false;
    }
    return true;
}
void solve(){
    vector<bool> sieve(10000001,1);
    sieve[1]=0;
    vector<ll> primes;
        for(ll i=2; i*i<=10000000; i++){
            if(sieve[i]==1){
                for(ll j=i; i*j<=10000000; j++){
                    sieve[i*j]=0;
                }
            }
        }
        f(i,2,10000001){
            if(sieve[i]==1) primes.push_back(i);
        }
    ll n,ans=0;
    cin>>n;
    f(i,0,sz(primes)){
        ll p = primes[i];
        if(p*p*p > n) break;
        ll k=0;
        while(n%p==0){
            n /= p;
            k++;
        }
        ll j = sqrt(2*k);
        while(j*(j+1) > 2*k) j--;
        ans += max(0ll,j);
    }
    if(MillerRabin(n)==1) ans += 1;
    else{
        ll t = sqrt(n);
        if(t*t==n && MillerRabin(t)==1) ans += 1;
        else if(n>1) ans += 2;
    }
    cout<<ans;
}
signed main() {
    teevra_gati
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    solve();

    return 0;
}

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

int main(){
    long long n;cin>>n;
    long long a=1;
    long long b=n;
    for(long long i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(i+n/i<a+b){
                a=i;
                b=n/i;
            }
        }
    }
    cout<<a+b-2<<"\n";
    return 0;
}

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

int main() {
	int N;
  	cin >> N;
  	vector<int> Mochi(N);
  	int d;
  	for(int i = 0; i < N; i++){
    	cin >> d;
      	Mochi.at(i) = d;
    }
    //Mochi配列を小さい順に並び替える
    sort(Mochi.begin(), Mochi.end());
  	int duplex = 0; //重複したもちの数を数えるための変数
    //Mochi配列の中で隣り合う要素が同じ場合の回数をduplexでカウントする
  	for(int i = 0; i < N - 1; i++){
    	if(Mochi.at(i) == Mochi.at(i + 1)){
        	duplex += 1;
        }
    }
  	cout << N - duplex << endl;
}


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

int main(){
	
	int q;
	cin >> q;
	
	int tmp,a,b;
	cin >> tmp >> a >> b;

	priority_queue<int> left;
	priority_queue<int,vector<int>,greater<int>> right;

	right.push(a);
	
	ll res = b;
	int p = a;
	
	int l = a; // 最小区間
	int r = a; // 最小区間
	
	rep(i,q-1){
		int tmp;
		cin >> tmp;
		if(tmp==1){
			int a,b;
			cin >> a >> b;
			
			res += b;
			if(right.size() - left.size() == 1) left.push(a);
			else right.push(a);
			
			while(true){
				if(right.top() < left.top()){
					int baf = left.top();
					left.pop();
					left.push(right.top());
					right.push(baf);
					right.pop();
				}
				else break;
			}
			
			// resの更新
			if(!(l <= a && a <= r)){
				res += min(abs(a-l), abs(a-r));
			}
			
			// p,l,rの更新
			if((right.size()+left.size())%2 == 0){
				p = left.top();
				l = p;
				r = right.top();
			}
			else{
				p = right.top();
				l = p;
				r = p;
			}
			/*
			if((right.size()+left.size())%2 == 0){
				p = left.top();
				res += min(abs(p-l), abs(p-r));
				l = left.top();
				r = right.top();
			}
			else{
				p = right.top();
				res += min(abs(p-l), abs(p-r));
				l = right.top();
				r = l;
			}
			*/
		}
		else{
			cout << p << " " << res << endl;
		}
		
	}
	
	return 0;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
void read(int &x){
	register char ch=getchar();x=0;
	for(;ch==' '||ch=='\n';ch=getchar());
	for(;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void reads(string &s){
	register char ch=getchar();s="";
	for(;ch==' '||ch=='\n';ch=getchar());
	for(;ch!=' '&&ch!='\n';s+=ch,ch=getchar());
}
void write(int x){
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
int K,pw[13],ans[800000],dat[800000],go[800000][3];
bool lz[800000];
string typ;
void built_trie(int id,int lv,int now){ 
	if(lv==K){
		dat[id]=now;return;
	}
	for(int i=0;i<3;i++){
		go[id][i]=id*3+i+1;
		built_trie(go[id][i],lv+1,now+i*pw[lv]);
	}
}
void push_down(int id){
	swap(go[id][1],go[id][2]);
	for(int i=0;i<3;i++)lz[go[id][i]]^=1;
	lz[id]=0;
}
void update_trie(int id,int lv){
	if(lv==K)return;
	if(lz[id])push_down(id);
	update_trie(go[id][2],lv+1);
	swap(go[id][1],go[id][2]),swap(go[id][0],go[id][1]);
}
void make_ans(int id,int lv,int now){
	if(lv==K){
		ans[dat[id]]=now;
		return;
	}
	if(lz[id])push_down(id);
	for(int i=0;i<3;i++)
		make_ans(go[id][i],lv+1,now+i*pw[lv]);
}
int main(){
	pw[0]=1,read(K),reads(typ);
	for(int i=1;i<=K;i++)pw[i]=pw[i-1]*3;
	built_trie(0,0,0);
	for(int i=0;i<typ.size();i++){
		if(typ[i]=='S')lz[0]^=1;
		else update_trie(0,0);
	}
	make_ans(0,0,0);
	for(int i=0;i<pw[K];i++)write(ans[i]),putchar(' ');
}

Measured memory_bytes: 12352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll gcd(ll a,ll b){
    return b?gcd(b,a%b) : a;
}

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

template<typename T>
struct SegmentTree{
private:
    int n;
    T E;
    vector<T> node;
    inline void updatef(T& x,T& y){
        x = y;
        //x += y;
        //x = max(x,y);
        //x = min(x,y);
    }
    inline T queryf(T& x,T& y){
        return lcm(x,y);
        //return x+y;
        //return max(x,y);
        //return min(x,y);
    }

public:
    SegmentTree(int sz,T E_):E(E_){
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
    }

    SegmentTree(vector<T>& A,T E_):E(E_){
        int sz=A.size();
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
        rep(i,sz)node[i+n-1]=A[i];
        for(int i=n-2;i>=0;--i){
            node[i]=queryf(node[2*i+1], node[2*i+2]);
        }
    }
    void update(int k,T x){
        k+=n-1;
        updatef(node[k],x);
        while(k>0){
            k=(k-1)/2;
            node[k]=queryf(node[2*k+1], node[2*k+2]);
        }
    }
       //[a,b)での和を返す
    T get(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return E;
        if(a<=l&&r<=b)return node[k];
        T xl=get(a,b,2*k+1,l,(l+r)/2);
        T xr=get(a,b,2*k+2,(l+r)/2,r);
        return queryf(xl, xr);
    }
};

ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    int n,q;
    cin>>n>>q;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
        --p[i];
    }
    vector<ll> t(n),sum(n+1);
    rep(i,n){
        int cur=p[i];
        sum[i+1]=cur+1;
        t[i]=1;
        while(cur!=i){
            cur=p[cur];
            sum[i+1]+=cur+1;
            ++t[i];
        }
        sum[i+1]=sum[i+1]*powmod(t[i],mod-2)%mod;
    }
    SegmentTree<ll> sg(t,1);
    rep(i,n)(sum[i+1]+=sum[i])%=mod;
    while(q--){
        int l,r;
        cin>>l>>r;
        --l;
        cout<<sg.get(l,r)%mod*(sum[r]-sum[l]+mod)%mod<<endl;
    }
    return 0;
}


Measured memory_bytes: 6820
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)    (x).begin(),(x).end()
# define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
# define mp        make_pair
# define eb        emplace_back
# define REP       (i, a) for (int i = 0; i < (a); i++)
# define INIT      std::ios::sync_with_stdio(false);std::cin.tie(0);

LL n, a[101010], sum, sa;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		if (i) {
			sa += (a[i] - a[i - 1]);
		}
	}
	sa += a[0] - a[n - 1];
	if (sum % (((1 + n)*n) / 2) == 0 && sa == 0) {
		LL num = sum / (((1 + n)*n) / 2);
		for (int i = 1; i < n; i++) {
			if (a[i] - a[i - 1] - num > 0 || (a[i] - a[i - 1] - num) % n != 0) {
				cout << "NO" << endl;
				return 0;
			}
		}
		if (a[0] - a[n - 1] - num > 0 || (a[0] - a[n - 1] - num) % n != 0) {
			cout << "NO" << endl;
			return 0;
		}
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 1024
import queue

h,w = map(int, input().split())

s = [input() for i in range(h)]

white = 0
for i in range(h):
    white += s[i].count('.')

q = queue.Queue()

q.put([0,0])
goal = [h-1,w-1]
visited = [[float('inf') for i in range(w)] for j in range(h)]
visited[0][0]=0

move = [[0,1],[0,-1],[1,0],[-1,0]]

while not q.empty():
    a,b = q.get()
    for y,x in move:
        if 0<=a+y<h and 0<=x+b<w:
            if s[a+y][x+b]=='.' and visited[a+y][x+b]==float('inf'):
                q.put([a+y,x+b])
                visited[a+y][x+b]=visited[a][b]+1

print(white-visited[-1][-1]-1if visited[-1][-1]!=float('inf')else -1)

Measured memory_bytes: 44776
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() 
{
  //ll n; cin >> n;
  //vector<int> a(n);
  //rep(i,n) cin >> a[i];
  ll l, r;
  cin >> l >> r;
  int min = 2020;
  bool flg = false;
  for(ll i=l;i<r;i++){
    for (ll j=i+1;j<r+1;j++){
      if ((i * j) % 2019 < min){
        min = (i * j) % 2019;
      }
      if (min == 0){
        flg = true;
        break;
      }
    }
    if(flg)break;
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1.01e9;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

void add(int & x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return (ll) x * y % mod;
}

int power(int x, ll p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
    p >>= 1;
  }
  return res;
}

void precalc() {
}

const int maxn = 3e3 + 100;

int n;
vector<vector<int> > tree;
int c[maxn];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  tree = vector<vector<int> > (n);
  for (int i = 0; i < n; i++) {
    scanf("%d", c + i);
  }
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    tree[a].pb(b);
    tree[b].pb(a);
  }
  return true;
}

int w[maxn];

void solve() {
  vector<pair<int, int> > tosort;
  for (int i = 0; i < n; i++) {
    tosort.pb(mp(c[i], i));
  }
  sort(tosort.begin(), tosort.end());
  for (int i = 0; i < n; i++) {
    int cur = tosort[i].second;
    w[cur] = 0;
    for (auto j : tree[cur]) {
      if (c[j] < c[cur] && !w[j]) {
        w[cur] = 1;
      }
    }
  }
  bool was = false;
  for (int i = 0; i < n; i++) {
    if (w[i]) {
      if (was) {
        printf(" ");
      }
      printf("%d", i + 1);
      was = 1;
    }
  }
  printf("\n");
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.3f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] heights = new int[10];
		for(int i = 0; i < 10; i++){
			heights[i] = scan.nextInt();
		}

		Arrays.sort(heights);
		for(int i = 9; i >= 7; i--){
			System.out.println(heights[i]);
		}
	}
}

Measured memory_bytes: 26132
#include<iostream>

void swap(const int x, const int y){
  if(x < y){
    std::cout << x << " " << y << std::endl;
  }else{
    std::cout << y << " " << x << std::endl;
  }
}

int main(){
  while(true){
    int x, y;
    std::cin >> x;
    std::cin >> y;
    if(x == 0 && y == 0) break;
    swap(x, y);
  }

  return 0;
}



Measured memory_bytes: 2984
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    unordered_map<int, int> cnt;
    cnt[0] = 1;
    ll cur = 0, fac = 1;
    ll ans = 0;
    // 2019 = 673 * 3
    for(int i = s.size()-1; i >= 0; i--) {
        cur = cur + (s[i]-'0') * fac;
        fac = (fac * 10) % 2019;
        cur %= 2019;
        ans += cnt[cur];
        cnt[cur] += 1;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3744
#coding: utf-8
n, k = map(int, input().split())
D = list(map(str, input().split()))
#print(D)
for i in range(n, 100000):
    tmp = list(str(i))
    cnt = 0
    for j in range(len(tmp)): 
        #print("tmp[j] =", tmp[j], type(tmp[j]))
        if tmp[j] in D:
            cnt += 1
    #print(cnt)
    if cnt == 0 and i >= n:
        print(i)
        break

Measured memory_bytes: 3060
w, h, n = [int(i) for i in input().split()]
table = [[0 for _ in range(w)] for _ in range(h)]

for _ in range(n):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        table[0][0] += 1
        if x < w:
            table[0][x] -= 1
    elif a == 2:
        if x < w:
            table[0][x] += 1
    elif a == 3:
        table[0][0] += 1
        if y < h:
            table[y][0] -= 1
    elif a == 4:
        if y < h:
            table[y][0] += 1

for i in range(len(table)):
    for j in range(1, len(table[i])):
        table[i][j] += table[i][j-1]
for i in range(1, len(table)):
    for j in range(len(table[i])):
        table[i][j] += table[i-1][j]
count = 0
for i in range(len(table)):
    for j in range(len(table[i])):
        if table[i][j] == 0:
            count += 1
print(count)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){
    int A, B, M;
    cin >> A >> B >> M;
    priority_queue<int, vector<int>, greater<int>> a;
    priority_queue<int, vector<int>, greater<int>> b;
    int a_t[A], b_t[B];
    for(int i = 0; i < A; i++){
        int t;
        cin >> t;
        a.push(t);
        a_t[i] = t;
    }
    for(int i = 0; i < B; i++){
        int t;
        cin >> t;
        b.push(t);
        b_t[i] = t;
    }
    int a_i[M], b_i[M], c[M];
    for(int i = 0; i < M; i++){
        cin >> a_i[i] >> b_i[i] >> c[i];
    }

    int ans = a.top() + b.top();
    int disc = INF;
    for(int i = 0; i < M; i++){
        int tmp = a_t[a_i[i] - 1] + b_t[b_i[i] - 1] - c[i];
        if(disc > tmp) disc = tmp;
    }

    if(ans > disc) ans = disc;

    cout << ans << endl;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

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

Measured memory_bytes: 3616
S = input().rstrip()
T = input().rstrip()

dic_S = {}
dic_T = {}

for i in range(len(S)):
	if S[i] in dic_S.keys():
		if dic_S[S[i]] == T[i]: continue
		else:
			print('No')
			break
	if T[i] in dic_T.keys():
		if dic_T[T[i]] == S[i]: continue
		else:
			print('No')
			break
	else:
		dic_S[S[i]] = T[i]
		dic_T[T[i]] = S[i]
else:
	print('Yes')

Measured memory_bytes: 3632
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int n;
    cin >> n;

    cout << (n / 100 == n % 10 ? "Yes" : "No") << endl;

    return 0;
}

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

int main(){
	int n, d;
	cin >> n >> d;
	
	vector<vector<int>> x(n, vector<int>(d));
	rep(i, n){
		rep(j, d){
			cin >> x.at(i).at(j);
		}
	}

	int ans = 0;
	for(int i = 0; i < n-1; i++){
		for(int j = i+1; j < n; j++){
			int dist = 0;
			rep(k, d){
				int now = x.at(i).at(k) - x.at(j).at(k);
				dist += now*now;
			}

			for(int n = 0; n <= dist;n++){
				if(n*n == dist) ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}



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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    string a = "AKIHABARA";
    for (int i = 0; i < 16; i++) {
        string b; int cnt = 0;
        for (auto &c: a) {
            if (c != 'A') b += c;
            else {
                if (i & (1 << cnt)) b += c;
                cnt++;
            }
        }
        if (s == b) {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    string s;
    cin >> n >>  s;
    if(n%2) puts("No");
    else {
        if(s.substr(0, s.size()/2) == s.substr(s.size()/2, s.size()/2)){
            puts("Yes");
        }else {
            puts("No");
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

using namespace std;
int N;
set<int> S;

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    int a;
    cin >> a;
    S.insert(a);
  }
  unsigned long len = S.size();
  cout << ((len%2 == 1) ? len : len-1) << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
//const ll mod = 1000000007LL;
const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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



  cin >> n;
  vector<double> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  rep(i, n - 1) {
    double d = (a[0] + a[1]) / 2;
    vector<double> b;
    FOR(i, 2, a.size()) b.pb(a[i]);
    b.pb(d);
    sort(all(b));
    a = b;
  }
  cout.precision(8);
  cout << fixed << a[0] << endl;



  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,m,ans=-100;
int st[500][500];
const ll MOD = 1000000007;
bool bfs(int ne,int k,vector<ll> &group,vector<vector<int>> s){
    queue<int> q;
    group.at(0)=1;
    q.push(0);
    while(!q.empty()){
        int i=q.front();
        int nowdist=group.at(i);
        q.pop();
        For(j,0,n){
            if(s.at(i).at(j)==1){
                if(group.at(j)==nowdist){
                    return false;
                }
                if(group.at(j)==0){
                    q.push(j);
                    if(group.at(j)==nowdist){
                        return false;
                    }
                    group.at(j)=group.at(i)+1;
                    //cout<<"dist_"<<j<<"="<<group.at(j)<<endl;
                }
            }
        }
    }
    return true;
}

ll count(vector<vector<int>> s){
    vector<ll> group(n,0);
    group.at(0)=1;
    bool flag=bfs(-1,0,group,s);
    if(!flag) return -1;
    map<int,int> kazu;
    For(i,0,n){
        //cout<<group.at(i)<<" ";
        if(group.at(i)==-1) return -1;
        else kazu[group.at(i)]++;
    }
    //cout<<endl;
    return kazu.size();
}
void Main(){    
    cin>>n;
    For(i,0,n){
        string x;cin>>x;
        For(j,0,n){
            st[i][j]=x.at(j)-'0';
        }
        For(j,n,2*n){
            st[i][j]=st[i][j%n];
        }
    }
    For(i,n,2*n){
        For(j,0,2*n){
            st[i][j]=st[i%n][j%n];
        }
    }
    /*For(i,0,2*n){
        For(j,0,2*n){
            cout<<st[i][j]<<" ";
        }
        cout<<endl;
    }*/
    For(t,0,n){
        vector<vector<int>> s(n,vector<int>(n));
        For(i,0,n){
            For(j,0,n){
                s.at(i).at(j)=st[i+t][j+t];
                //cout<<s.at(i).at(j)<<" ";
            }
            //cout<<endl;
        }
        ll cnt=count(s);
        ans=max(ans,cnt);
        //cout<<cnt<<endl;
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 1572
//10
#include<iostream>
#include<string>

using namespace std;

int main(){
  int N;
  string s;
  cin>>N>>s;
  int c=0;
  while(N--){
    string t;
    cin>>t;
    for(int i=0;i<t.size();i++){
      for(int j=1;j<t.size();j++){
	string u;
	for(int k=0;k<s.size();k++){
	  if(i+j*k<t.size()){
	    u+=t[i+j*k];
	  }
	}
	if(s==u){
	  c++;
	  goto next;
	}
      }
    }
  next:
    ;
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 123456789012

template <class T>
class SegTree {
    int n;                       // 葉の数
    vector<T> data;              // データを格納するvector
    T def;                       // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;    // 点更新で使う処理

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return data[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }

  public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
            function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};

int main(){
    ll i,j;
    int n,q;
    cin>>n>>q;
    SegTree<int> st(n,INT_MAX,
                    [](int a,int b) {return min(a,b);},
                    [](int a,int b) {return b;} 
                    );
   // for(i=0;i<n;i++)  st.change(i,INT_MAX);
    
    for(i=0;i<q;i++){
        int t,x,y;
        cin>>t>>x>>y;
        if(t==0) st.change(x,y);
        else cout<<st.query(x,y+1)<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3792
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

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

    ll a,b,c,k;cin>>a>>b>>c>>k;
    if(k%2){
        ll res=b-a;
        if(abs(res)>1e18) cout<<"Unfair"<<endl;
        else cout<<res<<endl;
    }
    else{
        ll res=a-b;
        if(abs(res)>1e18) cout<<"Unfair"<<endl;
        else cout<<res<<endl;
    }
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.size()){
        if(s[i] != t[i])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<pair<char,int>>cnt;
    cnt.push_back({'Z',-1});
    for(int i = 0; i < N; i++) {
        if(cnt.back().first == S[i]) {
            cnt.back().second++;
        }
        else {
            cnt.push_back({S[i],1});
        }
    }
    cnt.erase(cnt.begin());
    int l = 0,r = 0,sum = 0,ans = 0,now = 0;
    while(r < cnt.size()) {
        sum+=cnt[r].second;
        if(cnt[r].first == '0') {
            now++;
        }
        if(now > K) {
            if(cnt[l].first == '0') {
                sum-=cnt[l].second;
                l++;
            }
            else {
                sum-=cnt[l].second;
                sum-=cnt[l+1].second;
                l+=2;
            }
            now--;
        }
        ans = max(ans,sum);
        r++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5504
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int N;
	cin >> N;

	if (111 >= N) {
		cout << 111 << endl;
	}
	else if (222 >= N) {
		cout << 222 << endl;
	}
	else if (333 >= N) {
		cout << 333 << endl;
	}
	else if (444 >= N) {
		cout << 444 << endl;
	}
	else if (555 >= N) {
		cout << 555 << endl;
	}
	else if (666 >= N) {
		cout << 666 << endl;
	}
	else if (777 >= N) {
		cout << 777 << endl;
	}
	else if (888 >= N) {
		cout << 888 << endl;
	}
	else if (999 >= N) {
		cout << 999 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#%%
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]

T.sort()


cnt = 0
ans = 1
time = T[0]
for i in range(N-1):
    cnt += 1
    if cnt == C or time + K < T[i+1]:
        ans += 1
        cnt = 0
        time = T[i + 1]

print(ans)

Measured memory_bytes: 50264
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int d, n;
  cin >> d >> n;
  cout << (n + n / 100);
  for (int i = 0; i < d; ++i) cout << "00";
  cout << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int inX = stdin.nextInt();
		int inA = stdin.nextInt();
		int inB = stdin.nextInt();

		System.out.println((inX - inA) % inB);
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
void chmax(int &a, int b) {if(a < b) a = b;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0, sum = 0;
	for(int i = 0, j = 0; i < n; i++){
		while(j < i){
			if((sum & a[i]) == 0) break;
			sum ^= a[j];
			j++;
		}
		sum ^= a[i];
		ans += i - j + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int cnt=0,a[100001]={0},n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	cout<<a[n/2+1]-a[n/2];
	return 0;
} 

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
int n;


int main(){
	cin >> n;
	int temp = ((n +0.99) / 1.08);
	int temp2 = temp * 1.08;
	// cout << n << " " << temp2 << endl;
	if(n == temp2)cout << temp << endl;
	else cout << ":(" <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 int main(){
 int n,F=0;
 string s;
 cin>>n;
 int a[n];
 rep(i,n)cin>>a[i];
   
 rep(i,n){
 if(a[i]%2==0){
  	if(a[i]%3!=0&&a[i]%5!=0) 
        F=1;
 	}
 }
   if(F==1)cout <<"DENIED"<<endl;
   else cout <<"APPROVED"<<endl;
 }


Measured memory_bytes: 256
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long long int ar[100013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//int sieve(long long int a)
//{
//    long long int i,j;
//    memset(ar,0,sizeof(ar));
//    for(i=2; i<=a; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=a; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    if(ar[a]==0)
//        return 1;
//    else
//        return 0;
//}

void Ok()
{
    long long int a,b,c,d,e,f,g,h,t,i,j,k,l,m,n,r,rcv,lo,hi,mid;
    long long int sum = 0,ans_1,ans_2,ans_3,cnt_1 = 0,cnt_2 = 0,cnt_3 = 0,Max,Min,flag = 0,div,temp;
    long double aa,bb,cc,dd,ee,ff,gg;
    char aaa,bbb,ccc,ddd;
    string spc,in[113],rev;

    cin>>n>>m;
    ans_1 = (n * (n - 1))/2;
    ans_2 = (m * (m - 1))/2;
    ans_3 = ans_1 + ans_2;
    cout<<ans_3<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

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

    vector<int> b(2*n);
    for(int i=0; i<n; i++) b[i] = a[i];
    for(int i=n; i<2*n; i++) b[i] = a[i-n] + k;

    ll ans = INF;
    for(int i=n-1; i<2*n; i++){
        chmin(ans, (ll)(b[i] - b[i-(n-1)]));
        
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
    int a,b;
    char op;
    cin >> a >> op >> b;

while (op != '?')
    {
    if (op == '+')
    {
        cout << a + b << endl;
    }
    else if (op == '-')
    {
        cout << a - b << endl;
    }
    else if (op == '*')
    {
        cout << a * b << endl;
    }
    else if (op == '/')
    {
        cout << a / b << endl;
    }
    else
    {
        return 0;
    }
    cin >> a >> op >> b;
    }
}


Measured memory_bytes: 3048
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m, k;
    cin >> m >> k;
    if(k >= (1<<m)){
        cout << -1 << endl;
        return 0;
    }
    if(m == 0){
        cout << "0 0" << endl;
        return 0;
    }
    if(m == 1){
        if(k == 0) cout << "0 0 1 1" << endl;
        else cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    ans.push_back(k);
    rep(i,(1<<m)){
        if(i == k) continue;
        ans.push_back(i);
    }
    ans.push_back(k);
    for(int i = (1<<m)-1; i >= 0; --i){
        if(i == k) continue;
        ans.push_back(i);
    }
    cout << ans[0];
    for(int i = 1; i < ans.size(); ++i){
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 4248
#include<bits/stdc++.h>
#define ll long long
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])
#define mod 1000000007
using namespace std;

int main(){
    boostUP;

    int rows,cols;
    cin >> rows  >> cols;

    char arr[rows+1][cols+1];
    vector< vector<int> > up(rows+1,vector<int>(cols+1,0));
    vector< vector<int> > left(rows+1,vector<int>(cols+1,0));

    vector< vector<int> > right(rows+2,vector<int>(cols+2,0));
    vector< vector<int> > down(rows+2,vector<int>(cols+2,0));
    for(int i = 1; i <= rows; i++){
        for(int j = 1; j <= cols; j++){
            cin >> arr[i][j];
        }
    }
    for(int i = 1; i <= rows; i++){
        for(int j = 1; j <= cols; j++){
            if(arr[i][j] == '.'){
                up[i][j] = up[i-1][j] + 1;
                left[i][j] = left[i][j-1] + 1;
            }
        }
    }
    for(int i = rows; i >=1; i--){
        for(int j = cols; j >= 1; j--){
            if(arr[i][j] == '.'){
                right[i][j] = right[i][j+1] + 1;
                down[i][j] = down[i+1][j] + 1;
            }
        }
    }
    int maxSquares = 0;
    for(int i = 1; i <= rows; i++){
        for(int j = 1; j <= cols; j++){
            maxSquares = max(maxSquares, (up[i][j] + down[i][j] + right[i][j] + left[i][j]) );
        }
    }
    cout << maxSquares-3 << "\n";
//    #..#..
//    .....#
//    ....#.
//    #.#...

}



Measured memory_bytes: 69948
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
#define lint long long
static const int INF = 1 << 22;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
/*******source code below********/
int main(void) {
	int N; cin >> N;
	int V[21];
	int C[21];
	int max = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> V[i];
 	}
	for (int i = 0; i < N; i++)
	{
		cin >> C[i];
	}
	for (int i = 0; i < N; i++)
	{
		if (V[i] > C[i]) max += V[i] - C[i];
	}
	cout << max << endl;
	
}

Measured memory_bytes: 256
n,m=[int(i) for i in input().split()]
keiro=[]
relay_point=set()
for i in range(m):
    a,b=[int(i) for i in input().split()]
    if(a==1):
        relay_point.add(b)
    else:
        keiro.append([a,b])

for i in keiro:
    if(i[0] in relay_point):
        if(i[1]==n):
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')



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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

ll luca(ll n){
    if(n==0) return 2;
    else if(n==1) return 1;
    else if(n>=2) return luca(n-1)+luca(n-2);
}

int main(void)
{
    ll n; cin>>n;
    vector<ll> l(n+1,0);
    l[0]=2,l[1]=1;
    for(int i=1;i<n;i++){
        l[i+1]=l[i]+l[i-1];
    }
    cout<<l[n]<<endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N - 1];
		int[] B = new int[N - 1];
		int[] degree = new int[N];
		Arrays.fill(degree, 0);
		
		for(int i = 0; i < N - 1; i++){
			A[i] = sc.nextInt() - 1;
			B[i] = sc.nextInt() - 1;
			degree[A[i]]++;
			degree[B[i]]++;
		}
		
		int max = -1;
		for(int i = 0; i < N - 1; i++){
			max = Math.max(degree[i], max);
		}
		System.out.println(max);

		ArrayList<ArrayList<Integer>> vertexes = new ArrayList<ArrayList<Integer>>();
		for(int i = 0; i < N; i++){
			ArrayList<Integer> v = new ArrayList<Integer>();
			vertexes.add(v);
		}
		
		for(int i = 0; i < N - 1; i++){
			vertexes.get(A[i]).add(B[i]);
			vertexes.get(B[i]).add(A[i]);
		}

		boolean[] seen = new boolean[N];
		Arrays.fill(seen, false);
		ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
		int[] color = new int[N];
		Arrays.fill(color, 0);
		
		Map<Integer, Map<Integer,Integer>> map = new HashMap<Integer, Map<Integer,Integer>>();
		
		queue.add(0);
		seen[0] = true;
		while(!queue.isEmpty()){
			int x = queue.poll();
			int c = color[x];
			map.put(x , new HashMap<Integer,Integer>());
			ArrayList<Integer> v = vertexes.get(x);
			for(int i = 0; i < v.size(); i++){
				if(!seen[v.get(i)]){
					queue.add(v.get(i));
					seen[v.get(i)] = true;
					c = (c + 1) % max;
					map.get(x).put(v.get(i), c);
					color[v.get(i)] = c;
				}
			}
		}
		for(int i = 0; i < N - 1; i++){
			System.out.println(map.get(A[i]).get(B[i]) + 1);
		}
	}
}

Measured memory_bytes: 108056
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  char c;
  cin >> c;
  cout << char(c + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
//ProblemE

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemE

class Solve {
private:
	auto get_cost(const vector<pair<int, char>>& p, const vector<int>& ib) {
		const int n = (int)ib.size();
		vector<vector<int>> rst(n, vector<int>(n + 1, 0));

		const char c = p[ib.front()].second;
		for (int i = 0; i < n; i++) {
			auto& b = rst[i];
			int cntb = 0;
			unordered_set<int> sw;
			for (int j = 0; j < ib[i]; j++) {
				if (p[j].second != c) {
					sw.insert(p[j].first);
				}
				else if (p[j].first > i) {
					cntb++;
				}
			}

			for (int j = 0; j <= n; j++) {
				b[j] = cntb + sw.size();
				sw.erase(j);
			}
		}
		return rst;
	}

	void solve() {
		int n;
		cin >> n;

		vector<pair<int, char>> p(2 * n);
		vector<int> ib(n);
		vector<int> iw(n);
		
		for (int i = 0; i < n * 2; i++) {
			cin >> p[i].second >> p[i].first;
			p[i].first--;
			if (p[i].second == 'W') iw[p[i].first] = i;
			else ib[p[i].first] = i;
		}

		auto cb = get_cost(p, ib);
		auto cw = get_cost(p, iw);

		//dp[i][j]: i bs and j ws
		vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
		
		dp[0][0] = 0;
		for (int j = 1; j <= n; j++) dp[0][j] = dp[0][j - 1] + cw[j - 1][0];
		for (int i = 1; i <= n; i++) {
			dp[i][0] = dp[i - 1][0] + cb[i - 1][0];
			for (int j = 1; j <= n; j++) {
				dp[i][j] = min(dp[i][j - 1] + cw[j - 1][i], dp[i - 1][j] + cb[i - 1][j]);
			}
		}

		int cnt = dp[n][n];

		cout << cnt << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 47360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll a,b,x;
cin>>a>>b>>x;
if(a==0)
{
    cout<<b/x+1;
}
else
{
    cout<<(b/x)-((a-1)/x);
}
return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long 
#define qaq() for(int i=1;i<=n;i++)
using namespace std;
string s;
int main() {
	cin>>s;
	if(s[0]==s[s.length()-1]) {
		if(s.length()%2==0) {
			cout<<"First"<<endl;
			return 0;
		} else {
			cout<<"Second"<<endl;
			return 0;
		}
	} else {
		if(s.length()%2==0) {
			cout<<"Second"<<endl;
			return 0;
		} else {
			cout<<"First"<<endl;
			return 0;
		}
	}
	return 0;
}

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

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


using namespace std;

const int MAXN = 1111 , MOD = 1e9 + 7  ;


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

    string s ;
    cin >> s ;
    int n = s.size() , ans = 0 ;
    for(int i = 1 ; i < n ; i ++ )
        ans += (s[i]!=s[i-1]);
    cout<<ans;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
#include <atcoder/fenwicktree>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
using namespace atcoder;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

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

lli gcd2(lli x, lli y)
{
    lli t;
    while (y != 0)
        t = x % y, x = y, y = t;
    return (x);
}

lli lcm2(lli x, lli y)
{
    lli xy = x * y;
    if (xy < 0)
        xy = -xy;
    return (xy / gcd2(x, y));
}

int main(void)
{
    int N, Q;
    cin >> N >> Q;
    fenwick_tree<long long> f(N);
    int a, b, c;
    long long x = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> x;
        f.add(i, x);
    }
    for (int i = 0; i < Q; i++)
    {
        cin >> a >> b >> c;
        if (a == 0)
        {
            f.add(b, c);
        }
        else
        {
            long long k = f.sum(b, c);
            cout << k << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8236