akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int w,h;

bool check(int h1,int w1,int h2,int w2) {
    return (h1*h1+w1*w1 == h2*h2+w2*w2?h1<h2:h1*h1+w1*w1 < h2*h2+w2*w2);
}

void solve() {
    int ansH,ansW;
    ansH=ansW=1000;
    for(int i=1;i<200;i++) {
        for(int j=i+1;j<200;j++) {
            if(check(h,w,i,j) && check(i,j,ansH,ansW)) {
                ansH=i;
                ansW=j;
            }
        }
    }
    cout<<ansH<<" "<<ansW<<endl;

}

int main() {
    while(cin>>h>>w) {
        if(h+w==0) return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void) {
int c1, c5, c10, c50, c100, c500, sum, ryogae;
scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
sum = 1 * c1 + 5 * c5 +10 * c10 + 50 * c50 + 100 * c100 + 500 * c500;
if(sum >= 1000)
   ryogae = 1;
else
   ryogae = 0;
printf("%d\n",ryogae);
return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A1 = getint();
	int B = getint();
	A1 -= B;
	int A2 = A1 - 1;
	ll H[100000];
	rep(i, N) *(H + i) = getint();

	int L = 0, R = 1e9;

	while (L + 1 != R) {
		ll half = (L + R) / 2;
		ll damage = B * half;
		ll cnt = 0;
		rep(i, N) {
			ll kari = (*(H + i) - damage + A2) / A1;
			if (kari > 0) {
				cnt += kari;
			}
		}
		if (half >= cnt) R = half;
		else L = half;
	}

	co(R);

	Would you please return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long n = in.nextLong();
    long x = in.nextLong();
    long t = in.nextLong();
    long temp = (long) Math.ceil((double) n/x);
    System.out.println(temp*t);
    in.close();
  }
}


Measured memory_bytes: 35876
#include<stdio.h>
int main(){
    long int n;
    scanf("%ld",&n);
    unsigned long int fb[n+1];
    for(long int i=1;i<=n;i++) {
        fb[i]=i;
    }
    for (long int i=1;i<=n;i++) {
        if (i%3==0||i%5==0) {
            fb[i]=0;
        }
    }
    unsigned long int s=0;
    for (long int i=1;i<=n;i++) {
        s+=fb[i];
    }
    printf("%lu",s);
    return 0;

}

Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(i,a,b) for(ll i=a;i>=b;i--)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9+7;
const ll N=2e18 + 5;

ll power(ll a,ll b,ll p)
{
    a=a%p;
    ll ans=1;
    while(b>0)
    {
        if(b%2==1)
        {
            ans=(ans*a)%p;
        }
        b=b/2;
        a=(a*a)%p;
    }
    return ans;
}

 
int main()
{
    fast;
    ll n;
    cin>>n;
    ll g=(n/500)*1000;
    n -= (n/500)*500;
    g += (n/5)*5;
    cout<<g;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        
        int N=sc.nextInt();
        int A=sc.nextInt();
        int B=sc.nextInt();
        
        int ans=0;
        
        int sum;
        for(int i=1;i<=N;i++){
            sum=(i/10000)+(i/1000%10)+(i/100%10)+(i/10%10)+(i%10);
            if(A<=sum&&sum<=B){
                ans+=i;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005

#define bs binary_search
#define lb lower_bound
#define ub upper_bound

lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli r,g,b;
    cin>>r>>g>>b;
    lli ans=r*100+g*10+b;
    if(ans%4)
    {
        cout<<"NO";
    }
    else
    {
        cout<<"YES";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
#include<map>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define next(i,n)  ((i+1)%n)
const double eps = 1e-10;
typedef complex<double>P;
typedef vector<P> Polygon;

namespace std{
  bool operator==(P &a,P &b){
    return abs(a-b)<eps;
  }
}

bool is_point_online(P a,P b,P c){
  return abs(a-c)+abs(b-c)<abs(a-b)+eps;
}

bool is_adjacent(Polygon &a,Polygon &b){
  rep(i,a.size()){
    rep(j,b.size()){
      bool a0=false,a1=false,b0=false,b1=false;
      a0=is_point_online(b[j],b[next(j,b.size())],a[i]);
      a1=is_point_online(b[j],b[next(j,b.size())],a[next(i,a.size())]);
      b0=is_point_online(a[i],a[next(i,a.size())],b[j]);
      b1=is_point_online(a[i],a[next(i,a.size())],b[next(j,b.size())]);
      if ( a0&&a1)return true;
      else if (b0&&b1)return true;
      else if ( (a0&&b0&&a[i]!=b[j])||(a0&&b1&&a[i]!=b[next(j,b.size())])||
		(a1&&b0&&a[next(i,a.size())]!=b[j])||(a1&&b1&&a[next(i,a.size())]!=b[next(j,b.size())])){
	return true;
      }

    }
  }
  return false;
}

bool judge(vector<Polygon> &a,vector<Polygon> &b){
  rep(i,a.size()){
    rep(j,b.size()){
      if (is_adjacent(a[i],b[j]))return true;
    }
  }
  return false;
}

void make_graph(vector<int> *edge,vector<Polygon> *in,int n){
  rep(i,n){
    REP(j,i+1,n){
      if ( judge(in[i],in[j]))edge[i].push_back(j),edge[j].push_back(i);
    }
  }

}


int ans;
void dfs(int now,int n,int tmp,vector<int> *edge,int *color,bool *used){
  if ( tmp > ans)return;
  if (now == n){
    
    ans=min(ans,tmp);
    return ;
  }
  
  for(int i=now;i>=0;i--){
    bool flag=true;
    rep(j,edge[now].size()){
      if(color[edge[now][j]]==i){flag=false;break;}
    }
    if ( flag== true){
      bool tmpused=used[i];
      int next=used[i]==false?1:0;
      color[now]=i;
      used[i]=true;
      dfs(now+1,n,tmp+next,edge,color,used);
      used[i]=tmpused;
      color[now]=-1;
    }
  }
}

main(){
  int n;
  while(cin>> n && n){
    ans=10;
    vector<Polygon> in[10];
    vector<int> edge[10];
    bool used[10]={false};
    int color[10];
    map<string,int> M;
    rep(i,n){
      string name;
      getline(cin,name);
      getline(cin,name);
      if (M.find(name)==M.end()){int index=M.size();M[name]=index;color[index]=-1;}
      int index=M[name];
      Polygon tmp;
      P ins;
      while(cin>>ins.real() && ins.real()!=-1){
	cin>>ins.imag();
	tmp.push_back(ins);
      }
      in[index].push_back(tmp);
    }
    make_graph(edge,in,M.size());
    dfs(0,M.size(),0,edge,color,used);
    cout << ans << endl;
    /*
    rep(i,M.size()){
      cout << "From " << i ;
      rep(j,edge[i].size())cout << " " << edge[i][j];
      cout << endl;
    }
    */

  }
  return false;
}

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int N;
	cin>>N;
    typedef pair<int,int> P;
    vector<int> l(N+1);

    vector<vector<P>> vw(N+1);

    rep(i,N-1){
        int u,v,w;
        cin>>u>>v>>w;
        vw[u].push_back(P{v,w});
        vw[v].push_back(P{u,w});
    }

    queue<int> q;
    q.push(1);
    vector<int> ans(N+1);

    while(!q.empty()){
        int u = q.front();q.pop();
        for(auto p:vw[u]){
            int v = p.first;
            int w = p.second;
            if(l[v]==0){
                l[v]= (l[u]+w)%2+2;
                ans[v] = l[v]%2;
                q.push(v);
            }
        }
    }
    for(int i=1;i<=N;i++){
        cout<<ans[i]<<"\n";
    }

    return 0;
}


Measured memory_bytes: 7168
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		String Nlen = Integer.toString(N);
		
		int kijyun = N / 100;

		for(int i = 0;i < Nlen.length() -1 ;i++){
			int tmp = N % 10;
			if(tmp <= kijyun){
			}else{
				kijyun ++;
				System.out.println(Integer.toString(kijyun) + Integer.toString(kijyun) + Integer.toString(kijyun) );
		   		sc.close();
				return;
			}
			N = N / 10;
		} 

		System.out.println(Integer.toString(kijyun) + Integer.toString(kijyun) + Integer.toString(kijyun) );

   		sc.close();
        return ;

    }
    
}



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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(ALL(a));
  int ans=a[2]*10+a[1]+a[0];
  cout << ans << endl;
}


Measured memory_bytes: 256
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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 (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\,
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<=s.size();i++){
        for(int j=0;j<=s.size();j++){
            string sub = s.substr(i,j);
            // cout << sub << endl;
            for(int k=0;k<sub.size();k++){
                if(sub.at(k) != 'A'&& sub.at(k) != 'C' && sub.at(k) != 'G' && sub.at(k) != 'T'){
                    break;
                }else{
                    ans = max(ans,k+1);
                }

            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3660
#include<stdio.h>
#define N 500004

int h[N], n;

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}   


void maxheapify(i){
  int largest=0,tmp;
  int l,r;
  l = left(i);
  r = right(i);
  if(l <= n && h[l] > h[i]){
    largest = l;
  }
  else
    largest = i;
  if(r <= n && h[r] > h[largest]){
    largest = r;
  }
  if(largest != i){
    tmp = h[i];
    h[i] = h[largest];
    h[largest] = tmp;
    maxheapify(largest);
  }
}

void buildmaxheap(){
  int i;
  for(i = n/2; i>0; i--){
    maxheapify(i);
  }
}    
  

main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&h[i]);
//    if(h[i]<0)printf("[%d]\n",h[i]);
  }
  buildmaxheap();
  for(i=1;i<n+1;i++){
    printf(" %d",h[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
# 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    ans = 0
    i, j = 0, 1
    while j <= i + (n - i) // 2:
        if j <= i:
            j += 1
            continue
        t = s[i:j]
        if t in s[j:]:
            ans = max(ans, j - i)
            j += 1
        else:
            i += 1
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define M 200005
#define INF 0x3f3f3f3f
#define set(a,v) memset(a,v,sizeof(a))
int n,m,a[N],dst[N];bool ext[N],vs[N],fl[N];
int cntE,hd[N];struct Edge {int v,w,nxt;}e[M<<1];
void addE(int u,int v,int w)
{
	e[++cntE]=(Edge) {v,w,hd[u]};
	hd[u]=cntE;
}
bool SPFA(int u)
{
	vs[u]=fl[u]=1;
	for(int i=hd[u],v,w;~i;i=e[i].nxt)
	{
		v=e[i].v;
		w=e[i].w;
		if(dst[u]+w<dst[v])
		{
			if(vs[v]) return 0;
			dst[v]=dst[u]+w;
			if(!SPFA(v)) return 0;
		}
	}
	vs[u]=0;
	return 1;
}
int main()
{
	set(hd,-1);
	scanf("%d %d",&n,&m);
	for(int i=1,F[3];i<=m;++i)
	{
		scanf("%d %d %d",&F[0],&F[1],&F[2]);
		ext[F[0]]=ext[F[1]]=1;
		addE(F[0],F[1],F[2]);
		addE(F[1],F[0],-F[2]);
	}
	for(int i=1;i<=n;++i)
		if(ext[i] && !fl[i])
		{
			set(dst,INF);
			dst[i]=0;
			if(!SPFA(i))
			{
				puts("No");
				return 0;
			}
		}
	puts("Yes");
	return 0;
}

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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	string s,t;
	cin>>s;
	cin>>t;

	vector<vector<int> > dp(t.size()+1,vector<int> (s.size()+1,0));
	for(int i=1;i<=t.size();i++)
	{
		for(int j=1;j<=s.size();j++)
		{
			if(t[i-1]==s[j-1])
			{
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}

	string str;
	int i=t.size(),j=s.size();

	while(dp[i][j]!=0)
	{
		if(t[i-1]==s[j-1])
		{
			str.push_back(t[i-1]);
			i--;
			j--;
		}
		else{
			if(dp[i-1][j]<dp[i][j-1])
				j--;
			else i--;
		}
	}

	reverse(str.begin(),str.end());
	cout<<str<<"\n";

	return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
using namespace std;
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 (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int a,b,c,d;
    cin >> a>> b >> c >>d;
    int time = 0;
    for(int i=a; i<b; ++i) {
        if (i>=c && i<d) time++;
    }
    cout << time << "\n";
}


Measured memory_bytes: 256
/*
TASK: AGC143 - D - Triangles
LANG: C++
NAME: picolylamine
*/
#define _CRT_SECURE_NO_WARNINGS
#define N_MAX 2000

#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	//ソートして順に舐める。O(N^2logN)でいいのか？

	int N, L[N_MAX];
	scanf("%d", &N);
	for (int i = 0; i < N; i++){
		scanf("%d", L + i);
	}

	sort(L, L + N);

	int ret = 0;
	for (int i = 0; i < N; i++){
		for (int j = i+1; j < N; j++){
			int c_min = L[j] - L[i] + 1;
			int c_max = L[j] + L[i] - 1;
			ret += lower_bound(L + j + 1, L + N, c_max + 1) - lower_bound(L + j + 1, L + N, c_min - 1);
		}
	}

	printf("%d", ret);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n, A, B, C, l[10];

int solve(int bit, int X){
	vi cand;
	int res=1e9;
	REP(i, n){
		if(bit>>i&1){
			cand.push_back(l[i]);
		}
	}
	vi cand2;
	int sz=cand.size();
	FOR(i, 1, 1<<sz){
		int tmp=0;
		REP(j, sz){
			if(i>>j&1){
				tmp+=cand[j];
			}
		}
		int mp=10*(sz-1);
		CHMIN(res, mp+abs(tmp-X));
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>A>>B>>C;
	REP(i, n){
		cin>>l[i];
	}
	sort(l, l+n);
	int ans=1e9;
	bool ok=false;
	FOR(i, 1, 1<<n){
		FOR(j, 1, 1<<n){
			FOR(k, 1, 1<<n){
				if(i&j || j&k || k&i){
					continue;
				}
				CHMIN(ans, solve(i, A)+solve(j, B)+solve(k, C));
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b)){
    cout<<"A"<<endl;
  }else{
    cout<<"B"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n, arr[3001], dp[3001][3001], ans, dif, sum=0;
bool vis[3001][3001];

long long solve(long long i, long long j){
	if(vis[i][j]){
		return dp[i][j];
	}
	if(i==j){
		return dp[i][j]=arr[i];
	}
	if(i>j){
		return dp[i][j]=0;
	}
	vis[i][j]=1;
	long long d=arr[i]+min(solve(i+2, j), solve(i+1, j-1));
	long long b=arr[j]+min(solve(i, j-2), solve(i+1, j-1));
	return dp[i][j]=max(d, b);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> arr[i];
		sum+=arr[i];
	}
	long long x, y;
	x=solve(0, n-1);
	y=sum-x;
	cout << x-y << endl;

}

Measured memory_bytes: 78464
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b
     
N = int(input())
A = [ int(v) for v in input().split() ]
    
if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()
     
l_list = [0]
r_list = [0]
j = -1
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i],  A[j]) )
    j -= 1

j = -2
mymax = 1   
for i in range(0, N):
    tmp = GCD(l_list[i], r_list[j])
    if tmp > mymax: mymax = tmp 
    j -= 1
print(mymax)

Measured memory_bytes: 14428
import sys
from collections import deque

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

dy = [-1,0,1,0]
dx = [0,-1,0,1]

Y, X = [int(s) for s in input().split()]
sy, sx = [0, 0]
gy, gx = [Y-1, X-1]

M = []

for i in range(Y):
	M.append([s for s in input().rstrip()]) 

dist = [[[-1,-1,-1] for _ in range(X)] for _ in range(Y)]
queue = deque()

dist[sy][sx] = [0,0,0]
queue.append([sy, sx])

while queue:
	y, x = queue.popleft()
	#print(y,x)
	
	for i in range(4):
		ny = y+dy[i]
		nx = x+dx[i]
		
		if ny>=Y or ny<0 or nx>=X or nx<0: continue
		if dist[ny][nx][0] != -1: continue
		
		if M[ny][nx] == '.':
			dist[ny][nx] = [dist[y][x][0]+1,y,x]
			queue.append([ny, nx])

#print(dist[gy][gx][0])

walls = 0
for i in range(Y):
	for j in range(X):
		if M[i][j] == '#': walls += 1

if dist[gy][gx][0] != -1:
	print(Y*X-(dist[gy][gx][0]+1)-walls)
else:
	print(-1)

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

int main()
{
    double x1, x2, y1, y2, dx, dy, distance;
    cin >> x1 >> y1 >> x2 >> y2;
    dx = x2 - x1;
    dy = y2 - y1;
    distance = sqrt(dx * dx + dy * dy);
    printf("%10.8f\n", distance);
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N, A, B;
	cin >> N >> A >> B;

	co(min(N * A, B));


	Would you please return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x,k,i,j,count=0;
 

  while(1){
    scanf("%d %d",&n,&x);
    if(n == 0&& x == 0)break;
    for(i = 1;i <= n-2;i++){
      for(j = i+1;j <= n-1;j++){
	for(k = j+1;k <= n;k++){
	  if(x == i+j+k){
	    count++;
	  }
	}
      }
      }
    printf("%d\n",count);
    count = 0;
  }
  return 0;
}



Measured memory_bytes: 2044
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    max_a = max(A)
    min_a = min(A)

    max_i = A.index(max_a)
    min_i = A.index(min_a)

    ans = []
    if abs(max_a) >= abs(min_a):
        while A[0] < max_a:
            A[0] += max_a
            ans.append([max_i, 0])

        for i in range(N-1):
            while A[i+1] < A[i]:
                A[i+1] += A[i]
                ans.append([i, i+1])
    else:
        while A[N-1] > min_a:
            A[N-1] += min_a
            ans.append([min_i, N-1])

        for i in range(N-1, 0, -1):
            while A[i-1] > A[i]:
                A[i-1] += A[i]
                ans.append([i, i-1])

    print(len(ans))
    for a in ans:
        print(a[0]+1, a[1]+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>


using namespace std;

int main(){
	int N, A[100002], i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++){
		scanf(" %d", &A[i]);
	}
	A[0] = 0, A[100001] = 0;
	int total, ans;
	for (i = 1; i <= N; i++){
		total += abs(A[i] - A[i - 1]);
	}
	total += abs(A[N]);

	for (i = 1; i <= N; i++){
		ans = total - abs(A[i] - A[i - 1]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]);
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 1536
a = list(map(int,input().split()))

rb = a[1] + a[2]
n = a[0] // rb
n = n * a[1]
m = a[0] % rb
if m > a[1]:
  l = a[1]
else:
  l = m

#print(l)
#print(n)
print(n+l)

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

const int N = 201001;

int n, m, a[N][2], b[N];
char s[N];
vector<int> g[N];
queue<int> q;

int main(void) {
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  for(int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    a[u][s[v] - 'A']++;
    a[v][s[u] - 'A']++;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for(int i = 1; i <= n; i++)
    if(!a[i][0] || !a[i][1])
      q.push(i), b[i] = 1;
  while(!q.empty()) {
    int x = q.front(); q.pop();
    for(auto v : g[x])
      if(!b[v] && !--a[v][s[x] - 'A'])
	q.push(v), b[v] = 1;
  }
  for(int i = 1; i <= n; i++)
    if(!b[i]) return puts("Yes"), 0;
  return puts("No"), 0;
}


Measured memory_bytes: 13184
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#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 <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;
// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
int N,M; cin >> N >> M;
cout << (N * ( N - 1)/ 2 + M * (M - 1) / 2) << endl;
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main() {
	int n, k, d, cnt = 0;
	cin >> n >> k;
	int a[100];
	for (int i = 0; i < 100; i++) {
		a[i] = 0;
	}

	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			int x;
			cin >> x;
			if (a[x - 1] != 1) {
				a[x - 1] = 1;
				cnt++;
			}
		}
	}
	cout << n - cnt << endl;
	return 0;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

#include<atcoder/all>
using namespace atcoder;

constexpr ll MOD = 998244353;

using mint = modint998244353;

vector<mint> pows;

struct S {
    mint a;
    mint size;
};

struct F {
    mint a, b;
};

S op(S l, S r) { return S{pows[r.size.val()]*l.a + r.a, l.size + r.size}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { return S{r.a * l.a + (pows[r.size.val()]-1)*443664157 * l.b, r.size}; }

F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }

F id() { return F{1, 0}; }

int main(void) {
    pows = vector<mint>(300000, 1);
    for(ll i=0; i<300000; i++)
        pows[i+1] = pows[i] * 10;

    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n, q;
    cin >> n >> q;

    vector<S> a(n, S{1,1});
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    while(q--) {
        ll l, r, d;
        cin >> l >> r >> d;
        l--, r--;

        seg.apply(l, r+1, F{0, d});
        cout << seg.all_prod().a.val() << endl;
    }


}

Measured memory_bytes: 12168
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define MOD 1000000007

int main(int argc, char const *argv[]) {
  long a,b,x;
  cin >> a >> b >> x;
  long w1;
  w1 = ((a-1) - (a-1) % x) / x;
  long w2;
  w2 = (b - b % x) / x;
  if(a == 0){
    cout << w2 + 1 << endl;
  }else{
    cout << w2 - w1 << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String regex = "7";
    Pattern p = Pattern.compile(regex);

    check(p, s);
  }

  private static void check(Pattern pattern, String target){
    Matcher matcher = pattern.matcher(target);
    if (matcher.find())
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}


Measured memory_bytes: 35716
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i,j,n,R[200000],minv,maxv;

  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
    if(R[i]<1 || R[i]>1000000000){
      exit(8);
    }
  }

  maxv=R[1]-R[0];
  minv=R[0];

  for(j=1;j<n;j++){
    if(maxv<R[j]-minv){
      maxv=R[j]-minv;
    }else if(maxv>R[j]-minv){
      maxv=maxv;
    }

    if(minv>R[j]){
      minv=R[j];
    }else if(minv<R[j]){
      minv=minv;
    }
  } 

  printf("%d\n",maxv);

  return 0;
}

Measured memory_bytes: 1376
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
const double pi = 3.14159265359;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b, c;

int main()
{
	cin >> a >> b >> c;
	for (int i = 1;i <= 1000000;i++) {
		if (i % a == 0 && i % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}

	cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
/*
 *
 * Author: r3gz3n
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */

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

template <class T=int> using order_statistics = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
const int MAX = 1e5 + 5;
int dp[MAX][3];

int main(int argc, char* argv[]) {
    if(argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
    if(argc == 3) freopen(argv[2], "w", stdout);
    int n;
    int a[3];
    cin >> n;
    cin >> a[0] >> a[1] >> a[2];
    dp[0][0] = a[0];
    dp[0][1] = a[1];
    dp[0][2] = a[2];
    for(int i = 1;i < n;++i) {
        cin >> a[0] >> a[1] >> a[2];
        for (int j = 0;j < 3;++j) {
            dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + a[j];
        }
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using   namespace   std;
int main()
{
    int i,j,k;
    scanf("%d",&k);
    if(k==22)
        printf("Christmas Eve Eve Eve\n");
    else
    if(k==23)
        printf("Christmas Eve Eve\n");
    else
    if(k==24)
        printf("Christmas Eve\n");
    if(k==25)
        printf("Christmas\n");
    return  0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		s = s.replaceAll("/","");
		Integer temp = Integer.parseInt(s);
		Integer a = Integer.parseInt("20190430");

		if(temp.compareTo(a) <= 0) {
			System.out.println("Heisei");
		}else {
			System.out.println("TBD");
		}

	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define dbprint(s) {cout<<"db:"<<s<<endl;}
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){

  int N,M;
  cin >> N >> M;
  vector<int> A(M);
  rep(i,M) cin >> A[i];
  bool flag = false;
  rep(i,M) {
    N -= A[i];
    if (N < 0) {
      flag = true;
      break;
    }
  }
  if (!flag) {
    cout << N << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N=1e5+5;
int n,m;
VI adj[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    REP(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        adj[a].PB(b);
        adj[b].PB(a);
    }
    VI vis(n),ans(n,-1);
    vis[0]=1;
    queue<PII> q;
    q.emplace(0,0);
    while ( q.size() ) {
        int u=q.front().first;
        int p=q.front().second;
        q.pop();
        ans[u]=p;
        for ( auto v:adj[u] ) {
            if ( vis[v] ) {
                continue;
            }
            q.emplace(v,u);
            vis[v]=1;
        }
    }
    bool ok=true;
    for ( int i=1; i<n; i++ ) {
        if ( ans[i]==-1 ) {
            ok=false;
            break;
        } 
    }
    if ( !ok ) {
        cout << "No" << '\n';
    }
    else {
        cout << "Yes" << '\n';
        for ( int i=1; i<n; i++ ) {
            cout << ans[i]+1 << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 10784
if __name__ == '__main__':
    nk = input()
    nk = nk.split()
    n = int(nk[0])
    k = int(nk[1])

    d = []
    A = []

    for i in range(k):
        d_element = input()
        d_element = int(d_element)
        d.append(d_element)
        A_element = input()
        A_element = A_element.split()
        A_element = list(map(int,A_element))
        A.append(A_element)

    s = set()
    for i in range(len(A)):
        for j in range(len(A[i])):
            s.add(A[i][j])

    ans = n - len(s)
    print(ans)


Measured memory_bytes: 9208
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n, m, k;
set <int> bl[mn], fr[mn];
int root[mn], sz[mn];
int getroot(int u)
{
    if (u==root[u]) return u;
    return root[u]=getroot(root[u]);
}

void mergeroot(int u, int v)
{
    if (getroot(u)==getroot(v)) return;
    sz[getroot(u)]+=sz[getroot(v)];
    root[getroot(v)]=getroot(u);
}

// main solution goes here:
void execute(int test_number)
{
    cin>>n>>m>>k;
    for (int i=0; i<=n; i++) root[i]=i, sz[i]=1;
    int u, v;
    for (int i=1; i<=m; i++)
    {
        cin>>u>>v;
        fr[u].insert(v);
        fr[v].insert(u);
        mergeroot(u, v);
    }
    for (int i=1; i<=k; i++)
    {
        cin>>u>>v;
        if (getroot(u)==getroot(v)) bl[u].insert(v);
        if (getroot(u)==getroot(v)) bl[v].insert(u);
    }

    // cerr<<"got here!\n";
    // for (int i=1; i<=n; i++) cerr<<getroot(i)<<" "<<sz[getroot(i)]<<"\n";

    for (int i=1; i<=n; i++) cout<<sz[getroot(i)]-(int)fr[i].size()-(int)bl[i].size()-1<<" ";

}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/


Measured memory_bytes: 41344
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

long long dp[22][1 << 21] = {0};
int main() {
  long long P = 1000000007;
  int n;
  cin >> n;
  vector<vector<long long>> a(n);
  for (int i = 0; i < n; i++) {
    a[i].resize(n);
    for (int j = 0; j < n; j++)
      cin >> a[i][j];
  }
  long long bit = 1 << n;
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < bit; j++) {
      if (!dp[i][j])
        continue;
      for (int k = 0; k < n; k++) {
        if (!((j >> k) & 1) && a[i][k]) {
          dp[i + 1][j | (1 << k)] += dp[i][j];
          dp[i + 1][j | (1 << k)] %= P;
        }
      }
    }
  }
  cout << dp[n][bit - 1] << endl;
  return 0;
}


Measured memory_bytes: 309504
package main

import (
	"fmt"
	"math"
)

func digit(m int, def int) int {
	for m >= 10 {
		m /= 10
		def++
	}
	return def
}

func main() {
	var N, cnt int
	fmt.Scan(&N)

	var combi [10][10]int
	for i := 1; i <= N; i++ {
		A := i % 10
		B := i / int(
			math.Pow(
				float64(10),
				float64(digit(i, 0)),
			),
		)
		combi[A][B]++
	}
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			cnt += combi[i][j] * combi[j][i]
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.reverse()
ans = []
flag = False
for i in range(len(a) - 1):
    if flag == 1:
        flag = -1
        continue
    if a[i] == a[i+1]:
        ans.append(a[i])
        if flag == -1:
            break
        flag = 1
if len(ans) == 2:
    print(ans[0] * ans[1])
else:
    print(0)

Measured memory_bytes: 62704
import io.StdIn.readLine
object Main extends App {
  val Array(n, m) = readLine.split(" ").map(_.toInt)
  val (as, bs) = List.fill(m)(readLine.split(" ").map(_.toInt) match {
    case Array(a, b) => (a, b)
  }).unzip
  val rs = (as ++ bs).groupBy(identity)
  for (i <- 1 to n) println(rs.getOrElse(i, Nil).size)
}


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

int W,H;
int inf = 1e9;
int dx[4] = {0,-1,0,1},dy[4] = {1,0,-1,0};
int dp[31][31][4] = {};
int S[31][31] = {};
int C[4] = {};

struct state{
    int x,y,direction,dist;
    bool operator<(const state& right)const{
        return dist > right.dist;
    }
    void go(){
        x += dx[direction];
        y += dy[direction];
    }
    void turn_right(){
        direction--;
        (direction += 4)%=4;
        x += dx[direction];
        y += dy[direction];
    }
    void turn_back(){
        (direction += 2)%=4;
        x += dx[direction];
        y += dy[direction];
    }
    void turn_left(){
        direction++;
        direction %= 4;
        x += dx[direction];
        y += dy[direction];
    }
    void instruction(int i){
        if(i==0) go();
        if(i==1) turn_right();
        if(i==2) turn_back();
        if(i==3) turn_left();
    }
    bool in(){
        return 1<=x && x<=H && 1<=y && y<=W;
    }
};

int main(){
    while(cin >> W >> H && W>0){
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                cin >> S[i][j];
                for(int k=0;k<4;k++) dp[i][j][k] = inf;
            }
        }
        for(int i=0;i<4;i++) cin >> C[i];
        dp[1][1][0] = 0;
        priority_queue<state> Q;
        state init = {1,1,0,0};
        Q.push(init);
        while(!Q.empty()){
            state now = Q.top(); Q.pop();
            if(dp[now.x][now.y][now.direction]<now.dist) continue;
            for(int i=0;i<4;i++){
                state ne = now;
                ne.instruction(i);
                int c = now.dist+C[i]*(i!=S[now.x][now.y]);
                if(!ne.in()) continue;
                if(dp[ne.x][ne.y][ne.direction]>c){
                    dp[ne.x][ne.y][ne.direction] = c;
                    ne.dist = c;
                    Q.push(ne);
                }
            }
        }
        int ans = inf;
        for(int i=0;i<4;i++) ans = min(ans,dp[H][W][i]);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3244
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto nq = readints();
    int n = nq[0], q = nq[1];
    for (int i = 0; i < q; i++) {
        auto xs = readints();

        if (xs[0] == 0) {
            int s = xs[1];
            int t = xs[2];
            int x = xs[3];
            add(s, t + 1, x, 0, 0, N / 2);
        }
        else {
            int s = xs[1];
            int v = sum(s, s + 1, 0, 0, N / 2);
            writeln(v);
        }
    }
}

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

const int N = 1 << 18; // ???????????°

int[N * 2] _data;
int[N * 2] _datb;

/// [a, b) ??? x ???????????????
/// k ????????????????????§????????? [l, r) ???????????????
void add(int a, int b, int x, int k, int l, int r) {
    if (a <= l && r <= b) {
        _data[k] += x;
    }
    else if (l < b && a < r) {
        _datb[k] += (min(b, r) - max(a, l)) * x;
        add(a, b, x, k * 2 + 1, l, (l + r) / 2);
        add(a, b, x, k * 2 + 2, (l + r) / 2, r);
    }
}

/// [a, b) ??????????±???????
/// k ????????????????????§????????? [l, r) ???????????????]
int sum(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a)
        return 0;

    if (a <= l && r <= b)
        return _data[k] * (r - l) + _datb[k];

    int ret = (min(b, r) - max(a, l)) * _data[k];
    ret += sum(a, b, k * 2 + 1, l, (l + r) / 2);
    ret += sum(a, b, k * 2 + 2, (l + r) / 2, r);
    return ret;
}

Measured memory_bytes: 7256
al = [i for i in "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"]
dic = {i:j for i,j in zip("ABCDEFGHIJKLMNOPQRSTUVWXYZ",range(26))}
n = int(input())
s = input()
ans = ""
for i in range(len(s)):
  ans += al[dic[s[i]]+n]
print(ans)
  

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

int main()
{
  int k,n,min;
  cin >> k >> n;
  vector<int> a(n);
  vector<int> distance(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
  }
  
  for(int i = 0;i < n;++i){
    int clockwise = 0,counterclockwise = 0;
    
    if(i == 0){
      clockwise = a.at(n-1) - a.at(0);
      counterclockwise = k - (a.at(1) - a.at(0));
    }
    else if(i != (n-1)){
      clockwise = k - (a.at(i) - a.at(i-1));
      counterclockwise = k - (a.at(i+1) - a.at(i));
    }
    else if(i == (n-1)){
      clockwise = k - (a.at(n-1) - a.at(n-2));
      counterclockwise = a.at(n-1) - a.at(0);
    }
    if(clockwise >= counterclockwise){
      distance.at(i) = counterclockwise;
    }
    else{
      distance.at(i) = clockwise;
    }
  }
  
  min = distance.at(0);
  for(int i = 1;i < n;i++){
    if(min > distance.at(i)){
      min = distance.at(i);
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=2e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/
int n,flg,cnt;
char s[N];
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	n=read();
	cin>>s+1;
	int i=1,j=n; 
		while(i<=j){
//			bug(i); 
			while(s[i]!='W'&&i<=n) ++i; 
			while(s[j]!='R'&&j>=1) --j;
			if(s[i]=='W'&&s[j]=='R'&&i<=j) ++cnt,++i,--j; 
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 3784