akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}


template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  string s,t;
  cin >> s >> t;
  bool flag=true;
  if(s.size()+1 != t.size()) flag=false;
  rep(i,s.size()) {
    if(s.at(i) != t.at(i)) flag=false;
  }
  Yes(flag);


  return 0;
}


Measured memory_bytes: 3632
import bisect

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()

ans=0
for i in range(n):
    sita= bisect.bisect_left(a,b[i])
    ue= n-bisect.bisect_right(c,b[i])
    ans+=sita*ue
print(ans)

Measured memory_bytes: 23360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100 + 5;
int a[N];
int main()
{
	int n,m;
	cin >> n >> m;
	int sum = 0,t = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
	}
	sort(a+1,a+n+1);
	int flag = 0;
	for(int i = n; i > n - m; i--){
		if(a[i]*4*m<sum){
			flag = 1;
			break;
		}
	}
	if(flag)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

up=0
down=0
count = 0
x=a[0]
for i in range(n):
  if x==a[i]:
    continue
  elif x<a[i]:
    if down==0:
      up=1
    else:
      down=0
      up=0
      count+=1
  else:
    if up==0:
      down=1
    else:
      down=0
      up=0
      count+=1
  x=a[i]
print(count+1)

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

const int N = 8e5 + 9, P = 924844033;

int n, hd[N], tot, to[N], nxt[N], size[N], w[N], a[N], A[N], B[N], C[N], fac[N], ans[N], fac_rev[N];

void Dfs (int x, int fa) {
	size[x] = 1;
	for (int p = hd[x]; p != -1; p = nxt[p]) if (to[p] != fa) {
		Dfs(to[p], x);
		size[x] += size[to[p]];
		w[p] = size[to[p]];
		w[p ^ 1] = n - size[to[p]];
	}
}

int qp (int a, int b) { int c = 1; for (; b; b >>= 1, a = 1ll * a * a % P) if (b & 1) c = 1ll * c * a % P; return c; }

void bit_reverse (int *x, int n) {
	for (int i = 0, j = 0; i < n; ++i) {
		if (i < j) swap(x[i], x[j]);
		for (int l = n >> 1; (j ^= l) < l; l >>= 1) ;
	}
}

void NTT (int *buffer, int f, int n) {
	bit_reverse(buffer, n);
	int inv = qp(n, P - 2), i, j, k, x, y, wn, w;
	
	for (i = 1; i != n; i <<= 1) {
		wn = qp(5, (P - 1) / (i << 1));
		if (f == -1) wn = qp(wn, P - 2);
		for (j = 0; j != n; j += i << 1) {
			w = 1;
			for (k = j; k < j + i; ++k) {
				x = buffer[k]; y = 1ll * w * buffer[k + i] % P;
				buffer[k] = (x + y) % P;
				buffer[k + i] = (x - y) % P;
				w = 1ll * w * wn % P;
			}
		}
	}
	
	if (f == -1) for (int i = 1; i <= n; ++i) buffer[i] = 1ll * buffer[i] * inv % P;
}

void Mul (int *CC, const int *AA, const int *BB) {
	static int C[N], A[N], B[N];
	memset(C, 0, sizeof C);
	memset(A, 0, sizeof A);
	memset(B, 0, sizeof B);
	int m = (n + 1) << 1, t = 1;
	while (t < m) t <<= 1; m = t;
	for (int i = 0; i <= n; ++i) A[i] = AA[i], B[i] = BB[i];
//	for (int i = 0; i < m; ++i) for (int j = 0; j <= i; ++j) C[i] = (1ll * A[j] * B[i - j] + C[i]) % P;
	NTT(A, 1, m);
	NTT(B, 1, m);
	for (int i = 0; i < m; ++i) C[i] = 1ll * A[i] * B[i] % P;
	NTT(C, -1, m);
	for (int i = 0; i < m; ++i) CC[i] = C[i];
}

int main () {
	scanf("%d", &n);
	memset(hd, -1, sizeof hd);
	for (int i = 1, u, v; i < n; ++i) {
		scanf("%d%d", &u, &v);
		to[tot] = v; nxt[tot] = hd[u]; hd[u] = tot++;
		to[tot] = u; nxt[tot] = hd[v]; hd[v] = tot++;
	}
	Dfs(1, 0);
	for (int i = 0; i < tot; ++i) ++a[w[i]];
	fac[0] = 1; for (int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % P, A[i] = 1ll * a[i] * fac[i] % P;
	fac_rev[n] = B[n] = qp(fac[n], P - 2);
	for (int i = n - 1; ~i; --i) fac_rev[i] = B[i] = 1ll * B[i + 1] * (i + 1) % P;
	reverse(B, B + n + 1);
	Mul(C, A, B);
	for (int i = 1; i <= n; ++i)
	ans[i] = (1ll * n * fac[n] % P * fac_rev[i] % P * fac_rev[n - i] % P - 1ll * C[i + n] * fac_rev[i] % P) % P;
	for (int i = 1; i <= n; ++i) printf("%d\n", (ans[i] + P) % P);
	return 0;
}

Measured memory_bytes: 53760
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
using LL = long long;
using ULL = unsigned long long;
#define NUM 1000000007

using namespace std;

int main()
{
    string s;
    cin >> s;
    for (auto& i : s)
    {
        if (i==',')
        {
            cout << " ";
        }
        else
        {
            cout << i;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
S = input()
half_l = int((len(S) -1)/2)
mae = S[0:half_l]
ato = S[half_l+1:len(S)]

start = int((len(S) +3)/2)
target_str = S[start-1:len(S)]

def ispalindrome(str): return True if str == str[::-1] else False

if not ispalindrome(S):
    print('No')
    exit(0)

if not ispalindrome(mae):
    print('No')
    exit(0)

if not ispalindrome(target_str):
    print('No')
    exit(0)
print('Yes')

Measured memory_bytes: 38384
use std::io;


fn main() {
    let x = read_one::<usize>();
    let a = read_one::<usize>();
    let b = read_one::<usize>();
    println!("{}", (x - a) % b);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	n := oneInt()
	nums := scanNums(n)

	counts := make([]int, n)
	for i := 0; i < n; i++ {
		for nums[i]%2 == 0 {
			nums[i] /= 2
			counts[i]++
		}
	}
	fmt.Println(min(counts))
}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func oneStr() string {
	sc.Scan()
	return sc.Text()
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums []int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums []int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

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

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 640
a, b, c = map(int, input().split())

a1 = (b + c) / 2
b1 = (a + c) / 2
c1 = (a + b) / 2

diffs = [abs(a-a1), abs(b-b1), abs(c-c1)]

ans = []
for tmpdiff in diffs:
  count = 1
  while tmpdiff % 2 == 0:
    tmpdiff = tmpdiff / 2
    count += 1
    if tmpdiff == 0:
      count = -1
      break
      
  ans.append(count)

if not (a%2 ==0 and b%2 ==0 and c%2 ==0):
  print(0)
elif ans == [-1 for _ in range(len(ans))]:
  print(-1)
else:
  print(min([i for i in ans if i >0]))

Measured memory_bytes: 3064
import Control.Applicative
import Control.Monad

isLeap :: Int -> Bool
isLeap n
    | n `divisible` 400 = True
    | n `divisible` 100 = False
    | n `divisible` 4 = True
    | otherwise = False

divisible :: Int -> Int -> Bool
divisible n m = n `mod` m == 0

leaps :: Int -> Int -> [Int]
leaps a b = filter isLeap [a..b]

step :: Int -> IO ()
step x = do
    [n,m] <- map read . words <$> getLine
    unless (n == 0 && m == 0) $ do
            -- ugly because of the specification!!!!
            unless (x==0) $ putStrLn ""
            case leaps n m of
                [] -> putStrLn "NA"
                ys -> do
                    mapM_ print ys
            step (x+1)
main = step 0

Measured memory_bytes: 4020
#!/usr/bin/env python
# coding: utf-8

# In[9]:


K,T = map(int, input().split())
a = list(map(int, input().split()))


# In[10]:


if T == 1:
    ans = K-1
else:
    mylist = sorted(a)
    ans = max(mylist[-1]-sum(mylist[:-1])-1,0)
print(ans)



Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,i,j,k,l,ans=0;
  cin>>n>>m;
  vector<int> p(m);
  vector<set<int>> s(m);
  for(i=0;i<m;i++){
    cin>>k;
    for(j=0;j<k;j++){
      cin>>l;
      s.at(i).insert(l);
    }
  }
  for(i=0;i<m;i++) cin>>p.at(i);
  for(j=0;j<(1<<n);j++){
    bitset<10> b(j);
    for(i=0;i<m;i++){
      l=0;
      for(auto z:s.at(i)) if(b.test(z-1)) l++;
      if(l%2!=p.at(i)) break;
    }
    if(i==m) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
const ll mod = 1e9 + 7;
const int DEG = 30;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
static auto faster_iostream = []() {
    std::ios::sync_with_stdio(false);  // turn off sync
    std::cin.tie(nullptr);             // untie in/out streams
    return 0;
}();
long long C[2205][2205];
void get_C()
{
    C[0][0] = 1;
    for(int i = 1; i <= 2100; i++)
    {
        C[i][0] = 1;
        for(int j = 1; j <= i; j++)
        	C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
    }
}
int main(){
	ll n, k;
	get_C();
	cin >> n >> k;
	for(int i = 1; i <= k; i++){
		cout << (C[n - k + 1][i] * C[k - 1][i - 1]) % mod << endl; 
	}
	return 0;
}

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

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

	int cards[4][14] = {};

	for (int i = 0; i < N; i++) {
		char C;
		int A;
		cin >> C >> A;

		for (int j = 0; j < N; j++) {
			if (C == 'S') cards[0][A] = 1;
			if (C == 'H') cards[1][A] = 1;
			if (C == 'C') cards[2][A] = 1;
			if (C == 'D') cards[3][A] = 1;
		}
	}

	for (int i = 0; i <= 3; i++) {
		for (int j = 1; j <= 13; j++) {
			if (cards[i][j] == 0) {
				if (i == 0) cout << "S " << j << endl;
				if (i == 1) cout << "H " << j << endl;
				if (i == 2) cout << "C " << j << endl;
				if (i == 3) cout << "D " << j << endl;
			}
		}
	}
}


Measured memory_bytes: 3088
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))

X.sort() #昇順に

if N>=M:
  print(0)

else:
  intervals = [X[i+1]-X[i] for i in range(M-1)]
  intervals.sort()

  print(sum(intervals[:(M-N)]))

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


using namespace std;

#define ll long long

int main(){
   ios::sync_with_stdio(false);
   cin.tie(0);
   int a,b;
   cin >> a >> b;
   string s;
   cin >> s;
   int cnt=0;
   for(char c : s) {
	   if(c=='-') {
		   cnt++;
	   }
	   if(cnt>1) break;
   }
   if(cnt==1&&s[a]=='-') cout << "Yes";
   else cout << "No";
   return 0;
}




Measured memory_bytes: 3656
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a > b:
  if c > d:
    print(b+d)
  else:
    print(b+c)
else:
  if c > d:
    print(a+d)
  else:
    print(a+c)
	

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
S=[list(map(int,input().split()))[1:] for i in range(M)]

P=list(map(int,input().split()))
ANS=0

for i in range(1<<N):
    #print(i)
    for m in range(M):
        ANS2=0
        for s in S[m]:
            if i & (1<<(s-1))!=0:
                ANS2+=1

        #print(i,ANS2)
        if ANS2%2!=P[m]:
            break

    else:
        ANS+=1

print(ANS)
    

Measured memory_bytes: 3064
//
//  D - Five, Five Everywhere.cpp
//  atcoder beginner contest  096
//
//  Created by Huang,Zhiqiang on 2018/5/8.
//  Copyright © 2018年 Huang,Zhiqiang. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

bool is_prime[55557] = {1};
int N;
vector<int> primes;
int sum_[10] = {0};

void init() {
    for (int i = 0; i <= 55555; i++) is_prime[i] = 1;
    is_prime[0] = 0;
    is_prime[1] = 0;
    for (int i = 2; i <= 55555; i++) {
        if (is_prime[i]) {
            primes.push_back(i);
            sum_[i % 10]++;
        }
        for (int j = 0; j <= primes.size(); j++) {
            if (i * primes[j] > 55555) break;
            is_prime[i * primes[j]] = 0;
            if (i % primes[j] == 0) break;
        }
    }
}

int main() {
    cin >> N;
    init();
    int i = 0;
    for (; i < 10; i++) {
        if (sum_[i] >= N) break;
    }
    int size = N < primes.size() ? N : primes.size();
    int cnt = 0;
    for (int j = 0; cnt < size && j < primes.size(); j++) {
        if (primes[j] % 10 == i) {
            cout << primes[j] << " ";
            cnt++;
        }
    }
    cout << endl;
}


Measured memory_bytes: 384
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        mut s: Chars,
    }

    if s[s.len()-1] == 's' {
       s.push('e');
       s.push('s');
    } else {
        s.push('s');
    }

    for &ns in &s {
        print!("{}", ns);
    }
    println!();
}


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

int main(){
    int n;
    cin >> n;
    ll a[n], b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    ll ans = 0;

    for(int i = n - 1; i >= 0; i--){
        ll k = (a[i] + ans) % b[i];
        if(k != 0){
            ans += b[i] - k;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

using namespace std;

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

    int cnt = 0;
    rep(i, 3)
    {
        if (s[i] == t[i]) {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//import jdk.internal.org.jline.utils.InputStreamReader;

//import java.io.*;

public class Main{
        public static void main(final String[] args){
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            int[] A = new int[n];
            int count = 0;
            for(int i = 0; i < n; i++){
                A[i] = scanner.nextInt();
            }
            boolean flag = true;
            while(flag){
                flag = false;
                for(int j = n-1; j > 0; j--){
                    if(A[j] < A[j-1]){
                        int temp = A[j];
                        A[j] = A[j-1];
                        A[j-1] = temp;
                        flag = true;
                        count ++;
                    }
                }
            }
            for(int i = 0; i < n; i++){
                System.out.printf("%d", A[i]);
                if(i != n-1){
                    System.out.printf(" ");
                }
            }
            System.out.printf("\n%d\n", count);
            scanner.close();
        }
         

}


Measured memory_bytes: 26568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n,m; cin >> n >> m;
    int sum=0;
    int a[n];
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
    }
    int cnt=0;
    rep(i,n){
        if(4*m*a[i]>=sum) cnt++;
    }
    if(cnt>=m)cout << "Yes" << endl;
    else cout << "No" << endl;
}




Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++)
			a[i] = s.nextInt()-1;
		
		int b[] = new int[n];
		int c[] = new int[n-1];
		
		for(int i=0;i<n;i++)
			b[i] = s.nextInt();
		
		for(int j=0;j<n-1;j++)
			c[j] = s.nextInt();
		
		int sum = 0;
		sum+=b[a[0]];
		
		int prev = a[0];
		for(int i=1;i<n;i++) {
			if(a[i]==prev+1) {
				sum+=b[a[i]]+c[prev];
			}
			else {
				sum+=b[a[i]];
			}
			prev=a[i];
		}
		System.out.println(sum);
		
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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


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

int main() {
  int h, w;
  cin >> h >> w;

  /* if input is ".", it is judged as white. */
  bool white[h][w] = { false };
  bool row_check[h] = { false };
  bool column_check[w] = { false };
  vector<vector<char>> grids(h, vector<char>(w));

  /* input and judge row. */
  rep (i, h) {
      int count = 0;
      rep (j, w) {
          cin >> grids[i][j];
          if (grids[i][j] == '.') 
          {
              white[i][j] = true; count++;
          }
      }
      if (count == w)
      {
          row_check[i] = true;
      }
  }

  /* judge column. */
  rep (i, w) {
      int count = 0;
      rep (j, h) {
          if (grids[j][i] == '.') 
          {
              white[j][i] = true; count++;
          }
      }
      if (count == h)
      {
          column_check[i] = true;
      }
  }
  for (int i = 0; i < h; i++)
  {
      for (int j = 0; j < w; j++)
      {
          if (column_check[j] != true && row_check[i] != true)
          {
            cout << grids.at(i).at(j);
          }
          if (row_check[i] != true && j == w-1) cout << endl;
      }
  }
  //for(vector<char> grid : grids)
  //{
  //    cout << grid << endl;
  //}
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
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 T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    string S;
    cin >> S;
    int res = 0;
    for (int i = 0; i < S.size(); ++i) {
        int j;
        for (j = i; j < S.size(); ++j) {
            if (S[j] != 'A' && S[j] != 'G' && S[j] != 'T' && S[j] != 'C')
                break;
        }
        chmax(res, j - i);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC136B
#include <iostream>
using namespace std;
bool f(int i){
    int dgt=0;
    while (i) {
        dgt++;
        i/=10;
    }
    return dgt%2==1; // 奇数ならtrue 偶数ならfalseを返す
}
int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(f(i)==true) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3160
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        
        int even = num1 * (num1 - 1) / 2;
        int odd = num2 * (num2 -1) / 2;
      
        // System.out.println(even);
        // System.out.println(odd);
        
        System.out.println(even + odd);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define int __int128
#define min(a,b) a<b?a:b 
template<class T>inline void read(T& x) {
	T f=1;x=0;char s=getchar();
	while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
	while(s>='0'&&s<='9'){x=(x<<1)+(x<<3)+(s&15);s=getchar();}
	x*=f;
}
inline void print(int x) {
    if(x>=10) { print(x/10); }
    putchar(x%10+'0');
}
template<class T>inline T po(T a) { return a*a; }
inline int gcd(int a,int b) { return a%b==0?b:gcd(b,a%b); }
inline int lcm(int a,int b) { return (a*b)/gcd(a,b); }
int n,a[101],ans,nans;
signed main() {
	read(n); ans=1ll<<60;
	rep(i,1,n) read(a[i]);
	rep(i,1,100) {
		nans=0;
		rep(k,1,n) nans+=po(a[k]-i);
		ans=min(ans,nans);
	}
	print(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    if(n==m) cout << "Yes";
    else cout << "No";


    return 0;
}

Measured memory_bytes: 3608
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    xy = ii2nnn(N)
    if N == 1:
        print(1)
        return
    dic = defaultdict(lambda: 0)
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            dx = xy[i][0] - xy[j][0]
            dy = xy[i][1] - xy[j][1]
            if dx == 0 and dy == 0:
                continue
            dic[(dx, dy)] += 1
    n = N - max(dic.values())
    print(n)

main()


Measured memory_bytes: 39152
#include "bits/stdc++.h"
using namespace std;

const int maxn = 2e5 + 10;

int n;

vector<int> adj[maxn];

int used[maxn];

bool found;
vector<int> cicle, stk;

bool mrk[maxn];

void dfs(int v) {
    used[v] = 1;
    stk.push_back(v);

    for(auto u: adj[v])
	if(!used[u])
	    dfs(u);
	else
	    if(used[u] == 1) {
		found = true;

		for(int k = stk.size() - 1; k >= 0; --k) {
		    int c = stk[k];

		    cicle.push_back(c);
		    mrk[c] = true;

		    if(c == u)
			break;
		}
	    }

    stk.pop_back();
    used[v] = 2;
}

int g[maxn];

void dfsGrundy(int v) {
    set<int> Set;

    for(auto u: adj[v])
	if(!mrk[u]) {
	    dfsGrundy(u);
	    Set.insert(g[u]);
	}

    int k = 0;

    while(Set.find(k) != Set.end()) ++k;

    g[v] = k;
}

int G[maxn];

bool check() {
    int sz = cicle.size();

    for(int i = sz - 2; i >= 0; --i) {
	int c = cicle[i];
	int nx = cicle[i + 1];

	if(G[nx] != G[c])
	    continue;

	++G[c];
    }

    int First = cicle[0];
    int Last = cicle[sz - 1];

    if(G[First] == G[Last])
	return false;

    return true;
}

bool testCicle() {
    int sz = cicle.size();

    for(int i = 0; i < sz; ++i)
	G[cicle[i]] = g[cicle[i]];

    if(check())
	return true;

    for(int i = 0; i < sz; ++i)
	G[cicle[i]] = g[cicle[i]];

    ++G[cicle[sz - 1]];

    if(check())
	return true;

    return false;
}

bool solve() {
    for(int v = 1; v <= n; ++v)
	if(!used[v])
	    dfs(v);

    if(!found)
	return true;

    for(auto u: cicle)
	dfsGrundy(u);

    return testCicle();
}

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

    for(int i = 1; i <= n; ++i) {
	int p;

	scanf("%d", &p);

	adj[p].push_back(i);
    }

    if(solve())
	printf("POSSIBLE\n");
    else
	printf("IMPOSSIBLE\n");

    return 0;
}


Measured memory_bytes: 27124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = k&1 ? b-a : a-b;
    if(ans >= 1e18 || ans <= -1e18){cout << "Unfair" << endl;}
    else{cout << ans << endl;}
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,i,data[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&data[i]);
    }
    for(i=n-1;i>=0;i--){
        if(i!=n-1){
            printf(" ");
        }
        printf("%d",data[i]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 1768
#include <iostream>
using namespace std;	
int main(){
	int n, ans = 0;
	while (cin >> n){
		ans = 0;
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++) {
					for(int l=0;l<=9;l++){
						if (i + j + k + l == n)ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

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

int main(){
    int a;scanf("%d",&a);
    int L = a/100;
    int R = a%100;
    if(1 <= L && L <= 12){
        if(1 <= R && R <= 12){
            printf("AMBIGUOUS\n");
        }else{
            printf("MMYY\n");
        }
    }else{
        if(1 <= R && R <= 12){
            printf("YYMM\n");
        }else{
            printf("NA\n");
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;

int main(){
	ll n;
	cin>>n;
	ll a[n];
	ll res=0;
	ll sum=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum +=a[i];
	}
	double avg = (double)sum/(double)n;
	ll ans = round(avg);
	for(int i=0;i<n;i++){
		res +=(a[i]-ans)*(a[i]-ans);
	}
	cout<<res<<endl;



}

Measured memory_bytes: 384
N, S = input(), input()

clusters=[]
W, B = 0, 1
c_prev = None
seq=0
for c in S:
    if c != c_prev and c_prev!=None:
        clusters.append(seq)
        seq=0
    seq+=1
    c_prev=c
    
clusters.append(seq)
    
if S[0]=='.':
    clusters = [0] + clusters
if S[-1]=='#':
    clusters.append(0)

min_nflip = nflip = sum(clusters[1::2])
for i in range(len(clusters)//2):
    nflip+=clusters[i*2]-clusters[i*2+1]
    min_nflip = min(min_nflip, nflip)

print(min_nflip)


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

ll m, n;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    
    while (n>0) {
        if (n&1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    
    return res;
}

int main() {
    cin >> m >> n;
    cout << mod_pow(m, n, 1000000007) << endl;
}


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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n, k, s;
    cin >> n >> k >> s;
    int t;
    if (s == 1000000000) t = 1;
    else t = s + 1;

    forn(i, k) cout << s << ' '; // for (int i = 0; i < k; ++i) 
    forn(i, n - k) cout << t << ' ';
    cout << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using namespace std;

const int N = 123456;

int n;
long long a[N], b[N];
map<long long, int> number;
map<long long, bool> used;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    long long x = a[i];
    a[i] = b[i] = 1;
    for (int j = 2; j <= 2200; ++j) {
      if (x % j == 0) {
        int t = 0;
        while (x % j == 0) {
          x /= j;
          ++t;
        }
        if (t % 3 == 1) {
          a[i] *= j;
          b[i] *= j * j;
        } else if (t % 3 == 2) {
          a[i] *= j * j;
          b[i] *= j;
        }
      }
    }
    if (x != 1) {
      long long y = (long long) (sqrt(x) + 0.5);
      a[i] *= x;
      if (y * y == x) {
        b[i] *= y;
      } else {
        b[i] *= x * x;
      }
    }
    ++number[a[i]];
  }
  int answer = 0;
  for (int i = 1; i <= n; ++i) {
    if (!used[a[i]]) {
      used[a[i]] = used[b[i]] = true;
      if (a[i] == 1) {
        ++answer;
      } else {
        answer += max(number[a[i]], number[b[i]]);
      }
    }
  }
  cout << answer << '\n';
  return 0;
}

Measured memory_bytes: 26880
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    long long n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];

    for (int i = 0; i < n; i++) {
        string t = s[i];
        sort(t.begin(), t.end());
        s[i] = t;
    }

    sort(s.begin(), s.end());

    vector<long long> a(n + 1);
    a[0] = 1;
    a[1] = a[0] + 2;
    for (int i = 2; i < n; i++) {
        a[i] = a[i - 1] + i + 1;
    }

    long long cnt = 0;
    long long ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] != s[i + 1]) {
            if (cnt != 0) ans += a[cnt - 1];
            cnt = 0;
        }
        else cnt++;
        //cout << cnt << endl;
    }
    //cout << cnt << endl;
    if (cnt != 0) ans += a[cnt - 1];

    /*
    for (int i = 0; i < n; i++) {
        cout << s[i] << endl;
    }
    */

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

Measured memory_bytes: 7424
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool is = true;
    REP(i, n){
        if (i % 2 == 0){
            if (s[i] == 'L') is = false;
        }else{
            if (s[i] == 'R') is = false;
        }
    }
    string ans = is ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

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

int n,k;
int dp[100005][3];
int a[100005][3];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	
	for(int i=1;i<=n;i++){
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i][0];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + a[i][1];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + a[i][2];
	}
	
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));	
	
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=1e9;

int min(int a,int b){
  if(a>b)return b;
  else return a;
}

main(){
  int N,K;
  cin >> N >> K;
  int h[N];
  for(int ii=0;ii<N;ii++){
    cin >> h[ii];
  }
  /*  //sort
  for(int ii=0;ii<N;ii++){
    for(int jj=ii;jj<N;jj++){
      if(h[ii]>h[jj]){
	int tmp=h[ii];
	h[ii]=h[jj];
	h[jj]=tmp;
      }
    }
    }*/
  sort(h,h+N);
  //ans
  int ans=INF;
  for(int ii=0;ii<N-K+1;ii++){
    ans=min(ans,(h[ii+K-1]-h[ii]));
    //    cout << (h[ii+K]-h[ii]) << endl;
    //    cout << ans << endl;
    //    if((h[ii+K]-h[ii])<ans)ans=h[ii+K]-h[ii];
    //    cout << h[ii+K-1]-h[ii] << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N,K; cin >> N >> K; 
    string S; cin >> S;
    vector<int> v;
    int cnt=0;
    rep(i,N-1){
        cnt++;
        if(S[i]!=S[i+1]){
            v.push_back(cnt);
            cnt=0;
        }  
    }
    cnt++;
    v.push_back(cnt);
    if(S[0]=='0') v.insert(v.begin(),0);
    if(S[S.size()-1]=='0') v.push_back(0);
    int ans=0; 
    if(v.size()>=2*K+1){
    for(int i=0;i<=v.size()-2*K;i+=2){
        int pos=0;
        for(int j=i;j<i+2*K+1;j++){
            pos+=v[j];
        }
        ans=max(ans,pos);
    }
    cout << ans << endl;
    }
    else {
        rep(i,v.size()){
            ans+=v[i];
        }
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 1528
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    a, b, c, d = map(int, readline().rstrip().split())
    taka = math.ceil(c / b)
    aoki = math.ceil(a / d)
    print('Yes' if taka <= aoki else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9424
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;

int solve(const vector<ull>& g,ull flg,int cur)
{
	int n=g.size();
	if(flg==(1ull<<n)-1)
		return 0;
	
	int res=INFTY;
	repi(i,cur,n)
		res=min(res,1+solve(g,flg|g[i],i+1));
	return res;
}

int main()
{
	for(int n,m;scanf("%d%d",&n,&m),n|m;){
		vector<ull> g(n);
		rep(i,n)
			g[i]=1ull<<i;
		rep(i,m){
			int s,d; scanf("%d%d",&s,&d);
			g[s]|=1ull<<d;
			g[d]|=1ull<<s;
		}
		
		ull flg=0;
		int res=solve(g,flg,0);
		printf("%d\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 1188
import collections
dic = collections.defaultdict(int)
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
	dic[a[i]] += 1
ans = 0
for key in dic.keys():
    if dic[key] >= key:
      ans += (dic[key] - key)
    else:
        ans += dic[key]
print(ans)


Measured memory_bytes: 101420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;

#define rep(i,n) for(ll i=0; i<(n); i++)
#define rep2(i,x,n) for(ll i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
const ll INF = 1 << 29;
ll n;

int main()
{
    cin >> n;
    ll ans = n-1;
    
    rep2(i, 1, sqrt(n)+1)
    {
        if(n%i==0){
            if(ans>i+(n/i)-2)
                ans = i + (n / i) - 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    long long d[1010],e[1010];
    rep(i,a)cin>>d[i]>>e[i];
    int f=0;
    rep(i,a){
        if(d[i] >= b && e[i] >= c)++f;
    }
    cout<<f;
}

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

int main()
{
   int n,x,y,z;
   cin>>n;
   x=n/500;
   y=(n%500)/5;
   z=(1000*x)+(5*y);
   cout<<z<<endl;
}


Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector<int> vec;
  int v;
  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vec.pb(v);
    mp[v]++;
  }
  for (int i = 0; i < n; i++) {
    v = vec[i];
    mp[v]--;
    if (mp[v] == 0) mp.erase(v);
    cout << (*mp.rbegin()).F << endl;
    mp[v]++;
  }

  return 0;
}

Measured memory_bytes: 7924
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;




int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int k;
  cin>>k;
  while(k%2==0)k/=2;
  while(k%5==0)k/=5;
  int loop=0;
  int m=1;
  vector<int>edge;
  vector<int>f(k,0);
  do {
    //edge.push_back(m);
    if(f[m]==0)f[m]=1;
    else break;
    m*=10;
    m%=k;
    loop++;
  }while(m!=1);
  int l=0;
  rep(i,k)l+=f[i];
  //cout<<l<<endl;
  edge.resize(l);
  l=0;
  rep(i,k){if(f[i]){edge[l]=i;l++;}}
  //cout<<loop<<endl;
  //  cout<<k<<endl;
  if(k==1){cout<<1<<endl;return 0;}
  if(loop>k/2){cout<<2<<endl;return 0;}
  
  vector<int>dist(k,0);

  queue<int>que;
  que.push(1);
  while(!que.empty())
  {
    int now=que.front();que.pop();
    for(int i:edge)
    {
      int tmp=(i+now);
      if(tmp>=k)tmp-=k;
      if(dist[tmp]>0)continue;
      dist[tmp]=dist[now]+1;
      if(tmp==0)
      {
        cout<<dist[tmp]+1<<endl;
        return 0;
      }
      que.push(tmp);
    }
  }



  return 0;

}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

int main() {
    int a, b;
    char c;

    cin >> a >> c >> b;

    if(c == '+') {
        cout << a + b << endl;
    } else {
        cout << a - b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using I64I = pair<int64_t, int>;
using Graph = vector<vector<I64I>>;
using PriorityQueue = priority_queue<I64I, vector<I64I>, greater<I64I>>;

vector<int64_t>	calc_cost(int n, const Graph &graph, int src)
{
	vector<int64_t>	cost(n, -1);
	PriorityQueue	p_que;
	int				s, d;
	int64_t			cost_s, cost_d;	
	cost.at(src) = 0;
	p_que.push(make_pair(0, src));
	while (!p_que.empty()) {
		cost_s = p_que.top().first;
		s = p_que.top().second;
		p_que.pop();
		for (auto pr : graph.at(s)) {
			cost_d = pr.first + cost_s;
			d = pr.second;
			if (cost.at(d) == -1 || cost.at(d) > cost_d) {
				cost.at(d) = cost_d;
				p_que.push(make_pair(cost_d, d));
			}
		}
	}
	return cost;
}

int	main()
{
	const static int64_t	upper = 1e+15;
	int	n, m, s, t;
	cin >> n >> m >> s >> t;
	--s; --t;
	Graph	yen_graph(n),	snook_graph(n);
	int		u, v;
	int64_t	a, b;
	for (int i = 0; i < m; ++i) {
		cin >> u >> v >> a >> b;
		--u; --v;
		yen_graph.at(u).push_back(make_pair(a, v));
		yen_graph.at(v).push_back(make_pair(a, u));
		snook_graph.at(u).push_back(make_pair(b, v));
		snook_graph.at(v).push_back(make_pair(b, u));
	}
	vector<int64_t>	yen_cost = calc_cost(n, yen_graph, s);
	vector<int64_t> snook_cost = calc_cost(n, snook_graph, t);
	vector<int64_t> total_amount(n);
	int64_t	max_amount = -1, tmp_amount;
	for (int i = n - 1; i >= 0; --i) {
		tmp_amount = upper - yen_cost.at(i) - snook_cost.at(i);
		if (i == n - 1 || tmp_amount > max_amount) {
			max_amount = tmp_amount;
		}
		total_amount.at(i) = max_amount;
	}
	for (int i = 0; i < n; ++i) 
		cout << total_amount.at(i) << endl;
}


Measured memory_bytes: 19012
import collections
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = [list(map(int, input().split())) for i in range(Q)]
c = dict(collections.Counter(A))
S = sum(A)
for i in range(Q):
    [B, C] = BC[i]
    if B in c.keys():
        S = S+(C-B)*c[B]
        print(S)
        if C in c.keys():
            c[C] = c[C]+c[B]
        else:
            c[C] = c[B]
        c.pop(B)
    else:
        print(S)

Measured memory_bytes: 37408
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long e=max(max(max(a*c,a*d),b*c),b*d);
    cout<<e<<endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;

const int N = 1e6 + 69;

int n,x,y,m;

int A[N];

string s,t,u;

int main(){

    cin>>s>>t;
    cin>>x>>y;
    cin>>u;
    if(s==u)x--;
    else
        y--;

    cout<<x<<" "<<y<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int min, max;
    int[] a = new int[num];

    min = max = a[0] = sc.nextInt();
    long sum = (long)min;

    for(int i=1 ; i < num ; i++){
      a[i] = sc.nextInt();
      if(a[i]<min) min = a[i];
      if(a[i]>max) max = a[i];
      sum += a[i];
    }
      System.out.println(min+" "+max+" "+sum);
  }
}

Measured memory_bytes: 42160