akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,D,X;
	cin>>N>>D>>X;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin>>A[i];
	}
	vector<int> day(D,0);
	for(int i=0;i<N;++i){
		for(int j=0;j<D;j+=A[i]){
			day[j]++;
		}
	}
	int ans = 0;
	for(int i=0;i<D;++i){
		ans += day[i];
	}
	cout << ans + X << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int n, k, ans;
vector<vi> adj;
vi h;

void dfs(int x, int p) {
	h[x]=1;
	for(int y:adj[x]) {
		dfs(y, x);
		h[x]=max(h[x], h[y]+1);
	}
	if(h[x]==k && p!=1) {
		h[x]=0;
		ans++;
	}
}

int main() {
	int i, t;
	scanf("%d%d", &n, &k);
	adj.assign(n+1, vi(0));
	h.assign(n+1, 0);
	scanf("%d", &t);
	if(t!=1) ans++;
	for(i=2; i<=n; i++) {
		scanf("%d", &t);
		adj[t].pb(i);
	}
	dfs(1, 1);
	printf("%d\n", ans);
   	return 0;
}

Measured memory_bytes: 12288
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    C_temp,S_temp,F_temp = map(int,input().split())
    C.append(C_temp)
    S.append(S_temp)
    F.append(F_temp)
ans = S[0]
for i in range(N):
    t = 0
    for j in range(i,N-1):
        if t<S[j]:
            t = S[j]
        elif t%F[j] == 0:
            pass
        else:
            t = t+F[j] -t%F[j]
        t += C[j]
    print(t)


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

using namespace std;

const int N = 100010;

int a[N];

//36 - 38 - idea
//39 - 41  - how to code

int main() {
	int n;
	scanf("%d", &n);
	map<int, int> mp;
	vector <int> v;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		mp[a[i]]++;
		v.push_back(a[i]);
	}

	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());


	if(v.size() >= 4) {
		puts("No");
	} else if(v.size() == 3) {
		int ok = (mp[v[0]] == mp[v[1]]);
		ok = (ok & (mp[v[1]] == mp[v[2]]));
		ok = (ok & ((v[0] ^ v[1]) == v[2]));
		if(ok) {
			puts("Yes");
		} else {
			puts("No");
		}
	} else if(v.size() == 2) {
		int ok = (2*mp[v[0]] == mp[v[1]]);
		ok = (ok & (v[0] == 0));
		if(ok) {
			puts("Yes");
		} else {
			puts("No");
		}
	} else if(v.size() == 1){
		int ok = (v[0] == 0);
		if(ok) {
			puts("Yes");
		} else {
			puts("No");
		}
	}



}

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

int main(){
  int64_t n, k;
  cin >> n >> k;
  int64_t a = n / k;
  int64_t ans;
  if(n % k == 0){
    cout << "0" << endl;
  }
  else{
    ans = min(n - a * k, (a + 1) * k - n) ;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 200001
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, x[MAX_N];

ll modpow(ll x, ll n) {
    if (n == 0) return 1;
    return modpow(x * x % mod, n / 2) * (n & 1 ? x : 1) % mod;
}

ll modinv(ll a) {
    return modpow(a, mod - 2);
}

// assert m is prime
inline ll  inverse(ll  a, ll  m) {
    ll  b = m, x = 1, y = 0;
    // extgcd(a, m, x, y)
    while (b) {
        ll  t = a / b;
        swap(a -= t * b, b);
        swap(x -= t * y, y);
    }
    return (x % m + m) % m;
}


vector<ll> fact, inv_fact;
void init_fact(ll n) {
    fact.resize(n);
    fact[0] = 1;
    for (ll i = 1; i < n; i++) {
        fact[i] = i * fact[i - 1] % mod;
    }
    inv_fact.resize(n);
    inv_fact[n - 1] = inverse(fact[n - 1], mod);
    for (ll i = n - 2; i >= 0; i--) {
        inv_fact[i] = (i + 1) * inv_fact[i + 1] % mod;
    }
}

ll nPr(ll n, ll r) {
    if (n < r || n < 0 || r < 0) return 0;
    return fact[n] * inv_fact[n - r] % mod;
}

ll nCr(ll n, ll r) {
    if (n < r || n < 0 || r < 0) return 0;
    return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod;
}

ll nHr(ll n, ll r) {
    if (n == 0 && r == 0) return 1;
    return nCr(n + r - 1, r);
}

signed main(){
    cin >> n;
    REP(i, n) cin >> x[i+1];

    init_fact(n);
    ll inv_n[n+1], inv_n_sum[n+1];
    inv_n[0] = 0;
    for(ll i=1; i<=n; i++){
        inv_n[i] = inverse(i, mod);
    }

    inv_n_sum[0] = 0;
    for(ll i=0; i<n; i++){
        inv_n_sum[i+1] = inv_n[i+1] + inv_n_sum[i];
    }

    // REP(i, n){
    //     ll test = 0;
    //     for(ll j=1; j<=i; j++) test += inv_n[j];
    //     cout << test  << " " << inv_n_sum[i] << endl;
    // }

    ll ret = 0;
    REP(i, n){
        // for(ll j=1; j<=i; j++){
        //     ret += (x[i+1] - x[i]) * inv_n[j];
        //     // cout << i+1 << " " << i << " " << j << endl;
        //     ret %= mod;
        // }
        
        ret += (x[i+1] - x[i]) * inv_n_sum[i];
        // cout << i+1 << " " << i << " " << j << endl;
        ret %= mod;
    }
    // cout << ret << endl;
    ret *= fact[n-1];
    ret %= mod;

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if ((x-r) < 0 || W < (x+r) || (y-r) < 0 || H < (y+r)) {
            System.out.println("No");
            return;
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 26328
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let H:usize = read();
    let W:usize = read();
    let mut S:Vec<Vec<char>> = vec![Vec::new(); H];
    for i in 0..H {
        S[i] = read::<String>().chars().collect();
    }
    let mut res = vec![vec![0; W]; H];
    for h in 0..H {
        for w in 0..W {
            if S[h][w] == '#' {
                for dh in vec![-1 as isize, 0, 1] {
                    for dw in vec![-1 as isize, 0, 1] {
                        let next_h = (h as isize + dh) as usize;
                        let next_w = (w as isize + dw) as usize;
                        if next_h < 0 as usize || next_h >= H || next_w < 0 as usize || next_w >= W {
                            continue;
                        } else if S[next_h][next_w] == '#' {
                            res[next_h][next_w] = -1
                        } else {
                            res[next_h][next_w] += 1
                        }
                    }
                }
            }
        }
    }
    for i in 0..H {
        for j in 0..W {
            if res[i][j] == -1 {
                print!("#");
            } else {
                print!("{}", res[i][j]);
            }
        }
        println!("");
    }
}

Measured memory_bytes: 2164
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (chunk) {
	var tmp,i,j;
	var e = chunk.split(' ');
	b = parseInt(e[0],10);
	c = parseInt(e[1],10);
	d = parseInt(e[2],10);
	a = [b,c,d];
	a.sort();
	console.log(a[0]+' '+a[1]+' '+a[2]);
});

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

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int[] dp = new int[n + 1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for (int i = 0; i <= n; i++) {
            int power = 1;
            while (power <= i) {
                dp[i] = Math.min(dp[i], dp[i - power] + 1);
                power *= 6;
            }

            power = 1;
            while (power <= i) {
                dp[i] = Math.min(dp[i], dp[i - power] + 1);
                power *= 9;
            }
        }

        System.out.println(dp[n]);
    }
}


Measured memory_bytes: 23124
#include <stdio.h>

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF -1
 
int matrix[MAX+1][MAX+1];
int n;
int Q[MAX+1];
int d[MAX+1];
int color[MAX+1];
int head = 0, tail = 0;

void enq(int x){
    Q[tail] = x;
    tail++;
 
    if( tail == MAX+1 ){
        tail = 0;
    }
}
 
int deq(){
    int n;
    n = Q[head];
    head++;
 
    if( head == MAX+1 ){
        head = 0;
    }
 
    return n;
}
 
void bfs(int s){
    int i,v,u;
 
    for( i = 0 ; i <= n ; i++ ){
        color[i] = WHITE;
        d[i] = INF;
    }
 
    color[s] = GRAY;
    d[s] = 0;
    enq(s);
 
    while( tail != head ){
 
        u = deq();
 
        for( i = 1 ; i <= n ; i++ ){
 
            if( color[i] == WHITE && matrix[u][i] == 1 ){
 
                color[i] = GRAY;
                d[i] = d[u]+1;
 
                enq(i);
            }
        }
        color[u] = BLACK;
    }
}
 
int main(){
    int i,j;
    int row,col;
    int num;
 
    scanf("%d",&n);
 
 
    for( i = 0 ; i <= n ; i++ ){
        for( j = 0 ; j <= n ; j++ ){
            matrix[i][j] = WHITE;
        }
    }
 
    for( i = 1 ; i <= n ; i++ ){
 
        scanf("%d",&row);
        scanf("%d",&col);
 
        for( j = 0 ; j < col ; j++ ){
            scanf("%d",&num);
            matrix[row][num] = 1;
        }
 
    }
 
    bfs(1);
 
    for( i = 1 ; i <= n ; i++ ){
        printf("%d %d\n",i,d[i]);
    }
 
 
    return 0;
}

Measured memory_bytes: 636
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int value;
		int i = 1;
		while((value = scan.nextInt()) != 0){
			System.out.println("Case " + i + ": " + value);
			i++;
		}

		scan.close();
	}
}

Measured memory_bytes: 41072
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j].value < A[j-1].value ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int n){
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j].value < A[mini].value ) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
  }
}

void print(struct Card A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main(){
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c ", &C1[i].suit, &C1[i].value);
  }

  for ( i = 0; i < n; i++ ) C2[i] = C1[i];

  bubble(C1, n);
  selection(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}



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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N,K;
  cin >> N >> K;
  ll ans=1;
  rep(i,N){
    ans = min(ans*2LL, ans+K);
  }
  cout << ans << endl;
  return 0;
    

}


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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N;
  cin>>N;
  int a,b,c;
    a=N%10;
    b=((N-a)/10)%10;
    c=(N-10*b-a)/100;
  //cout<<a<<b<<c;
  if(a!=7&&b!=7&&c!=7)
    cout<<"No";
  else
    cout<<"Yes";
}


Measured memory_bytes: 3632
def calc(n, a, d):
    return (n * (2 * a + (n - 1) * d)) // 2


n = int(input())
ans = 0
for i in range(1, n + 1):
    n_ = (n // i)
    d, a = i, i
    sm = calc(n_, a, d)
    ans += sm
print(ans)


Measured memory_bytes: 63956
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
using ull = unsigned long long;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    n=1000000-n;
    cout << n%1000 << endl;
}


Measured memory_bytes: 3636
def count(li, first):
    if first == '0':
        isZero = True
    else:
        isZero = False
    counter = 0
    for i in li[1:]:
        if i == '0' and isZero:
            counter += 1
            isZero = False
        elif i == '1' and (not isZero):
            counter += 1
            isZero = True
        else:
            isZero = not isZero
    return counter


S = input()

print(min([count(list(S), S[0]), count(list(S)[::-1], list(S)[::-1][0])]))


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);


int dp[302][302][302];
int L[302], R[302], x[302];
vector<int> qs[302];

bool satisfy(int L, int x, int r, int g, int b) {
  // R == k == max(r, g, b)
  // [L, R]の間にちょうどx種類の色が出現する
  return (L <= r)+(L <= g)+(L <= b) == x;
}

int main2() {
  CLR(dp, 0);
  REP(i, 302) qs[i].clear();

  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    L[i] = nextInt();
    R[i] = nextInt();
    x[i] = nextInt();
    qs[R[i]].push_back(i);
  }

  dp[0][0][0] = 1;
  for (int r = 0; r <= N; r++) {
    for (int g = 0; g <= N; g++) {
      for (int b = 0; b <= N; b++) {
        if (dp[r][g][b] == 0) continue;
        int k = max(r, max(g, b));
        bool ng = false;
        for (int q : qs[k]) if (!satisfy(L[q], x[q], r, g, b)) ng = true;
        if (ng) {
          dp[r][g][b] = 0;
          continue;
        }
        dp[k+1][g][b] += dp[r][g][b]; if (dp[k+1][g][b] >= MOD) dp[k+1][g][b] -= MOD;
        dp[r][k+1][b] += dp[r][g][b]; if (dp[r][k+1][b] >= MOD) dp[r][k+1][b] -= MOD;
        dp[r][g][k+1] += dp[r][g][b]; if (dp[r][g][k+1] >= MOD) dp[r][g][k+1] -= MOD;
      }
    }
  }
  ll ans = 0;
  for (int r = 0; r <= N; r++) {
    for (int g = 0; g <= N; g++) {
      for (int b = 0; b <= N; b++) {
        if (r == N || g == N || b == N) {
          ans += dp[r][g][b];
          if (ans >= MOD) ans -= MOD;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 107904
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]

N,S = map(int,input().split())
MOD = 998244353
A = list(map(int,input().split()))
dp = [[0]*(S+1) for _ in range(N)]
if A[0] <= S:
    dp[0][A[0]] = 1
dp[0][0] = 2
for i in range(1,N):
    a = A[i]
    for j in range(S+1):
        dp[i][j] += 2*dp[i-1][j] % MOD
        if j - a < 0:
            continue
        else:
            dp[i][j] += dp[i-1][j-a]
        dp[i][j] %= MOD
print(dp[N-1][S])
    





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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    bool ans = true;
    if (s[2]!=s[3]) ans = false;
    if (s[4]!=s[5]) ans = false;
    cout << (ans?YES:NO) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int ind = -1;
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] == 1)
            ind = i;
    }
    int ans = INT_MAX;

    rep(i, k)
    {
        int left = ind - i;
        int right = n - (ind + k - i);
        int count = 1;
        if (0 < left)
            count += ceil(left / (double)(k - 1));
        if (0 < right)
            count += ceil(right / (double)(k - 1));
        ans = min(ans, count);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size())cout<<"GREATER"<<endl;
    else if(a.size()<b.size())cout<<"LESS"<<endl;
    else if(a>b)cout<<"GREATER"<<endl;
    else if(a<b)cout<<"LESS"<<endl;
    else cout<<"EQUAL"<<endl;

    
    return 0;
    
    
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
input = sys.stdin.readline
n,m = map(int,input().split())
a = list(map(int,input().split()))
ls_0 = [0 for i in range(m*2+2)]
ans_0 = 0
for i in range(1,n):
  if a[i-1] < a[i]:
    l = a[i-1]+2
    r = a[i]+1
  else:
    l = a[i-1]+2
    r = a[i]+m+1
  ls_0[l] += 1
  ls_0[r] -= (r-l+1)
  ls_0[r+1] += r-l
  ans_0 += r-l+1

ls_1 = list(accumulate(ls_0))
ls_2 = list(accumulate(ls_1))
ls_3 = [0]+[ls_2[i]+ls_2[i+m] for i in range(1,m+1)]
print(ans_0-max(ls_3))

Measured memory_bytes: 32996
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    ll k;
    cin>>k;
    ll rem=k;
    const ll var=1e16;
    int n=-1;
    for(int i=2;i<=50;i++)
    {
        if(i-k+(k/i)*(i+1)>0&&i-k+(k/i)*(i+1)<var+500)
        {
            n=i;
            break;
        }
    }
    assert(n!=-1);
    //dbg(n);
    vc<ll> ans(n);
    for(int i=0;i<n-1;i++)
    {
        ll tt=(k+n-1)/n;
        rem-=tt;
        ans[i]=n-k+tt*(n+1)-1;
        //dbg(i,rem);
    }
    ans[n-1]=n-k+rem*(n+1)-1;
    print(n);
    print(ans);
    for(int i=0;i<n;i++) assert(ans[i]>=0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();

        char c = sc.next().charAt(0);
        print("" + (char)((int)c + 1));

        System.exit(0);
    }

    static  private void print(String s) {
        System.out.println(s);
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define int long long 
#define LL long long 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;




	
int32_t main()
{
	int a,b;cin>>a>>b;
	cout<<max({a+a-1,b+b-1,a+b})<<endl;
}
				
				   
	

	


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int a[] = new int[100];  // 配列確保（大きめに）
	  	boolean tranp[] = new boolean[500];
        int n = scanner.nextInt(); // データ数
        int i;
        int x = 0;
        int y = 0;
        String Mark;
        
        for(i = 0; i < 500; i++)
        	tranp[i] = false;
        
        // データ入力
        for (i = 0; i < n; i++) {
            Mark = scanner.next();
            
            switch(Mark){
            case "S":
           		 x = 100 + scanner.nextInt();
           		 a[i] = x;
           		 tranp[x] = true;
           		 break;
           	case "H":
          		 x = 200 + scanner.nextInt();
          		 a[i] = x;
          		 tranp[x] = true;
          		 break;
           	case "C":
          		 x = 300 + scanner.nextInt();
          		 a[i] = x;
          		 tranp[x] = true;
          		 break;
           	case "D":
          		 x = 400 + scanner.nextInt();
          		 a[i] = x;
          		 tranp[x] = true;
          		 break;
            }
        }
        //ないカードのチェック
        for(i = 1; i <= 4 ; i++){
        	y = i *100;
        	for(int j = 1; j <= 13; j ++ ){
        		if(!(tranp[y + j]) ) {
        			switch(y){
		            case 100:
		           		 System.out.println("S " + j);
		           		 tranp[y + j] = true;
		           		 break;
		           	case 200:
		           		 System.out.println("H " + j);
		           		 tranp[y + j] = true;
		           		 break;
		           	case 300:
		           		 System.out.println("C " + j);
		           		 tranp[y + j] = true;
		           		 break;
		           	case 400:
		           		 System.out.println("D " + j);
		           		 tranp[y + j] = true;
		           		 break;
		        	}
        		}
        	}
        }
        scanner.close();
  }
}


Measured memory_bytes: 26364
# include <bits/stdc++.h>
// # define INF 1e9
using namespace std;


int main(){
  int N;
  cin >> N;
  map<string, long long> m;
  for(int i=0; i<N; i++){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }
  long long ans = 0;
  for(auto x: m){
    long long v = x.second;
    ans += (v-1)*v/2;
  }
  cout << ans << endl;

}

Measured memory_bytes: 11136
N=int(input())
I=[[0,0,0]]
for i in range(N):
    I.append(list(map(int,input().split())))
    
check=0
for i in range(N):
    time=I[i+1][0]-I[i][0]
    len=abs(I[i+1][1]-I[i][1])+abs(I[i+1][2]-I[i][2])
    if len>time:
        check=1
        break
    if (time-len)%2 != 0:
        check=1
        break

if check==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27300
#include<cstdio>
#include<iostream>
using namespace std;
main(){
  double x1,x2,x3,x4,y1,y2,y3,y4,a1,a2;
  int n,i;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    a1=(y1-y2)/(x1-x2);
    a2=(y3-y4)/(x3-x4);
    if(a1==a2){
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 305;

int n,m,L;
int e[maxn][maxn];
int f[maxn][maxn][2];
bool in[maxn][maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n>>m>>L;
  for(int i=0;i<m;i++){
    int x,y,z;
    cin>>x>>y>>z;
    e[x][y] = e[y][x] = z;
  }
  memset(f,-1, sizeof(f));
  queue<int>qx,qy;
  for(int i=1;i<=n;i++){
    f[i][i][0] = 0;
    f[i][i][1] = L;
    in[i][i] = 1;
    qx.push(i);
    qy.push(i);
  }
  while(!qx.empty()){
    int x = qx.front();
    int y = qy.front();
    qx.pop();
    qy.pop();
    in[x][y] = 0;
    for(int i=1;i<=n;i++){
      if(e[y][i]>L||!e[y][i])continue;
      if(f[x][y][1]>=e[y][i]){
        if(f[x][i][0]>f[x][y][0]||f[x][i][0]==-1||(f[x][i][0]==f[x][y][0]&&f[x][i][1]<f[x][y][1]-e[y][i])){
          f[x][i][0] = f[x][y][0];
          f[x][i][1] = f[x][y][1]-e[y][i];
          if(!in[x][i]){
            in[x][i]=1;
            qx.push(x);
            qy.push(i);
          }
        }
      } else {
        if(f[x][i][0]>f[x][y][0]+1||f[x][i][0]==-1||(f[x][i][0]==f[x][y][0]+1&&f[x][i][1]<L-e[y][i])){
          f[x][i][0] = f[x][y][0]+1;
          f[x][i][1] = L-e[y][i];
          if(!in[x][i]){
            in[x][i]=1;
            qx.push(x);
            qy.push(i);
          }
        }
      }
    }
  }
  int Q;
  cin>>Q;
  while(Q--){
    int x,y;
    cin>>x>>y;
    cout<<f[x][y][0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 2304
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
 
class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int m = scanner.nextInt();
    int[][] a = new int[m][2];
    for (int i = 0; i < m; i++) {
      a[i][0] = scanner.nextInt();
      a[i][1] = scanner.nextInt();
    }
 
    Arrays.sort(a, Comparator.comparingInt(o -> o[1]));
 
    int count = 0;
    for (int i = 0; i < m;) {
      count++;
      int right = a[i][1];
      i++;
      while (i < m && a[i][0] < right) {
        i++;
      }
    }
    System.out.println(count);
  }
}

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

using namespace std;

int main() {
    string input;
    int number_of_min_hags = 0;

    do {
        cin >> input;
    } while(input.length() > 100);

    auto first = input.begin();
    auto end = input.end() - 1; // 末尾は空白のため-1した
    // 入力文字列の先頭と末尾を比較し、
    // 一致しなければ置き換える
    for(int i = 0; i < input.length()/2; i++) {
        if(*first != *end) {
            *end = *first;
            number_of_min_hags++;
        }
        first++;
        end--;
    }

    cout << number_of_min_hags << endl;

    return 0;
}

Measured memory_bytes: 256
import math
lis=[]
N=int(input())
P=list(map(int, input().split()))
Q=list(map(int, input().split()))
lP=[i+1 for i in range(N)]
lQ=[i+1 for i in range(N)]
#print(P,Q,lP,lQ)
bangoP=[]
bangoQ=[]
pnum=0
qnum=0
for i in range(N):
    j=0
    while True:
        if (lP[j]==P[i]):
            bangoP.append(j)
            #print(j)
            lP.pop(j)
            #print(lP)
            break
        j=j+1
for i in range(N):
    j=0
    while True:
        if (lQ[j]==Q[i]):
            bangoQ.append(j)
            #print(j)
            lQ.pop(j)
            #print(lQ)
            break
        j=j+1
#print(bangoP,bangoQ)

for i in range(N-1):
    #print(bangoP[i],bangoQ[i])
    pnum=pnum+math.factorial(N-1-i)*bangoP[i]
    qnum=qnum+math.factorial(N-1-i)*bangoQ[i]
print(abs(pnum-qnum))

'''
wacount=0
account=0
count=0
zero=0
flag=1
cur=0
changeflag=1
#s=[list(input()) for i in range(2)] 
#for range(M):
#print(N,M)
 
for i in range(M):
     lis=input().split()
     #print(lis)
     lis[0]=int(lis[0])
     lis.append(i)
     #print(lis)
     s.append(lis)
 
s2=sorted(s,key=lambda x:x[0])
sorted(s2,key=lambda x:x[2])
j=1
for i in range(len(s2)):
    if s2[i][0]>j:
        j=s2[i][0]
        flag=1
        count=0
    if (s2[i][0]==j)and(flag==1):
        if s2[i][1]=="WA":
            count=count+1
        elif s2[i][1]=="AC":
            account=account+1
            wacount=wacount+count
            flag=0
            count=0
                
print(account,wacount)
s=[]
lis=[]
N,M=map(int, input().split())
wacount=0
account=0
count=0
zero=0
flag=1
cur=0
changeflag=1
#s=[list(input()) for i in range(2)] 
#for range(M):
#print(N,M)
 
for i in range(M):
     lis=input().split()
     #print(lis)
     lis[0]=int(lis[0])
     lis.append(i)
     #print(lis)
     s.append(lis)
 
s2=sorted(s,key=lambda x:x[0])
sorted(s2,key=lambda x:x[2])
j=1
for i in range(len(s2)):
    if s2[i][0]>j:
        j=s2[i][0]
        flag=1
        count=0
    if (s2[i][0]==j)and(flag==1):
        if s2[i][1]=="WA":
            count=count+1
        elif s2[i][1]=="AC":
            account=account+1
            wacount=wacount+count
            flag=0
            count=0
print(account,wacount)
'''


Measured memory_bytes: 38384
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let mut m: i64 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut abv = vec![(0i64, 0i64); n];
    for i in 0..n {
        abv[i].0 = read(&mut stdin_lock, &mut buf, b' ');
        abv[i].1 = read(&mut stdin_lock, &mut buf, b'\n');
    }

    abv.sort();

    let mut ans = 0i64;
    for i in 0..n {
        let x = min(abv[i].1, m);
        ans += abv[i].0 * x;
        m -= x;
        if m <= 0 {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6524
#include <stdio.h>

using namespace std;

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x >= r && x <= W-r) && (y >= r && y <= H-r))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}


Measured memory_bytes: 2684
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>;
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
#include<cassert>
#include<deque>
using namespace std;
int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])
	{
		cout << "YES";
		return 0;
	}
	cout << "NO";
	return 0;
 } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=19,M=1<<N;
#define fi first
#define se second
typedef pair<int,int> P;
int n,v,ans[M];
P dp[M];
void merge(P &a,int x){
    if(x>=a.fi){
        a.se=a.fi;
        a.fi=x;
    }
    else if(x>a.se){
        a.se=x;
    }
}
int main(){
    scanf("%d",&n);
    dp[0]=P(-1,-1);
    for(int i=0;i<(1<<n);++i){
        scanf("%d",&v);
        dp[i]=P(v,-1);
    }
    for(int i=0;i<n;++i){
        for(int j=0;j<(1<<n);++j){
            if(j>>i&1){//去掉1位的子集
                merge(dp[j],dp[j^(1<<i)].fi);
                merge(dp[j],dp[j^(1<<i)].se);
            }
        }
    }
    for(int j=1;j<(1<<n);++j){
        ans[j]=dp[j].fi+dp[j].se;
        ans[j]=max(ans[j],ans[j-1]);
        printf("%d\n",ans[j]);
    }
    return 0;
}


Measured memory_bytes: 9216
#include<iostream>
#include<string>
#define endl '\n'
using namespace std;




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

	string s,t;
	cin >> s >> t;

	if (s.size() == t.size() - 1) {
		bool b = true;
		for (int i = 0; i < s.size(); i++)
			if (s[i] != t[i])
				b = false;
		if (b)
			cout << "Yes";
		else
			cout << "No";
	}
	else
		cout << "No";



	return 0;
}





Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  string s; cin >>s;
  ll res = 0;
  vector<int> alph(26,0);
  for (int i=0; i<N; i++){
    // s[i]を含むやつを足していく
    ll tmp = 1;
    for (int j=0; j<alph.size(); j++){
      if (s[i]-'a' == j) continue;
      tmp *= alph[j]+1;
      tmp %= MOD;
    }
    res += tmp;
    res %= MOD;
    alph[s[i]-'a']++;
  }
  cout <<res <<endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main ();
    main.solve();
  }
  
  private void solve (){
    
    Scanner scanner = new Scanner (System.in);
    
    int prefectureNum = scanner.nextInt();
    int cityNum = scanner.nextInt();
    
    ArrayList <Integer> cityList = new ArrayList <Integer>();
    ArrayList <Integer> cityListCopy = new ArrayList <Integer>();
    HashMap <Integer,Integer> map = new HashMap <Integer,Integer>();
    for (int index=0; index<cityNum; index++){
      Integer prefecture = scanner.nextInt();
      Integer year = scanner.nextInt();
      map.put(year,prefecture);
      cityList.add(year);
      cityListCopy.add(year);
    }
    
    Collections.sort(cityList);
    HashMap <Integer,Integer> orderMap = new HashMap <Integer,Integer>();
    for (Integer index=0; index<cityNum; index++){
      Integer year=cityList.get(index);
      orderMap.put(index,year);
    }
    
    int[] prefectureList = new int[prefectureNum];
    
    HashMap <Integer,Integer> CityOrder = new HashMap <Integer,Integer>();
    
    for (int index=0; index<cityNum; index++){
      int year = orderMap.get(index);
      int prefecture = map.get(year);
      int order = prefectureList[prefecture-1]+1;
      CityOrder.put(year,order);
      prefectureList[prefecture-1]+=1;
    }
    for (int index=0; index<cityNum; index++){
      int year = cityListCopy.get(index);
      int prefecture = map.get(year);
      StringBuffer sbPrefecture = new StringBuffer();
      sbPrefecture=getString(prefecture);
      int order = CityOrder.get(year);
      StringBuffer sbOrder = new StringBuffer();
      sbOrder=getString (order);
      
      
      System.out.print(sbPrefecture);
      System.out.println(sbOrder);
      
    }
  }
  
  private StringBuffer getString (int num){
    StringBuffer sb = new StringBuffer ();
	if (num<10){
      sb.append("00000");
    } else if (num<100){
      sb.append("0000");
    } else if (num<1000){
      sb.append("000");
    } else if (num<10000){
      sb.append("00");
    } else if (num<100000){
      sb.append("0");
    }
    sb.append(Integer.toString(num));
    return sb;
  }
}

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

using namespace std;

int solve(int N) {
  unordered_map<int, int> map_odd;
  unordered_map<int, int> map_even;

  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    int vi;
    cin >> vi;
    v.at(i) = vi;

    unordered_map<int, int> &map = i % 2 == 0 ? map_even : map_odd;
    if (map.find(vi) == map.end()) {
      map.insert({vi, 0});
    }
    map.at(vi) += 1;
  }

  if (N == 2) {
    return 0;
  }

  vector<tuple<int, int>> pair_even(N/2);
  for (auto &pair: map_even) {
    pair_even.push_back(make_tuple(pair.second, pair.first));
  }

  vector<tuple<int, int>> pair_odd(N/2);
  for (auto &pair: map_odd) {
    pair_odd.push_back(make_tuple(pair.second, pair.first));
  }

  sort(pair_even.begin(), pair_even.end(), greater<tuple<int, int>>());
  sort(pair_odd.begin(), pair_odd.end(), greater<tuple<int, int>>());

  if (get<1>(pair_even.at(0)) != get<1>(pair_odd.at(0))) {
    return (N - get<0>(pair_even.at(0)) - get<0>(pair_odd.at(0)));
  }

  int ans1 = N - get<0>(pair_even.at(0)) - get<0>(pair_odd.at(1));
  int ans2 = N - get<0>(pair_even.at(1)) - get<0>(pair_odd.at(0));

  return min(ans1, ans2);
}

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

  int ans = solve(N);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6676
#include <stdio.h>


int main(void)
{
  int a, b, c;
  int kawaiso = 0;
  
  scanf("%d %d %d", &a, &b, &c);
  
  if (a == b)
    kawaiso++;
  if (b == c)
    kawaiso++;
  if (c == a)
    kawaiso++;

  if (kawaiso == 1)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}



Measured memory_bytes: 1660
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std; 
#define int long long int
#define ld long double
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(v) (int) v.size()
#define For(i, st, en) for(int i=st; i<en; i++)
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef SWAPNIL07
#define endl '\n'
#endif
mt19937
rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){    // l, r inclusive
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);   }

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int arr[N], h[N], a[N];
int tree[4*N];

void build(int idx, int l, int r){
    // cout<<idx<<endl;
    if(l>r)
        return;
    if(l==r){
        tree[idx]=arr[l];
        return;
    }
    int mid = (l+r)>>1;
    build(2*idx, l, mid);
    build(2*idx+1, mid+1, r);
    tree[idx] = max(tree[2*idx], tree[2*idx+1]);
}

void update(int idx, int l, int r, int pos, int val){
    if(l > r)
        return;
    if(l > pos || r < pos)
        return;
    if(l==r && l==pos){
        tree[idx] = val;
        arr[l] = val;
    }
    if(l==r){
        return;
    }
    int mid = (l+r)>>1;
    update(2*idx, l, mid, pos, val);
    update(2*idx+1, mid+1, r, pos, val);
    tree[idx]=max(tree[2*idx], tree[2*idx+1]);
}

int query(int idx, int l, int r, int x){
    if(l > r)
        return 0;
    if(x < l)
        return 0;
    if(r <= x){
        return tree[idx];
    }
    int mid = (l+r)>>1;
    return max(query(2*idx, l, mid, x), query(2*idx+1, mid+1, r, x));
}

signed main() {
    IOS;
    #ifdef SWAPNIL07
        freopen("input.txt","r", stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n; cin>>n;
    For(i, 1, n+1){
        cin>>h[i];
    }
    For(i, 1, n+1){
        cin>>a[i];
    }
    For(i, 0, n+1){
        arr[i]=0;
    }
    int ans = 0;
    build(1, 0, n);
    for(int i=1; i<=n; i++){
        int hh = h[i];
        int aa = a[i];
        arr[hh] = aa + query(1, 0, n, hh-1);
        // cout<<hh<<" "<<arr[hh]<<endl;
        ans = max(ans, arr[hh]);
        update(1, 0, n, hh, arr[hh]);
    }
    cout<<ans;
    return 0;       
 }


Measured memory_bytes: 11264
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String A = sc.next();
        String B = sc.next();
        String C = sc.next();

        int diff=0;
        for(int i=0; i<N; i++){
            char ca = A.charAt(i);
            char cb = B.charAt(i);
            char cc = C.charAt(i);

            int tmpPlanA=0;
            if(ca != cb){
                tmpPlanA++;
            }
            if(ca != cc) {
                tmpPlanA++;
            }

            int tmpPlanB=0;
            if(cb != ca){
                tmpPlanB++;
            }
            if(cb != cc) {
                tmpPlanB++;
            }

            int tmpPlanC=0;
            if(cc != ca){
                tmpPlanC++;
            }
            if(cc != cb) {
                tmpPlanC++;
            }

            int plan=tmpPlanA;
            if(plan>tmpPlanB){
                plan=tmpPlanB;
            }
            if(plan>tmpPlanC){
                plan=tmpPlanC;
            }
            diff+=plan;
        }
        System.out.printf("%d%n",diff);
    }

}


Measured memory_bytes: 23124
k,a,b = gets.split.map(&:to_i)
if a >= b-2 || a+1 > k
  puts 1+k
else
  change = b - a
  count = k - (a-1)
  if count % 2 == 0
    puts a + (change*(count/2))
  else
    puts a + (change*(count/2)) + 1
  end
end


Measured memory_bytes: 1788
#include<stdio.h>
int main()
{
	int N;
	int A[2][150];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[0][i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[1][i]);
	}
	// 出力
	long output = 0;
	long max = 0, num = 0;
	for (int i = 0; i < N; i++){
		max += A[0][i];
	}
	max += A[1][N - 1];
	num = max;
	for (int i = N - 1; i >0; i--){
		num -= A[0][i];
		num += A[1][i - 1];
		if (num>max)max = num;
	}
	printf("%ld\n", max);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		int N = 100;
		int n;
		int[] p = new int[N + 1];
		int[][] m = new int[N+1][N+1];
		
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		for (int i = 1; i <= n; i++) {
			p[i-1] = scan.nextInt();
			p[i] = scan.nextInt();
		}
		
		for (int i = 1; i <= n; i++) {
			m[i][i] = 0;
		}
		for (int l = 2; l <= n; l++ ) {
			for (int i = 1; i <= n - l + 1; i++ ) {
				int j = i + l - 1;
				m[i][j] = Integer.MAX_VALUE;
				for (int k = i; k <= j -1; k++ ){
					int x = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
					if (x < m[i][j]) {
						m[i][j] = x;
					}
				}
			}
		}
		
		System.out.println(m[1][n]);
		scan.close();
	}

}

Measured memory_bytes: 26588