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

public class Main {
    
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        
        while (true) {
            // read line
            int a = scanner.nextInt();
            String op = scanner.next();
            int b = scanner.nextInt();
            
            if ("?".equals(op)) {
                break;
            }
            
            // calc output
            switch(op) {
                case "+":
                    sb.append(a + b).append("\n");
                    break;
                case "-":
                    sb.append(a - b).append("\n");
                    break;
                case "*":
                    sb.append(a * b).append("\n");
                    break;
                case "/":
                    if (a % b == 0) { 
                        sb.append(a / b).append("\n"); 
                    } else {
                        long adivb = (long)Math.floor(a / b);
                        sb.append(adivb).append("\n"); 
                    }
                    break;
                default:
                    break;
            }
        }
        
        System.out.print(sb);
    }
    
}


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

int main(){
  int n, z, w;
  int a[2001];
  cin >> n >> z >> w;
  for(int i = 0; i < n; i++) cin >> a[i];
  if(n == 1) cout << abs(a[0] - w) << endl;
  else cout << max(abs(a[n-1] - w), abs(a[n-1] - a[n-2])) << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        mut s: Chars,
    }

    let mut ans = 0;
    loop {
        s.pop();
        if s.len() % 2 != 0 { continue; }

        if s[0..s.len()/2] == s[s.len()/2..s.len()] {
            ans = s.len();
            break;
        }
    }

    println!("{}", ans);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2172
// e
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
const int maxn=1e6+7;
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define rep(i,a,b) for(int i=a;i>=b;--i)
#define endl '\n'
int n,dp[maxn][2];
string s;
int main(){
    IOS
    cin>>s;
    n=s.length();
    dp[n-1][0]=s.back()-'0';// pay the literally number of 個位數
    dp[n-1][1]=1+(10-(s.back()-'0'));// 10-個位數 == 11-change
    rep(i,n-2,0){
        dp[i][0]=min(dp[i+1][0],dp[i+1][1])+s[i]-'0';// pay literally number
        dp[i][1]=min(dp[i+1][0]+1+10-(s[i]-'0'),dp[i+1][1]+9-(s[i]-'0'));// dp[i+1][1]+(21,31,41)+9-某位數       
    }
    cout<<min(dp[0][0],dp[0][1])<<endl;
}



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

using namespace std;

char a[60][60];
int b[60],c[60][30],d[30];

int main()
{
    int n,i,j;
    cin >> n;
    for(i=0;i<n;i++)
    {
        scanf(" %s",a[i]);
        b[i]=strlen(a[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<b[i];j++)
        {
            c[i][a[i][j]-'a']++;
        }
        for(j=0;j<26;j++)
        {
            if(i==0) d[j]=c[i][j];
            else d[j]=min(d[j],c[i][j]);
        }
    }
    for(i=0;i<26;i++)
    {
        for(j=0;j<d[i];j++)
        {
            printf("%c",i+'a');
        }
    }
    printf("\n");
    return 0;
}

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

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

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

int K;
int a[101010];

bool C(int mid) {
  for (int i = 0; i < K; i++) {
    mid -= mid % a[i];
  }
  if (mid >= 2) {
    return true;
  } else {
    return false;
  }
}

bool C2(int mid) {
  for (int i = 0; i < K; i++) {
    mid -= mid % a[i];
  }
  if (mid <= 2) {
    return true;
  } else {
    return false;
  }
}

signed main() {
  cin >> K;
  for (int i = 0; i < K; i++) {
    cin >> a[i];
  }

  int ok1 = 1e15, ng1 = 0;
  for (int i = 0; i < 60; i++) {
    int mid = (ok1 + ng1) / 2;
    if (C(mid)) {
      ok1 = mid;
    } else {
      ng1 = mid;
    }
  }

  int ok2 = 0, ng2 = 1e15;
  for (int i = 0; i < 60; i++) {
    int mid = (ok2 + ng2) / 2;
    if (C2(mid)) {
      ok2 = mid;
    } else {
      ng2 = mid;
    }
  }

  if (ok1 > ok2) {
    cout << -1 << endl;
  } else {
    cout << ok1 << " " << ok2 << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
import collections
N= int(input())
n=[]
for i in range(N):
	n.append(input())
c = collections.Counter(n)
if len(c) !=len(n):
	print("No")
	exit()
for i in range(N-1):
	if n[i+1][0] != n[i][len(n[i]) -1]:
		print("No")
		exit()

print("Yes")


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

using namespace std;

int main()
{
    int n, a[100001], x;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> x;
        a[x] = i;
    }
    for (int i = 1; i <= n; ++i) cout << a[i] << ' ';
    return 0;
}


Measured memory_bytes: 1152
from _collections import deque

n,m=map(int,input().split())
f=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    f[a].append(b)
    f[b].append(a)
g=[0]*(n+1)
p=[0]*(n+1)
for i in range(1,n+1):
    if p[i]==0:
        p[i]=i
        data=[i]
        data=deque(data)
        while len(data)>0:
            pos=data.popleft()
            p[pos]=i
            for j in f[pos]:
                if p[j]==0:
                    data.append(j)
            f[pos]=[]
for i in range(n):
    g[p[i+1]]+=1
print(max(g))



Measured memory_bytes: 113524
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

const double PI=3.14159265358979323846;

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

    ll a, b;
    cin >> a >> b;

    // (a + b + res) % 3 == 0

    REP(i, 3) {
        ll res = i + 1;
        if ((a + b + res) % 3 == 0) {
            cout << res << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,k = LI()
    s = input()
    for i in range(k-1):
        print(s[i],end = "")
    print(s[k-1].lower(),end = "")
    for i in range(k,n):
        print(s[i],end = "")
    print()
    return

#B
def B():
    s = S()
    k = int(s[0])*10+int(s[1])
    l = int(s[2])*10+int(s[3])
    if k == 0:
        if l == 0:
            print("NA")
        elif l < 13:
            print("YYMM")
        else:
            print("NA")
    elif k < 13:
        if l == 0:
            print("MMYY")
        elif l < 13:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if l == 0:
            print("NA")
        elif l < 13:
            print("YYMM")
        else:
            print("NA")

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    vector<string> s;
    forn(i, 3) {
        string cur;
        cin >> cur;
        s.pb(cur);
    }
    int turn = 0;
    while (sz(s[turn])) {
        auto x = s[turn].begin();
        char aux = *x;
        s[turn].erase(x);
        turn = aux - 'a';
        //cout << s[0] << " " << s[1] << " " << s[2] << " " << turn << " " << aux << endl;
    }
    char ans[] = {'A', 'B', 'C'};
    cout << ans[turn] << endl;
    return 0;
}


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

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

  const int NUM_RATE = 9;//レート帯の数

  //レートからレート帯の番号を返す関数
  auto rate_to_idx = [&](int r){
    vector<P> edges;
    edges.push_back(make_pair(1,399));
    edges.push_back(make_pair(400,799));
    edges.push_back(make_pair(800,1199));
    edges.push_back(make_pair(1200,1599));
    edges.push_back(make_pair(1600,1999));
    edges.push_back(make_pair(2000,2399));
    edges.push_back(make_pair(2400,2799));
    edges.push_back(make_pair(2800,3199));
    edges.push_back(make_pair(3200,4800));

    rep(i,NUM_RATE){
      int lower = edges[i].first;
      int upper = edges[i].second;
      if(lower<=r&&r<=upper) return i;
    }

  };

  vector<int> p(NUM_RATE,0);//各レート帯の人数

  rep(i,n){
    int a;
    cin >> a;
    p[rate_to_idx(a)]++;
  }

  int zeros = 0;//人がいない色固定レート帯の数
  int exist_cols = 0;//人がいる色固定レート帯の数
  int strong = p[NUM_RATE-1];//色フリー帯にいる人数

  rep(i,NUM_RATE-1){
    if(p[i]==0) zeros++;
    else exist_cols++;
  }

  int ans_min = max(exist_cols,1);
  int ans_max = exist_cols + strong;
  printf("%d %d\n",ans_min,ans_max);

  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;



int main(){
    int N; string S; cin >> N >> S;
    vector<ll> num(26);
    for(auto ch : S) num[(int)ch-97]++;
    ll ans = 1;
    for(int i = 0; i < 26; i++) { ans*=(num[i]+1);ans%=MOD;}
    cout << ans -1 << endl;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N = inputI()
l = inputILs(N)

l.sort()

print(sum(l)-l[-1]//2)

Measured memory_bytes: 66028
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;
typedef vector<int> vi;

/* global variables */

ll ss[MAX_N], sums[MAX_N + 1];

/* subroutines */

/* main */

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

  sums[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> ss[i];
    sums[i + 1] = sums[i] + ss[i];
  }

  vi ds;
  for (int p = 1; p * p <= n; p++)
    if (n % p == 0) {
      ds.push_back(p);
      int q = n / p;
      if (q != p) ds.push_back(q);
    }

  sort(ds.begin(), ds.end(), greater<int>());
  int dn = ds.size();

  for (int i = 0; i < dn; i++) {
    int &di = ds[i];
    if (di == 1) break;
    //printf("%d\n", di);

    int m = n / di;
    bool ok = true;
    for (int j = 2; j <= di; j++)
      if (sums[m] * j != sums[m * j]) {
	ok = false;
	break;
      }
    if (! ok) continue;

    for (int j = 1; j < di; j++) {
      ok = true;
      for (int k = 0; k < m; k++)
	if (ss[k] != ss[j * m + k]) {
	  ok = false;
	  break;
	}
      if (ok) {
	printf("%d\n", di);
	return 0;
      }
    }
  }

  puts("1");
  return 0;
}

Measured memory_bytes: 4332
# coding: utf-8
# Your code here!

nums = list(input().rstrip())
nums = list(map(int,nums))

def proc(nums):
    op_h = []
    n = nums.pop(0)
    fl,op_h = find_operator(nums.copy(), 7-n, op_h)
    print(n,end="")
    for i,num in enumerate(nums):
        if op_h[i] == 1:
            print("+",end="")
        else:
            print("-",end="")
        print(num,end="")
    print("=7")

def find_operator(nums, to_be, operation_history):
    ope = [-1,1]

    n = nums.pop(0)
    if len(nums) == 0:
        for op in ope:
            if to_be - op*n == 0:
                operation_history.append(op)
                return True, operation_history
        return False, operation_history    
    
    for op in ope:
        op_h = operation_history.copy()
        op_h.append(op)
        fl, h = find_operator(nums.copy(), to_be-op*n, op_h)
        if fl == True:
            return True,h
    return False,h
        
proc(nums)
        

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdint>

int dfs(intmax_t N, intmax_t i, int b) {
  if (i > N) return 0;
  int res = 0;
  if (b == 7) ++res;
  res += dfs(N, 10*i+7, b|4);
  res += dfs(N, 10*i+5, b|2);
  res += dfs(N, 10*i+3, b|1);
  return res;
}

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

  printf("%d\n", dfs(N, 0, 0));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

template <class T>inline bool chmin(T &a, const T b){
    if(a > b){a = b; return true;}
    return false;
}

template <class T>inline bool chmax(T &a, const T b){
    if(a < b){a = b; return true;}
    return false;
}


int main(){
    int N, W; cin >> N >> W;
    int V = N * 1000;
    vector<pair<int, int>> a(N);
    rep(i, N){
        int w, v; cin >> w >> v;
        a[i] = make_pair(w, v);
    }
    vector<vector<ll>> dp(N + 1, vector<ll>(V + 1, INF));
    dp[0][0] = 0;
    rep(i, N){
        rep(j, V + 1){
            if(j - a[i].second >= 0) chmin(dp[i + 1][j], dp[i][j - a[i].second] + a[i].first);
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }

    // rep(i, N + 1){
    //     rep(j, V + 1){
    //         if(j < 21){
    //             if(dp[i][j] == INF){
    //                 cout << "-1" << " ";
    //             }else cout << dp[i][j] << " ";
    //         }
    //     }
    //     cout << endl;
    // }
    ll ans = 0;
    rep(i, V + 1){
        if(dp[N][i] <= W) ans = i;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 83224
int main(){
    int N;
    scanf("%d",&N);
 
    int a[N];
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
 
    int temp,min;
    for(int i=-100;i<=100;i++){
      int sum=0;
      for(int j=0;j<N;j++){
        sum+=(a[j]-i)*(a[j]-i);
      }
      if(i==-100){
        min=sum;
        temp=sum;
      }else{
        temp=sum;
      }
      if(temp<min){
        min=temp;
      }
    }
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 1632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
enum{LEFT,DOWN,RIGHT,UP};

int main(){
     vector< pair<int,int> > pieces;
     int N;
     while(1){
	  pieces.clear();
	  pieces.push_back(pair<int,int>(0,0));
	  cin>>N;
	  if(N==0)break;
	  int maxx,maxy,minx,miny;
	  maxx=maxy=minx=miny=0;
	  for(int i=0;i<N-1;i++){
	       int ni,di;
	       cin>>ni>>di;
	       //cout<<"N"<<i+1<<"="<<ni<<endl;
	       int x=pieces[ni].first;//cout<<"x="<<x<<endl;
	       int y=pieces[ni].second;//cout<<"y="<<y<<endl;
	       switch(di){
	       case LEFT:
		    x=x-1;
		    break;
	       case DOWN:
		    y=y-1;
		    break;
	       case RIGHT:
		    x=x+1;
		    break;
	       case UP:
		    y=y+1;
		    break;
	       }
	       maxx=max(maxx,x);
	       maxy=max(maxy,y);
	       minx=min(minx,x);
	       miny=min(miny,y);
	       pieces.push_back(pair<int,int>(x,y));
	  }
	  //cout<<maxx<<" "<<maxy<<endl;
	  //cout<<minx<<" "<<miny<<endl;
	  cout<<maxx-minx+1<<" "<<maxy-miny+1<<endl;
     }
}

Measured memory_bytes: 0
n, m = map(int, input().split())
box = [list(map(int, input().split())) for i in range(m)]

box = sorted(box, key=lambda x: x[1])
count, cut = 0, 0

for x, y in box:
    if cut <= x:
        count += 1
        cut = y

print(count)

Measured memory_bytes: 65396
n=int(input())
a=list(map(int,input().split()))
ans=[0 for i in range(100001)]
for i in range(n):
    ans[a[i]-1]+=1
tmp=0
for i in range(100001):
    tt=(i+1)*ans[i]
    tmp+=tt
q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    tt=-ans[b-1]*b+ans[b-1]*c
    ans[c-1]+=ans[b-1]
    ans[b-1]=0
    tmp+=tt
    print(tmp)

Measured memory_bytes: 20908
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1e9+7))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define sqrt sqrtl
#define cbrt cbrtl
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi; 

const int N=100010;
vector<int> G[N];
vector<bool>B(N);
vector<int>pre(N),post(N);
int t=0;

void dfs(int I)
{
	B[I]=true;
	pre[I]=t++;
	for(int i=0;i<(int)G[I].size();i++)
	if(!B[ G[I][i] ])dfs(G[I][i]);
	post[I]=t++;
}

int32_t main()
{
	IOS
	// Topological sorting or memoisations
	// Lest do Topological sort now
	int n,m;cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v;cin>>u>>v;
		G[u].push_back(v);
	}
	for(int i=1;i<=n;i++)
	if(!B[i])dfs(i);
	
	vector<pair<int,int>>topo(n);
	for(int i=1;i<=n;i++)
	{
		topo[i-1].first=post[i];
		topo[i-1].second=i;
	}
	
	sort(topo.rbegin(),topo.rend());
	//now done topological sort
	//we have to fill dp now;
	
	vector<int>dp(n+1,0);
	int source=topo[0].second;
	dp[source]=0;
	for(int i=0;i<n;i++)
	{
		int source=topo[i].second;
		//cout<<source<<" ";
		for(int j=0;j<(int)G[source].size();j++)
		dp[ G[source][j] ]=max(dp[ G[source][j] ],dp[source]+1);
	}
	
	int mxlength=0;
	for(int i=1;i<=n;i++)
	{
		//cout<<dp[i]<<" ";
		mxlength=max(mxlength,dp[i]);
	}
	cout<<mxlength<<endl;
	
	
}
		


Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


int main(){
    int N,x; cin >> N >>x;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin >> a[i];
    int ans = 0;
    sort(a.begin(),a.end());

    for(int i=0; i<N;i++){
        x -= a[i];
        if(x<0) break;
        else if(i==N-1 && x!=0) break;
        else ans++;
    }
    cout << ans << endl;

}

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[200010];
	long long sum=0;
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	}
	long long ans=1000LL*1000*1000*1000*1000*1000;
	for(int i=0;i<n-1;i++)
	{
	    sum-=2*a[i];
	    ans=min(ans,llabs(sum));
	}
	cout<<ans;
}

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

int n,m;
set<int> s;
int fa[100005];

int find(int x){
    if(fa[x]==x)return x;
    return fa[x]=find(fa[x]);
}

void unite(int x,int y){
    x=find(x);
    y=find(y);
    fa[x]=y;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    iota(fa+1,fa+1+n,1);
    while(m--){
        int a,b;
        cin>>a>>b;
        unite(a,b);
    }
    for(int i=1;i<=n;i++)s.insert(find(i));
    cout<<s.size()-1<<endl;

    return 0;
}

Measured memory_bytes: 7860
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>     
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n;
ll x, a[N], S;

inline void boost () {                        //(a[1]-T)^(a[2]+T) != x
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n;
   //a+b=2*(a&b)+(a^b)
   for (int i = 1; i <= n; i ++) {
      cin >> a[i];
      if (i >= 3) x ^= a[i];                                      //(a&b)=D,(a^b)=X
      else S += a[i];
   }
   if ((S - x) & 1) cout << -1, exit (0);
   ll D = (S - x) / 2;
   if (D < 0) cout << -1, exit (0);
   ll c = 0, d = 0;
   for (int i = 60; i >= 0; i --) {
      if (D & (1ll << i)) {
         c += (1ll << i);
         d += (1ll << i);
         if (x & (1ll << i)) cout << -1, exit (0);
      }
   }
   if (c > a[1]) cout << -1, exit (0);
   for (int i = 60; i >= 0; i --) {
      if (D & (1ll << i)) continue;
      if (x & (1ll << i)) {
         if (c + (1ll << i) <= a[1]) c += (1ll << i);
         else d += (1ll << i);    
      }
   }
   if ((c & d) != D || (c ^ d) != x || c == 0) cout << -1, exit (0);
   cout << a[1] - c;
   
}               
 
signed main () {                                       
   #ifdef QWERTY
      freopen("input", "r", stdin);
   #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
 
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
 
typedef pair<int,int> pii;
 
int N;
vector<int> V[100010];
queue<pii> Q;
int D[100010] = {0};
int sum[3] = {0};
 
int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N - 1; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        V[a].push_back(b);
        V[b].push_back(a);
    }
    Q.push(mk(1,1));Q.push(mk(N,2));
    while(Q.size())
    {
        pii now = Q.front();Q.pop();
        if(D[now.fi] != 0)continue;
        D[now.fi] = now.se;
        sum[now.se]++;
        for(int i = 0; i < V[now.fi].size(); i++)
        {
            Q.push(mk(V[now.fi][i],now.se));
        }
    }
    if(sum[1] <= sum[2])printf("Snuke\n");
    else printf("Fennec\n");
    return 0;
}

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


void solve(long long A, long long B){
  if (A <= 12) B /= 2;
  if (A <= 5) B = 0;
  cout << B << endl;
}

int main(){
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int> P(N);
  vector<int> Q(N);
  for (int i=0; i<N; i++) cin >> P[i];
  for (int i=0; i<N; i++) cin >> Q[i];
  
  if (P>Q) swap(P,Q); //P<Qになるよう並び替え（絶対値しんどそうなので）
 
  int ans = 0;
  while (P<Q){
    next_permutation(P.begin(), P.end()); //P以上の順列を順番に作っていく、Qに来たらやめる
    ans += 1;
  }
  cout << ans << endl;
}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define INF 		2000000007
#define MOD			10e9+7
#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;


int main(){
	string s;cin>>s;

	if(s[0]==s[1] || s[1]==s[2] || s[2]== s[3])
		cout << "Bad" << endl;
	else cout << "Good" << endl;


	return 0;
}



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

int n,m;
int q;
int a[100011];
int b[100011];
int lenb;


bool has[100011];

int calc[100011];

int atob[100011];


int main()
{
	int i,j;
	
	scanf("%d %d",&n,&m);
	scanf("%d",&q);
	for(i=1;i<=q;i++)
	{
		scanf("%d",&a[i]);
	}
	memset(has,0,sizeof(has));
	memset(atob,0,sizeof(atob));
	lenb=0;
	for(i=q;i>=1;i--)
	{
		if(has[a[i]]==0)
		{
			has[a[i]]=1;
			lenb++;
			b[lenb]=a[i];
			atob[a[i]]=lenb;
		}
	}
	
	int temp=0x3f3f3f3f;
	for(i=1;i<=m;i++)
	{
		if(has[i]==0)
		{
			temp=i;
			break;
		}
	}
	
	while(lenb>0 && b[lenb]<temp)
	{
		temp=b[lenb];
		lenb--;
	}
	
	
	
	
	memset(calc,0,sizeof(calc));
	calc[1]=n;
	int maxlen=1;
	for(i=q;i>=1;i--)
	{
		int pos=atob[a[i]];
		
		if(pos>lenb)continue;
		
		
		if(calc[pos]>0)
		{
			calc[pos]--;
			calc[pos+1]++;
			
			maxlen=max(maxlen,pos+1);
		}
		else
		{
			if(pos<=maxlen)
			{
				
			}
			else
			{
				break;
			}
		}
		
		/*
		cout<<i<<"    "<<lenb<<"  i"<<endl;
		for(j=1;j<=10;j++)
		{
			cout<<calc[j]<<' ';
		}
		cout<<endl;
		*/
		
	}
	if(i>=1)
	{
		cout<<"No"<<endl;
		return 0;
	}
	
	
	if(maxlen==lenb+1 && calc[lenb+1]==n)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1920
A, B = map(int, input().split())

result = []
for i in range(1, 100000):
    if int(i * 0.08) == A and int(i * 0.1) == B:
        result.append(i)

if len(result) == 0:
    print('-1')
else:
    print(min(result)) 

Measured memory_bytes: 3060
n=int(input())
abc = [[int(i) for i in input().split()] for i in range(n)]

dp = [[0]*3]*n

dp[0]= abc[0]

for i in range(1,n):
	dp[i] = [abc[i][0]+max(dp[i-1][1], dp[i-1][2]),
			abc[i][1]+max(dp[i-1][0], dp[i-1][2]),
			abc[i][2]+max(dp[i-1][0], dp[i-1][1])]
print(max(dp[n-1]))

Measured memory_bytes: 44148
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long lli;
int main()
{
	lli a, b, c; cin >> a >> b >> c;
	lli tmp = (b + c);
	lli res = b * (a / tmp);
	res += min(b, a % tmp);
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define in auto&it
#define out auto it
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
const double pi = acos(-1);
#define error(x) cerr<<#x<<" = "<<x<<'\n';
int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif
	fastio
	ll n,a,mx=0,sum=0;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a;
		if(mx<=a) mx=a;
		else sum+=mx-a;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  ll N;
  cin>>N;
  vector<ll> H(N);
  rep(i, N){
    cin>>H[i];
  }
  vector<ll> dp(N, INF);
  dp[0]=0;
  rep(i, N-1){
    dp[i+1]=min(dp[i+1], dp[i]+abs(H[i+1]-H[i]));
    if(i>0)dp[i+1]=min(dp[i+1], dp[i-1]+abs(H[i+1]-H[i-1]));
  }
  cout<<dp[N-1]<<endl;
  return 0;
} 

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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 2e5 + 5;
const int K = 1 << 18;

ll t[2*K];
int h[N], a[N];

void upd(int id, ll x) {
	int cur = id + K - 1;
	while (cur) {
		t[cur] = max(t[cur], x);
		cur /= 2;
	}
}

ll get(int l, int r) {
	l += K-1;
	r += K-1;
	ll res = 0;
	while (l <= r) {
		if (l & 1) res = max(res, t[l++]);
		if (!(r & 1)) res = max(res, t[r--]);
		l /= 2;
		r /= 2;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i=1; i<=n; i++) cin >> h[i];
	for (int i=1; i<=n; i++) cin >> a[i];
	for (int i=0; i<2*K; i++) t[i] = 0;
	for (int i=1; i<=n; i++) {
		ll cur = get(1, h[i]-1);
		upd(h[i], cur + a[i]);
	}
	ll ans = get(1, n);
	cout << ans << "\n";
	return 0;
}


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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  uint64_t g = gcd(m,n);
  if(m%g==0) return (m/g)*n;
  if(n%g==0) return (n/g)*m;
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

// keyが降順ソートされるmap
// map<int, int, std::greater<int>> edges;

signed main() {
  int n;
  cin >> n;
  int a;
  list<int> b;
  for(int i=0;i<n;i++){
    cin >> a;
    if(i%2==0) b.push_back(a);
    else b.push_front(a);
  }
  if(n%2==1){
    reverse(b.begin(),b.end());
  }
  
  for(auto v:b){
    cout << v << " ";
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 9972
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

string n;
int main() {
  cin >> n;
  if (n[0] == n[1] && n[1] == n[2]) cout << "Yes" << endl;
  else if (n[1] == n[2] && n[2] == n[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(a.begin(),a.end());
  if(a[0]+a[1]==a[2])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const int MOD = 123456789;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };

char s[101];
int main() {
	int n;
	scanf("%d%s",&n,s);
	int ans=0;
	fup(i,0,n-2,1)
	{
		bool chk[2][26]={0};
		fup(j,0,i,1)
		{
			chk[0][s[j]-'a']=1;
		}
		fup(j,i+1,n-1,1)
		{
			chk[1][s[j]-'a']=1;
		}
		int res=0;
		fup(i,0,25,1)if(chk[0][i]&&chk[1][i])res++;
		ans=max(ans,res);
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n) cin >> a[i];
    b = a;
    sort(all(b));
    int maxi = b[n-1];
    for(int i=0; i<n; i++){
        if(maxi == a[i]){
            out(b[n-2]);
        }
        else out(maxi);
    }

}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;
string solve(int n){
    string s;
    s = "000000";
    for(int i = 0; i < 6; i++){
        s[5-i] = '0'+n%10;
        n /= 10;
    }
    return s;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<map<int,int>> mp(n+1);
    for(int i = 0; i < m; i++){
        int p,y;
        cin >> p >> y;
        mp[p][y] = i;
    }
    vector<string> ans(m);
    for(int i = 1; i <= n; i++){
        int j = 1;
        for(auto r:mp[i]){
            string ken = solve(i);
            string num = solve(j);
            ans[r.second] = ken+num; 
            j++;
        }
    }
    for(int i = 0; i < m; i++){
        cout << ans[i] << endl;
    }
}

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

const double PI=acos(-1.0);
const int N=1001;
const int MOD=1e9+7;


int main()
{
  int n, d;
  cin>>n>>d;
  d = d + d + 1;
  
  int ans = n / d;
  if(n % d)
    ans++;
  cout<<ans;
    

}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int n;
  long long a;
  long long minValue = 1000000;
  long long maxValue = -1000000;
  long long sum = 0;

  cin >> n;
  for (int i = 0; i<n ; i ++){
      cin >> a;
      if (a <minValue ) minValue = a;
      if (a > maxValue) maxValue = a;
      sum += a;
  }
  cout << minValue << " " << maxValue << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 3120
import java.util.*;

class Main {
	Scanner sc;
	String S;
	
	private void calc() {
		sc = new Scanner(System.in);
		S = sc.next();
		
		if (S.equals("AAA") || S.equals("BBB")) System.out.println("No");
		else System.out.println("Yes");
	}

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


Measured memory_bytes: 35492
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <list>
using namespace std;

bool dead[200000];

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    list<int> student;
    for (int i=0; i<N; ++i) student.push_back(i);
    auto it = student.begin();
    int a;
    for (int i=0; i<M; ++i) {
        cin >> a;
        if (a % 2 == 0) { // direction +
            while (a--) {
                it ++;
                if (it == student.end()) it = student.begin();
            }
        } else { // direction -
            while (a--) {
                if (it == student.begin()) it = student.end();
                it --;
            }
        }
        dead[*it] = true;
        it = student.erase(it);
        if (it == student.end()) it = student.begin();
    }
    int q;
    for (int i=0; i<Q; ++i) {
        cin >> q;
        cout << (dead[q] ? 0 : 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 7636
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  int n[15];
  int sum=0;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0'){
      n[sum]=0;
      sum++;
    }
    else if(s[i]=='1'){
      n[sum]=1;
      sum++;
    }
    else{
      if(sum>0) sum--;
    }
  }
  for(int i=0;i<sum;i++){
    cout<<n[i];
  }
  cout<<'\n';
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public final class Main {

    private static final int MOD = (int) (1e9 + 7);

    static int solve(long[] nums, int k) {
        final int n = nums.length;
        Arrays.sort(nums);
        long product = 1;
        if (nums[n - 1] <= 0 && k % 2 != 0) {
            for (int i = n - 1; i >= n - k; i--) {
                product = (product * nums[i]) % MOD;
            }
            return Math.floorMod(product, MOD);
        }
        int i = 0;
        int j = n - 1;
        if (k % 2 != 0) {
            product = (product * nums[j]) % MOD;
            j--;
            k--;
        }
        k >>= 1;
        for (int itr = 0; itr < k; itr++) {
            final long left = nums[i] * nums[i + 1];
            final long right = nums[j] * nums[j - 1];
            if (left > right) {
                product = (product * (left % MOD)) % MOD;
                i += 2;
            } else {
                product = (product * (right % MOD)) % MOD;
                j -= 2;
            }
        }
        return Math.floorMod(product, MOD);
    }

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        final int k = in.nextInt();
        in.nextLine();
        final long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextLong();
        }
        in.nextLine();
        System.out.println(solve(arr, k));
    }
}


Measured memory_bytes: 61784
N, A, B = map(int, input().split())

if N == 1:
    print('YES')
    print(A, B)
    exit()

A_bin = bin(A)
B_bin = bin(B)
one_A = 0
one_B = 0
for a in A_bin:
    if a == '1':
        one_A += 1
for b in B_bin:
    if b == '1':
        one_B += 1
if (one_A + one_B) % 2 == 0:
    print('NO')
    exit()
else:
    print('YES')

A_ori = A
A = A_ori ^ A
B = A_ori ^ B

nxt = {0: 1}
last = 1
for n in range(1, N):
    i = 0
    p = 2**n
    while True:
        if i == B-p:
            tmp = []
            while True:
                tmp.append(i+p)
                if i == last:
                    break
                else:
                    i = nxt[i]
            j = last
            for k in range(len(tmp)-1, -1, -1):
                nxt[j] = tmp[k]
                j = tmp[k]
            last = B
            break

        j = nxt[i]
        nxt[i] = i + p
        nxt[i+p] = j+p
        nxt[j+p] = j
        if j == last:
            break
        else:
            i = nxt[j]

i = 0
while True:
    print(i ^ A_ori)
    if i == last:
        break
    i = nxt[i]


Measured memory_bytes: 58584
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i=0;i<s.size();i++){
    for(int j=0;j<n;j++){
    s[i]++;
    if(s[i]>=91 ||s[i]<=64){
    s[i]=65;
    }
    }
    }
    cout << s <<endl;
return 0;
}

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

int main() {
	int N;
  	cin >> N;
    long long res = 0;
    for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 and i % 5 != 0) res += i;
    }
  	cout << res << '\n';
}


Measured memory_bytes: 3596