akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;

  int favorites = 0;

  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;

    int bits = 0;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      bits |= (1 << A);
    }

    if (i == 0) {
      favorites |= bits;
    } else {
      favorites &= bits;
    }
  }

  cout << bitset<31>(favorites).count() << endl;
}

Measured memory_bytes: 256
# LDS1_5_A

def solve(target, sum, idx, arr)
  return true if sum == target
  return false if sum > target || idx >= arr.size

  solve(target, sum + arr[idx], idx + 1, arr) ||
    solve(target, sum, idx + 1, arr)
end

_n = gets.to_i
nums = gets.split.map(&:to_i).reverse
_q = gets.to_i
targets = gets.split.map(&:to_i)

targets.each do |target|
  puts solve(target, 0, 0, nums) ? 'yes' : 'no'
end



Measured memory_bytes: 8888
import std.stdio;
import std.string;
import std.conv;
import std.ascii;
import std.algorithm;


void main()
{
    foreach (_; 0..readln.chomp.to!int) {
        auto script = readln;
        auto keys   = script.split.filter!(str => str.length == 4);
    loop:
        foreach (a; [0, 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25]) {
            foreach (b; 0..26) {
                foreach (key; keys) {
                    string decoded = key.decrypt(a, b);
                    if (decoded == "this" || decoded == "that") {
                        script.decrypt(a, b).write;
                        break loop;
                    }
                }
            }
        }
    }
}


string decrypt(string input, int a, int b)
{
    string output;
    
    foreach (c; input) {
        output ~= isAlpha(c) ? ((c - 'a') * a + b) % 26 + 'a' : c;
    }

    return output;
}

Measured memory_bytes: 1232
fun main() {
    var (a, b, c, k) = readLine()!!.split(" ").map{ it.toInt() }
    var sum = 0
    for(i in 1..k) {
        if(a > 0) {
            sum += 1
            a -= 1
            continue
        }
        if(b > 0) {
            sum += 0
            b -= 1
            continue
        }
        if(c > 0) {
            sum -= 1
            c -= 1
        }
    }
    println(sum)
}


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

#define int long long
int gA, sA, bA, gB, sB, bB;

int solve(int mon) {
	int dp[mon + 1] = {};
	dp[0] = 0;
	for (int i = 1; i <= mon; i++) {
		dp[i] = dp[i - 1] + 1;
		if (i >= gA)
			dp[i] = max(dp[i], dp[i - gA] + gB);
		if (i >= bA)
			dp[i] = max(dp[i], dp[i - bA] + bB);
		if (i >= sA)
			dp[i] = max(dp[i], dp[i - sA] + sB);
	}
	return dp[mon];
}

int32_t main() {
	int n;
	cin >> n;
	cin >> gA >> sA >> bA >> gB >> sB >> bB;
	int m = solve(n);
	swap(gA, gB), swap(sA, sB), swap(bA, bB);
	cout << solve(m);
}


Measured memory_bytes: 195584
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define REPE(i,a,b) for(int i=(a); i<=(b); i++)
int hd[100007], to[400007], nxt[400007], en;
inline void adde(int a, int b) {
	nxt[en]=hd[a]; hd[a]=en; to[en]=b; en++;
}
queue<int> q;
bool vis[100007]; int fa[100007];
inline void bfs(int x) {
	q.push(x);
	memset(vis,0,sizeof vis); vis[1]=1;
	while(!q.empty()) {
		int now=q.front(); q.pop();
		for(int i=hd[now]; ~i; i=nxt[i]) if(!vis[to[i]]){
			int t=to[i];
			vis[t]=1;
			fa[t]=now;
			q.push(t);
		}
	}
}
int main() {
	int n,m; scanf("%d%d", &n, &m);
	en=0;
	memset(hd,-1,sizeof hd);
	while(0<m--) {
		int a,b; scanf("%d%d", &a, &b);
		adde(a,b); adde(b,a);
	}
	bfs(1);
	puts("Yes");
	REPE(i,2,n) {
		printf("%d\n", fa[i]);
	}
}


Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int x,a,b;
  cin  >> x >> a >> b;
  cout << (abs(x-a) < abs(x-b) ? 'A' :'B') << endl;
  return 0;
} 

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

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

int main(){
    int N,K;
    cin >> N >> K;
    map<int,int> m;
    priority_queue<int> que;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        m[a]++;
    }

    auto begin = m.begin(), end = m.end();
    for (auto iter = begin; iter != end; iter++) {
        que.push(iter->second);
    }
    for(int i=0;i<K;i++){
        N -= que.top();
        que.pop();
    }
    cout << max(N,0);

    return 0;
}

Measured memory_bytes: 10748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		@SuppressWarnings("resource")
		Scanner cd = new Scanner(System.in);
		String a = cd.next();
		String b = cd.next();
		int n = Integer.parseInt(a+b);
		int k =0;
		for(int i=1;i<n;i++) {
			if(n==i*i) k=n;
		}
		if(k>0)System.out.println("Yes");
		if(k==0)System.out.println("No");
		
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <queue>

#define gc (c = getchar())
#define gi(x) scanf("%d",&x)
#define gid(x, y) scanf("%d%d",&x,&y)
#define gll(x) scanf("%lld",&x);

#define pi(x) printf("%d\n",&x)

#define pll(x) printf("%lld\n",&x)
#define dbg(x) std::cerr << #x << " " << x << std::endl

inline long long max(long long x, long long y) { return x > y ? x : y; }

inline long long min(long long x, long long y) { return x > y ? y : x; }


const int maxn = 1e5 + 5;
int seq[maxn];
int gg[maxn];
int ngg[maxn];

int main() {
    char c;
    int cur = 0;
    std::string str;
    std::cin >> str;
    int cu = 0;

    str += '0';
    for (int i = 0; i + 1 < str.length(); ++i) {
        if (str[i] == 'R' && str[i + 1] == 'L') {
            gg[i] = cur + 1;
            cur = 0;
        } else if (str[i] == 'R') cur++;
        else if (str[i] == 'L') cur = 0;
    }
    cur = 0;
    for (int i = (int) str.length() - 2; i >= 0; --i) {
        if (str[i] == 'L' && str[i - 1] == 'R') {
            gg[i] = cur + 1;
            cur = 0;
        } else if (str[i] == 'L') cur++;
        else if (str[i] == 'R') cur = 0;
    }
    //   for (int i = 0; i + 1 < str.length(); ++i) std::cout << gg[i] << std::endl;
    for (int i = 0; i + 1 < str.length(); ++i)  {
        if (gg[i] != 0 && gg[i + 1] != 0 && str[i] == 'R' && str[i + 1] == 'L') {
            if ((gg[i] + gg[i + 1]) % 2 == 0) {
                int tm = (gg[i] + gg[i + 1]) / 2;
                gg[i] = gg[i + 1] = tm;

            } else {
                int mx = std::max(gg[i], gg[i + 1]);
                int mn = std::min(gg[i], gg[i + 1]);
                int gl = (mx + mn)/ 2;
                if (gg[i] & 1) gg[i] = gl + 1, gg[i + 1] = gl;
                else gg[i] = gl, gg[i + 1] = gl + 1;
            }
            //     i ++;
        }
    }
    for (int i = 0; i + 1 < str.length(); ++i) std::cout << gg[i] << " ";
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    static constexpr ll INF = 1LL << 59;
    Graph(int n) : d(n, vector<ll>(n, INF)), n(n) {}
    void add_edge(int i, int j, int l) {
        d[i][j] = l;
    }
    void warshall_floyd() {
        for (int k = 0; k < n; k++)
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    vector<vector<ll>> d;
    int n;
};

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

    int n, m, l;
    cin >> n >> m >> l;

    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;

        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }
    g.warshall_floyd();

    Graph g1(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (g.d[i][j] <= l) g1.add_edge(i, j, 1);
        }
    }
    g1.warshall_floyd();

    int q;
    cin >> q;

    for (int h = 0; h < q; h++) {
        int s, t;
        cin >> s >> t;
        s--; t--;

        ll x = g1.d[s][t];
        cout << (x == g1.INF ? -1 : x - 1) << '\n';
    }

    return 0;
}

Measured memory_bytes: 1920
import java.util.Arrays;
import java.util.Date;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);

        String[] sp = sc.next().split("/");
        long x = Integer.parseInt(sp[0]) * 10000 + Integer.parseInt(sp[1]) * 100 + Integer.parseInt(sp[2]);

        if (x <= 20190430) {
            System.out.println("Heisei");
        } else {

            System.out.println("TBD");
        }

    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 21844
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		
		if (0 < a && a <= b){
		 	System.out.println("Positive");
		} else if (a <= b && b < 0){
			if((b - a + 1) % 2 == 0 || b - a == 0){
				System.out.println("Positive");
			} else {
			 	System.out.println("Negative");
			}
		} else if (a <= 0 && 0 <= b){
		 	System.out.println("Zero");
		}
	}
}


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

int main() {
	int N;
	long double x[4],y[4];
	cin>>N;
	while(N--){
		for(int i=0;i<4;i++) cin>>x[i]>>y[i];
		long double y1=y[1]-y[0]; long double x1=x[1]-x[0];
		long double y2=y[3]-y[2]; long double x2=x[3]-x[2];
		if(y1*x2==y2*x1) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

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


using namespace std;

int main() {

  int N;
  cin >> N;

for (int i = 1; i < 10; i++) {
  if(N%i == 0 && N/i <= 9){
    cout << "Yes" <<endl; 
    return 0;
  }
}

  cout << "No" << endl;
  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 N;
	vector<int64> a;
	string s;
	a.resize(3);
	REP(i, 3) cin >> a[i];
	sort(all(a));
	int64 res = 0;
	REP(i, 2){
		res += (a[2]-a[i])/2;
		a[i] += (a[2]-a[i])/2*2;
	}
	if(a[0] != a[2] && a[1] != a[2]){
		res++;
	}else if(max(a[0], a[1]) == a[2] && min(a[0], a[1]) != a[2]){
		res += 2;
	}
	cout << res << endl;
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void)
{
  int n, sum, count;
  int i, j;
  
  while(1){
    scanf("%d", &n);
    if(n == 0){
      break;
    }
    count = 0;
    for(i = 0 ; i < n/2 ; i++){
      sum = 0;
      for(j =  i + 1 ; sum < n ; j++){
	sum += j;
      }
      if(sum == n){
	count++;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}

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

int main()
{
    int H, W, N;
    std::cin >> H >> W >> N;
    std::vector<std::vector<int>> board(H + 1, std::vector<int>{});
    for (int i = 0; i < N; i++) {
        int x, y;
        std::cin >> x >> y;
        board.at(x).emplace_back(y);
    }
    int width = 1;
    for (int i = 1; i < H; i++) {
        std::vector<int> row = board.at(i + 1);
        bool has_end = false;
        for (const auto& r : row) {
            if (r == width + 1) {
                has_end = true;
            }
            if (r <= width) {
                std::cout << i << std::endl;
                return 0;
            }
        }
        if (not has_end) {
            width++;
        }
    }
    std::cout << H << std::endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sc(t) scanf("%d",&t)
#define sc3(t,u,v) scanf("%d %d %d",&t,&u,&v)
#define sc2(t,u) scanf("%d %d",&t,&u)
#define scL(t) scanf("%lld",&t)
#define scL3(t,u,v) scanf("%lld %lld %lld",&t,&u,&v)
#define scL2(t,u) scanf("%lld %lld",&t,&u)
#define mem(a,i) memset(a,i,sizeof a)
#define fr(i,n) for(int i=0;i<n;i++)
#define fr1(i,n) for(int i=1;i<=n;i++)
#define itr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define inf 10000007
#define endd printf("\n")
#define MAXX 100007
///unsigned int isprime[(MAXX>>6)+2];
///freopen("in.txt","r",stdin);
///freopen("out.txt","w",stdout);
#define check(i) (isprime[i>>6] & (1<<((i>>1)&31)))
#define sett(i) (isprime[i>>6] |= (1<<((i>>1)&31)))
#define eps 1e-6

int h[MAXX],dp[MAXX];

int main()
{
    int n,k;
    sc2(n,k);
    for(int i=0;i<n;i++) sc(h[i]);
    dp[0] = 0;
    for(int i=1;i<n;i++){
        dp[i] = INT_MAX;
        for(int j=1;j<=k;j++){
            if(i-j>=0){
                dp[i] = min(dp[i],dp[i-j] + abs(h[i] - h[i-j]));
            }
            else break;
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define vi vector <int>
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define tiii tuple <int,int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define matrix vector <vector <int> >
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 20001
#define mod 1000000007
#define mod2 998244353
#define inf 1e17


int dp[N];
piii a[1001]; // weight , stack,value


bool cmp(piii a,piii b)
{
    return (a.ff+a.ss.ff)<(b.ff+b.ss.ff);
}


int32_t main()  
{
    boost
    // #ifndef ONLINE_JUDGE 
    // NAYAN
    // #endif

    int n;
    cin >> n;
    int i,j;

    
    for(i=1;i<=n;i++)
    {
        cin >> a[i].ff >> a[i].ss.ff >> a[i].ss.ss;
    }

    sort(a+1,a+n+1,cmp);

    for(i=1;i<=n;i++)
    {
        int w,s,v;
        w=a[i].ff;
        s=a[i].ss.ff;
        v=a[i].ss.ss;
        for(j=N-1;j>=0;j--)
        {
            if(j<=s)
            {
                dp[j+w]=max(dp[j+w],dp[j]+v);
            }
        }
    }


    

    int ans=0;

    for(i=0;i<N;i++)
    {
        ans=max(ans,dp[i]);
    }

    cout << ans;

    

    
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
	char a[10],b[10],c[10];
	scanf("%s %s %s",&a,&b,&c);
      a[0]=a[0]-32;
      b[0]=b[0]-32;
      c[0]=c[0]-32;
	printf("%c%c%c\n",a[0],b[0],c[0]);
}

Measured memory_bytes: 128
N=int(input())
A=list(map(int, input().split()))
B=0
for i in A:
	if i%2==0:
		if i%3==0 or i%5==0:
			B+=0
		else:
			B+=1
if B==0:
	print('APPROVED')
else:
	print('DENIED')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin>>v[i];
    ll ans = 0;
    ans += abs(v[0]);
    ans += abs(v[n-1]);
    rep(i,n-1){
        ans+=abs(v[i]-v[i+1]);
    }
    rep(i,n){
        if(i==0){
            cout << ans - abs(v[i]) + abs(v[i+1]) -abs(v[i]-v[i+1])  << endl;
        }
        else if(i==n-1){
            cout << ans - abs(v[i]) + abs(v[i-1]) -abs(v[i]-v[i-1]) << endl;
        }else{
            cout << ans - abs(v[i-1]-v[i]) - abs(v[i]-v[i+1]) + abs(v[i-1]-v[i+1]) << endl; 
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
const ll MAX_N=1e5;
ll N,P,v[MAX_N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>P;
	ll bsm=0;
	REP(i,N){
		ll w,b;
		cin>>w>>b;
		bsm+=b;
		v[i]=100*w-P*w+P*b;
	}
	sort(v,v+N);
	ll ans=0,vsm=0;
	REP(i,N){
		vsm+=v[N-1-i];
		if(vsm>=P*bsm){
			ans=i+1;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::*;
use proconio::{input, fastout, marker::*};

#[fastout]
fn main() {
  input!{
    n:usize,
    a:[u64;n],
  }
  let mod_num:u64 = 1000000007;
  let mut asum:u64 = a.iter().sum();
  let mut ans = 0;
  for x in a {
      asum -= x;
      ans += ((x%mod_num)*(asum%mod_num))%mod_num;
      ans %= mod_num;
  }
  println!("{}",ans);
}


Measured memory_bytes: 5480
#入力
N=int(input())

top   = N // 100
under = N % 100


for i in range(top):
    #print(i,under)
    if(under == 0):
        break
    elif(under - 5 >= 0):
        under -= 5
    elif(under - 4 >= 0):
        under -= 4
    elif (under - 3 >= 0):
        under -= 3
    elif (under - 2 >= 0):
        under -= 2
    elif (under - 1 >= 0):
        under -= 1


if(under == 0):
    print(1)
else:
    print(0)

Measured memory_bytes: 3064
#include <iostream>
#define int long long

using namespace std;

main() {

    int q,h,s,d;
    int n;
    cin >> q >> h >> s >> d;
    cin >> n;

    int perl = min(min(q*4, h*2), s);
    int cost = 0;

    if(d/2 <= perl) {
        cost += d*(n/2);
        n %= 2;
    }

    cost += n*perl;

    cout << cost;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll n;
	ll m;
	cin >> n;
	vector<char> v;
	if( n == 0 ){
		cout << 0 << endl;
		return 0;
	}
	while( n ){
		if( n % 2 == 0 ){
			v.push_back('0');
			m = n / (-2);
		} else {
			v.push_back('1');
			m = (n-1) / (-2);
		}
		n = m;
	}
	reverse(v.begin(), v.end());
	for( auto s : v ){
		cout << s;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
while True:
	n,m,a = map(int,input().split())
	if n == m == a == 0:
		break
	A = [[0]*1002 for i in range(n + 1)]
	for i in range(m):
		h,p,q = map(int,input().split())
		A[p][1001 - h] = q
		A[q][1001 - h] = p
		
	for i in range(1001):
		if A[a][i] == 0:
			pass
		else:
			a = A[a][i]
	print(a)

Measured memory_bytes: 9260
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main(){
  long long a,b;
  cin>>a>>b;
  long long suma,sumb;//f(0,a-1),f(b)
  a--;
  if(a%4==0) suma=a;
  if(a%4==1) suma=1;
  if(a%4==2) suma=a+1;
  if(a%4==3) suma=0;
  
  if(b%4==0) sumb=b;
  if(b%4==1) sumb=1;
  if(b%4==2) sumb=b+1;
  if(b%4==3) sumb=0;
  
  cout<<(sumb^suma)<<endl;
  return 0;
}

Measured memory_bytes: 256
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{


long long a,b,c,d,e,f,g,h;

cin>>a;
	cout<<pow(a,2)+pow(a,3)+a<<endl;

	return 0;
}

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

typedef long long ll;

const int N = 3e5;
int occ[N + 5];
ll jumlah[N + 5];
ll ssum[N + 5];
ll psum[N + 5];

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin>>n;
	for(int i = 0;i <n;i++) {
		int x;
		cin>>x;
		occ[x]++;
	}
	for(int i = 0;i <= n;i++) jumlah[occ[i]]++;
	for(int i = n;i >= 0;i--) ssum[i] = jumlah[i] + ssum[i + 1];
	for(ll i = 0;i <= n;i++) {
		psum[i] = jumlah[i] * i;
		if(i) psum[i] += psum[i - 1];
	}
//	for(int i = 0;i <= n;i++) cout<<i<<" "<<psum[i]<<" "<<ssum[i]<<endl;
	for(int i = 1;i <= n;i++) {
		ll lo = 1;
		ll hi = n / i;
		ll res = 0;
		while(lo <= hi) {
			ll mid = (lo + hi) / 2;
			if(psum[mid - 1] + mid * ssum[mid] >= mid * i) {
				res = mid;
				lo = mid + 1;
			} else hi = mid - 1;
		}
		cout<<res<<'\n';
	}
}

Measured memory_bytes: 9088
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<=((int)n);++i)
#define rev(i,n,j) for(int i=(n);i>=((int)j);--i)
typedef long long int ll;
#define int long long int
const ll INFL=0x3f3f3f3f3f3f3f3fLL;
const int INF=0x3f3f3f3f;
const int mod=1000000007;
#define endl "\n"
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define readmat(a, n, m) int a[n + 5][m + 5] = {}; rep(i, 1, n) {rep(j, 1, m) cin >> a[i][j];}
#define printmat(a, n, m) rep (i, 1, n) {rep (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define printarr(a, n) rep(i, 1, n) cout << a[i] << " "; cout << endl;
typedef std::map< int,int> mii;
typedef std::vector< int > vi;
typedef std::vector< vi > vvi;
typedef std::pair< int,int > ii;
using namespace std;
#define cerr cout
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);}
const int N = 1e6+5, M = N;
vector <int>g[N];

void solve()
{
	int n;
	cin>>n;
	int a[n+5];
	int b[n+5];
	for(int i = 1; i <=n; ++i) 
	{
		cin>>a[i]>>b[i];
	}

	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	if (n%2)
	{
		int u=a[(n+1)/2];
		int v=b[(n+1)/2];
		cout<<v-u+1<<endl;
	}
	else
	{
		int ans=(b[n/2]+b[n/2+1])-(a[n/2]+a[n/2+1])+1;
		cout<<ans<<endl;

	}


  

}



signed main()
{
  FAST;
#ifdef LOCAL
    freopen("C:\\Users\\hp\\Documents\\input.txt", "r", stdin);
    freopen("C:\\Users\\hp\\Documents\\output.txt", "w", stdout);
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::high_resolution_clock::now();
#endif

solve();

#ifdef LOCAL
    end = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    cout<<endl;
    cout << "\nElapsed Time: " << elapsed_time << "ms\n";
#endif

return 0;

}

// vector string set map first second continue break return upper_bound lower_bound length void sort
// stack queue pop size erase empty insert
// #Hala BBCF



Measured memory_bytes: 30176
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
i64 fact [N];

i64 mult (i64 a, i64 b) {
  a %= MOD;
  b %= MOD;
  return (a * b) % MOD;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  fact[0] = fact[1] = 1;
  FOR (i, 2, N) {
    fact[i] = mult (fact[i - 1], i);
  }
  int n, m;
  cin >> n >> m;
  if (abs(n - m) >= 2) {
    cout << 0 << '\n';
    return 0;
  }
  i64 res = mult (fact[n], fact[m]);
  if (n == m) res = mult (res, 2);
  cout << res << '\n';
  return 0; 
}


Measured memory_bytes: 1024
n = int(input())

t, a = map(int, input().split())

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

ans = 100000000000000000
ansi = 100000
for i in range(n):
    temp = t - h[i] * 0.006
    if abs(a - temp) < ans:
        ansi = i + 1
        ans = min(ans, abs(a - temp))
print(ansi)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

int main(){
    cin.sync_with_stdio(false);
    ll n;
    cin >> n;
    vi A(n);
    ll mx = 0;
    rep(i,0,n) {
        cin >> A[i];
        mx = max(mx, A[i]);
    }
    sort(A.begin(), A.end());
    int cnt = 0;
    rep(i,0,mx+1){
        int lo = 0;
        int hi = n-1;
        //cout << i << endl;
        while(lo <= hi){
            //cout << lo << ' ' << hi << endl;
            int mid = (lo+hi)/2;
            if(A[mid] < i){
                lo = mid+1;
            }else{
                hi = mid-1;
            }
        }
        if(lo == n/2) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
function Main(input) {
    const args = input.split(' ');
	const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);
    
    if((a+b)%2==1){
        console.log("IMPOSSIBLE");
    }else{
        console.log((a+b)/2);
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22080
#include <iostream>

using namespace std;

#define ll long long
#define double long double
#define FOR(i,a,b) for(long i = a; i <= b; i++)
#define FOD(i,b,a) for(long i = b; i >= a; i--)

#define DEBUG(x) cerr << #x << " = " << x << endl

#define mod 1000000007

int main(){
	ios_base::sync_with_stdio(0);
	ll r, g, b;
	ll num = 0;
	cin >> r >> g >> b;
	num = r * 100 + g * 10 + b;
	
	if (num % 4== 0) cout << "YES";
	else cout << "NO";
	


	return 0;
}





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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S;
	ll K;
	cin >> S >> K;
	int f=-1;
	REP(i, S.size()){
		if(S[i]!='1'){
			f = i;
			break;
		}
	}
	char res;
	if(K-1<f || f==-1) res = '1';
	if(f!=-1 && K-1>=f) res = S[f];
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String a = sc.next(), b = sc.next();
		int comp = new BigInteger(a).compareTo(new BigInteger(b));
		if (comp < 0) {
			System.out.println("LESS");
		} else if(comp == 0){
			System.out.println("EQUAL");
		} else{
			System.out.println("GREATER");
		}
	}
}

Measured memory_bytes: 25300
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int n = 1;
  int ans = 0;
  while (n < b) {
    n--;
    n += a;
    ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		int[] a=fs.readArray(n);
		int c=0;
		for (int i=0; i<n; i+=2) if (a[i]%2==1) c++;
		System.out.println(c);
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


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

#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;

int H, W, K;
ll DP[101][10];

int main(void){
    cin >> H >> W >> K;
    
    memset(DP, 0, sizeof(DP));
    DP[0][0] = 1;
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            
           for(int k=0;k<1<<(W-1);k++){
               bool ok = true;
               for(int l=0;l<W-2;l++){
                   if( (k >> l) & 1 && (k >> (l+1)) & 1) ok = false;
               }
               
               if(ok){
                   if(1 <= j && k >> (j-1) & 1){
                       DP[i+1][j-1] += DP[i][j];
                       DP[i+1][j-1] %= MOD;
                   } else if(j < W-1 && k >> j & 1){
                       DP[i+1][j+1] += DP[i][j];
                       DP[i+1][j+1] %= MOD;
                   } else {
                       DP[i+1][j] += DP[i][j];
                       DP[i+1][j] %= MOD;
                   }
               }
           }
            
        }
    }
    
    cout << DP[H][K-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

int main(void){
    int n,d; cin >> n >> d;
    vi A;
    int count=0;
    rep(i,n*d){int x; cin >>x; A.pb(x);}
    rep(i,n){
        rep2(j,i+1,n){
            float len;
            int len_2 = 0;
            int sub_len;
            rep(k,d){
                sub_len = A.at(i*d + k) - A.at(j*d + k);
                len_2 += pow(sub_len,2);     
            }
            //cout << len_2 << endl;
            len = sqrt((float)len_2);
            //cout << len << endl;
            if(ceil(len)==floor(len))count++;
        }
    
    }
    
    cout << count <<endl;
   // copy(ALL(A), ostream_iterator<int>(cout, " "));
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int h, w, n, y, x;
    cin >> h >> w >> n >> y >> x;
    string s, t;
    cin >> s >> t;
    bool flg = true;

    // Left
    int l = x;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'L') --l;
        if(l <= 0) flg = false;
        if(t[i] == 'R') ++l;
        if(l > w) l = w;
    }

    // Right
    int r = x;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'R') ++r;
        if(r > w) flg = false;
        if(t[i] == 'L') --r;
        if(r <= 0) r = 1;
    }

    // UP
    int u = y;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'U') --u;
        if(u <= 0) flg = false;
        if(t[i] == 'D') ++u;
        if(u > h) u = h;
    }

    // Down
    int d = y;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'D') ++d;
        if(d > h) flg = false;
        if(t[i] == 'U') --d;
        if(d <= 0) d = 1;
    }
    
    cout << (flg ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 920
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
////
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

//#define solvsh
//#define multi

#ifdef solvsh
#else

ll mod = 1e9 + 7;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll ml(ll a, ll b) {
    return (a * b) % mod;
}

const int MAXN = 1e4 + 25;

void solve() {

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max({a * c, b * d, a * d, c * b});
}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE
#else
#endif
#ifdef multi
    //        gen();
    multisolve();
#else
    solve();
//    gen();
#endif
//    time_calc();
}


Measured memory_bytes: 3652
x=[]
for i in range(3):
    x.append(list(map(int,input().split())))

flag=1
for i in range(2):
    if not(x[i+1][0]-x[i][0]==x[i+1][1]-x[i][1]==x[i+1][2]-x[i][2]):
        flag = 0
        break
if flag==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long N, long long K)
{
    double ans = 0;
    for (long long i = 1; i < N + 1; i++)
    {
        if (i < K)
        {
            double u = (double)K / (double)i;
            ans += (double)((double)1 / (double)(N * pow(2, ceil(log(u) / log(2)))));
        }
        else
        {
            ans += (double)((double)1 / (double)N);
        }
    }

    cout << fixed << setprecision(20) << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	/**
	 * AOJ001 List of Top 3 Hills
	 *
	 * @param args
	 */
	public static void main(String[] args) throws IOException {
		ArrayList<Integer> mountainList = getMountainList();

		Collections.sort(mountainList);
		Collections.reverse(mountainList);

		for (int i = 0; i < 3; i++) {
			System.out.println(mountainList.get(i));
		}
	}

	/**
	 * ??\??????????????¨??????10???????±±????????????????´???????????????????????????´??????
	 *
	 * @return 10???????±±????????????????´???????????????????
	 * @throws IOException ??\????????¨??????
	 */
	private static ArrayList<Integer> getMountainList() throws IOException {
		BufferedReader bufferedReader = new BufferedReader(
				new InputStreamReader(System.in));
		ArrayList<Integer> mountainList = new ArrayList<Integer>();

		String strInput;
		for (int i = 0; i < 10; i++) {
			strInput = bufferedReader.readLine();
			mountainList.add(Integer.parseInt(strInput));
		}

		bufferedReader.close();
		return mountainList;
	}

}

Measured memory_bytes: 16888
n = int(input())


def func(x):
    while x >= 10:
        x //= 10
    return x


cnt = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
    digit_end = i % 10
    digit_start = func(i)
    cnt[digit_start][digit_end] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += cnt[i][j] * cnt[j][i]

print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long dp[100005],h[100005];
int n;
int main()
{
	dp[1]=0;dp[0]=1000000000000000UL;
	scanf("%d",&n);for(int i=1;i<=n;++i) scanf("%lld",&h[i]);
	for(int i=2;i<=n;++i) dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	printf("%lld",dp[n]);
	return 0;
}

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

int n, t;
string str;

int main() {
    cin >> n;
    deque<int> idk;
    for (int i=0; i<n; i++) {
        cin >> str;
        if (str == "insert") {
            cin >> t;
            idk.push_front(t);
        }
        if (str == "deleteFirst") {
            idk.pop_front();
        }
        if (str == "deleteLast") {
            idk.pop_back();
        }
        if (str == "delete") {
            cin >> t;
            for (int i=0; i<idk.size(); i++) {
                if (idk[i] == t) {
                    idk.erase(idk.begin()+i);
                    break;
                }
            }
        }
    }
    for (int i=0; i<idk.size()-1; i++) cout << idk[i] << " ";
    cout << idk[idk.size()-1] << endl;
}


Measured memory_bytes: 7120
N = int(input())

S = input()
while True:
	nl = 0
	nr = 0
	j = "O"
	for i in S:
		if i == "(":
			nl += 1
		else:
			nr += 1
		if nr > nl:
			S = "(" + S
			j = "N"
			break
	if j == "O":
		break

n = S.count("(") - S.count(")")
print(S + n * ")")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int n, h;
    cin >> n >> h;

    int a[100000], b[100000];
    REP(i, n) {
        cin >> a[i] >> b[i];
    }

    int maxA = *max_element(a, a + n);
    sort(b, b + n);
    reverse(b, b + n);

    int count = 0;
    REP(i, n) {
        if ( b[i] <= maxA ) {
            continue;
        } else if ( h <= 0) {
            break;
        }

        h -= b[i];
        ++count;
    }

    if ( h > 0 ) {
        count += h / maxA;
        if ( h % maxA != 0 ){
            ++count;
        }
    }

    cout << count << endl;


    return 0;
}



Measured memory_bytes: 1024
S=input()
T=input()

def ans103(S:str, T:str):
    jugde_count=0
    for i in range(0,len(S)):
        S=S[-1]+S[:-1]
        if T==S:
            jugde_count+=1
    if jugde_count>0:
        return "Yes"
    else:
        return "No"

print(ans103(S,T))

Measured memory_bytes: 9100
fun main(args: Array<String>) {
    val (N, T) = readLine()!!.split(" ").map { it.toInt() }
    val a = (1..N).map {
        val (c, t) = readLine()!!.split(" ").map { it.toInt() }
        Pair(c, t)
    }.filter { it.second <= T }.sortedBy { it.first }
    println(if (a.isEmpty()) "TLE" else a[0].first)
}

Measured memory_bytes: 37988
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
  int p[A], q[B], r[C];
  rep(i,A) cin >> p[i];
  rep(i,B) cin >> q[i];
  rep(i,C) cin >> r[i];
  sort(p,p+A,greater<int>());
  sort(q,q+B,greater<int>());
  vector<int> vec;
  rep(i,X) vec.push_back(p[i]);
  rep(i,Y) vec.push_back(q[i]);
  rep(i,C) vec.push_back(r[i]);

  sort(all(vec));
  reverse(all(vec));
  ll ans = 0;
  rep(i,X+Y) ans += vec[i];
  cout << ans << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 6472
#include <cstdio>

int main() {
    int n;
    scanf("%d", &n);

    int ans = 0;
    while (n > 0) {
        ans += n % 10;
        n /= 10;
    }
    if (ans == 1) { ans = 10; }
    printf("%d\n", ans);
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
struct UnionFind {
	std::vector<int> par;
	std::vector<int> sizes;

	UnionFind(int n) {
		par.resize(n);
		sizes.resize(n);
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			sizes[i] = 1;
		}
	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

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

	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)return;
		if (sizes[x] < sizes[y]) std::swap(x, y);

		par[y] = x;
		sizes[x] += sizes[y];
	}
	int size(int x) {
		return sizes[root(x)];
	}
};
int h, w;
int ind(int i, int j) {
	return i * w + j;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> h >> w;
	vector<string> v(h);
	REP(i, h)cin >> v[i];
	UnionFind uf(h*w);
	REP(i, h)REP(j, w) {
		REP(k, 4) {
			int ni = i + dx[k * 2], nj = j + dy[k * 2];
			if (ni < 0 || ni >= h || nj < 0 || nj >= w || v[ni][nj] == '#')continue;
			if (v[i][j] != v[ni][nj])uf.unite(ind(i, j), ind(ni, nj));
		}
	}
	map<int, ll > cnt1, cnt2;
	REP(i, h)REP(j, w) {
		if (v[i][j] == '.')cnt1[uf.root(ind(i,j))] ++;
		else cnt2[uf.root(ind(i,j))]++;
	}
	ll ans = 0;
	for (auto a : cnt1) {
		ans += a.second*cnt2[a.first];
	}
	cout << ans << endl;
}

Measured memory_bytes: 10240