akhauriyash/Code-Regression huggingface dataset:
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <bits/stdc++.h>
/*#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>*/
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

//const int INF = 100000;

void Solve(){
	int n,k;	cin >> n >> k;
	int arr[n],dp[n];
	Rep(i,0,n){
		cin >> arr[i];
		//dp[i] = INF;
	}
	dp[0] = 0;
	Rep(i,1,n){
		dp[i] = INT_MAX;
		for(int j = 1; (j <= k && i-j >= 0); ++j){
			dp[i] = min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	cout << dp[n-1] << endl;
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	//int t;	cin >> t;
	while(t--) Solve();
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;


int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> An(N);
	rep(i, N) cin >> An[i];

	for (int i = K; i < N; ++i)
	{
		if (An[i] > An[i - K])
		{
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
} 

Measured memory_bytes: 4048
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <unordered_map>
#include <map>
#include <bitset>
#include <string>
#include <cstring>

#define pb push_back
#define mp make_pair
#define l(x) x << 1
#define r(x) x << 1 | 1
#define scan(x) do {while((x=getchar())<'0') ; for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0') ; } while(0)
char _;
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<float, float> pff;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

int N;
ull l = 1, T[105];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        l = l / __gcd(l, T[i]) * T[i];
    }
    cout << l << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        n: i64,
        k: i64,
    }

    let t = n % k;
    let s = k - t;

    println!("{}", std::cmp::min(t,s));
}


Measured memory_bytes: 2136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };

int main() {
	
	int a, b;
	char op;
	cin >> a >> op >> b;

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

	return 0;
}

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


int main(){
    int x;
    vector<int> city(4);
    rep(i,6){
        cin >> x;
        city.at(x-1)++;
    }
    
    int cnt = 0;
    for(int c:city){
        if(c%2) cnt++;
    }
    if(cnt>2 || !city.at(0) || !city.at(1) || !city.at(2) || !city.at(3)) cout << "NO" << endl;
    else cout << "YES" << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vecl = vector<ll>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  set<ll> A;
  REP(i, N) {
    ll tmp;
    cin >> tmp;
    if (A.count(tmp)) {
      cout << "NO" << endl;
      return 0;
    } else
      A.insert(tmp);
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
 
int main(){
  int H, W, i;
  char s[100][101];
  
  scanf("%d %d", &H, &W);
  for (i = 0; i < H; i++){
    scanf("%s", s[i]);
  }
  for (i = 0; i <= W + 1; i++){
    printf("#");
  }
  printf("\n");
  for (i = 0; i < H; i++){
    printf("#%s#\n", s[i]);
  }
  for (i = 0; i <= W + 1; i++){
    printf("#");
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

typedef struct{
  char suit;
  int num;
  int order;
} Card;

void bub_sort(Card *,int );
void selec_sort(Card * ,int );

int main(){
  int n,i,j,a=0;
  Card c1[36],c2[36];

  scanf("%d",&n);

  if(1>n || n > 36 ) exit(8);

  for(i=0;i<n;i++){
    scanf(" %c%d",&c1[i].suit,&c1[i].num);
    c1[i].order = i;
    c2[i] = c1[i];
  }
  bub_sort(c1,n);
  selec_sort(c2,n);
 

  return 0;
}



void bub_sort(Card c[],int n){
  int k,i,stable=0,j;
  Card a;
  for(i = 0; i < n-1; ++i){
    for(j=n-1;j>=1;j--){
      if(c[j].num<c[j-1].num){
	a=c[j];
	c[j]=c[j-1];
	c[j-1]=a;
      }
    }
  }
  stable = 1;
  for(i = 0; i < n; i++){
    if(i)printf(" ");
    printf("%c%d",c[i].suit,c[i].num);
    if(i > 0 && c[i].num == c[i-1].num && c[i].order < c[i-1].order) stable=0;
  }
  printf("\n");
  puts((stable ? "Stable" : "Not stable"));
}
  

void selec_sort(Card c[] ,int n){
  int i,j,minj,stable;
  Card a;
  for(i=0; i<n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(c[j].num < c[minj].num)
	minj = j;
    }
    a = c[i];
    c[i]=c[minj];
    c[minj]=a;
  }
  stable = 1;
  for(i=0; i < n; i++){
    if(i)printf(" ");
    printf("%c%d",c[i].suit,c[i].num);
    if(i > 0 && c[i].num == c[i-1].num && c[i].order < c[i-1].order) stable=0;
  }
  printf("\n");
  puts((stable ? "Stable" : "Not stable"));
}
 







Measured memory_bytes: 2108
void main()
{
    long n = rdElem;
    string s = rdStr;

    long result;
    foreach (i; 0 .. n)
    {
        long[] z_arr = s[i..$].z;
        foreach (j; 0 .. n-i)
        {
            if (j >= z_arr[j]) result = max(result, z_arr[j]);
        }
    }

    result.writeln;
}

long[] z(string s)
{
    long len = s.length;
    long[] result = new long[len];
    result[0] = len;

    long i = 1, j;
    while (i < len)
    {
        while (i + j < len && s[j] == s[i+j]) ++j;
        result[i] = j;

        if (j == 0)
        {
            ++i;
            continue;
        }

        long k = 1;
        while (i + k < len && k + result[k] < j)
        {
            result[i+k] = result[k];
            ++k;
        }

        i += k;
        j -= k;
    }

    return result;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int dp[19][19];
bool b[19][19];
int main(){
	int y,x,n,p,o;
	while(cin>>x>>y,x){
		cin>>n;
		r(i,0,19)r(j,0,19)dp[i][j]=b[i][j]=0;
	while(n--){
		cin>>p>>o;
		b[o-1][p-1]=true;
	}
	r(i,0,y){if(!b[i][0])dp[i][0]=1;else break;}
	r(i,0,x){if(!b[0][i])dp[0][i]=1;else break;}
	r(i,1,y)r(j,1,x){
		if(b[i][j])continue;
		else dp[i][j]=dp[i-1][j]+dp[i][j-1];
	}
	cout<<dp[y-1][x-1]<<endl;
}
}

Measured memory_bytes: 3064
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }

int main() {

	long A, B; cin >> A >> B;

	long res = (B - 1) / (A - 1);

	res++;
	if ((B - 1) % (A - 1) == 0) res--;

	cout << res << endl;
}

Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort{|x,y|y<=>x} end##
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
s=gs
cnt=0
0.upto(9) do |i|
  ii=s.index(i.to_s)
  next if ii.nil? || ii==s.length-1
  0.upto(9) do |j|
    ji=s.index(j.to_s,ii+1)
    next if ji.nil? || ji==s.length-1
    0.upto(9) do |k|
      ki=s.index(k.to_s,ji+1)
      cnt+=1 unless ki.nil?
    end
  end
end

puts cnt

Measured memory_bytes: 1916
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	if N == 1 {
		ans := "Hello World"

		fmt.Println(ans)
	} else {
		var A, B int
		fmt.Scan(&A, &B)

		ans := A + B

		fmt.Println(ans)
	}
}

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

template <class Monoid>
class SegmentTree {
 private:
  using S = typename std::vector<Monoid>::size_type;
  using F = std::function<Monoid(Monoid, Monoid)>;
  S size;
  std::vector<Monoid> nodes;
  const Monoid identity;
  const F operate;

 public:
  SegmentTree(S n, const Monoid& identity, const F& operate) : identity(identity), operate(operate) {
    size = 1;
    while (size < n) size *= 2;
    nodes.assign(2 * size, identity);
  }
  void Update(S i, const Monoid& x) {
    i += (size - 1);
    nodes[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      nodes[i] = operate(nodes[2 * i + 1], nodes[2 * i + 2]);
    }
  }
  Monoid Query(S begin, S end, S i = 0, S b = 0, S e = 0) {
    if (e == 0) e = size;
    if (e <= begin || end <= b) return identity;
    if (begin <= b && e <= end) return nodes[i];
    return operate(Query(begin, end, 2 * i + 1, b, (b + e) / 2), Query(begin, end, 2 * i + 2, (b + e) / 2, e));
  }
};

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

  SegmentTree<int> st(n, 0, [](int a, int b) { return a | b; });
  for (int i = 0; i < n; i++) st.Update(i, 1 << (s[i] - 'a'));

  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int i;
      char c;
      cin >> i >> c;
      st.Update(i - 1, 1 << (c - 'a'));
    } else if (t == 2) {
      int l, r;
      cin >> l >> r;
      cout << bitset<26>(st.Query(l - 1, r)).count() << endl;
    }
  }
}


Measured memory_bytes: 4996
n, m, x = list(map(int, input().split()))
lists = []
result_price = 0
existed = False

for i in range(n):
  lists.append(list(map(int, input().split())))

for i in range(1 << n):
  flag = True
  scores = [0] * m
  tmp_price = 0
  for j in range(n):
    if i & (1 << j):
      for k in range(m):
        scores[k] += lists[j][k+1]
      tmp_price += lists[j][0]
  for l in range(m):
    if scores[l] < x:
      flag = False
      break
  if flag and (result_price > tmp_price or result_price == 0):
    existed = True
    result_price = tmp_price
if existed:
  print(result_price)
else:
  print(-1)

Measured memory_bytes: 9236
n = input()
M = []
inf = 1000000000
for i in range(n):
  M.append(map(int, raw_input().split()))
for i in range(n):
  for j in range(n):
    if M[i][j]==-1:
      M[i][j] = inf
d = [inf for i in range(n)]
p = [-1 for i in range(n)]
color = [0 for i in range(n)]

d[0] = 0

while 1:
  minv = inf
  u = -1
  for i in range(n):
    if minv>d[i] and color[i]!=2:
      u = i
      minv = d[i]
  if u == -1:
    break
  color[u] = 2
  for v in range(n):
    if color[v]!=2 and M[u][v]!=inf:
      if d[v]>M[u][v]:
        d[v] = M[u][v]
        p[v] = u
        color[v] = 1

sum = 0
for i in range(n):
  if p[i]!=-1:
    sum += M[i][p[i]]
print sum

Measured memory_bytes: 6528
# Your code here!
while l = gets
    a = l.split.map(&:to_i)
    b = gets.split.map(&:to_i)

    hit = 0
    blaw = 0
    3.downto(0) do |i|
        if a[i] == b[i]
            a.slice!(i)
            b.slice!(i)
            hit += 1
        end
    end

    blaw = a.length - (a - b).length
    puts "#{hit} #{blaw}"
end



Measured memory_bytes: 6848
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        Map<Integer,Integer>map=new HashMap<>();
        for(int i=0;i<n;i++){
            int index=sc.nextInt();
            if(!map.containsKey(index))
            map.put(index,1);
            else map.put(index,map.get(index)+1);
        }
        int indexmin=100000;
        for(Integer a:map.keySet()){
            indexmin=Math.min(map.get(a),indexmin);
        }
        boolean po=true;
        for(Integer a:map.keySet()){
            if(map.get(a)/indexmin*indexmin==map.get(a))
            map.put(a,map.get(a)/indexmin);
            else po=false;
        }
        if(po){
            ArrayList<Integer>aaa=new ArrayList<>();
            int kl=0;
            for(Integer a:map.keySet()){
                kl=a;
                for(int i=0;i<map.get(a);i++){
                    aaa.add(a);
                }
            }
            Collections.sort(aaa);
            if(aaa.size()==1){
                if(kl!=0)po=false;
            }
            else if(aaa.size()==2){
                if(aaa.get(0)==aaa.get(1)){
                }
                else{
                    po=false;
                }
            }
            else {for(int i=0;i<aaa.size()-2;i++){
                int k=aaa.get(i)^aaa.get(i+1);
                if(aaa.get(i+2)!=k){
                    po=false;
                    break;
                }
            }
            int k=aaa.get(0)^aaa.get(1);
            if(aaa.get(aaa.size()-1)!=k&&indexmin==1)po=false;
            }
        }
        System.out.println(po?"Yes":"No");
    }
}


Measured memory_bytes: 61448
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

max_weight = W + 1
max_cost = sum([v for w,v in WV])
dp = [max_weight for _ in range(max_cost + 1)]
# dp[cost] weight
dp[0] = 0

for w,v in WV:
    for index in reversed(range(len(dp))):
        if dp[index] == max_weight:
            continue

        dp[index + v] = min(dp[index + v], dp[index] + w)


for cost in reversed(range(max_cost + 1)):
    if dp[cost]<=W:
        print(cost)
        break



Measured memory_bytes: 45020
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define sint(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define sset(s) cout<<#s<<":";each(i,s)cout <<" "<<i;cout<<endl

using namespace std;


typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    int n,m,t;
    cin >> n >> m >> t;
    vector<int> vec(n);
    int ans = 0;
    rep(i,n){
        cin >> vec[i];
    }
    ans += vec[0] - m;
    rep(i,n-1){
        ans += max(vec[i+1] - vec[i] - 2*m,0);
    }
    ans += max(t-vec[n-1]-m,0);
    cout << ans << "\n";
}

Measured memory_bytes: 3084
#include<stdio.h>
int main(void)
{
    int i,j,k,sec[5]={0};
    for(i=0;i<4;i++){
        scanf("%d",&sec[i]);
        sec[4]+=sec[i];
    }
    if(3600>sec[4]&&sec[4]>59){
        printf("%d\n%d\n",sec[4]/60,sec[4]%60);
    }
    else printf("%d\n",sec[4]);

    return 0;
}

Measured memory_bytes: 1808
import numpy as np
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
A=(a+9)//10*10
B=(b+9)//10*10
C=(c+9)//10*10
D=(d+9)//10*10
E=(e+9)//10*10
F=max(A-a,B-b,C-c,D-d,E-e)
print(A+B+C+D+E-F)

Measured memory_bytes: 12424
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

int n,k,ans,cnt,cnt_;
int a[100005],w[100005];
bool flag=true;

bool cmp(int a,int b) {
	return a>b;
}

int main() {
	scanf("%d%d",&n,&k);
	char c=getchar();
	for (int i=1;i<=n;i++) {
		c=getchar();
		if (c=='R') {
			a[i]=1;
			if (a[i-1]==1)
				w[cnt]++;
			else w[++cnt]++;
		} else flag=false;
		if (a[i]==a[i-1] && i>1) ans++;
	}
	if (flag) {
		printf("%d\n",n-1);
		return 0;
	}
	int tot=cnt;
	if (a[1]==1) tot--;
	if (a[n]==1) tot--;
	if (a[1]==1 && a[n]==1) cnt_=cnt-1;
	else if (a[1]==0 && a[n]==0) cnt_=cnt+1;
	else cnt_=cnt;
	if (cnt_<=k) {
		printf("%d\n",n-1);
		return 0;
	}
	int kk=k;
	for (int i=1;i<=std::min(kk,tot);i++) {
		ans+=2; k--;
	}
	if (k && cnt>tot)
		for (int i=1;i<=std::min(k,cnt-tot);i++)
			ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
H, W = input().strip().split()
H, W = [int(H), int(W)]

data_list = []
#data_list = [ list(map(str,input().split(" "))) for i in range(H)]
for i in range(H):
  l = input()
  data_list.append(l)
  data_list.append(l)
  
for i in data_list:
  print(i)

Measured memory_bytes: 38384
/*
https://atcoder.jp/contests/dp/tasks/dp_l
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

const int N = 3004;

ll DP[N][N][2];

ll solve(ll arr[], int i, int j, int turn){

    if(i > j){
        return 0;
    }

    if(DP[i][j][turn] != -1){
        return DP[i][j][turn];
    }

    if(turn == 1){
        ll a1 = arr[i] + solve(arr,i+1,j,0);
        ll a2 = arr[j] + solve(arr,i,j-1,0);

        return DP[i][j][turn] = max(a1,a2);
    }
    else{
        ll x =  solve(arr,i+1,j,1);
        ll y =  solve(arr,i,j-1,1);

        return DP[i][j][turn] = min(x,y);
    }
}

int main(){

    int n;  cin>>n;
    ll arr[n];
    ll sum = 0;

    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum += arr[i];
    }

    memset(DP,-1,sizeof(DP));

    ll ans = solve(arr,0,n-1,1);

    cout<<ans-(sum-ans)<<endl;

return 0;
}


Measured memory_bytes: 144852
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }

int main(){
    ll X=ii(),Y=ii(),Z=ii();
    oi(Z);os(" ");
    oi(X);os(" ");
    oi(Y);os(" ");
    oe();

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { lint to, cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

lint m, a, b;
int main() {
	scanf("%lld", &m);
	rep(i, m) {
		lint d, c;
		scanf("%lld %lld", &d, &c);
		a += d * c;
		b += c;
	}
	printf("%lld\n", b - 1 + (a - 1) / 9);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mov(x) (1<<(x))

using namespace std;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n, m, sum;
int grp[mov(15)];
int w[15][15];
int f[mov(15)][15];

int main()
{
	read(n), read(m);
	memset(w, 0x9f, sizeof(w));
	for(int i=1; i<=m; i++)
	{
		int a, b, c;
		read(a), read(b), read(c);
		w[a-1][b-1] = c;
		w[b-1][a-1] = c;
		sum += c;
	}
	memset(f, 0x9f, sizeof(f));
	for(int s=1; s<mov(n); s++)
		for(int i=0; i<n; i++)
			if(s & mov(i))
				for(int j=i+1; j<n; j++)
					if(s & mov(j))
						if(w[i][j] > 0)
							grp[s] += w[i][j];
	for(int s=1; s<mov(n); s++)
		if(s & 1)
			f[s][0] = grp[s];
	for(int s=1; s<mov(n); s++)
		for(int i=0; i<n; i++)
			if((mov(i)&s) && (s&1))
			{
				int u = ((~s)&(mov(n)-1));
				for(int t=u; t; t=((t-1)&u))
					for(int j=0; j<n; j++)
						if(mov(j) & t)
							if(w[i][j] > 0)
								cmax(f[s|t][j], f[s][i] + w[i][j] + grp[t]);
			}
	printf("%d\n", sum-f[mov(n)-1][n-1]);
	return 0;
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

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

int main() {
    ll N, L;
    cin >> N >> L;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int j = -1;
    for (int i = 0; i < N - 1; i++) {
        if (A[i + 1] + A[i] >= L) {
            j = i;
        }
    }
    if (j == -1) {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    for(int k = N - 2; k >= j + 1; k--) {
        cout << k + 1 << endl;
    }
    for (int k = 0; k < j; k++) {
        cout << k + 1 << endl;
    }
    cout << j + 1 << endl;
    cout << endl << endl;
    return 0;
}


Measured memory_bytes: 1664
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),A[]=new int[n];
		for(int i=0;i<n;i++) {
			A[i]=Integer.parseInt(in.next());
		}
		
		int min=A[0],max=A[1]-A[0];
		for(int i=1;i<n;i++) {
			max=Math.max(max,A[i]-min);
			min=Math.min(min,A[i]);
		}
		System.out.println(max);
	}

}




Measured memory_bytes: 72404
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

struct Point {
    int x;
    int y;
};

const int MAX_SIZE = 1050;

int H, W;
int d[4][2];

std::string S[MAX_SIZE];

char A[MAX_SIZE][MAX_SIZE];

int dist[MAX_SIZE][MAX_SIZE];

const int MAX_DIST = MAX_SIZE * 3; 

int main(int argc, char **argv) {
    std::cin >> H >> W;

    for (int i = 1; i <= H; i++) {
        std::cin >> S[i];
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            A[i][j] = S[i][j-1];
            dist[i][j] = MAX_DIST;
        }
    }

    d[0][0] =  1; d[0][1] = 0;
    d[1][0] =  0; d[1][1] = 1;
    d[2][0] = -1; d[2][1] = 0;
    d[3][0] =  0; d[3][1] = -1;

    std::queue<std::pair<int, Point>> que;

    //int num = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (A[i][j] == '#') {
                Point p;
                p.x = i; p.y = j;
                que.push(std::pair<int, Point>({0, p}));
                //num++;
            }
        }
    }

    while(!que.empty()) {
        std::pair<int, Point> pair = que.front(); que.pop();
        Point p = pair.second;
        if (pair.first < dist[p.x][p.y]) {
            dist[p.x][p.y] = pair.first;
            for (int i = 0; i < 4; i++) {
                Point next;
                next.x = p.x + d[i][0];
                next.y = p.y + d[i][1];
                que.push(std::pair<int, Point>({pair.first + 1, next}));
            }
        }
    }

    int ret = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            ret = std::max(ret, dist[i][j]);
        }
    }
    
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 56136
#include<stdio.h>
#include<memory.h>
int max(int a, int b)
{
   if(a > b)return a;
   return b; 
}
int min(int a, int b)
{
    if(a < b)return a;
    return b;
}
int abs(int a)
{
    if(a<0)return -a;
    return a;
}
int h[100000];
int dp[100000];
int main()
{
    int N, K;
   // freopen("input.txt", "r", stdin);
    scanf("%d %d", &N, &K);
    
    for(int i=0; i<N; i++)
    {
        scanf("%d", &h[i]);
        dp[i] = 1e9 + 5;
    }
    dp[0] = 0;
    for(int i=0; i<N; i++)
    {
        for(int k=1; k<=K; k++)
        {
            if(i+k<N)
            {
                dp[i+k] = min(dp[i+k], dp[i]+abs(h[i]- h[i+k]));
            }
        }
    }
    printf("%d\n", dp[N-1]);
    return 0;
}

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

#define M 1046257
#define NTL (-1)
#define L 14

char H[M][L];

/*文字から数値に変換*/
int getChar(char ch){
	if(ch=='A')return 1;
	else if(ch =='C')return 2;
	else if(ch =='G')return 3;
	else if(ch =='T')return 4;
	return 0;
}

/*文字列から数値へ変換してkeyを生成する*/
long long getkey(char str[]){
	long long sum =0, p=1, i;
	for(i=0;i<strlen(str);i++){
		sum+= p*(getChar(str[i]));
		p*=5;
	}
	return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
	long long key, i, h;
	key = getkey(str);
	for(i=0;;i++){
		h=(h1(key)+i*h2(key))%M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0)return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key = getkey(str);
	for(i=0;;i++){
		h=(h1(key) + i * h2(key)) %M;
		if(strcmp(H[h],str)==0)return 1;
		else if(strlen(H[h])==0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(void){
	int i, n;
	char str[L], com[9];
	for(i=0;i<M;i++) H[i][0]='\0';
	scanf("%d", &n);
	for(i=0;i<n;i++){
	scanf("%s %s", com, str);
	
	if(com[0]=='i'){
		insert(str);
	}else{
		if(find(str)){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	 }
	}
	return 0;
}


Measured memory_bytes: 16096
#include <bits/stdc++.h>
using namespace std;
 
int A, B;
 
int main(){
    cin >> A >> B;
    for (int i=0; i<10000; i++){
        if(floor(i*0.08) == A && floor(i*0.1) == B){
            cout << i << "\n";
            return 0;
        } else{
            continue;
        }
    }

    cout << -1 << "\n";
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

ll dp[51][51][2510];

int main(){
    ios;
    INT(n, a);
    VEC(int, x, n);
    dp[0][0][0] = 1;
    REP(i, n){
        REP(j, 51) REP(k, 2510){
            dp[i + 1][j][k] += dp[i][j][k];
            if(k - x[i] >= 0 and j + 1 <= 50) dp[i + 1][j + 1][k] += dp[i][j][k - x[i]];
        }
    }
    ll res = 0;
    REPS(j, n) res += dp[n][j][a * j];
    print(res);
}

Measured memory_bytes: 53648
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M, X = [int(x) for x in input().split()]
    CA = [[int(x) for x in input().split()] for _ in range(N)]

    ans = float("inf")
    for i in range(2 ** N):
        a = [0] * M
        anstmp = 0
        for j in range(N):
            if i >> j & 1:
                anstmp += CA[j][0]
                for k in range(1, M + 1):
                    a[k - 1] += CA[j][k]

        for aa in a:
            if aa < X:
                break
        else:
            ans = min(ans, anstmp)

    if ans == float("inf"):
        print(-1)
    else:
        print(ans)





if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] S = new String[N];
		int C0 = 0;
		int C1 = 0;
		int C2 = 0;
		int C3 = 0;

		for(int i = 0; i < N; i ++){
			S[i] = sc.next();
		}

		for(int i = 0; i < N; i ++){
			if(S[i].equals("AC"))
			C0 ++;
			else if(S[i].equals("WA"))
			C1 ++;
			else if(S[i].equals("TLE"))
			C2 ++;
			else if(S[i].equals("RE"))
			C3 ++;
		}
		System.out.println("AC" +" " +  "x" +" " + C0);
		System.out.println("WA" +" " +  "x" +" " + C1);
		System.out.println("TLE" +" " +  "x" +" " + C2);
		System.out.println("RE" +" " +  "x" +" " + C3);

	}
}

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

int main() {
  int N,K,count=0,ans=1; cin >> N >> K;
  for(int i=0; i<N; i++){
    if(ans*2 < ans+K) ans *=2;
    else ans +=K;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

pub trait BITOperator {
    fn unit() -> Self;
    fn apply(a: &Self, b: &Self) -> Self;
}

pub struct BIT<T: BITOperator> {
    buffer: Vec<T>,
}

impl<T: BITOperator> BIT<T> {
    pub fn new(n: usize) -> BIT<T> {
        let mut buffer = vec![];
        for _ in 0..n {
            buffer.push(T::unit());
        }
        BIT { buffer }
    }

    pub fn update(&mut self, i: usize, v: T) {
        let mut x = i + 1;
        let mut base = 1;
        while x <= self.buffer.len() {
            self.buffer[x - 1] = T::apply(&v, &self.buffer[x - 1]);
            while x & base == 0 {
                base *= 2;
            }
            x += base;
        }
    }

    pub fn query(&self, i: usize) -> T {
        let mut v = T::unit();
        let mut x = i + 1;
        let mut base = 1;
        while x > 0 {
            v = T::apply(&v, &self.buffer[x - 1]);
            while x & base == 0 {
                base *= 2;
            }
            x -= base;
        }
        v
    }
}

impl BITOperator for isize {
    fn unit() -> isize {
        0
    }

    fn apply(a: &isize, b: &isize) -> isize {
        a + b
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let msize = n * (n + 1) / 2;
    let mut l = 0;
    let mut r = INF;
    while r - l > 1 {
        let m = (r + l) / 2;
        let b = a
            .iter()
            .map(|&ai| if ai >= m { 1 } else { -1 })
            .collect::<Vec<isize>>();
        let mut acc_b = vec![0; n + 1];
        for i in 0..n {
            acc_b[i + 1] = acc_b[i] + b[i];
        }
        let acc_b_min = *acc_b.iter().min().unwrap();
        for i in 0..=n {
            acc_b[i] -= acc_b_min;
        }
        let acc_b_max = *acc_b.iter().max().unwrap();

        let mut bit = BIT::new(acc_b_max as usize + 1);
        let mut count = 0;
        for i in 0..=n {
            count += bit.query(acc_b[i] as usize) as usize;
            bit.update(acc_b[i] as usize, 1);
        }
        // dbg!((l, r, m, count));
        if count >= (msize + 1) / 2 {
            l = m;
        } else {
            r = m;
        }
    }
    println!("{}", a.iter().filter(|&&ai| ai <= l).max().unwrap());
}


Measured memory_bytes: 6388
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
void Yay(bool f) { cout << (f ? "Yay!" : ":(") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	deque<int>P, M;
	for (auto x : A) {
		if (x >= 0) {
			P.emplace_back(x);
		}
		else {
			M.emplace_back(x);
		}
	}
	sort(all(P));
	sort(all(M));

	int Max, Min;
	if (P.size() and M.size()) {
		Max = P.back();
		P.pop_back();
		Min = M.front();
		M.pop_front();
	}
	else if (P.size()) {
		Max = P.back();
		P.pop_back();
		Min = P.front();
		P.pop_front();
	}
	else if (M.size()) {
		Max = M.back();
		M.pop_back();
		Min = M.front();
		M.pop_front();
	}

	int ans = 0;

	vector<pii>l;
	for (auto x : P) {
		l.eb(Min, x);
		Min -= x;
	}
	l.eb(Max, Min);
	Max -= Min;
	for (auto x : M) {
		l.eb(Max, x);
		Max -= x;
	}

	cout << Max << endl;
	rep(i, 0, l.size()) {
		cout << l[i].first << " " << l[i].second << endl;
	}

	return 0;
}


Measured memory_bytes: 5236
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int a[100010], n, cnt;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	loop(i,1,n){
		if (a[i] <= a[i - 1])cnt++;
	}
	cout << cnt+1 << endl;
	cout << n << endl;
}


Measured memory_bytes: 3876
#include <iostream>

using namespace std;
int main(){
	double w,h,x,y;
	cin >> w >> h >> x >> y;
	cout << w*h/2 << " ";
	if(x==w/2 && y==h/2){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
}
	


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string A,B,C;

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>A>>B>>C;
	A[0]+='A'-'a';
	B[0]+='A'-'a';
	C[0]+='A'-'a';
	cout<<A[0]<<B[0]<<C[0]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main()
{

long long n,x,mx=0,nx=0;
cin>>n;
vector<long long> v(n);
vector<long long> v2(n);
for(long long i=0;i<n;i++)
{

cin>>v[i];
if(v[i]>mx)
{
    mx=v[i];
    nx=0;
}
else if(mx==v[i]){nx++;}
else{}
}
v2=v;
sort(v.begin(),v.end());

for(long long i=0;i<n;i++)
{
    if(v2[i]!=mx){cout<<mx<<endl;}
    else
    {
        if(nx>0){cout<<mx<<endl;}
        else
        {
            cout<<v[n-2]<<endl;
        }

    }
}
	return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>

using namespace std;

int P[10010];

void init(int N){
  for(int i = 0;i<N;i++){
    P[i] = i;
  }
}

int root(int a){
  if(P[a] == a){
    return a;
  }
  return(P[a] = root(P[a]));
}

bool is_same_set(int a,int b){
  return root(a) == root(b);
}

void unite(int a,int b){
  P[root(a)] = root(b);
}

int main(){
  int n,q,com,x,y;
  cin >>n >>q;
  init(n);
  for(int i=0;i<q;i++){
    cin >>com >>x >>y;
    if(com == 0){
      unite(x,y);
    }
    else{
      cout << is_same_set(x,y) <<endl;
    }
  }
}



Measured memory_bytes: 3180
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;


public class Main {
    public static void main(String[] args)throws Exception{
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String st = "";
        ArrayList<Integer> numbers = new ArrayList<Integer>();
        for(int i = 0;i <= n - 1;i++){
            int a = scan.nextInt();
            numbers.add(a);
        }
        for(int j = n - 1;j >= 0;j--){
            if(j != 0){
                st += numbers.get(j) + " ";
                
            }else{
                st += numbers.get(j);
            }
        }
        System.out.println(st);
    }
}


Measured memory_bytes: 26452
#include<stdio.h>

int mx, mn, n, as, t, i, s;
int main() {
  while(1) {
    scanf("%d", &n);
    if(n == 0) break;
    mx = 0;
    mn = 1000;
    t = 0;
    for(i = 0; i < n; i++) {
      scanf("%d", &s);
      t += s;
      if(s < mn) mn = s;
      if(mx < s) mx = s;
    }
    as = (t - mn - mx) / (n - 2);
    printf("%d\n", as);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	ll n;
	cin>>s;
	n=s.size()+1;
	vl r(n),l(n);
	ll cnt=0;
	rep(i,n){
		if(i==0)continue;
		if(s[i-1]=='<')cnt++;
		else cnt=0;
		l[i]=cnt;
	}
	cnt=0;
	rrep(i,n){
		if(i==n-1)continue;
		if(s[i]=='>')cnt++;
		else cnt=0;
		r[i]=cnt;
	}
	ll ans=0;
	rep(i,n)ans+=max(l[i],r[i]);
	cout<<ans<<endl;
}


Measured memory_bytes: 8732
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
int main(){
    int k;
    cin >> k;
    int ans=0;
    for(int a=1; a<=k; a++){
        for(int b=1;b<=k;b++){
            for(int c=1;c<=k;c++){
                ans += gcd(gcd(a,b),c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<cinttypes>
#include<numeric>

using ui32 = std::uint32_t;
using ui64 = std::uint64_t;

int main() {

	std::cin.sync_with_stdio(false);
	//std::cin.tie(nullptr);

	ui64 n, m;
	std::cin >> n >> m;


	//key,count
	std::map<ui64, ui64> mp;
	for (ui32 i{}; i < n; ++i) {
		ui32 a;
		std::cin >> a;


		++mp[a];
	}

	for (ui32 i{}; i < m; ++i) {
		ui64 b, c;
		std::cin >> b >> c;

		mp[c] += b;

	}


	ui64 ans = 0;
	auto it = rbegin(mp);
	const auto end_ = rend(mp);
	while (n > 0) {
		if (it->second <= n) {
			ans += it->second * it->first;
			n -= it->second;
		}else {
			ans += n * it->first;
			n = 0;
		}
		++it;
	}


	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 12800
h, w = map(int, input().split())

ans = 10**9
for i in range(1,h):
  x = h-i
  s0 = i*w
  s1 = x*(w//2)
  s2 = x*(w-w//2)
  s = max(s0,s1,s2)-min(s0,s1,s2)
  ans = min(ans,s)
  s3 = w*(x//2)
  s4 = w*(x-x//2)
  s = max(s0,s3,s4)-min(s0,s3,s4)
  ans = min(ans,s)

for i in range(1,w):
  x = w-i
  s0 = i*h
  s1 = x*(h//2)
  s2 = x*(h-h//2)
  s = max(s0,s1,s2)-min(s0,s1,s2)
  ans = min(ans,s)
  s3 = h*(x//2)
  s4 = h*(x-x//2)
  s = max(s0,s3,s4)-min(s0,s3,s4)
  ans = min(ans, s)
print(ans)

Measured memory_bytes: 9180