akhauriyash/Code-Regression huggingface dataset:
import java.util.Deque;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Deque<Integer> queue = new LinkedList<>();
		Deque<String> names = new LinkedList<>();
		int time = 0;
		int n = sc.nextInt();
		int q = sc.nextInt();
		for (int i = 0; i < n; i++) {
			names.add(sc.next());
			queue.add(sc.nextInt());
		}
		while (queue.size() > 0) {
			queue.addLast(queue.poll() - q);
			names.addLast(names.poll());
			time += q;
			if (queue.peekLast() <= 0) {
				time += queue.pollLast();
				System.out.println(names.pollLast() + " " + time);
			}
		}
	}
}



Measured memory_bytes: 75760
def solve():
  n = int(input())
  if n == 0:
    print(0)
    exit()
  n *= -1
  ans = ""
  while n != 0:
    if n%2 == 1:
      ans = "1"+ans
    else:
      ans = "0"+ans
    n //= -2
  print(ans)
solve()

Measured memory_bytes: 2940
program sum_of_three_integers
  implicit none
  integer :: k, s, i, m
  read(*,*) k, s
  m = 0
  do i = 0, min(k,s)
    m = m+max(0,min(k,s-i)-max(0,s-i-k)+1)
  end do
  write(*,'(i0)') m
  stop
end program sum_of_three_integers

Measured memory_bytes: 256
l = [];n = int(input())
for i in range(1,n+1):
    x = i
    if x%3==0 or x%10==3:
        l.append(i)
    elif x%10!=3:
        while(x):
            x = int(x/10)
            if(x%10==3):
                l.append(i);break;
for i in range(len(l)):
    print(" %d"%l[i],end = '')
print()


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


#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 1e3 + 5;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

ll dp[maxn][(1 << 12) + 5];

int n,m;
int a[maxn], b[maxn];

ll solve(int pos, int mask)
{
  if(mask == (1 << n) - 1)
    return 0;
  if(pos == m)
    return INF;
  ll &ans = dp[pos][mask];
  if(ans != -1)
    return ans;
  ans = INF;
  ans = min(ans, solve(pos + 1, mask));
  ans = min(ans, solve(pos + 1, mask | b[pos]) + a[pos]);
  return ans;
}

int main()
{
  MSET(dp, -1);
  cin >> n >> m;
  for(int i = 0; i < m ; i++)
  {
    cin >> a[i];
    int qt;
    cin >> qt;
    for(int j = 0 ; j < qt; j++)
    {
      int c;
      cin >> c;
      c--;
      b[i] |= (1 << c);
    }
  }

  auto ans = solve(0,0);
  if(ans == INF)
    ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35912
// AtCoder ABC113: C - ID
// 2020.1.29 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long ll;

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示（出力）
	int i, k; char b[30];

	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	k = 6 - i;
	while (k--) pc('0');
	while (i--) pc(b[i]);

}

#define MAX 100005
typedef struct { int id; ll n; int p, x; } T;
T t[MAX]; int M;

void Usort(T *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	ll t1[1 << B], t2[1 << B];
	
	T *tmp = malloc(n * sizeof(T));	
	for (k = 0; k < 8; ++k) {  // for 64ビット
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i].n >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
		i = n; while (i--) tmp[--t1[(a[i].n >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i].n >> k*B) & BMSK]++;
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
		i = n; while (i--) a[--t2[(tmp[i].n >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
// for (i = 0; i < n; ++i) printf("[%d] %lld\n", i, a[i]);
}

int ap[MAX], ax[MAX];

int main()
{
	int i, N, P, Y;
	
	N = in(), M = in();
	for (i = 1; i <= M; ++i) {
		P = in(), Y = in();
		t[i].id = i, t[i].n = ((ll)P << 32) | Y, t[i].p = P;
		ap[i] = P;
	}
	Usort(t+1, M);
	for (i = 1; i <= M; ++i) {
		if (t[i].p != t[i-1].p) ax[t[i].id] = t[i].x = 1;
		else ax[t[i].id] = t[i].x = t[i-1].x+1;
	}
	for (i = 1; i <= M; ++i) {
		out(ap[i]), out(ax[i]), pc('\n');
	}
	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <limits.h>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    int ans=0;
    for(int i=0;i<n;i++){
        int x=0;
        while(t[x]==s[i+x]){
            x++;
            if(x+i==n){
                break;
            }
        }
        ans=max(ans,x);
    }
    cout << n*2-ans << endl;
}

Measured memory_bytes: 256
def fact(n):
  result = n
  for i in range(n - 1, 0, -1):
    result *= i
  return result

while True:
  n = int(input())
  if n == 0:
    break
  f = list(str(fact(n)))
  count = 0
  while True:
    check = f.pop()
    if check != '0':
      break
    else:
      count += 1
  print(count)



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

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

int main(){
    int N;
    cin >> N;
    ll ans = 1;
    rep(i, N){
        ll t;
        cin >> t;
        ans *= t / gcd(ans, t);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N,M = map(int, raw_input().split())
ab = [[0 for i in range(2)] for j in range(N)]
for i in range(N):
    ab[i][0], ab[i][1] = map(int, raw_input().split())
AB = sorted(ab, key=lambda x:x[0])
count = 0
total = 0
for AB_ in AB:
    num = min(M, AB_[1])
    total += AB_[0]*num
    M -= num
print total

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

int n, a[3][3], b[10];
bool appear[3][3];

int main(){
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++)
            cin >> a[i][j];
    }
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            appear[i][j] = false;
            for (int k = 0; k < n; k++){
                if(a[i][j] == b[k])
                    appear[i][j] = true;
            }
        }
    }
        string ans = "No";
    for (int i = 0; i < 3; i++)
    {
        if (appear[0][i] and appear[i][1] and appear[i][2])
            ans = "Yes";
}
for (int i = 0; i < 3; i++){
    if(appear[0][i] and appear[1][i] and appear[2][i])
        ans = "Yes";
}
if(appear[0][0] and appear[1][1] and appear[2][2])
    ans = "Yes";
if(appear[0][2] and appear[1][1] and appear[2][0])
    ans = "Yes";
cout << ans << endl;

return 0;
}

Measured memory_bytes: 3636
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    yt = []
    p = 1
    nk = 1000
    kb = 0
    for i,na in enumerate(a[1::]):
        ai = a[i]
        if p:
            if ai < na:
                p = 0
                kb = nk//ai
                nk %= ai
        else:
            if ai > na:
                p = 1
                nk += kb*ai
                kb = 0

    print(nk+kb*a[-1])
    return None

if __name__ == '__main__':
    main()


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

int main() {
  string s;int h = 200001,t;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) == 'A' && i < h){
      h = i;
    }
    if(s.at(i) == 'Z'){
      t = i;
    }
  }
  cout << t-h+1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll count_range(const vector<ll>& cs, ll left, ll right){
    if(right == 0 || left >= right){ return 0; }
    ll ret = cs.at(min(right - 1, (ll)cs.size() - 1));
    if(left > 0){ ret -= cs.at(left - 1); }
    return ret;
}

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll q;
    cin >> q;

    // csc[i] = num of C in [0, i]
    // csm[i] = num of M in [0, i]
    vector<ll> csc(n, 0), csm(n, 0);
    REP(i, n){
        if(i > 0){
            csc.at(i) = csc.at(i - 1);
            csm.at(i) = csm.at(i - 1);
        }
        csc.at(i) += s.at(i) == 'C';
        csm.at(i) += s.at(i) == 'M';
    }

    // num of MC in [i, n)
    vector<ll> num_mc(n, 0);
    RREP(i, n){
        if(i + 1 < n){ num_mc.at(i) = num_mc.at(i + 1); }
        if(s.at(i) == 'M'){
            num_mc.at(i) += count_range(csc, i + 1, n);
        }
    }

    REP(i, q){
        ll ki;
        cin >> ki;

        ll ans = 0;
        REP(j, n - 2){
            if(s.at(j) != 'D'){ continue; }
            ll tmp = 0;
            tmp += num_mc.at(j + 1);
            if(j + ki < n){
                tmp -= num_mc.at(j + ki);
            }
            tmp -= count_range(csm, j + 1, j + ki) * count_range(csc, j + ki, n);
            assert(tmp >= 0);
            ans += tmp;
        }
        cout << ans << endl;
    }
    return 0;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 200005
#define f first
#define s second
using namespace std;

int main()
{
    FLASH
    ll n,x;
    unsigned ll ans = 1;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++)
    {
    	cin >> a[i];
    	if(a[i] == 0)
    	{
    		cout << 0;
    		return 0;
    	}
    }
    for(int i = 0; i < n; i++)
    {
    	if(ans > 1000000000000000000 / a[i])
    	{
    		cout << -1;
    		return 0;
    	}
    	ans *= a[i];
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4396
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

using std::cout;
using std::cin;
using std::endl;


#define __int128 int64_t

__int128 A[200100];
int qtype[200100];
__int128 qx[200100];
__int128 qs[200100];
__int128 qt[200100];

const int64_t INF = 2000000000;
const int64_t INFINF = (((uint64_t)(1) << 63) - 1);

int main()
{

	int N, Q;
	__int128 L, R;

	cin >> N >> Q >> L >> R;

	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}

	for (int i = 0; i < Q; ++i) {
		cin >> qtype[i] >> qx[i] >> qs[i] >> qt[i];
	}

	//L以上になる条件
	int64_t ok_range = INF, ng_range = -INF;
	while (std::abs(ok_range - ng_range) > 1) {
		auto mid = (ok_range + ng_range) / 2;

		auto nowpos = mid;
		for (int i = 0; i < Q; ++i) {
			if (qtype[i] == 1) {
				if (qx[i] <= nowpos) {
					nowpos = qt[i] * (nowpos + qs[i]);
				}
			}
			else {
				if (nowpos <= qx[i]) {
					nowpos = (nowpos - qs[i])/ qt[i];
				}
			}
		}
		if (L <= nowpos) {
			ok_range = mid;
		}
		else {
			ng_range = mid;
		}
	}
	auto LLL = ok_range;

	//R以下になる条件
	ok_range = -INF, ng_range = INF;
	while (std::abs(ok_range - ng_range) > 1) {
		auto mid = (ok_range + ng_range) / 2;

		auto nowpos = mid;
		for (int i = 0; i < Q; ++i) {
			if (qtype[i] == 1) {
				if (qx[i] <= nowpos) {
					nowpos = qt[i] * (nowpos + qs[i]);
				}
			}
			else {
				if (nowpos <= qx[i]) {
					nowpos = (nowpos - qs[i]) / qt[i];
				}
			}
		}
		if (nowpos <= R) {
			ok_range = mid;
		}
		else {
			ng_range = mid;
		}
	}
	auto RRR = ok_range;

	int count = 0;
	for (int i = 0; i < N; ++i) {
		if (LLL <= A[i] && A[i] <= RRR) {
			++count;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 9940
#include <bits/stdc++.h>
using namespace std;
const int N = 500 * 500 + 5;
int n, x[N], c[N], id[N], a[N];
int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &x[i]), id[i] = i;
	sort(id + 1, id + n + 1, [](int a, int b) { return  x[a] < x[b]; });
	for(int i = 1, p = 1; i <= n; ++i) {
		for(int j = p; j < x[id[i]] && c[id[i]] < id[i] - 1; ++j, p = j)
			if (!a[p]) a[p] = id[i], c[id[i]]++;
		if (id[i] - 1 == c[id[i]] && x[id[i]] >= p) a[x[id[i]]] = id[i];
	}
	int flag = true;
	for(int i = 1; i <= n; ++i) flag &= a[x[i]] == i, flag &= c[i] == i - 1;
	if (!flag) { printf ("No\n"); return 0; }
	for(int i = n, p = n * n; i >= 1; --i) for(int j = p; j > x[id[i]] && c[id[i]] < n - 1; --j, p = j) {
		if (!a[p]) a[p] = id[i], c[id[i]]++;
	}
	flag = true;
	for(int i = 1; i <= n; ++i) flag &= c[i] == n - 1;
	if (!flag) { printf ("No\n"); return 0; }
	printf("Yes\n");
	for(int j = 1; j <= n * n; ++j) printf("%d%c", a[j], " \n"[j == n * n]);
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {

		boolean prime_flag;
		int cnt = 0;
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		for (int i = 0,j; i < N; i++) {
			 prime_flag = true;
			 j = sc.nextInt();
			 if(j % 2 == 0 && j != 2){
				prime_flag = false;
			 }

			 for (int k = 3; k <= Math.sqrt(j) && prime_flag; k += 2){
				 if(j % k == 0){
					prime_flag = false;
					break;
				 }
			 }
			 if(prime_flag){
				 cnt++;
			 }
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 12000
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int c1 = 0, c2 = 0;
    for (int i = 0; i < n;i+=2){
        if(s[i]=='0')
            c1++;
        else
            c2++;
    }
    for (int i = 1; i < n;i+=2){
        if(s[i]=='0')
            c2++;
        else
            c1++;
    }
    cout << min(c1, c2) << endl;
}

Measured memory_bytes: 512
fn main() {
    let (n,m) = { 
        let s = rv::<usize>();
        (s[0],s[1])
    };
    let mut p = vec![-1;n+m];
    let mut k = vec![0usize;m];
    for i in 0..n {
        let s = rv::<usize>();
        for &l in &s[1..] {
            k[l-1]=1;
            u(i,n+l-1,&mut p);
        }
    }
    let k=k.into_iter().sum::<usize>();
    println!("{}",if n+k==c(0,&mut p) {"YES"} else {"NO"});
}
fn f(i: usize, p: &mut Vec<i32>) -> usize {
    if p[i]<0 {
        i
    }
    else {
        p[i]=f(p[i]as usize,p)as i32;
        p[i] as usize
    }
}
fn u(i: usize, j: usize, p: &mut Vec<i32>) {
    let mut i=f(i,p);
    let mut j=f(j,p);
    if i==j {return;}
    if i<j {std::mem::swap(&mut i, &mut j);}
    p[j]+=p[i];
    p[i]=j as i32;
}
fn c(i: usize, p: &mut Vec<i32>) -> usize {
    let i=f(i,p);
    (-p[i])as usize
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T>
  where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 6396
H,W=map(int, raw_input().split())
N=input()
a=map(int, raw_input().split())

s=[]
for ind, i in enumerate(a):
	for j in range(i):
		s.append(str(ind+1))

for i in range(H):
	tmp_s=s[i*W:i*W+W]
	if i%2==1:
		print ' '.join(tmp_s[::-1])
	else:
		print ' '.join(tmp_s)


Measured memory_bytes: 3204
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  print_newline ();
  preorder (fun e -> print_string " "; print_int e) t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let rec read i t =
    if i < m then
      match read_line () |> split_on_char ' ' with
      | ["insert"; n] -> read (i + 1) (insert (int_of_string n) t)
      | ["find"; n] -> print_endline (if find (int_of_string n) t then "yes" else "no"); read (i + 1) t
      | _ -> print t; read (i + 1) t in
  read 0 (create ())

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

int main(void) {
	int i, j;
	int count = 0;
	char str[101];
	while (scanf("%s", str) != EOF) {
		j = strlen(str) - 1;
		for (i = 0; i < j; i++) {
			if (str[i] == str[j])
				j--;
			else
				break;
		}
		if (i >= j)
			count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ll K, A, B;
	cin >> K >> A >> B;
	
	auto ans = 1ll;
	if (A + 2 >= B || A + 1 > K)
	{
		ans += K;
	}
	else
	{
		K -= A - 1;
		ans = A + (B - A) * (K / 2);
		if (K % 2 > 0)
		{
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int Stack[1000];
int top;

void push(int x) {

	top++;
	Stack[top] = x;

}

int pop() {

	top--;

	return Stack[top+1];
}

int main() {
	
	int a, b;
	top = 0;
	char s[100];

	while(scanf("%s",s) != EOF){
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
//			printf("c\n");
		}
		else if (s[0] == '-') {
			a = pop();
			b = pop();
			push(b - a);
//			printf("d\n");
		}else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
//			printf("e\n");
		}else{
//			printf("a\n");
			push(atoi(s));
		}
	}

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

	return 0;

}

Measured memory_bytes: 552
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

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

/** 1. if smallest first and biggest last, two sortings end in same P.
 *  2. if subsets are presorted their sorting ends in same result. (n-1 time) */
    cini(n);
    cini(k);
    cinai(p, n);

    vb sorted(n);   // if sorted[i], p[i]...p[i+k-1] is sorted

    int unsort=0;
    int scount=0;
    
    for(int i=1; i<n; i++) {
        if(p[i-1]>p[i])
            unsort=i;

        if(i-unsort+1>=k) {
            sorted[i-(k-1)]=true;
            scount++;
        }
    }

    multiset<int> ms;
    for(int i=0; i<k; i++)
        ms.insert(p[i]);
    

    int ans=n-k+1;
    for(int i=0; i<n-k; i++) {
        ms.insert(p[i+k]);
        int mi=*ms.begin();
        int ma=*ms.rbegin();
        if(p[i]==mi && p[i+k]==ma && !sorted[i])
            ans--;
        ms.erase(ms.find(p[i]));
    }
    if(scount>1)
        ans-=(scount-1);

    cout<<ans<<endl;

}



Measured memory_bytes: 10496
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    ll a[n],b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    bool same = true;
    for(int i = 0; i < n; i++){
        if(a[i] != b[i]) same = false;
    }
    if(same){
        cout << 0 << endl;
    }else{
        ll sum = 0,sub = INF;
        for(int i = 0; i < n; i++){
            sum += a[i];
            if(sub > b[i] && a[i] > b[i]) sub = b[i];
        }
        cout << sum - sub << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define HRX 1e18
#define INF 1000000007
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;


int main()
{
  hs;
  ll n;
  cin>>n;
  ll a[n];
  f(n)
  {
    cin>>a[i];
  }
  ll cnt=0;
  for(ll i=1;i<n-1;i++)
  {
    if((a[i]>a[i-1] && a[i]<a[i+1])|| (a[i]<a[i-1] && a[i]>a[i+1]))
        cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pro{
	char name[100];
	int time;
}pro_in;

pro_in pros[LEN];
int head,tail,n;

void enqueue(pro_in x)
{
	pros[tail]=x;
	tail=(tail+1)%LEN;
}

pro_in dequeue()
{
	pro_in x;
	
	x=pros[head];
	head=(head+1)%LEN;
	
	return x;
}

int samll(int q,int t)
{
	if(t<q)
	{
		return t;
	}
	if(q<t)
	{
		return q;
	}
	if(q==t)
	{
		return t;
	}
}

int main(void)
{
	int i;
	int q;
	pro_in outp;
	int c,total=0;
	
	scanf("%d %d",&n,&q);
	
	for(i=1;i<=n;i++)
	{
		scanf("%s",pros[i].name);
		scanf("%d",&pros[i].time);
	}
	
	head=1;
	tail=n+1;
	
	while(head!=tail)
	{
		outp=dequeue();
		c=samll(q,outp.time);
		outp.time-=c;
		total+=c;
		
		if(outp.time>0)
		{
			enqueue(outp);
		}
		else
		{
			printf("%s %d\n",outp.name,total);
		}
	}
	
	return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (ll i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << (x) << endl
#define int long long
using namespace std;
using II = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

signed main() {
  int N = in();
  VI A(N);
  REP (i, N) cin >> A[i];
  sort(ALL(A));
  int ans = 0;
  int l = 0, r = N - 1;
  ans += A[N - 1] - A[0];
  while (l < r - 2) {
    ans += A[r - 1] - A[l];
    ans += A[r] - A[l + 1];
    l++; r--;
  }
  if (l == r - 2) {
    ans += max(A[l + 1] - A[l], A[r] - A[r - 1]);
  } else {
    assert(l == r - 1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1152
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    N,M = i_map()
    a = [s_input() for _ in range(N)]
    b = [s_input() for _ in range(M)]

    for i in range(N-M+1):
        for j in range(N-M+1):
            flg = True

            for x in range(M):
                for y in range(M):
                    if b[x][y] != a[i+x][j+y]:
                        flg = False
                        break
                if flg == False:
                    break
            if flg == True:
                print("Yes")
                exit()
    print("No")

if __name__=="__main__":
    main()


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	int x,D;

	vi v;
	deque<int>dq;

	cin>>n;

	cin>>D>>x;

	f(i,0,n-1) {
        int a;
        cin>>a;
        v.pb(a);
	}

	f(i,0,n-1){
        f(j,0,D){
           m=j*v[i]+1;
           if(m<=D) dq.pb(m);
        }
	}
	cout<<dq.size()+x<<endl;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int t , n;
int a , b , c;
string s;

int main()
{
    _FastIO;
    cin >> n;
    if(n >= 30){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
    return 0;
}


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

int main(){
 	int n,m;
	cin >>n >> m;
	if(m!=100)
  	cout << m << (n==2? "00" : "") <<(n>=1?"00":"")<< endl;
	else
      	cout << m+1<<(n==2? "00" : "") <<(n>=1?"00":"")<< 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 = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        
        if (A == B) {
            System.out.println(C);
        } else if (B == C) {
            System.out.println(A);
        } else {
            System.out.println(B);
        }
    }
}

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

int main()
{
    int N, count=0;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N;i++){
        cin >> a.at(i);
        if(a.at(i)%2==0){
            if(a.at(i)%3==0 || a.at(i)%5==0){
            
            }
            else{
                count = 1;
            }

        }
        //cout << i << "-" << count << endl;
    }
    if(count==0){
        cout << "APPROVED" << endl;
    }
    else{
        cout << "DENIED" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
 
int main() {
    ll N,i,H,s=0,A[100000];
    cin>>H>>N;
    for(i=0;i<N;i++)
        cin>>A[i];
      for(i=0;i<N;i++)
        s+=A[i];
  	if(s>=H)
    cout<<"Yes";
    else
    cout<<"No";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    }else if(a == b){
        cout << "a == b" << endl;
    }else{
        cout << "a < b" << endl;
    }
}



Measured memory_bytes: 3088
S = list(input())
N = len(S)
S.append("R")

ans = [int(0)] * N
count = 0
state = "R"

for i in range(N+1):
        if S[i] == state:
                count += 1
        else:
                odd = int((count + 1)/2)
                even = int(count/2)
                if state == "R":
                        ans[i-1] += odd
                        ans[i] += even
                elif state == "L":
                        ans[i-count] += odd
                        ans[i-count-1] += even

                state = S[i]
                count = 1

for i in range(N):
        print(ans[i], " ", end = "")

print("")

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

using namespace std;

#define int long long
int mod = 998244353;
int gt[300005], cgt[300005];
int pw(int a, int pm){
	if(pm == 0) return 1;
	int p = pw(a, pm / 2);
	if(pm % 2 == 0) return p * p % mod;
	else return p * p % mod * a % mod;
}
int nck(int a, int b){
	if(a < b) return 0;
	return gt[a] * cgt[b] % mod * cgt[a - b] % mod;
}
signed main(){
	int n, a, b, k;
	cin >> n >> a >> b >> k;
	gt[0] = 1;
	cgt[0] = 1;
	for(int i = 1; i <= n; i++){
		gt[i] = gt[i - 1] * i % mod;
		cgt[i] = cgt[i - 1] * pw(i, mod - 2) % mod;
	}
	int ans = 0;
	for(int i = 0; i <= min(n, k / a); i++){
		if((k - i * a) % b == 0){
			int j = (k - i * a) / b;
			ans = (ans + nck(n, i) * nck(n, j)) % mod;
		}
	}
	cout << ans;
}

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

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

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

int main(){
	ll n, x;
	cin >> n >> x;
	vector<ll>num(n+1);
	rep(i, n)cin >> num[i];
	num[n] = x;
	sort(num.begin(), num.end());
	vector<ll>dif(n);
	rep(i, num.size() - 1){
		dif[i] = num[i+1] - num[i];
	}
	ll ans = dif[0];
	for(int i = 1; i < dif.size(); i++){
		ans = gcd(dif[i], ans);		
	}
	cout << ans << endl;

}

Measured memory_bytes: 1792
import heapq
from collections import deque
N,M = map(int,input().split())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
A = [(-A[i][1],A[i][0]) for i in range(N)]
A = deque(A)
heap = []
cnt = 0
for i in range(M-1,-1,-1):
    k = M-i
    while len(A)>0 and A[0][1]<=k:
        heapq.heappush(heap,A.popleft())
    if len(heap)>0:
        b,a = heapq.heappop(heap)
        b = -b
        cnt += b
print(cnt)

Measured memory_bytes: 103076
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int z[4]= {1,-1,0,0},zz[4]= {0,0,1,-1},q1,q2;
int n,a[510000],b,cd,mp[510][510],q[510][510],ans;
int dfs(int x,int y) {
	if(x<=-1||x>n||y<=-1||y>n)
	{
		return 0;
	}
	for(int xx=0; xx<4; xx++) {
		int cx=x+z[xx],cy=y+zz[xx];
		if(mp[cx][cy]>mp[x][y]+q[cx][cy]) {
			mp[cx][cy]=mp[x][y]+q[cx][cy];
			dfs(cx,cy);
		}
	}
	return 0;
}
int main() {
	cin>>n;
	for(int x=1; x<=n*n; x++) {
		cin>>a[x];
	}
	for(int x=1; x<=n; x++) {
		for(int y=1; y<=n; y++) {
			q[x][y]=1;
			mp[x][y]=min(min(x,n-x+1),min(y,n-y+1));
		}
	}
	for(int x=1; x<=n*n; x++) {
		q1=(a[x]-1)/n+1;
		q2=a[x]%n;
		if(q2==0) {
			q2=n;
		}
		q[q1][q2]=0;
		ans+=mp[q1][q2]-1;
		mp[q1][q2]-=1;
		dfs(q1,q2);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 21600
#include<bits/stdc++.h>
    using namespace std;
     
    int main() {
      string S;
      cin >> S;
      int n = S.size(), r = 0;
      for (int i = 0, j = n-1; i < j; i++, j--) {
		r += S[i] != S[j];
      }
      cout << r << endl;
      return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>

int A[100000],B[100000];

int main(void){
  int N;
  scanf("%d",&N);
  int i;
  int minrank ,minscore = 10000000000;
  for(i=0;i<N;++i){
    int a,b;
    scanf("%d %d",&a,&b);
    if(b < minscore){
      minrank = a;
      minscore = b;
    }
  }
  printf("%d\n",minrank + minscore);
  return 0;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;

using ld = long double;
using vd = vector<double>;
using vvd = vector<vd>;

#define FOR(i,a,b) for(ll i=(a); i < (b); (i)++)

#define DBG 0
#define TR(X) ({if (DBG) cerr << "TR " << (#X) << " = " << (X) << endl; })
#define TRM(i,j,c) ({if (DBG) cerr << "TR (" << (i) << ", " << (j) << ") = " << (c)[i][j] << endl;})

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

    ll N;
    cin >> N;
    vd p(N);
    FOR(i,0,N)
        cin >> p[i];

    vvd dp(N+1, vd(N+1));
    dp[0][0] = 1;

    FOR(i,0,N) FOR(j,0,i+1){
        dp[i+1][j] += dp[i][j] * (1-p[i]);
        dp[i+1][j+1] += dp[i][j] * p[i];
    }
    ld res = 0;
    FOR(i,(N+1)/2,N+1){
        res += dp[N][i];
    }
    cout << fixed << setprecision(9) << res << endl;
}


Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 2000;
const int MOD = 1001;


struct UnionFind {
    //number of parents(par[i] = i => root)
    vector <int> par;
    //rank of tree
    vector <int> rank;

    UnionFind(int n) : par(n), rank(n, 1) {
        //initialize
        rep(n, i) par[i] = i;
    }

    //find root (keiroasshuku at the same time)
    int root(int x){
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //unite
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) swap(x, y);
        par[x] = y;
        if (rank[x] == rank[y]) rank[y]++;
    }

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

int f[MAX];

void solve(void){
	int V, d;

	f[0] = 1, f[1] = 2;
	rep(MOD, i) f[i+2] = (f[i] + f[i+1]) % MOD;

	while (cin >> V >> d) {
		UnionFind uf(V);
		rep(V, i) {
			Rep(i+1, V-1, j) {
				if (abs(f[i+1]-f[j+1]) < d) uf.unite(i, j);
			}
		}
		set <int> s;
		rep(V, i) s.insert(uf.root(i));
		cout << s.size() << endl;
	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



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

class disjointSet{
    public:
    vector<int> rank,p;
    disjointSet(){}
    disjointSet(int size){
        rank.resize(size);
        p.resize(size);
        rep(i,size)makeSet(i);
    }
    void makeSet(int x){
        p[x]=x;
        rank[x]=0;
    }
    void unite(int x,int y){
        x=findg(x);y=findg(y);
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[x]=y;
            if(rank[x]==rank[y])rank[y]++;
        }
    }
    int findg(int x){
        if(x!=p[x]){
            p[x]=findg(p[x]);
        }
        return p[x];
    }
};

int main(){
    int n,m;cin>>n>>m;
    disjointSet S(n);
    int a,b;
    rep(i,m){
        scanf("%d %d",&a,&b);
        a--;b--;
        S.unite(a,b);
    }
    int ans=0;
    int B[n];
    rep(i,n)B[i]=0;
    rep(i,n){
        int group=S.findg(i);
        B[group]++;
    }
    rep(i,n){
        ans=max(ans,B[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5656
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in); 
        int x;
         
        for(int i = 1; i <= 10000; i++){
            x = scan.nextInt();
            if(x == 0){
                break;
            }
             
            System.out.println("Case " + i + ": " + x);
        }
     
    }
 
}

Measured memory_bytes: 43184
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define reverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
	int A,B;
  	cin>>A>>B;
  	cout<<A*B<<endl;
}

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

// 写経
int main() {
  int k;
  cin >> k;
  int x = 7%k;
  set<int> s;
  int i = 1;
  while(s.count(x) == 0) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    s.insert(x);
    x = (x*10+7)%k;
    ++i;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 50476
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int x = x2;
		int y = y2;
		int distX = x2 - x1;
		int distY = y2 - y1;

		for (int i = 0; i < 2; i++) {
			int tmp = distX;
			distX = distY;
			distY = tmp;

			distX = -distX;

			x2 += distX;
			y2 += distY;

			System.out.print(x2 + " " + y2 + " ");
		}
	}
}

Measured memory_bytes: 21972
#include <iostream>
using namespace std;
int main(){
  int n, num[100000] = {0}, count = 0, max = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> num[i];
  }
  for(int i = 0; i < n - 1; i++){
    if(num[i] >= num[i + 1]){
      count++;
      if(i == n - 2){
        if(max < count){
          max = count;
        }
      }
    }else{
      if(max < count){
        max = count;
      }
      count = 0;
    }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

typedef long long LL;

const int N=105;
const int MOD=1000000007;

int n,f[N][N],h[N],w[N],m;

int ksm(int x,int y)
{
    if (y<0) return 1;
    int ans=1;
    while (y)
    {
        if (y&1) ans=(LL)ans*x%MOD;
        x=(LL)x*x%MOD;y>>=1;
    }
    return ans;
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&h[i]),w[++m]=h[i];
    std::sort(w+1,w+m+1);
    m=std::unique(w+1,w+m+1)-w-1;
    for (int i=1;i<=n;i++) h[i]=std::lower_bound(w+1,w+m+1,h[i])-w;
    f[0][0]=1;
    for (int i=1;i<=n;i++)
    {
        for (int j=h[i]+1;j<=h[i-1];j++) (f[i][0]+=f[i-1][j]*2%MOD)%=MOD;
        (f[i][0]+=f[i-1][0]*2%MOD)%=MOD;
        for (int j=1;j<=h[i];j++)
        {
            f[i][j]=(LL)f[i-1][j]*ksm(2,w[h[i]]-w[h[i-1]])%MOD;
            if (h[i-1]>=j) continue;
            if (j>1) (f[i][j]+=(LL)f[i-1][0]*(ksm(2,w[j]-w[j-1])-1)%MOD*2%MOD*ksm(2,w[h[i]]-w[j])%MOD)%=MOD;
            else (f[i][j]+=(LL)f[i-1][0]*(ksm(2,w[j])-2)%MOD*ksm(2,w[h[i]]-w[j])%MOD)%=MOD;
        }
    }
    int ans=0;
    for (int i=0;i<=m;i++) (ans+=f[n][i])%=MOD;
    printf("%d",ans);
    return 0;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int N_MAX = 100000;
int main()
{
  int n,k,i,t,res=1000000000;
  int h[N_MAX];
  cin >> n >> k;
  for(i=0;i<n;i++)
    cin >> h[i];
  sort(h,h+n);
  for(i=0;i<n-k+1;i++){
    t=h[i+k-1]-h[i];
    if(t<res) res=t;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
n, l = map(int, input().split())

apple = [l+i for i in range(n)]

if l > 0:
    ans = sum(apple) - apple[0]
elif (l + n - 1) >= 0:
    ans = sum(apple)
elif (l + n - 1) < 0:
    ans = sum(apple) - apple[-1]

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
class Data{
public:
    string bc;
    int t;
    Data(string bc,int t):bc(bc),t(t){}
    Data(){}
};
bool judge(string s,int l){
    for(int i=0;i<l-1;++i){
        if(s[i]!=s[i+1])return false;
    }
    return true;
}
char cj(char a,char b){
    if(a=='b'&&b=='g')return 'r';
    if(a=='b'&&b=='r')return 'g';
    if(a=='g'&&b=='r')return 'b';
    swap(a,b);
    if(a=='b'&&b=='g')return 'r';
    if(a=='b'&&b=='r')return 'g';
    if(a=='g'&&b=='r')return 'b';
}
int main()
{
    string s;
    while(cin>>s,s!="0")
    {
        int l=s.length();
        int res=-1;
        queue<Data> Q;
        set<string> visited;
        Q.push(Data(s,0));
        while(!Q.empty())
        {
            Data t=Q.front();
            Q.pop();
            if(visited.count(t.bc))continue;
            if(judge(t.bc,l)){
                res=t.t;
                break;
            }
            visited.insert(t.bc);
            for(int i=0;i<l-1;++i){
                if(t.bc[i]==t.bc[i+1])continue;
                char nc=cj(t.bc[i],t.bc[i+1]);
                string nbc=t.bc;
                nbc[i]=nbc[i+1]=nc;
                Q.push(Data(nbc,t.t+1));
            }
        }
        if(res==-1)
                cout<<"NA"<<endl;
        else
                cout<<res<<endl;
    }
    return 0;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;

int main()
{
  string s, t; cin >> s >> t;
  int d = s.size();
  int i = 0;
  bool ok = true;
  while (d > 0)
  {
    //cout << s[i] << endl;
    if (s[i] != t[i])
    {
      ok = false;
      break;
    }
    d--;
    i++;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
/*
 * Author : Sadi
 * Wed 01/07/2020
 * 18:23:09.20
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int a, b;
    cin >> a >> b;
    if(a & 1 ^ 1 or b & 1 ^ 1) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 3596