akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	if(s[0]=='A'){
		int cnt=0;
		FOR(i,2,n-1){
			if(s[i]=='C') cnt++;
		}
		if(cnt==1){
			cnt=0;
			rep(i,n){
				int now=s[i]-'a';
				if(0<=now && now<=25) cnt++;
			}
			if(cnt==n-2){
				cout<<"AC"<<endl;
				return 0;
			}
		}
	}
	cout<<"WA"<<endl;
}

Measured memory_bytes: 256
from itertools import accumulate
from operator import add
line, row = [int(x) for x in input().split()]
k = int(input())
L=[]
J=[[0]*(row+1) for _ in range(line+1)]
O=[[0]*(row+1) for _ in range(line+1)]
I=[[0]*(row+1) for _ in range(line+1)]

for _ in range(line):
    L.append(input())

for i in range(line):
    for j in range(row):
        if L[i][j] == "J":
            J[i+1][j+1] = 1
        elif L[i][j] == "O":
            O[i+1][j+1] = 1
        else:
            I[i+1][j+1] = 1

for i in range(len(J)):
    J[i] = list(accumulate(J[i]))
    O[i] = list(accumulate(O[i]))
    I[i] = list(accumulate(I[i]))

for i in range(1,len(J)):
    J[i] = list(map(add, J[i], J[i-1]))
    O[i] = list(map(add, O[i], O[i-1]))
    I[i] = list(map(add, I[i], I[i-1]))

def fcheck(M, a, b, c, d):
    return M[c][d] + M[a][b] - M[c][b] - M[a][d]

for _ in range(k):
    a, b, c, d = [int(x)-1 for x in input().split()]
    j = o = i = 0
    c +=1
    d +=1
    print( fcheck(J,a,b,c,d), fcheck(O,a,b,c,d), fcheck(I, a, b, c,d))



Measured memory_bytes: 125504
N,M = map(int,input().split())
*S, = map(int,list(input()))

for i in range(N-1,0,-1):
    if S[i]>0:
        S[i] = S[i+1]+1

ans = []
j = N
while j>0:
    k = max(0,j-M)
    while k<j:
        if S[k] == 0:
            ans.append(j-k)
            j = k
            break
        else:
            k += S[k]
    else:
        ans = [-1]
        break
print(*ans[::-1])

Measured memory_bytes: 59640
def f():
 global d
 p=[d[0]]
 for i in range(len(d)-1):
  a,b=d[i],d[i+1]
  r=(b-a)/3
  p+=[a+r,a+r+r*(1+3**.5*1j)/2,b-r,b]
 d=p
d=[0j,100+0j]
for _ in[0]*int(input()):f()
for e in d:print(e.real,e.imag)


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

int main(){
    int n;
    cin>>n;
    int ans=0;
    rep(i,n){
        int count=0;
        if(i%2==0)continue;
        rep(j,i){
            if(i%j==0){
                count++;
            }
        }
        if(count==8)ans++;
    }

cout<<ans;
}

Measured memory_bytes: 3640
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = ns()
    T = ns()
    for i in range(len(T)):
        if S == T[i:] + T[:i]:
            print('Yes')
            break
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 8944
#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
inline ll gcd(ll x,ll y){return x==0?y:gcd(y%x,x);}
int prime[20100000],isprime[20100000],cnt;
bool vis[20100000];
int main(){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	ll c=gcd(a,b);
	prime[0]=prime[1]=1;
	for(int i=2;i<=sqrt(c)+10000;i++){
		if(!prime[i])isprime[++cnt]=i;
		for(int j=1;isprime[j]*i<=sqrt(c)+10000;j++){
			prime[isprime[j]*i]=1;
			if(i%isprime[j]==0)break;
		}
	}
//	for(int i=1;i<=cnt;i++){
//		printf("%8d",isprime[i]);
//	}
	int ans=0;
	for(int i=1;c>1&&i<=cnt;i++){
		if(c%isprime[i]==0){
			if(!vis[isprime[i]])ans++;
			vis[isprime[i]]=1;
			c/=isprime[i];
			i--;
		}
	}
	if(c!=1){
		printf("%d\n",ans+2);
		return 0;
	}
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 8448
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    println!("{}", max(v[0] * v[1], v[2] * v[3]));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main(void)
{
    
    char a[100]={},b[100]={},c[100]={};
    int i,j,len;
    
    scanf("%s",a);
    scanf("%s",b);
    
    len = strlen(a);
    
    for(i=1;i<=len;i++){
        c[i*2-2] = a[i-1];
        c[i*2-1] = b[i-1];
    }
    printf("%s\n",c);
    
    return 0;
}

Measured memory_bytes: 128
import java.io.{PrintWriter, _}
import java.util._


object Main {
  def main(args: Array[String]): Unit = {
    val inputStream = System.in
    val outputStream = System.out
    val in = new InputReader(inputStream)
    val out = new PrintWriter(outputStream)
    val solver = new Task
    solver.solve(1, in, out)
    out.close()
  }

  def ?(item: Boolean, first: Object, second: Object): Object = if (item) first else second

  class Task {
    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {
      val a = in.nextInt
      val b = in.nextInt
      out.println(math.max(a + b, math.max(a + a - 1, b + b - 1)))
    }

  }


  class InputReader(val stream: InputStream) extends AutoCloseable {
    //reader = new BufferedReader(new FileReader(stream), 32768);
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer = new StringTokenizer("")


    def next: String = {
      while ( {
        tokenizer == null || !tokenizer.hasMoreTokens
      }) try
        tokenizer = new StringTokenizer(reader.readLine)
      catch {
        case e: IOException =>
          throw new RuntimeException(e)
      }
      tokenizer.nextToken
    }

    def nextLine: String = {
      try
        return reader.readLine
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
      ""
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    override def close(): Unit = {
    }
  }

}


Measured memory_bytes: 25548
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class Main {

    private static boolean IS_TEST = false;

    public static void main(String[] args) throws Throwable {
        InputStream is = null;
        if (IS_TEST) {
            String input = "5\n"
                + "1 4 3 5 2";
            is = new ByteArrayInputStream(input.getBytes());
        } else {
            is = System.in;
        }
        try (BufferedReader r = new BufferedReader(new InputStreamReader(is))) {
            int N = readInt(r);
            int[] ps = readInts(r);

            int manipCount = 0;
            for (int i = 0; i < ps.length; i++) {
                if (ps[i] == i + 1) {
                    if (i == ps.length - 1) {
                        int buf = ps[i - 1];
                        ps[i - 1] = i;
                        ps[i] = buf;
                        manipCount++;
                    } else {
                        int buf = ps[i + 1];
                        ps[i + 1] = i;
                        ps[i] = buf;
                        manipCount++;
                    }
                }
            }
            System.out.println(manipCount);
        }
    }

    private static int readInt(BufferedReader r) throws IOException {
        return Integer.parseInt(r.readLine());
    }

    private static int[] readInts(BufferedReader r) throws IOException {
        String[] data = r.readLine().split("\\s");
        int[] vals = new int[data.length];
        for (int i = 0; i < vals.length; i++) {
            vals[i] = Integer.parseInt(data[i]);
        }
        return vals;
    }

    private static void log(Object... logs) {
        if (IS_TEST) {
            StackTraceElement ste[] = Thread.currentThread().getStackTrace();
            String clazz = "UK";
            if (ste.length > 2) {
                clazz = ste[2].getClassName().replaceAll("^.+\\.", "") + "-" + ste[2].getMethodName();
            }
            System.out.println("*LOG*\t" + clazz + "\t" + Arrays.stream(logs).map(o -> Objects.toString(o)).collect(Collectors.joining("\t")));
        }
    }

    private static String toString(Object obj) {
        List<String> values = new ArrayList<>();
        for (Field f : obj.getClass().getDeclaredFields()) {
            try {
                f.setAccessible(true);
                Object val = f.get(obj);
                if (val != null) {
                    values.add(f.getName() + "=" + Objects.toString(val));
                }
            } catch (Exception e) {
            }
        }
        return obj.getClass().getSimpleName() + " {" + String.join(", ", values) + "}";
    }

}


Measured memory_bytes: 35764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = Integer.parseInt(sc.next());
        String ans = "No";
        int[] a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        int[] b = {1, 2, 3, 4, 5, 6, 7, 8, 9};

        if (N > 81) {
            ans = "No";
        } else {
            for (int i = 0; i < 9; i++) {
                for (int j = 0; j < 9; j++) {
                    if (N == (a[i] * b[j])) {
                        ans = "Yes";
                    }
                }
            }
        }
        // 出力
        System.out.println(ans);

    }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 0; ; i++){
    for(int j = 0; j < n; j++){
      if(a[j] % 2 != 0){
        cout << ans << endl;
        return 0;
      }else{
        a[j] /= 2;
      }
    }
    ans++;
  }
}

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


int main() {
    int x = 0;
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'I') {
            x++;
            ans = max(ans, x);
        } else {
            x--;
        }
    }

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


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;


public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskT solver = new TaskT();
        solver.solve(1, in, out);
        out.close();
    }
    
    

    static class TaskT {
    	static int counter = 0;
        public void solve(int testNumber, InputReader in, PrintWriter out) {

        	int N = in.nextInt();
        	int M = in.nextInt();
        	
        	Map<Integer, Set<Integer>> map = new HashMap<>();
        	
        	for(int i = 0; i < M ; i ++){
        		int source = in.nextInt();
        		Set<Integer> source_set = map.getOrDefault(source, new HashSet<>());
        		int dest = in.nextInt();
        		source_set.add(dest);
        		map.put(source, source_set);
        		
        		Set<Integer> dest_set = map.getOrDefault(dest, new HashSet<>());
        		dest_set.add(source);
        		map.put(dest, dest_set);
        	}
        	
        	Set<Integer> visited = new HashSet<>();
        	int num_island = 0;
        	for(int key : map.keySet()){
        		if(!visited.contains(key)){
        			dfs(map, visited, key);
            		num_island++;
        		}

        	}
        	
        	out.print(num_island - 1 + N - map.size());
        }
        
        public void dfs (Map<Integer, Set<Integer>> map, Set<Integer> visited, int source){
        	
        	visited.add(source);

    		for(int dest : map.get(source)){
    			if(visited.contains(dest))
    				continue;
    			dfs(map, visited, dest);
    		}
        		

        }
        
        

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        
        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 91996
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();

    int[] a = new int[n];

    long sum = 0;

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      sum += a[i];
    }

    int count = 0;
    double k = (double)1/(4*m);

    for (int i = 0; i < n; i++) {
      if (a[i] >= k*sum) {
        count++;
      }
      if (count == m) {
        System.out.println("Yes");
        return;
      }
    }

    System.out.println("No");



  }

}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), p(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) p[i] = i + 1;

    int a, b, cnt = 0;
    do {
        bool flag = true;
        rep(i, N) if (A[i] != p[i])
            flag = false;
        if (flag)
            a = cnt;

        flag = true;
        rep(i, N) if (B[i] != p[i])
            flag = false;
        if (flag)
            b = cnt;
        ++cnt;
    } while (next_permutation(p.begin(), p.end()));

    cout << abs(a - b) << endl;

    return 0;
}

Measured memory_bytes: 256
ar = [list(map(int,input().split(" "))),list(map(int,input().split(" "))),list(map(int,input().split(" ")))]
count = 0
if ar[0][0] - ar[0][1] == ar[1][0] - ar[1][1] and ar[1][0] - ar[1][1] == ar[2][0] - ar[2][1]:
    count += 1
if ar[0][1] - ar[0][2] == ar[1][1] - ar[1][2] and ar[1][1] - ar[1][2] == ar[2][1] - ar[2][2]:
    count += 1
if ar[0][0] - ar[1][0] == ar[0][1] - ar[1][1] and ar[0][1] - ar[1][1] == ar[0][2] - ar[1][2]:
    count += 1
if ar[1][0] - ar[2][0] == ar[1][1] - ar[2][1] and ar[1][1] - ar[2][1] == ar[1][2] - ar[2][2]:
    count += 1
if count == 4:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 500005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int ans = 0;
    int t1 = min(k, a);
    ans += t1;
    k -= t1;
    t1 = min(k, b);
    k -= t1;
    ans -= k;
    cout << ans << '\n';
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
#include <atcoder/all>
using namespace atcoder;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int)(0);
}

int dp[300005];

int main() {
    // dpとsegtree、最後の数字だけが問題
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    segtree<int, op, e> seg(300005);
    for (int i = 0; i < N; i++) {
        int left = max(0, A[i] - K);
        int right = min(300000, A[i] + K);
        dp[A[i]] = seg.prod(left, right+1) + 1;
        seg.set(A[i], dp[A[i]]);
    }
    int ans = 0;
    for (int i = 0; i < 300001; i++) {
        ans = max(ans, dp[i]);        
    }
    cout << ans << '\n';
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 9764
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string str[] = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    string S;
    cin >> S;
    rep(i,0,7){
        if(str[i] == S){
            cout << i + 1 << endl;
        }
    }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{ abcde: [i32; 5] };
    let mut un: i32 = 10;
    let mut zero_count: i32 = 0;
    let mut sum: i32 = -10;
    for i in abcde {
        let tun = i % 10;
        if tun == 0 {
            zero_count += 1;
        } else if un > tun {
            un = tun;
        }
        sum += i / 10 * 10 + 10;
    }
    if zero_count == 5 {
        sum -= 40;
    } else {
        sum -= (zero_count * 10) - un;
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

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

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

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

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	for(int i=0;i<3;++i){
		string str;
		cin >> str;
		str[0] = (str[0]-'a'+'A');
		cout << str[0];
	}
	cout << endl;
}

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

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


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

int main(){
	char m[100][100];
	int h,w;
	cin>>h>>w;
	int i=0;
	int j=0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++)
		cin>>m[i][j];
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(j==w-1){
				cout<<m[i][j]<<endl;
				break;
			}
			cout<<m[i][j];
			
		}
		for(j=0;j<w;j++){
			if(j==w-1){
				cout<<m[i][j]<<endl;
				break;
			}
			cout<<m[i][j];
		}
		
		
	}
}

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

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

  int n, m, x, y, s, t;
  vector <int> a[100100];
  cin >> n >> m;
  while (m--)
  {
    cin >> x >> y;
    a[x].push_back(y);
  }

  cin >> s >> t;
  queue < pair<int, int> > q;
  q.push({s, 0});
  int dist[100100][3];
  memset(dist, -1, sizeof dist);
  dist[s][0] = 0;

  while (!q.empty())
  {
    auto u = q.front();
    q.pop();
    int x = u.first, z = u.second;
    for (int y : a[x])
      if (dist[y][(z + 1) % 3] < 0)
      {
        dist[y][(z + 1) % 3] = dist[x][z] + 1;
        q.push({y, (z + 1) % 3});
      }
  }

  cout << (dist[t][0] >= 0 ? dist[t][0] / 3 : -1) << endl;
}


Measured memory_bytes: 6912
#include <stdio.h>
#define N 10000
#define NIL -1

struct Node{
  int id;
  int left;
  int right;
};

struct Node Tree[N];
int n;

void preorder(int x){
  if(x == NIL) return;
  printf(" %d", x);
  preorder(Tree[x].left);
  preorder(Tree[x].right);
}

void inorder(int x){
  if(x == NIL) return;
  inorder(Tree[x].left);
  printf(" %d", x);
  inorder(Tree[x].right);
}

void postorder(int x){
  if(x == NIL) return;
  postorder(Tree[x].left);
  postorder(Tree[x].right);
  printf(" %d", x);
}

int main(){
  int i, v, left, right, root;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    Tree[i].id = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d %d %d", &v, &left, &right);
    Tree[v].left = left;
    Tree[v].right = right;
    if(left != NIL){
      Tree[left].id = v;
    }
    if(right != NIL){
      Tree[right].id = v;
    }
  }

  for(i = 0; i < n; i++){
    if(Tree[i].id == NIL){
      root = i;
    }
  }

  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
  postorder(root);
  printf("\n");

  return 0;
}



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

int main()
{
	int l, k;
	cin >> l >> k;
	ll res = 0;
	int N = (l - 1) / 2;
	vector<vector<ll>> dp(N + 1, vector<ll>(l + 1));
	dp[0][1] = 1;
	if (k <= l) dp[0][k] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= l; j++) {
			if (j + 2 <= l) {
				dp[i + 1][j + 2] += dp[i][j];
			}
			if (j + k + 1 <= l) {
				dp[i + 1][j + k + 1] += dp[i][j];
			}
		}
	}
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= l; j++) {
			res += dp[i][j];
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3208
#include<iostream>
using namespace std;
int main(){
	int a,b,n,ansa=0,ansb=0;

	for(;;){
		cin>>n;
		if(n==0)break;
		ansa=0;
		ansb=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			if(a>b){
				ansa=ansa+a+b;
			}
			else if(a<b){
				ansb=ansb+a+b;
			}
			else if(a==b){
				ansa=ansa+a;
				ansb=ansb+b;
			}
		}
		cout<<ansa<<" "<<ansb<<endl;
	}


	return 0;
}


Measured memory_bytes: 3028
# coding: utf-8

N = int(input())
moto = []
if N ==0:
    moto.append(0)
else:
    while N != 0:
        amari = (N % -2)*-1
        moto.append(amari)
        N = int((N - amari) /-2)
ans = moto[::-1]
for i in ans:
    print(i,end="")

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

using namespace std;

int main() {
  string S; cin >> S;
  string Su = "Sunny", Cl = "Cloudy", Ra = "Rainy";
  cout << (S == Su ? Cl : S == Cl ? Ra : Su) << endl;
  return 0;
}


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

using std::cin;
using std::cout;
using std::endl;
using std::sort;
using std::unique;
using std::vector;
using std::for_each;
using std::binary_search;

int main() {
	int n,q;
	cin >> n;
	vector<int> S(n);
	for_each(S.begin(),S.end(),[](int &s){cin >> s;});
	sort(S.begin(),S.end());
	unique(S.begin(),S.end());
	cin >> q;
	vector<int> T(q);
	for_each(T.begin(),T.end(),[](int &t){cin >> t;});
	sort(T.begin(),T.end());
	unique(T.begin(),T.end());
	int C = 0;
	for (auto i = T.begin();i != T.end();++i) {
		if (binary_search(S.begin(),S.end(),*i)) {
			++C;
		}
	}
	cout << C << endl;
}

Measured memory_bytes: 3304
import math

n, d = map(int, input().split())
l = [[0]*d for i in range(n)]
for i in range(n):
  l[i] = list(map(int, input().split()))

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist += (l[i][k] - l[j][k])**2
    dist = math.sqrt(dist)
    if dist.is_integer():
      ans += 1
print(ans)

Measured memory_bytes: 38384
# 幅優先探索（行きがけ）
import collections
import sys


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    A, V = LI()
    B, W = LI()
    T = I()

    if A <= B:
        a = A+V*T
        b = B+W*T
        if a >= b:
            print("YES")
        else:
            print("NO")
    else:
        a = A-V*T
        b = B-W*T
        if a <= b:
            print("YES")
        else:
            print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9464
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

n = int(input())
if n ==1:
  print(0)
  exit()
arr = factorization(n)
ans=0
for p,i in arr:
  j = 0
  while i>j:
    j += 1
    i -= j
  ans += j
print(ans)

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)

typedef long long ll;

const int N = 17;
int n;
int dgt[N], oprt[N];
char input[N+5];

int main() {
	int i, j, k;
	int tgt;

	memset(input, 0, sizeof(input));
	gets(input);
	i = j = k = 0;
	char c = input[0];
	while (c=='+' || c=='*' || ('0'<=c && c<='9')) {
		c = input[k++];
		if (c=='+' || c=='*')
			oprt[j++] = c;
		else if ('0'<=c && c<='9')
			dgt[i++] = c - '0';
	}
	n = i;

/*
printf("dgt:");
for (i=0; i<n; i++)
	printf("%d ", dgt[i]);
puts("");

printf("oprt:");
for (i=0; i<n-1; i++)
	printf("%c ", oprt[i]);
puts("");
*/

	scanf("%d ", &tgt);
//printf("tgt = %d\n", tgt);

	vector<int> mlt;
	mlt.push_back(dgt[0]);
	i = j = 0;
	while (j<n-1) {
		if (oprt[j]=='*')	{
			mlt[i] *= dgt[j+1];
		} else {
			mlt.push_back(dgt[j+1]);
			i++;
		}
		j++;	
	}
	int mltRes = mlt[0];
	for (i=1; i<mlt.size(); i++)
		mltRes += mlt[i];
//printf("mltRes = %d\n", mltRes);

	int addRes = dgt[0];	
	for (i=0; i<n-1; i++)
		if (oprt[i]=='*')
			addRes *= dgt[i+1];
		else
			addRes += dgt[i+1];
//printf("addRes = %d\n", addRes);

	char res = 'I';
	if (mltRes==tgt && addRes==tgt)
		res = 'U';
	else if (mltRes==tgt)
		res = 'M';
	else if (addRes==tgt)
		res = 'L';

	printf("%c\n", res);

	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
using namespace std;
    
int main()
{
    int r, g, b, n, ans = 0;
    cin >> r >> g >> b >> n;
    for (int i = 0; i <= n / r; i++)
        for (int j = 0; j <= n / g; j++)
        {
            int tmp = n - i * r - j * g;
            if (tmp >= 0 && tmp % b == 0)
                ans++;
        }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N;
  cin >>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  vector<vector<int> > DP (3001,vector<int>(3001,0));

  for (int bit = 0; bit < N; bit++)
  {
    for (int l = 0; l + bit < N; l++)
    {
      int r =l +bit;
      DP[l][r] = max(vec[l] - DP[l+1][r],vec[r] - DP[l][r-1]);
    }
    
  }
  cout<<DP[0][N-1]<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 70784
/**
 * @author: Mackenzie
**/
#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;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n;
    cin >> n;
    vector<int> v(n);
    forn(i, n) cin >> v[i];
    vector<int> pre(n);
    pre[0] = v[0];
    for (int i = 1; i < n; i++) {
        pre[i] = min(pre[i - 1], v[i]);
    }
    int ans = 0;
    forn(i, n) {
        if (pre[i] >= v[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;


void solve(long long N){
	string ans = "";
	char c;
	ll div = 26;
	int keta = 1;
	while(N > div) {
		N -= div;
		keta++;
		div *= 26;
	}
	N -= 1;
	REP(i, keta) {
		c = 'a' + (N % 26);
		ans = c + ans;
		N /= 26;
	}

	cout << ans << endl;

}

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



Measured memory_bytes: 3688
#include <stdio.h>
#define N 100
#define exch(a, b) {int x = a; a = b; b = x; count++;}
#define less(a, b) (a < b)

void printarr(int *a, int n){
  int i;
  for(i = 0; i < n; i++){
    printf("%d", a[i]);
    printf((i == n - 1) ? "" : " ");
  }
  printf("\n");
}

int selectionSort(int *a, int n){
  int i, j, min, count = 0;
  for(i = 0; i < n - 1; i++){
    min = i;
    for(j = i + 1; j < n; j++)
      if(less(a[j], a[min])) min = j;
    if(min != i) exch(a[i], a[min]);
  }
  return count;
}

int main(void){
  int n, i, a[N], count;
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);
  count = selectionSort(a, n);
  printarr(a, n);
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
using namespace std;
int main()
{
  int n,y;
  cin >> n >> y;
  for(int i=0;i<=2000;i++){
    for(int j=0;j<=2000;j++){
      int z = 10000*i + 5000*j;
      int k = (y - z)/1000;
      if(k >= 0){
        if(i+j+k == n){
          printf("%d %d %d\n",i,j,k);
          return 0;
        }
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>

typedef std::pair<int64_t, int64_t> Int64Pair;

int main(void)
{
    int64_t N;
    std::cin >> N;

    std::vector<Int64Pair> data;

    for (int64_t i = 0; i < N; ++i) {
        std::pair<int64_t, int64_t> student;
        student.first = i + 1;
        std::cin >> student.second;
        data.emplace_back(student);
    }

    std::sort(data.begin(), data.end(), [](const Int64Pair& a, const Int64Pair& b){
        if (a.second != b.second) {
            return a.second < b.second;
        } else {
            return a.first < b.first;
        }
    });

    for (auto& student : data) {
        std::cout << student.first << " ";
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    int a,b;
    cin >> a >>b;
    if(a>0 && b>0){
        cout<<"Positive"<<endl;
    }
    else if(a<=0 && b>=0){
        cout<<"Zero"<<endl;
    }
    else{
        if((b-a)%2==0){
            cout<<"Negative"<<endl;
        }
        else{
            cout<<"Positive"<<endl;
        }
    }
}

Measured memory_bytes: 3528
use proconio::input;

// ordtools {{{
mod ordtools {
    pub trait Ordtools: PartialOrd + Clone + Sized {
        fn change_min(&mut self, rhs: &Self) {
            if rhs < self {
                *self = rhs.clone();
            }
        }

        fn change_max(&mut self, rhs: &Self) {
            if rhs > self {
                *self = rhs.clone();
            }
        }
    }

    impl<T: PartialOrd + Clone + Sized> Ordtools for T {}
}
// }}}

use ordtools::Ordtools;

fn main() {
    input!(n: usize, a: [u32; n], b: [u32; n]);
    let mut sum = a[0] + b.iter().sum::<u32>();
    let mut ans = sum;
    for i in 0..n - 1 {
        sum += a[i + 1];
        sum -= b[i];
        ans.change_max(&sum);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2152
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,s=0,i;
cin>>n;
for(i=1;i<=n;i++){
    if(((i%3)!=0)&&((i%5)!=0))
    s=s+i;
}cout<<s;
    return 0;
  
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<unordered_map>
#include<map>
#include<stack>
#include<queue>
#include<iterator>
#include<functional>
#include<climits>
#include<set>
#include<utility>

#define ll long long
#define MOD 1000000007

using namespace std;

void solve () {
	ll n,w;
	cin >> n >> w;
	ll cost[n];
	ll weights[n];
	for (ll i = 0;i < n;++i) {
		cin >> weights[i] >> cost[i];
		//cout << "weight " << i << " is " << weights[i] << '\n';
	}
	ll dp[n+1][w+1];
	for (ll i = 0;i <= n;++i) {
		for (ll j = 0;j <= w;++j) {
			if (i == 0 || j == 0) {
				dp[i][j] = 0;
			} else if (weights[i-1] <= j) {
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-weights[i-1]]+cost[i-1]);
				// cout << dp[i][j] << " ";
			} else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	// for (int i = 0;i <= n;++i) {
	// 	for (int j = 0;j <= w;++j) {
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << '\n';
	// }
	cout << dp[n][w] << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}



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

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

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

    // start
    int n;
    cin >> n;
    cout << (n % 2 == 0 ? n : n * 2) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
def resolve():
    N = int(input())
    a = list(map(int,input().split()))
    tmp = 1
    ans = 0
    for i in range(N):
        if a[i] != tmp:
            ans += 1
        else:
            tmp += 1
    if ans == N:
        print(-1)
    else:
        print(ans)
resolve()

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

#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 F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int n;
ll k;
const int mod=1e9+7;
struct MAT{
    ll a[55][55];
};
MAT mul(MAT &a,MAT &b){
    MAT c;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            c.a[i][j]=0;
            for(int k=1;k<=n;++k)(c.a[i][j]+=a.a[i][k]*b.a[k][j])%=mod;
        }
    }
    return c;
}
int main(){
    cin>>n>>k;
    MAT x,ans;
    memset(ans.a,0,sizeof(ans.a));
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j)cin>>x.a[i][j];
        ans.a[i][i]=1;
    }
    while(k){
        if(k&1)ans=mul(x,ans);
        k>>=1,x=mul(x,x);
    }
    ll out=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j)out+=ans.a[i][j];
    }
    cout<<out%mod<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 3648
from sys import stdin, stdout
def main():
    N=int(stdin.readline())
    S=stdin.readline().rstrip()
    R, G, B = set(), set(), set()
    for i, c in enumerate(S):
        if c == 'R':
            R.add(i)
        elif c == 'G':
            G.add(i)
        else:
            B.add(i)
    cnt, total = 0, len(R) * len(G) * len(B)
    for ri in R:
        for gi in G:
            if abs(ri-gi)+gi in B:
                cnt += 1
            if abs(ri-gi)+ri in B:
                cnt += 1
    for ri in G:
        for gi in B:
            if abs(ri-gi)+gi in R:
                cnt += 1
            if abs(ri-gi)+ri in R:
                cnt += 1
    for ri in R:
        for gi in B:
            if abs(ri-gi)+gi in G:
                cnt += 1
            if abs(ri-gi)+ri in G:
                cnt += 1

    stdout.write(str(total-cnt)+"\n")

main()


Measured memory_bytes: 9612
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    int q; cin>>q;

    ll bsum = 0;
    priority_queue<ll> head;
    priority_queue<ll, vector<ll>, greater<ll>> tail;
    ll headsum = 0, tailsum = 0;

    while(q--){
        int type; cin>>type;
        if(type == 1){
            int a, b; cin>>a>>b;
            bsum += b;

            if(head.size() > tail.size()){
                int t = head.top();
                if(t <= a){
                    tail.emplace(a); tailsum += a;
                }
                else{
                    head.pop(); headsum -= t;
                    head.emplace(a); headsum += a;
                    tail.emplace(t); tailsum += t;
                }
            }
            else{
                if(!head.size()){
                    head.emplace(a); headsum += a;
                }
                else{
                    int t = tail.top();
                    if(a <= t){
                        head.emplace(a); headsum += a;
                    }
                    else{
                        tail.pop(); tailsum -= t;
                        tail.emplace(a); tailsum += a;
                        head.emplace(t); headsum += t;
                    }
                }
            }
        }
        else{
            ll x = head.top();
            ll ans = (x * (ll)head.size() - headsum) + (tailsum - x * (ll)tail.size()) + bsum;
            cout << x << " " << ans << endl;
        }
    }
}

Measured memory_bytes: 3828
#include<stdio.h>

int main(){
		long long n,a,b;
		scanf("%lld%lld%lld",&n,&a,&b);
		if(b<a)puts("0");
		else if(n!=1)printf("%lld\n",(n-1)*b+a-((n-1)*a+b)+1);
		else if(a==b)puts("1");
		else puts("0");
		return 0;
}


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

int main() {
  int s; cin >> s;
  int ans;
  set<int> cnt;
  cnt.insert(s);
  for (int i = 2; i < 1000000; i++) {
    if (s % 2 == 0) s = s / 2;
    else s = 3 * s + 1;
    if (cnt.count(s) == 0) cnt.insert(s);
    else {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
int n, k;
ll b[100000];
//区间和最大
ll solve(VI &a,int beg,int end) {

	//int a[] = { 1,2,3,4,-5,10,-1,-1 };  // 原数组
	//int* b = (int*)malloc(sizeof(a)); // 数组b，和原数组等长

									  // 初始化
	b[beg] = a[beg];

	// 遍历构造，注意i的边界
	
	for (int i = beg; i < end; i++) {
		b[i + 1] = b[i] + a[i + 1] > a[i + 1] ? b[i] + a[i + 1] : a[i + 1];
	}

	// 然后找出b中的最大值
	ll max = b[beg];
	for (int i = beg+1; i <= end; i++)
		if (b[i] > max)
			max = b[i];
	return max;
}
void solve() {
	cin >> n >> k;
	VI a(n+1), c(n+1);
	rep(i, 0, n)cin >> a[i+1];
	rep(i, 0, n)cin >> c[i+1];
	VI vis(n+1, 0);
	vector<VI> loop;
	rep(i, 1, n+1) {
		if (vis[i])continue;
		int beg = i;
		VI lp;
		while (!vis[i]) {
			vis[i] = 1;
			lp.push_back(c[i]);
			i = a[i];
		}
		loop.push_back(lp);
	}
	ll ans = -ll(1e18);
	for (auto &lp : loop) {
		int n = sz(lp);
		ll full = 0;
		ll sum = 0;
		rep(i, 0, n)sum += lp[i];
		rep(i, 0, n)lp.push_back(lp[i]);
		for (ll i = 0; i < n; i++) {
			int end = min(i + n - 1, 1LL * sz(lp) - 1);
			full = max(full, solve(lp, i, end));
			if (end >= sz(lp) - 1) {
				break;
			}
		}
		
		if (sum > 0) {
			int K = k%n;
			if (K == 0) {
				ans = max(ans, sum*(k / n));
			}else
			for (ll i = 0; i < sz(lp); i++) {
				int end = min(i + K - 1, 1LL * sz(lp) - 1);
				ans = max(ans, sum*(k/n) + solve(lp, i, end));
				if (end >= sz(lp) - 1) {
					break;
				}
			}
			if(full > sum)
			if (k / n >= 1) {
				ans = max(ans, sum*(k / n - 1) + full);
			}
		}
		for (ll i = 0; i < sz(lp); i++) {
			int end = min(i + k - 1, 1LL * sz(lp) - 1);
			ans = max(ans, solve(lp, i, end));
			if (end >= sz(lp) - 1) {
				break;
			}
		}
	}
	
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



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

int main(){
    ll N;
    cin >> N;
    vector<ll> x(N,0);
    vector<ll> y(N,0);
    vector<ll> h(N,0);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> h[i];
    }

    ll C_x;
    ll C_y;
    ll H = 0;



    //h[i] = max(H - abs(x[i] - C_x) - abs(y[i] - C_y), 0LL);
    for(int j = 0; j < 101; j++){
        for(int k = 0; k < 101; k++){
            H = -1;
            ll n = 0;
            while(H < 1) {
                if(h[n] > 0) H = abs(x[n]-j) + abs(y[n]-k) + h[n];
                n++;
            }
            for(int i = 0; i < N; i++){
                if(max(H - abs(x[i]-j) - abs(y[i]-k) , 0LL) != h[i]) break;
                if(i == N-1) {
                    cout << j << " " << k << " " << H << endl;
                return 0;
                }
            }
        }
    }
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    int n;
    cin>>n;
    long long a[n],max=0,ans=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]>max){
            max=a[i];
        }else if(a[i]<max){
            ans+=max-a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5200