akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const DY: [usize; 9] = [0, 0, 0, 1, 1, 1, 2, 2, 2];
const DX: [usize; 9] = [0, 1, 2, 0, 1, 2, 0, 1, 2];

fn main() {
    let (h, w, n): (usize, usize, usize) = read();
    let a: Vec<(usize, usize)> = readn(n);

    let mut blocks = HashSet::new();
    let mut seen = HashSet::new();
    for &(y, x) in &a {
        blocks.insert(y * (w+1) + x);
    }


    let mut ans: Vec<usize> = vec![0; 10];
    let mut total = 0;
    for &(y, x) in &a {
        for d in 0..9 {
            let bx = x + DX[d] - 1;
            let by = y + DY[d] - 1;
            if bx <= 1 || by <= 1 || bx >= w || by >= h {
                continue
            }
            let id = by * (w + 1) + bx;
            if seen.contains(&id) {
                continue
            }
            seen.insert(id);

            let mut counter = 0;
            for d2 in 0..9 {
                let cx = bx + DX[d2] - 1;
                let cy = by + DY[d2] - 1;
                let id = cy * (w + 1) + cx;
                if blocks.contains(&id) {
                    counter += 1;
                }
            }
            ans[counter] += 1;
            total += 1;
        }
    }
    ans[0] = (h - 2) * (w - 2) - total;

    for ai in ans {
        println!("{}", ai);
    }
}

Measured memory_bytes: 32472
#include <iostream>
#include <string>
#include <cmath>
#include <stdio.h>
using namespace std;

int main() {
  int n;
  int x[1000], y[1000];
  double a;
  double d1 = 0;
  double d2 = 0;
  double d3 = 0;
  double dm = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> y[i];
  }

  for (int i = 0; i < n; i++) {
    a = abs(x[i] - y[i]);
    d1 += a;
    d2 += a * a;
    d3 += a * a * a;
    if (a > dm) dm = a;
  }

  printf("%f\n", d1);
  printf("%f\n", sqrt(d2));
  printf("%f\n", pow(d3, 1.0 / 3.0));
  printf("%f\n", dm);

  return 0;
}

Measured memory_bytes: 1232
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();

        System.out.println(A1+A2+A3 >= 22 ? "bust" : "win");
    }
}



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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n,0);
  int k;
  for(int i=1; i<n; i++){
    cin >> k;
    vec.at(k-1)++;
  }
  for(int i=0; i<n; i++){
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 4044
#include <cstdio>
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
    int index;
    scanf("%d", &index);
   
    char *str = (char *)malloc(sizeof(char) * index);
    scanf("%s", str);

    map<char, int> mp;

    int i, j, k;
    int num;
    int max = 0;
    for(i=0; i<(index-1); i++){
        mp[str[i]] = 0;
        for(auto itr = mp.begin(); itr != mp.end(); ++itr){
            itr->second = 0;
        }

        for(j=i+1; j<index; j++){
            if(mp.find(str[j]) != mp.end()){
                mp[str[j]] = 1;
            }
        }

        num = 0;
        for(auto itr = mp.begin(); itr != mp.end(); ++itr){
            num += itr->second;
        }

        if(max < num){
            max = num;
        }
    }
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 256
"""#################################################################
【ABC109】
B_Shiritori
#################################################################"""

#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
txt = []
good = True
txt = [IS() for i in range(N)]
for s in txt:
    if txt.count(s) > 1:
        good = False
for i in range(N-1):
    if txt[i][-1] != txt[i+1][0]:
        good = False
if good == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

ll N;

void next_num (ll num, ll digit, ll& count, bool tflag, bool fflag, bool sflag){
  if (num <= N) {
    if (tflag && fflag && sflag) count++;
    next_num(num + 3*digit, 10*digit, count, true, fflag, sflag);
    next_num(num + 5*digit, 10*digit, count, tflag, true, sflag);
    next_num(num + 7*digit, 10*digit, count, tflag, fflag, true);
  }
}


int main() {
  cin >> N;
  ll count=0;

  next_num (3, 10, count, true, false, false);
  next_num (5, 10, count, false, true, false);
  next_num (7, 10, count, false, false, true);

  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll x,a;
	cin>>x>>a;
	if (x<a)
		cout<<0;
	else
		cout<<10;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const ll maxn = 1e2 + 20;
ll res , sum[7][maxn] , w[maxn] , v[maxn];
vector<ll> a[7];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n , V;
    cin >> n >> V;
    for(ll i = 0; i < n; i++)
        cin >> w[i] >> v[i] , a[w[i] - w[0]].pb(v[i]);
    for(ll i = 0; i < 4; i++)
        sort(a[i].begin() , a[i].end());
    for(ll i = 0; i < 4; i++)
        for(ll j = 0; j < a[i].size(); j++)
        {
            if(j)
                sum[i][j] = sum[i][j - 1] + a[i][j];
            else
                sum[i][j] = a[i][j];
        }
    for(ll i = 0; i <= a[0].size(); i++)
        for(ll j = 0; j <= a[1].size(); j++)
            for(ll z = 0; z <= a[2].size(); z++)
                for(ll k = 0; k <= a[3].size(); k++)
                {
                    if(w[0] * (i + j + z + k) + j + 2 * z + 3 * k > V)
                        continue;
                    ll s = 0;
                    for(ll k1 = 0; k1 < 4; k1++)
                    {
                        ll l;
                        if(k1 == 0)
                            l = i;
                        else if(k1 == 1)
                            l = j;
                        if(k1 == 2)
                            l = z;
                        if(k1 == 3)
                            l = k;
                        if(l != a[k1].size())
                            s += sum[k1][a[k1].size() - 1] - sum[k1][a[k1].size() - l - 1];
                        else
                            s += sum[k1][a[k1].size() - 1];
                    }
                    res = max(res , s);
                }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

struct Solver {
    memo: std::collections::BTreeMap<u64, u64>,
    a: u64,
    b: u64,
    c: u64,
    d: u64,
}
impl Solver {
    fn new(a: u64, b: u64, c: u64, d: u64) -> Self {
        Self {
            memo: std::collections::BTreeMap::new(),
            a: a,
            b: b,
            c: c,
            d: d,
        }
    }
    fn solve(&mut self, x: u64) -> u64 {
        if x == 0 {
            0
        } else if x == 1 {
            self.d
        } else if let Some(y) = self.memo.get(&x) {
            *y
        } else {
            let mut res = x.saturating_mul(self.d);
            use std::cmp::min;
            if x % 2 == 0 {
                res = min(res, self.solve(x / 2) + self.a);
            } else {
                let y = (x / 2) * 2;
                res = min(res, self.solve(y / 2) + self.a + (x - y) * self.d);
                res = min(res, self.solve(y / 2 + 1) + self.a + (y + 2 - x) * self.d);
            }
            if x % 3 == 0 {
                res = min(res, self.solve(x / 3) + self.b);
            } else {
                let y = (x / 3) * 3;
                res = min(res, self.solve(y / 3) + self.b + (x - y) * self.d);
                res = min(res, self.solve(y / 3 + 1) + self.b + (y + 3 - x) * self.d);
            }
            if x % 5 == 0 {
                res = min(res, self.solve(x / 5) + self.c);
            } else {
                let y = (x / 5) * 5;
                res = min(res, self.solve(y / 5) + self.c + (x - y) * self.d);
                res = min(res, self.solve(y / 5 + 1) + self.c + (y + 5 - x) * self.d);
            }
            self.memo.insert(x, res);
            res
        }
    }
}

fn main() {
    input! {
        t: usize,
    }
    for _ in 0..t {
        input! { n: u64, a: u64, b :u64, c: u64, d: u64 }
        let mut solver = Solver::new(a, b, c, d);
        println!("{}", solver.solve(n));
    }
}


Measured memory_bytes: 2404
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

const int maxN = 502;

void solve() {
    int x, y , z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

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

using namespace std;

char t[77];

int ask(int p) {
  printf("%d\n", p);
  fflush(stdout);
  scanf("%s", t);
  if (t[0] == 'V') {
    return 2;
  }
  return t[0] == 'M';
}

int a[100010];

int main() {
  int n;
  scanf("%d", &n);
  a[0] = ask(0);
  if (a[0] == 2) {
    return 0;
  }
  a[n - 1] = ask(n - 1);
  if (a[n - 1] == 2) {
    return 0;
  }
  int l = 0, r = n - 1;
  while (r - l > 1) {
    int s = (l + r) / 2;
    a[s] = ask(s);
    if (a[s] == 2) {
      return 0;
    }
    int v = (s - l - 1) % 2;
    if ((a[l] == a[s] && v == 0) || (a[l] != a[s] && v == 1)) {
      r = s;
    } else {
      l = s;
    }
  }
}


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


using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    bool flag = true;
    string s;
    cin>>s;
    long int n=s.length(),count=0;
    long int hash[128]={0};
    for(long int i=0;i<n;i++)
    {
        if(hash[s[i]]==0)
            count++;
        hash[s[i]]++;
        
    }
    for(long int i=0;i<n;i++)
    {
        if(hash[s[i]]!=2)
        {
            flag = false;
            break;
        }
    }
    if(flag && count==2)
        cout<<"Yes\n";
    else
        cout<<"No\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

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

	long long A[N];
	int card_num = 0;

	pair<long long, int> p[M];
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	for (int i = 0; i < M; i++){
		cin >> p[i].second >> p[i].first;
		card_num += p[i].second;
	}
	sort(A, A + N);
	sort(p, p + M, greater<pair<long long, int> >());

	int index = 0;
	long long ans = 0;
	for (int i = 0; i < M; i++){
		for (int j = 0; j < p[i].second; j++){
			if(A[index] < p[i].first){
				ans += p[i].first;
			} else {
				ans += A[index];
				j--;
			}
			index++;
			if(index == N){
				goto END;
			}
		}
	}

END:
	for (; index < N; index++){
		ans += A[index];
	}

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

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

int main(){

    char X, Y;
    cin >> X >> Y;

    if(X > Y){
        cout << '>' << endl;
    }else if(X < Y){
        cout << '<' << endl;
    }else{
        cout << '=' << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<memory.h>
#include<ctime>
#include<cstdio>
#include<map>
#include<stack>

using namespace std;

int main()
{
	int a,b;
	string s;
	cin>>a>>b>>s;
	if(s[a]!='-')
	{
		cout<<"No"<<endl;
		return 0;
	}
	int cnt=0;
	for(int i=0;i<s.size();i++)
	{
		if(!(s[i]>='0'&&s[i]<='9'))
		{
			cnt++;
		}
	}
	if(cnt!=1)
	{
		cout<<"No"<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int w,h, n;
int xs,ys, xg,yg;
int c,d,x,y;
char board[100][100];

bool rec(int y, int x, char c){
  if( y<0 || x<0 )
    return false;
  if( y>=h || x>=w )
    return false;

  if( board[y][x] !=c )
    return false;

  if( y==yg && x==xg )
    return true;
  board[y][x] = 9;

  int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
  for( int z=0;z<4;z++ ){
    if( rec(y+dy[z], x+dx[z], c) )
      return true;
  }

  return false;
}
int main(){
  while(cin>>w>>h,w){
    for( int i=0;i<h;i++ )
      for( int j=0;j<w;j++ )
	board[i][j] = 0;

    cin >> xs >> ys;
    cin >> xg >> yg;
    xs--;ys--;
    xg--;yg--;

    cin >> n;
    while(n--){
      cin >> c >> d >> x >> y;
      x--; y--;
      int li=d?4:2; // d==0 => yoko
      int lj=d?2:4;

      for( int i=0;i<li;i++ )
	for( int j=0;j<lj;j++ )
	  board[y+i][x+j] = c;
    }
    if( rec(ys, xs, board[ys][xs]) )
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
    /*
    for( int i=0;i<h;i++ ){
      for( int j=0;j<w;j++ )
	cout << (int)board[i][j];
      cout << endl;
    }
    */
  }

  return 0;
}

Measured memory_bytes: 1176
import sys
import numpy as np

N, M = list(map(int, input().split()))
A = []
for _ in range(N):
    A.append(list(input()))
B = []
for _ in range(M):
    B.append(list(input()))

A = np.array(A)
B = np.array(B).flatten()

for row in range(N - M + 1):
    for col in range(N - M + 1):
        patch = A[row:row + M, col:col + M].flatten()
        if str(patch) == str(B):
            print('Yes')
            sys.exit()
print('No')

Measured memory_bytes: 21284
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for k in range(D)]

ans = []
last = [0]*26

for d in range(D):
    score = -100000000
    t = -1
    for p in range(26):
        prev = last[p]
        last[p] = d+1
        temp = s[d][p]
        for i in range(26):
            temp -= c[i]*(d+1-last[i])
        if temp > score:
            score = temp
            t = p
        last[p] = prev
    ans.append(t+1)

print(*ans,sep="\n")


Measured memory_bytes: 74196
from bisect import bisect_left, bisect_right
N = int(input())
seq = [0] * N
for i in range(N):
  seq[i] = (-1) * int(input())

"""
#リストseqからLISの長さを出す
LIS = [seq[0]]
for i in range(len(seq)):
    if seq[i] >= LIS[-1]:
        LIS.append(seq[i])
    else:
        LIS[bisect_right(LIS, seq[i])] = seq[i]

print(len(LIS) - 1)
#print(LIS)
"""
def getLIS(_N,a):
  INF = 1e18
  MaxP = _N+10
  dp = [INF for _ in range(MaxP)]
  for i in range(_N):
    dp[bisect_right(dp,a[i])] = a[i]

  #print(dp[:10])
  return dp[:bisect_left(dp, INF)]

LIS2 = getLIS(N,seq)

print(len(LIS2))

Measured memory_bytes: 14508
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;
typedef pair<int, int> pii;

int main(){
    int n,k;
    cin >> n >> k;
    vector<vector<int>> val_pre(10);
    for(int i=0; i<n; i++){
        int v,g;
        cin >> v >> g;
        val_pre[g-1].push_back(v);
    }
    vector<int> dp(k+1, 0);
    for(int i=0; i<10; i++){
        sort(val_pre[i].begin(), val_pre[i].end(), greater<int>());
        vector<int> v(k+1, 0);
        int curr = 0;
        for(int j=0; j<min(k, (int)val_pre[i].size()); j++){
            curr += val_pre[i][j];
            v[j+1] = curr +j*(j+1);
        }
        for(int j=k; j>=0; j--){
            for(int s=0; s<=j; s++){
                dp[j] = max(dp[j], dp[s]+v[j-s]);
            }
        }
    }
    cout << dp[k] << endl;
    return 0;
}



Measured memory_bytes: 3192
s = input()
if s == "SUN":
	print(7)
elif s == "MON":
	print(6)
elif s == "TUE":
	print(5)
elif s == "WED":
	print(4)
elif s == "THU":
	print(3)
elif s == "FRI":
	print(2)
elif s == "SAT":
	print(1)

Measured memory_bytes: 3060
N, W = map(int, input().split())

import numpy as np
dp = np.zeros(W + 1, dtype='int64')

for i in range(1, N + 1):
    w, v = map(int, input().split())
    dp[w:W+1] = np.maximum(dp[w:W+1], dp[:W-w+1] + v)

print(dp[-1])


Measured memory_bytes: 15476
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long total = 0;
		for (int i = 0; i < n; i++) {
		    total += sc.nextInt() - 1;
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 25808
D = int(input())
cs = list(map(int, input().split()))
#s = [input().split() for l in range(D)]
S=0
for d in range(D):
    s=list(map(int, input().split()))
    max_value = max(s)
    max_index = s.index(max_value)
    print(max_index+1)
    S+=max_value

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

#define MAX 200000
int N;
int a[MAX + 1];
int A[MAX + 1];
int M = 0;
int b[MAX];
int r = 1;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		A[i] = 0;
		cin >> a[i];
	}
	for (int i = N; i > 0; i--) {
		int sum = 0;
		for (int j = 2 * i; j <= N; j += i) {
			sum += A[j];
		}
		A[i] = (sum % 2 == a[i] ? 0 : 1);
	}
	for (int i = 1; i <= N; i++) {
		if (A[i] == 1) {
			M++;
			b[r++] = i;
		}
	}
	cout << M << endl;
	for (int i = 1; i <= M; i++) {
		cout << b[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h> 
using namespace std; 
int main(){ int a,b;
 scanf("%d %d",&a,&b);
 if(a > b){ printf("a > b\n"); 
 }
 else if(a < b){ printf("a < b\n");
 }
else{ printf("a == b\n");
 }

 } 


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int main() {
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	int t;
    t = 1;
	while (t--) {
		ll n, x, m;
		cin >> n >> x >> m;
		ll ans = x;
		ll pos[m + 5];
		memset(pos, -1, sizeof pos);
		pos[x] = 1;
		ll a = x;
		ll f = -1, s = -1, rest = 0;
		ll sum[m + 5];
		sum[0] = 0;
		sum[1] = x;
		for (ll i = 2; i <= n; ++i) {
			a = (a * a) % m;
			sum[i] = a;
			sum[i] += sum[i - 1];
			if (a == 0)
				break;
			else if (a == 1) {
				ans += n - i + 1;
				break;
			}
			if (pos[a] == -1) {
				pos[a] = i;
				ans += a;
			}
			else {
				f = pos[a];
				s = i - 1;
				rest = n - i + 1;
				break;
			}
		}
		//cout << ans << endl;
		if (rest != 0) {
			ans += (rest / (s - f + 1)) * (sum[s] - sum[f - 1]);
			ll temp = rest % (s - f + 1);
			ans += sum[f + temp - 1] - sum[f - 1];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 4664
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)
int n,q;
vector<int> v;
vector<pair<pair<int,int>,int>> query;
int block;
bool comp(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b) {
  if(a.first.first/block != b.first.first/block)
    return a.first.first/block < b.first.first/block;
  return a.first.second<b.first.second;
}
int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin>>n>>q;
  v.resize(n);
  for(int &i:v)
    cin>>i;
  query.resize(q);
  int pos = 0;
  for(auto &i:query){
    cin>>i.first.first>>i.first.second;
    i.second = pos++;
  }
  
  block = sqrt(n);
  sort(query.begin(),query.end(),comp);

  int curL = 0,curR = 0;
  vector<int> ans(q);
  int freq[n+1];
  memset(freq,0,sizeof freq);
  int si = 0;
  for(auto i:query) {
      int l = i.first.first-1,r = i.first.second-1;
      while(curR<=r) {
        if(freq[v[curR]] == 0)
          si++;
        freq[v[curR]]++;
        curR++;
      }
      while(curR>r+1) {
        freq[v[curR-1]]--;
        if(freq[v[curR-1]]==0)
          si--;
        curR--;
      }
      while(curL<l) {
        freq[v[curL]]--;
        if(freq[v[curL]] == 0)
          si--;
        curL++;
      }
      while(curL>l) {
        if(freq[v[curL-1]]==0)
          si++;
        freq[v[curL-1]]++;
        curL--;
      }
      ans[i.second] = si;
  }
  for(int i:ans)
    cout<<i<<"\n";
  return 0;
}

Measured memory_bytes: 27160
#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()

const ll MOD = 1000000007;

int N;
ll pw[200010];
int p[200010];
vi g[200010];
int cnt[200010];
int md;

deque<int> dp[3][200010];

void dfs(int v, int d)
{
	++cnt[d];

	md = max(md, d);

	int pos = 0;

	for (int to : g[v]) {
		dfs(to, d + 1);

		if (dp[0][v].size() < dp[0][to].size()) {
			rep(j, 3) swap(dp[j][v], dp[j][to]);	
		}

		int sz = dp[0][to].size();
		pos = max(pos, sz);

		rep(i, sz) {
			ll u[3] = {};

			ll s = ((ll)dp[0][v][i] + dp[1][v][i] + dp[2][v][i]);
			if (s >= MOD) s %= MOD;
			ll t = ((ll)dp[0][to][i] + dp[1][to][i] + dp[2][to][i]) % MOD;
			if (t >= MOD) t %= MOD;

			u[0] = (ll)dp[0][v][i] * dp[0][to][i] % MOD;
			u[1] = ((ll)dp[1][v][i] * dp[0][to][i] + (ll)dp[0][v][i] * dp[1][to][i]) % MOD;
			u[2] = (s * t - u[0] - u[1]) % MOD;

			if (u[2] < 0) u[2] += MOD;

			rep(j, 3) dp[j][v][i] = u[j];	
		}

		rep(j, 3) {
			deque<int> emp;
			dp[j][to].swap(emp);
		}	
	}

	dp[1][v].push_front(1);
	dp[0][v].push_front(1);
	dp[2][v].push_front(0);

	rep(i, pos + 1) {
		dp[0][v][i] = (dp[0][v][i] + dp[2][v][i]) % MOD;
		dp[2][v][i] = 0;
	}
}

int main() {
	pw[0] = 1;
	for (int i = 1; i < 200010; ++i) {
		pw[i] = pw[i-1] * 2 % MOD;
	}

	scanf("%d", &N);

	rep(i, N) {
		scanf("%d", &p[i]);
		g[p[i]].pb(i + 1);
	}

	dfs(0, 0);

	ll ret = 0;

	for (int i = 0; i <= md; ++i) {
		ll t = dp[1][0][i];
		ret = (ret + t * pw[N + 1 - cnt[i]]) % MOD;
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 498048
#include <iostream>
#define MOD (1000000007)
using namespace std;

int main () {

  int n, re;
  string s;
  cin >> s;

  n = s.length();
  long dp[n][13];

  for ( int i=0; i < n; i++ ) {
    for ( int j=0; j < 13; j++ ) {
      dp[i][j] = 0;
    }
  }
  if ( s[0] == '?' ) {
    for ( int k=0; k < 10; k++ ) {
      dp[0][k]++;
    }
  } else {
    int k = int(s[0] - '0');
    dp[0][k]++;
  }

  for ( int i=1; i < n; i++ ) {
    if ( s[i] == '?' ) {
      for ( int j=0; j < 13; j++ ) {
        for ( int k=0; k < 10; k++ ) {
          re = ( (( 10*j ) % 13) + k ) %13;
          dp[i][re] += dp[i-1][j];
        }
      }
    } else {
      int k = int(s[i] - '0');
      for ( int j=0; j < 13; j++ ) {
        re = ( (( 10*j ) % 13) + k ) %13;
        dp[i][re] += dp[i-1][j];
      }
    }
    for ( int j=0; j < 13; j++ ) {
      dp[i][j] %= MOD;
    }
  }

  cout << dp[n-1][5] << endl;

}

Measured memory_bytes: 10688
#include <stdio.h>
#include <string.h>

char s[4], ju[6];

int judge()
{
    if (ju[0]&1 && ju[2]&1) return 0;
    if (ju[0]&2 && ju[2]&8) return 1;
    if (ju[0]&8 && ju[2]&2) return 1;
    if (ju[4]&1 && ju[5]&4) return 1;
    if (ju[4]&4 && ju[5]&1) return 1;
    if (ju[4]&2 && ju[5]&2) return 2;
    if (ju[4]&8 && ju[5]&8) return 2;
    if (ju[0]&4 && ju[2]&4) return 2;
    if (ju[1]&2 && ju[3]&8) return 2;
    if (ju[1]&8 && ju[3]&2) return 2;
    return 3;
}

int main()
{
    char i, j, k;
    for(;;)
    {
        memset(ju, 0, sizeof(ju));
        for (i = 0; i < 6; i++)
        {
            for (j = 0; j < 3; j++)
            {
                scanf("%s", s);
                if (s[0] == '#') return 0;
                for (k = 0; k < 3; k++)
                {
                    if (s[k] == '*')
                    {
                        if (j == 0) ju[i] |= 4;
                        if (j == 2) ju[i] |= 1;
                        if (k == 0) ju[i] |= 8;
                        if (k == 2) ju[i] |= 2;
                    }
                }
            }
        }
        printf("%d\n", judge());
    }
    return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;
const int MAX_N = 100005;

class Edge{
  public:
    ll cost;int to;
    Edge(ll cost,int to)
      :cost(cost),to(to){}
};

vector<Edge> graph[MAX_N];

void dijkstra(int start,vector<Edge> graph[],ll dist[],ll pat[]){
  priority_queue<Pl,vector<Pl>,greater<Pl>> que;
  fill(dist,dist+MAX_N,LINF);
  dist[start] = 0LL;
  pat[start] = 1LL;
  que.push(Pl(0LL,start));
  while(!que.empty()){
    Pl p=que.top(); que.pop();
    int v=int(p.second); //行き先
    if(dist[v]<p.first)  continue;
    rep(i,graph[v].size()){
      Edge e=graph[v][i];
      if(dist[v]+e.cost<dist[e.to]){
        dist[e.to]=dist[v]+e.cost;
        // 最小値を更新したら今までのパターンを消す
        pat[e.to] = 0LL;
        que.push(Pl(dist[e.to],e.to));
      }
      if(dist[v]+e.cost==dist[e.to]){
        // 最小値を見つけたらパターンを足す
        (pat[e.to] += pat[v]) %= lmod;
      }
    }
  }
  return ;
}

ll distS[MAX_N],distT[MAX_N],patS[MAX_N],patT[MAX_N];

int main(){
  int N,M; scanf("%d%d",&N,&M);
  int S,T; scanf("%d%d",&S,&T); S--; T--;
  rep(i,M){
    int l,r; ll dd; scanf("%d%d%lld",&l,&r,&dd);
    l--; r--; graph[l].pb(Edge(dd,r)); graph[r].pb(Edge(dd,l));
  }
  dijkstra(S,graph,distS,patS);
  dijkstra(T,graph,distT,patT);
  ll ans = patS[T] * patS[T] % lmod;
  ll len = distS[T];
  rep(i,N){
    if(distS[i]+distT[i]==len && distS[i]*2LL==len){
      (ans += (lmod - patS[i]*patS[i]%lmod*patT[i]%lmod*patT[i]%lmod)) %= lmod;
    }
  }
  rep(i,N) for(auto e:graph[i]){
    int j = e.to; ll c = e.cost;
    if(distS[i]+c+distT[j]==len && distS[i]*2LL<len && distT[j]*2LL<len){
      (ans += (lmod - patS[i]*patS[i]%lmod*patT[j]%lmod*patT[j]%lmod)) %= lmod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 18772
n,m=map(int,input().split())
a=[input() for i in range(n)]
b=[input() for j in range(m)]
res = 'No'
for k in range(n-m+1):
    for l in range(n-m+1):
        if list(map(lambda o:o[l:l+m],a[k:k+m]))==b:
                    res = 'Yes'
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

    int i,j;
    char s[110];
    cin>>s;
    sort(s,s+strlen(s));
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main(){
  int h, w;
  cin >> h >> w;
  int cnt[26] = {};
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char c;
      cin >> c;
      cnt[c - 'a']++;
    }
  }
  int cnt4 = 0, cnt2 = 0, cnt1 = 0;
  for (int i = 0; i < 26; i++) {
    cnt4 += cnt[i] / 4;
    cnt[i] %= 4;
    cnt2 += cnt[i] / 2;
    cnt[i] %= 2;
    cnt1 += cnt[i];
  }

  if (cnt4 < (h / 2) * (w / 2)) {
    puts("No");
    return 0;
  } else {
    cnt4 -= (h / 2) * (w / 2);
  }

  cnt2 += cnt4 * 2;
  if (cnt2 < (h / 2) * (w % 2) + (w / 2) * (h % 2)) {
    puts("No");
    return 0;
  } else {
    cnt2 -= (h / 2) * (w % 2) + (w / 2) * (h % 2);
  }
  cnt1 += 2 * cnt2;
  if (cnt1 < (h%2)*(w%2)) {
    puts("No");
    return 0;
  }
  puts("Yes");
  return 0;
}


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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int mod = 1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	ll n,k;
	cin>>n>>k;
	ll q = k - 1;
	k = k * (k + 1) / 2;
	k %= mod;
	vector<int> a(n);
	ll ans = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ll big = 0;
		for(int j=0;j<i;j++){
			big += a[j] > a[i];
		}
		ans = (ans + (big*k) % mod) % mod;
	}
	q = q * (q+1) / 2;
	q %= mod;
	for(int i=0;i<n;i++){
		ll big = 0;
		for(int j=n-1;j>i;j--){
			big += a[j] > a[i];
		}
		ans = (ans + (big*q) % mod) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskB {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			List<Integer>[] chains = new List[n];
			for (int i = 0; i < n; i++) {
				chains[i] = new ArrayList<>();
			}
			for (int i = 1; i < n; i++) {
				a[i] = in.nextInt() - 1;
				chains[a[i]].add(i);
			}
			out.println(solve(0, chains));
		}

		private int solve(int i, List<Integer>[] chains) {
			int[] a = new int[chains[i].size()];
			for (int j = 0; j < a.length; j++) {
				a[j] = solve(chains[i].get(j), chains);
			}
			Arrays.sort(a);
			int res = 0;
			for (int j = 0; j < a.length; j++) {
				res = Math.max(res, 1 + j + a[a.length - j - 1]);
			}
			return res;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



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

int main(void){
    int cnt[10001] = {};
    int N, sum;
    cin >> N;

    for(int i= 1; i < 100; i++){
        for(int j = 1; j < 100; j++){
            for(int k = 1; k < 100; k++){
                sum = (i + j + k) * (i + j + k) - i * (j + k) - j * k;
                if(sum <= 10000) cnt[sum]++;
            }
        }
    }
    for(int i = 1; i <= N; i++){
        cout << cnt[i] << endl;
    }    
    
    return 0;
}


Measured memory_bytes: 3560
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string>
const long long mod = 1000000007;

int main() {
	int N;
	scanf("%d",&N);
	char c[55],cc;
	scanf("%c",&cc);
	for (int i = 0; i < N;i++) {
		scanf("%c",&c[i]);
	}scanf("%c", &cc);
	for (int i = 0; i < N; i++) {
		scanf("%c", &cc);
	}scanf("%c", &cc);

	int start;
	long long ans = 0;
	int s;
	bool flag = false;
	if (c[0] == c[1]) {
		ans = 6;
		start = 2;
		s = 2;
		flag = true;
	}
	else {
		ans = 3;
		start = 1;
		s = 1;
	}
	
	
	for (int i = start; i < N;i++) {
		if (c[i]==c[i+1]) {
			flag = true;
			if (s==1) {
				ans *= 2;
				ans %= mod;
			}
			else {
				ans *= 3;
				ans %= mod;
			}
			s = 2;
			i++;
		}
		else {
			if (s == 1) {
				ans *= 2;
				ans %= mod;
			}
			s = 1;
		}
	}
	

	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int a,b,A,B,c,gcd,lcm;
    while(scanf("%d%d",&a,&b)!=EOF){
        A=a;
        B=b;
        while(1){
            if(a==b){
                gcd=a;
                break;
            }else if(a<b){
                c=a;
                a=b;
                b=c;
            }
            a=a-b;
        }
        lcm=A/gcd*B;
        printf("%d %d\n",gcd,lcm);
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            long D = sc.nextInt();
            long[] X = new long[N];
            long[] Y = new long[N];
            for (int i = 0; i < N; i++) {
                X[i] = sc.nextInt();
                Y[i] = sc.nextInt();
            }

            int count = 0;
            for (int i = 0; i < N; i++) {
                if (X[i] * X[i] + Y[i] * Y[i] <= D * D) {
                    count++;
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 53228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            int[][] counts = new int[6][9];
            for (int i = 0; i < 13; i++) {
                counts[0][line.charAt(i) - '1']++;
            }
            boolean found = false;
            for (int i = 0; i < 9; i++) {
                if (counts[0][i] == 4) {
                    continue;
                }
                System.arraycopy(counts[0], 0, counts[1], 0, 9);
                counts[1][i]++;
                for (int j = 0; j < 9; j++) {
                    if (counts[1][j] < 2) {
                        continue;
                    }
                    System.arraycopy(counts[1], 0, counts[2], 0, 9);
                    counts[2][j] -= 2;
                    if (check(counts, 2)) {
                        if (!found) {
                            found = true;
                        } else {
                            out.print(' ');
                        }
                        out.print(i + 1);
                        break;
                    }
                }
            }
            if (!found) {
                out.print(0);
            }
            out.println();
        }
    }

    private static boolean check(int[][] counts, int r) {
        for (int k = 0; k < 9; k++) {
            if (counts[r][k] == 0) {
                continue;
            }
            if (k < 7 && counts[r][k + 1] > 0 && counts[r][k + 2] > 0) {
                if (r == 5) {
                    return true;
                }
                System.arraycopy(counts[r], 0, counts[r + 1], 0, 9);
                counts[r + 1][k]--;
                counts[r + 1][k + 1]--;
                counts[r + 1][k + 2]--;
                if (check(counts, r + 1)) {
                    return true;
                }
            }
            if (counts[r][k] >= 3) {
                if (r == 5) {
                    return true;
                }
                System.arraycopy(counts[r], 0, counts[r + 1], 0, 9);
                counts[r + 1][k] -= 3;
                if (check(counts, r + 1)) {
                    return true;
                }
            }
        }
        return false;
    }
}

Measured memory_bytes: 9468
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

void solve() {
    ll K;
    cin >> K;
    // DEBUG(K);
    if(K%2==0){
        print(-1);
        return;
    }
    ll a = 0;
    ll b = 7%K;
    ll mod = 0;
    ll ans = -1;
    rng(i,1,1000000){
        a = 10*a+7;
        // DEBUG(a);
        // DEBUG(a%K);
        mod = ((10*mod)%K + b) % K;
        // DEBUG(mod);
        if(mod == 0){
            ans = i;
            break;
        }
    }
    print(ans);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
ll f(ll x){
    ll count = 0;
    ll answer = 0;
    REP(i,40){
        ll index = (1ll << i);
        count += ((x+1)/(index*2))*index;
        count += max(0ll,(x+1)%(index*2)-index);
        if(count%2)answer+=index;
        count = 0;
    }
    return answer;
}
int main(){
    ll a,b;
    cin >> a >> b;
    cerr << f(a) << " " << f(b) << endl;
    cout << (f(max(a-1,0ll))^f(b)) << endl;
    return 0;
}

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

int main(){
  int n,cnt=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int ok = j;//常にokの最小値
      int ng = n;//常にngの最大値
      while(ng-ok>1){
      	int mid = ok+(ng-ok)/2;
      	if(a[mid]<a[i]+a[j]) ok = mid;//midがokなら
      	else ng = mid;//midがngなら
      }
      cnt+=ok-j;
    }
  }
  cout << cnt << endl;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const ll INF = 1e15;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VLL a(n);
  rep(i,n) cin >> a[i];
  deque<ll> maxArray;
  maxArray.push_back(a[0]);

  FOR(i, 1,n){
    if( lower_bound(all(maxArray),a[i]) == maxArray.begin()){
      maxArray.push_front(a[i]);
      //cout << "hi"<< a[i] << endl;
    }else{
      *(lower_bound(all(maxArray),a[i]) - 1) = a[i];
      //cout << a[i] << endl;
    }

  }
  cout << maxArray.size()<< endl;
  return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int M,N;
  cin>>M>>N;
  int a[100][100];
  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      cin>>a[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<M;i++){
    int l=0;
    for(int j=0;j<N;j++){
      l+=a[i][j]^!!i^(j!=0&&j!=N-1);
    }
    ans+=
      (N==1)?l:
      (l==N)?l-1:l+1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1200
#include <stdio.h>

int tansaku_2(int target) {
	int left,right,mid;
	unsigned long long mid2;
	if(target<4)return 0;
	left=2;right=target;
	while(left<=right) {
		mid=(left+right)/2;
		mid2=(unsigned long long)mid*mid;
		if(mid2==(unsigned long long)target)return mid;
		else if(mid2<(unsigned long long)target)left=mid+1;
		else right=mid-1;
	}
	return left-1;
}
/*
int tansaku_3(int target) {
	int left,right,mid;
	unsigned long long mid3;
	if(target<8)return 0;
	left=2;right=target;
	while(left<=right) {
		mid=(left+right)/2;
		mid3=(unsigned long long)mid*mid*mid;
		if(mid3==(unsigned long long)target)return mid;
		else if(mid3<(unsigned long long)target)left=mid+1;
		else right=mid-1;
	}
	return left-1;
}
*/
int main(void) {
	int e,e2;
	int x,y,z;
	int min;
	while(1) {
		scanf("%d",&e);
		if(e==0)break;
		min=0x7fffffff;
		for(z=0;z*z*z<=e;z++) {
			e2=e-z*z*z;
			y=tansaku_2(e2);
			x=e2-y*y;
			if(x+y+z<min)min=x+y+z;
		}
		printf("%d\n",min);
	}
	return 0;
}

Measured memory_bytes: 408
#include <bits/stdc++.h>
using namespace std;
main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  
  string t;
  cin >> t;
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  string ans;
  if(s<t) ans="Yes";
  else ans="No";
  
  
  cout << ans << endl;
}

Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main
{
	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		for(int i=0; i<n; i++)
		{
		    StringBuffer s1 = new StringBuffer(br.readLine());
		    StringBuffer s2 = new StringBuffer(br.readLine());
  
		    if(s1.length() > 80 || s2.length() > 80)
			System.out.println("overflow");
		    else if ((s1.length() < 10) && (s2.length() < 10)) {
			System.out.println(Integer.parseInt(s1.toString()) + 
					   Integer.parseInt(s2.toString()));
		    } else {	
			StringBuffer s3 = cal(s1,s2);
			char[] budget = s3.toString().toCharArray();
			int m = budget.length;
			if( m > 80 ) System.out.println("overflow");
			else {
			    for(int j=0; j<m; j++)
			    System.out.print(Integer.parseInt(budget[j]+""));
			    System.out.println();
			}
		    }
		 }
	}

	private static StringBuffer cal(StringBuffer a, StringBuffer b)
	{
		a.reverse();
		b.reverse();
		int lenA = a.length(), lenB = b.length(), max = Math.max(lenA,lenB);
		int roundup=0; //determine whether round up is needed
		StringBuffer c = new StringBuffer();
		Integer temp=0;
		for(int i=0; i<max; i++)
		{
		    if( i < lenA && i < lenB) {
		        temp = Integer.parseInt(a.substring(i,i+1).toString()) + 
			       Integer.parseInt(b.substring(i,i+1).toString()) + 
			       roundup;
		    } else if( i < lenA && i >= lenB) {
			temp = Integer.parseInt(a.substring(i,i+1).toString()) + roundup;
		    } else {
			temp = Integer.parseInt(b.substring(i,i+1).toString()) + roundup;
		    }
		
		    if(temp>9) {roundup = 1; temp-=10;}
		    else       roundup = 0;
		    c.append(temp);
		    if(i==max-1 && roundup == 1)
			c.append(1);
		}
		return c.reverse();
	}
}

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >>a>>b;
  
  string s;
  if(a<b) {
    for(int i=0;i<b;i++) cout <<a;
    cout <<endl;
  }
  else if(a>b){
    for(int i=0;i<a;i++) cout <<b;
    cout <<endl;
  }
  else if(a==b){
    for(int i=0;i<a;i++) cout <<a;
    cout <<endl;
  }
  
}

Measured memory_bytes: 3592