akhauriyash/Code-Regression huggingface dataset:
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$s = $sc->next();

$s_arr = str_split($s);
$price = 700;

for ($i = 0; $i < count($s_arr); $i++) {
    if ($s_arr[$i] === 'o') {
        $price += 100;
    }
}

echo $price;

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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i = 0; i < n; i++){
		cin >> d.at(i);
	}
	sort(d.begin(), d.end());
	cout << d.at(n / 2) - d.at(n / 2 - 1) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <utility>
#include <cstring>
#include <string>

#define MAXN 3005
#define fst first
#define snd second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

ll arr[MAXN];
ll dp[MAXN][MAXN];

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

    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    memset(dp, 0LL, sizeof(dp));
    
    for(int i = n; i > 0; i--) {
        for(int j = i; j <= n; j++) {
            if(i == j) dp[i][i] = arr[i];
            else dp[i][j] = max(arr[i] - dp[i + 1][j], arr[j] - dp[i][j - 1]);
        }
    }
    cout << dp[1][n] << '\n';

    return 0;
}

Measured memory_bytes: 74216
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ff first
#define ss second
 
#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif
 
const int inf = 2e18;
const int ninf = -2e18-5;
const int mod = 1e9 + 7;

signed main(){
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	int x,k,d; cin>>x>>k>>d;
	x = abs(x);
	int n1 = x%d; int m1 = x/d;
	int n2 = abs(n1-d); int m2 = m1+1;
	// cout<<m1<<" "<<k<<endl;
	if(k>=m1){
		if(k%2==m1%2) cout<<n1<<endl;
		else cout<<n2<<endl;
	}
	else{
		// cout<<"yo"<<endl;
		cout<<x-k*d<<endl;
	}

	return 0;
}

Measured memory_bytes: 3688
# coding: utf-8
	
def main():
	# 文字数を入力
	N = int(input())
	# 黒板に書かれている整数を入力します。
	A = input().split(' ')
	value = 0
	for i in range(N):
		value |= int(A[i])
	C = 0
	if value > 0:
		while (value & 1) == 0:
			C += 1
			value >>= 1

	# 結果を出力します。
	print(C)


if __name__ == '__main__':
	main()


Measured memory_bytes: 3188
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = min(a - b, c);
    cout << c - ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N, K; cin >> N >> K;
	cout << N - K + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++)cin >> a[i];
    sort(a.begin(),a.end());
    int ans=INF;
    for(int i=k-1; i<n; i++){
        ans=min(ans,a[i]-a[i-(k-1)]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(N);
    int total = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        total += A[i];
    }
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (4*M*A[i] >= total) cnt++;
    }
    if (cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int pri[80000];
void prime()
{
	int i,j,k,t;
	for(i=2,t=0;i<=1000005;i++)
	{
		k=sqrt(i);
		for(j=2;j<=k;j++)
			if(i%j==0)
				break;
		if(j>k)
			pri[t++]=i;
	}
}
int main()
{
	int n,i;
	prime();
	while(scanf("%d",&n) != EOF)
	{
		for(i=0;;i++)
			if(pri[i]>n)
				break;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 904
ALPH='ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

N=int(input())
S=str(input())
list_ans=[]

for i in range(len(S)):
    for j in range(26):
        if S[i]==ALPH[j]:
            list_ans.append(ALPH[j+N])
print(''.join(list_ans))
            

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<limits>
#include<string>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
const static ll MOD = 1e9+7;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

/*
累積和？O(N)
折れ線グラフできる->そーと->同じ値でいい感じに
*/
template<typename T_n>
inline T_n Accumulate(T_n input){
  T_n v(input.size()+1);
  v[0] = 0;
  for(int i = 1; i < input.size()+1; i++){
    v[i] = v[i-1] + input[i-1];
  }

  return v;
}

void oprint(vector<ll> vec){
  for(ll elem : vec){
    cout << elem << endl;
  }
}
int main(){
  int N; cin >> N;
  vector<ll> vec(N);
  rep(i,N){
    cin >> vec[i];
  }
  vector<ll> accum(N+1);
  accum = Accumulate(vec);
  sort(accum.begin(),accum.end());

  //oprint(accum);
  ll ans = 0;
  ll cnt = 0;
  for(int i=1; i < N+1; i++){
    if(accum[i-1] == accum[i]){
      cnt++;
      if(i == N){
        cnt++;
        ans += cnt * (cnt-1) / 2;
      }
    }else{
      cnt++;
      //cout << "ELSE CALLED at" << i <<  "cnt is " << cnt << endl;
      ans += cnt * (cnt-1) / 2;
      cnt = 0;
    }
  }


  cout << ans << endl;
}


Measured memory_bytes: 6528
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main(){
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	H, W, K := nextInt(), nextInt(), nextInt()
	T := make([][]string, H)
	for i:=0; i<H; i++{
		T[i] = make([]string, W)
		T[i] = chars(next())
	}
	ans := 0
	for bity := 0; bity < (1<<uint64(H)); bity++{
		for bitx := 0; bitx < (1<<uint64(W)); bitx++{
			tmpT := make([][]string, H)
			for i:=0; i<H; i++{
				tmpT[i] = append([]string{}, T[i]...)
			}
			for y := 0; y < H; y++{
				for x := 0; x<W; x++{
					if (bity >> uint64(y)) & 1 == 1 || (bitx >> uint64(x)) & 1 == 1{
						tmpT[y][x] = "赤"
					}
				}
			}
			count := 0
			for y:=0; y<H; y++{
				for x :=0; x<W; x++{
					if tmpT[y][x] == "#"{
						count++
					}
				}
			}
			if count == K{
				ans++
			}
		}
	}
	fmt.Fprintln(out, ans)
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int{
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

Measured memory_bytes: 4852
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
		cout<<"hon"<<endl;
	else if(n%10==0||n%10==1||n%10==6||n%10==8)
		cout<<"pon"<<endl;
	else if(n%10==3)
		cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll h,w;
    cin>>h>>w;
    if(w==1||h==1){
        cout<<1<<endl;
        return 0;
    }
    ll ans=0;
    ans+=h*(w/2);
    if(w%2==1)ans+=(h+1)/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for i in range(n)]

ans=[set([a[0][0],a[0][1],a[0][2]]),set([a[1][0],a[1][1],a[1][2]]),set([a[2][0],a[2][1],a[2][2]]),set([a[0][0],a[1][0],a[2][0]]),set([a[0][1],a[1][1],a[2][1]]),set([a[0][2],a[1][2],a[2][2]]),set([a[0][0],a[1][1],a[2][2]]),set([a[0][2],a[1][1],a[2][0]])]
from itertools import combinations


for i in combinations(b, 3):
    if set(i) in ans:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
i,count,o = 0,0,0
h = 1
for i in range(n):
    if (a[i] == h):
        count += 1
        h += 1
if (count != 0 or n == 1):
    print(n-count)
else:
    print(-1)


Measured memory_bytes: 26012
N=int(input())
h=list(map(int,input().split()))
h.reverse()
flag=True
for i in range(1,N):
    if h[i]-h[i-1]>1:
        flag=False
    elif h[i]-h[i-1]==1:
        h[i]=h[i]-1
    if flag==False:
        break
if flag==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
g(){int x;scanf("%d",&x);return x;}
main(m,v,x){
  for(;;){double s=0,t=0,z=.0174532925199433,e=.0000001;
    scanf("%d",&m);if(!m)return 0;
    for(v=360;--m;s+=sin(x*z))v-=(x=g());s+=sin(v*z);
    scanf("%d",&m);
    for(v=360;--m;t+=sin(x*z))v-=(x=g());t+=sin(v*z);
    puts(s>t+e?"1":s+e<t?"2":"0");
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <math.h>
using namespace std;


long x;

int main() {

  cin >> x ;

  for(int a=-200 ; a<200 ; a++){
    for(int b=-200 ; b<200 ; b++){
      if(pow(a,5)-pow(b,5)==x){
        cout << a<<' '<<b<<endl;
        return 0;

      }
 
    }
  }
 
  
  return 0;
}



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

using namespace std;

int main(void){
    string s;
    string t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for(int i = 0;i < s.size();i++){
          if(s[i] != t[i])ans++;
    }
    cout << ans << endl;
}



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


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

	int x[9] = { 0, 1, 2, 0, 1, 2, 0, 1, 2 };
	int y[9] = { 0, 0, 0, 1, 1, 1, 2, 2, 2 };

	int N = 1000;
	for(int i = 0; i < N; i++) {
		string s;
		cin >> s;
		bool ok = true;
		int nx = -1, ny = -1;
		for(auto c : s) {
			int k = c - 'A';
			if(nx == -1 || (abs(nx - x[k]) + abs(ny - y[k]) == 1)) {
				nx = x[k];
				ny = y[k];
			}
			else {
				ok = false;
				break;
			}
		}
		if(ok) {
			cout << s << endl;
		}
	}
}

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if((a==b) && (a!=c) && (b!=c)) printf("Yes\n");
	else if((c==b) && (a!=b) && (a!=c)) printf("Yes\n");
	else if((a==c) && (a!=b) && (b!=c)) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

typedef	vector<int>	vi;

int main(){
	int t;	cin>>t;
	while(t--){
		string s;	cin>>s;
		int len=s.length();
		vi v(len);
		for(int i=0;i<len;i++)	v[i]=s[i]-'0';
		int step;
		for(int i=0,p=len-1;;i++){
			if(p==0){ step=i; break; }
			int a=v[p-1]+v[p];
			if(a<10)	v[p-1]=a,p--;
			else	v[p-1]=a/10,v[p]=a%10;
		}
		if(step%2)	cout<<"Fabre wins."<<endl;
		else		cout<<"Audrey wins."<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
using namespace std;

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
using ll = long long;
const int INF = 1e9;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }



signed main()
{
    int n,m; cin>>n>>m;
    vector<int> a(n);
    vector<int> b(n);
    map<int,vector<int>> mp;
    rep(i,n){
        int a,b; cin>>a>>b;
        mp[a].push_back(b);
    }

    ll ans=0;
    priority_queue<int> que;
    for(int i=1; i<=m; i++){
        for(auto e: mp[i]){
            que.push(e);
        }
        if(que.empty())continue;
        ans+=(ll)que.top();
        que.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11648
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int N;
ll A[200000];

ll inv = 500000004;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll sum = 0;
    ll sum_p = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
        sum %= MOD;
        sum_p += (A[i]*A[i])%MOD;
        sum_p %= MOD;
    }
    ll ans = (sum*sum)%MOD;
    ans = (ans-sum_p)*inv;
    ans %= MOD;
    ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 5172
import java.util.*;
 
import java.io.*;
 
public class Main{
    
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        HashMap<String, Integer> normalSet = new HashMap<String, Integer>();
        for(int i = 0; i <= 9; i++){
            for(int j = 0; j <= 9; j++){
                normalSet.put(String.valueOf(i)+String.valueOf(j), 0);
            }
        }

        for(int i = 1; i <= N; i++){
            String normal = String.valueOf(i);
            String normalmoji = String.valueOf(normal.charAt(0)) + String.valueOf(normal.charAt(normal.length()-1));
            normalSet.put(normalmoji, normalSet.get(normalmoji)+1);
        }

        long result = 0;
        for(int i = 0; i <= 9; i++){
            for(int j = 0; j <= 9; j++){
                result += normalSet.get(String.valueOf(i)+String.valueOf(j))*normalSet.get(String.valueOf(j)+String.valueOf(i));
                
            }
        }
        
        System.out.println(result);
	}
} 

Measured memory_bytes: 41808
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace C_ABC152
{
    class MainClass
    {

        static int[] s, n;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int ans = 0;
            int min = n[0];
            for(int i = 0;i< s[0];i++){
                if(n[i]<=min){
                    ans++;
                    min = n[i];
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 35292
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.container;
import std.bigint;
import std.math;

void main()
{
	auto ab = readln.split.map!(to!int);
	writeln(ab[0]*ab[1], " ", ab[0]*2+ab[1]*2);
}

Measured memory_bytes: 1084
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
int n;
int arr[N];
int lft[N];
int rgt[N];
stack < int > s;
long long ans;
int main(){
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , arr + i);
    }
    arr[0] = 0;
    s.push(0);
    for(int i = 1 ; i <= n ; ++i){
        while(arr[s.top()] >= arr[i]){
            s.pop();
        }
        lft[i] = s.top();
        s.push(i);
    }
    while(!s.empty()){
        s.pop();
    }
    arr[n + 1] = 0;
    s.push(n + 1);
    for(int i = n ; i >= 1 ; --i){
        while(arr[s.top()] >= arr[i]){
            s.pop();
        }
        rgt[i] = s.top();
        s.push(i);
    }
    for(int i = 1 ; i <= n ; ++i){
        ans += 1LL * arr[i] * (i - lft[i]) * (rgt[i] - i);
    }
    printf("%lld\n" , ans);
}

Measured memory_bytes: 3456
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
		int x1,y1,x2,y2;
      	x1=reader.nextInt();
      y1=reader.nextInt();
      x2=reader.nextInt();
      y2=reader.nextInt();
      int diff_x=x2-x1;
      int diff_y=y2-y1;
      int x3 = x2 - diff_y;
    int y3 = y2 + diff_x;
    int x4 = x1 - diff_y;
    int y4 = y1 + diff_x;
    System.out.printf("%d %d %d %d",x3,y3,x4,y4);
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 200000 + 10;
int a[maxn];
int n,m;
int main()
{
	while( ~ scanf("%d%d",&n,&m))
	{
		for(int i = 1; i <= n; i ++)
		scanf("%d",&a[i]);
		int ans = 0,t = a[1] + m;
		for(int i = 2; i <= n; i ++)
		{
			if(a[i] <= t)
			{
				ans += a[i] - a[i - 1];
				t = a[i] + m;
			}
			else 
			{
				t = a[i] + m;
				ans += m;
			}
		}
		cout << ans + m << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
	
int main(){
	vector<char> s;
	char t;
	while(cin>>t){
		s.push_back(t);
	}
	for(vector<char>::reverse_iterator  it = s.rbegin(); it != s.rend(); it ++)
	{
		cout<<(*it);
	}

	
	cout<<endl;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a == 5 && b== 5 && c == 7) cout << "YES" << endl;
    else if(a == 5 && c == 5 && b == 7) cout << "YES" << endl;
    else if(a == 7 && b == 5 && c == 5) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;

 
int main(){
  int a, b;
  cin >> a>>b;
  cout << a*b;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using ll = long long;
#define MOD 1000000007
using namespace std;

int main(){
    int N, m = 0;
    cin >> N;
    vector<int> b(N), a(N);
    for(int i = 0; i < N; i++)
    {
        cin >> b[i];
        m = max(m,b[i]);
    }
    for(int j = N-1; j >= 0; j--)
    {
        m = min(m,(int)b.size());
        for(int i = 0; i < m; i++)
        {
            if (b[m-i-1] == m-i) {
                a[j] = b[m-i-1];
                b.erase(b.begin()+m-i-1);
                break;
            }
            else if (i == m-1){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for(int i = 0; i < N; i++)
    {
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<ll, ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
//#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int>
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF -1e16

#define maxn 100005
int spf[maxn];
vll primes,prev[maxn],next[maxn];
set<int>s;
void sieve()
{
	rep(i,2,maxn)
	{
		if (spf[i]==0)
		{
			spf[i]=i;
			for(int j=2*i;j<=maxn;j+=i)
			{
				if(spf[j]==0)
					spf[j]=i;
			}
		}
	}
}
void SieveOfEratosthenes(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*2; i<=n; i += p) 
                prime[i] = false; 
        } 
    }
    for (int p=2; p<=n; p++) 
    {
        if (prime[p]) 
        {
            primes.pb(p); 
            s.insert(p);
        }
    }    
} 
// bool isPrime(ll n) 
// { 
//     if (n <= 1) 
//         return false; 
//     if (n <= 3) 
//         return true; 
//     if (n % 2 == 0 || n % 3 == 0) 
//         return false; 
//     for (int i = 5; i * i <= n; i = i + 6) 
//         if (n % i == 0 || n % (i + 2) == 0) 
//             return false; 
//     return true; 
// } 
// ll power(ll x,ll y)
// {
//     ll X=x;
//     //X=X%p;//if x is greater than p
//     if(X==0)
//     {
//         return 0;
//     }
//     ll res=1ll;
//     while(y>0)
//     {
//         if(y&1)
//         {
//             res=((res)*(X));
//             y--;
//         }
//         y=y>>1;
//         X=((X)*(X));
//     }
//     // res=(res>=0)?(res%p):(res+p)%p;
//     return(res);
// }
// void dfs(int u, int par){
//     cnt[u] = 1;
//     p[u] = par;
//     for(int i : g[u]){
//         if(i != par){
//             dfs(i,u);
//             cnt[u] += cnt[i];
//         }
//     }
// }
// int children(vll v[],int parent,int src,vll& chil)
// {
// 	int ans =0;
// 	for(auto it:v[src])
// 	{
// 		if(it!=parent)
// 		{
// 			ans+= 1+children(v,src,it,chil);
// 		}
// 	}
// 	chil[src] = ans;
// 	return ans;
 
// }
bool cmp(const pair<int,int>&a,const pair<int,int>&b)
{
    if (a.F==b.F)
    return a.S<b.S;
    else
    return a.F>b.F;
}

signed main() {
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	srand (static_cast <unsigned> (time(0)));
// 	SieveOfEratosthenes(100005); 
// 	sort(all(primes));
    sieve();
	int t=1;
	//cin >> t;
	while (t--) 
	{
	    int n,k;
	    cin >> n >> k;
	    vll h(n);
	    rep(i,0,n)
	    cin >> h[i];
	    vll dp(n,INT_MAX);
	    dp[0]=0;
	    rep(i,0,n)
	    {
	        rep(j,i+1,i+k+1)
	        {
	            if(j<n)
	            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
	        }
	        
	    }
	    cout<<dp[n-1]<<endl;
	}
	return 0;
}

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

const int MAX = 45;

//2D cumulative sum(座標は1-indexedであることに注意せよ)
int64_t sum[MAX][MAX];



int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    long double x;
    cin >> x;
    x *= 1e9;
    vec[i] = round(x);
  }
  
  vector<int> T(N);
  vector<int> F(N);
  
  //掛け算して10^18 = 2^18 * 5^18で割れれば良い
  
  for(int i=0; i<N; i++){
    int two = 0;
    int five = 0;
    int64_t x = vec[i];
    while(x %2 == 0){
      x /= 2;
      two++;
    }
    while(x %5 == 0){
      x /= 5;
      five++;
    }
    T[i] = two;
    F[i] = five;
    sum[two][five]++;
  }
  
  
  int64_t ans = 0;
  
  for(int i=0; i<N; i++){
    int64_t x = vec[i];
    for(int j=max(0,18-T[i]); j<MAX; j++){
      for(int k=max(0,18-F[i]); k<MAX; k++){
        ans += sum[j][k];
        if(j == T[i] && k == F[i]){
          ans--;
        }
      }
    }
  }
  
  cout << ans / 2 << endl;
  
}

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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define in(type,a) type a;cin >> a
using ll = long long;

int main() {
    in(int, n);
    in(int, k);
    char ch[n];
    REP(i,n){
        cin >> ch[i];
    }
    
    ch[k-1] = tolower(ch[k-1]);
    
    REP(i,n){
        cout << ch[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

struct element {
  int node;
  int used_color;
  int from;
};

long long MOD = 1000000007;
long long counter = 1;
deque<element> que;
int nnode, ncolor;
vector<int> edges[100000 + 1];

bool contain(vector<int> edge, int num) {
  for (int i = 0; i < edge.size(); i++) {
    if (edge[i] == num) {
      return true;
    }
  }
  return false;
}

void expand(int node, int used_color, int from) {
  counter = (counter * (ncolor - used_color)) % MOD;
  int add = contain(edges[node], from) ? 1 : 0;
  vector<int> edge(edges[node]);
  REP(i, edge.size()) {
    if (edge[i] == from) {
      edge.erase(edge.begin() + i);
      break;
    }
  }
  REP(i, edge.size()) {
    element push_element = {edge[i], 1 + add + i, node};
    que.push_back(push_element);
  }
}

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

  REP(i, nnode - 1) {
    int wk1, wk2;
    scanf("%d %d", &wk1, &wk2);
    (edges[wk1]).push_back(wk2);
    (edges[wk2]).push_back(wk1);
  }

  REP(i, nnode + 1) {
    if (edges[i].size() > ncolor) {
      cout << 0 << endl;
      return 0;
    }
  }

  element first = {1, 0, -1};
  que.push_back(first);

  while (!que.empty()) {
    element next = que.front();
    que.pop_front();
    expand(next.node, next.used_color, next.from);
  }
  cout << counter << endl;

  return 0;
}

Measured memory_bytes: 7664
#include <stdio.h>

int main() {
	char x,y;
	
	scanf("%c %c", &x, &y);
	if (x < y) {
		printf("<\n");
	} else if (x > y) {
		printf(">\n");
	} else {
		printf("=\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    bool N,W,S,E;
    N = false;
    W = false;
    S = false;
    E = false;
    
    rep(i,s.size()){
        if(s[i] == 'N') N = true;
        if(s[i] == 'E') E = true;
        if(s[i] == 'W') W = true;
        if(s[i] == 'S') S = true;
    }
    
    bool ans = true;
    if(E^W) ans = false;
    if(N^S) ans = false;
    if(ans) cout <<"Yes" << endl;
    else cout << "No" << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 100

int main(){
    int n;
    int t_point=0, h_point=0;
    char tarou[MAX], hanako[MAX];

    scanf("%d", &n);
    for(;n>0;n--){
        scanf(" %s %s", tarou, hanako);
        if(strcmp(tarou, hanako)>0){
            t_point+=3;
        }else if(strcmp(tarou, hanako)==0){
            t_point+=1;
            h_point+=1;
        }else if(strcmp(tarou, hanako)<0){
            h_point+=3;
        }
    }
    printf("%d %d\n", t_point, h_point);

    return 0;
}


Measured memory_bytes: 2108
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		h = scanner.nextInt();
		w = scanner.nextInt();
		n = scanner.nextInt();
		num = new Point[n + 1];
		map = new boolean[h][w];
		for (int i = 0; i < h; i++) {
			char[] chs = scanner.next().toCharArray();
			for (int j = 0; j < w; j++) {
				if (chs[j] == '.')
					continue;
				else if (chs[j] == 'X')
					map[i][j] = true;
				else if (chs[j] == 'S')
					num[0] = new Point(i, j);
				else
					num[chs[j] - '0'] = new Point(i, j);
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += slove(num[i].y, num[i].x, num[i + 1].y, num[i + 1].x);
		}
		System.out.println(ans);
	}

	private int slove(int sy, int sx, int gy, int gx) {
		Deque<Point> deque = new ArrayDeque<Main.Point>();
		deque.offer(new Point(sy, sx, 0));
		boolean[][] tmpmap = new boolean[h][w];
		tmpmap[sy][sx] = true;
		while (!deque.isEmpty()) {
			Point p = deque.poll();

			for (int[] m : move) {
				int ny = p.y + m[0];
				int nx = p.x + m[1];
				if (!isOK(ny, nx))
					continue;
				if (map[ny][nx])
					continue;
				if (ny == gy && nx == gx) {
					return p.step + 1;
				}
				if (tmpmap[ny][nx])
					continue;
				tmpmap[ny][nx] = true;
				deque.offer(new Point(ny, nx, p.step + 1));
			}
		}
		return -1;
	}

	private boolean isOK(int ny, int nx) {
		if (0 <= ny && ny < h && 0 <= nx && nx < w)
			return true;
		return false;
	}

	int h, w, n;
	Point[] num;
	boolean[][] map;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

	class Point {
		int y, x, step;

		@Override
		public String toString() {
			return "Point [y=" + y + ", x=" + x + ", step=" + step + "]";
		}

		public Point(int y, int x, int step) {
			super();
			this.y = y;
			this.x = x;
			this.step = step;
		}

		public Point(int y, int x) {
			super();
			this.y = y;
			this.x = x;
		}

	}
}

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

int main() {
	// your code goes here
	int ar[3];
	cin>>ar[0]>>ar[1]>>ar[2];
	sort(ar,ar+3);
	int abal= ar[2]-ar[0];
	cout<<abal<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdint>
#include <iostream>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

} // namespace null_null

#include <string>
#include <stack>

namespace null_null {

void main_() {
  usize N;
  std::string S;
  std::cin>>N>>S;

  std::stack<char> stk;
  stk.push('0');

  for(usize i=0;i<N;i++){
    if(stk.top()!=S[i]){
      stk.push(S[i]);
    }
  }

  std::cout<<stk.size()-1<<std::endl;
}

} // namespace null_null

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  null_null::main_();
  return 0;
}

Measured memory_bytes: 512
import itertools

n, a, b, c = map(int, input().split())
l = []
for i in range(n):
    l.append(int(input()))
mp = float("inf")
for i in itertools.product([0,1,2,3], repeat = n):
    if 0 not in i or 1 not in i or 2 not in i:
        continue
    la, lb, lc = 0, 0, 0
    temp = 0
    for j in range(3):
        temp += (i.count(j) - 1) * 10
    for j in range(n):
        if i[j] == 0:
            la += l[j]
        elif i[j] == 1:
            lb += l[j]
        elif i[j] == 2:
            lc += l[j]
    for j, k in [[la, a], [lb, b], [lc, c]]:
        temp += abs(j - k)
    mp = min(mp, temp)
print(mp)

Measured memory_bytes: 9012
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    swap(x, y);
    swap(x, z);
    printf("%d %d %d\n", x, y, z);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
  int wi, hi, xi, yi;
  cin >> wi >> hi >> xi >> yi;

  long double w, h, x, y;
  w = wi;
  h = hi;
  x = xi;
  y = yi;

  long double ans;

  long double ah, av;

  ans = w * h / 2.0;

  cout << fixed << setprecision(16);
  if (x == w/2 && y == h/2) {
    cout << ans << endl;
    cout << '1' << endl;
  } else {
    cout << ans << endl; 
    cout << '0' << endl;
  }
}


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

using namespace std;

using ll = long long;

char T[100005];
char t[100005];

int main() {
    int N,K; cin>>N>>K;
    int R,S,P; cin>>R>>S>>P;
    cin>>&T[1];

    int ans = 0;
    for (int i=1;i<=N;i++) {
        switch (T[i]) {
            case 'r':
                //cout << 'P';
                if (i < K) {
                    ans += P;
                    t[i] = 'P';
                } else {
                    if (t[i-K] != 'P') {
                        ans += P;
                        t[i] = 'P';
                    } else {
                        t[i] = '*';
                    }
                }
                break;
            case 's':
                //cout << 'R';
                if (i < K) {
                    ans += R;
                    t[i] = 'R';
                } else {
                    if (t[i-K] != 'R') {
                        ans += R;
                        t[i] = 'R';
                    } else {
                        t[i] = '*';
                    }
                }
                break;
            case 'p':
                //cout << 'S';
                if (i < K) {
                    ans += S;
                    t[i] = 'S';
                } else {
                    if (t[i-K] != 'S') {
                        ans += S;
                        t[i] = 'S';
                    } else {
                        t[i] = '*';
                    }
                }
                break;
        }

    }
    //cout << endl;
    //cout << &t[1] << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

for _ in range(K):
    S = [0] * (N + 1)
    for i, a in enumerate(A):
        l = min(N-1, max(0, i-a))
        r = min(N-1, i+a)
        S[l] += 1
        S[r+1] -= 1
    t = 0
    for i in range(N):
        t += S[i]
        A[i] = t
    if sum(A) == N**2:
        break
print(*A)

Measured memory_bytes: 157244
#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.at(i);
  }
  sort(A.begin(), A.end());
  cout << A.at(A.size()-1) - A.at(0) << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    int n,r;
    cin>>n>>r;
    if(n<10){
        cout<<100*(10-n)+r;
    }else{
        cout<<r;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=e-1; i>=s; i--)

int main(){

    ll n, m; cin >> n >> m;

    priority_queue<double> que;

    rep(i, n){
        double temp; cin >> temp;
        que.push(temp);
    }

    rep(i, m){
        double temp = que.top();
        // cout << temp << endl;
        que.pop();

        que.push(temp/2.0);
    }

    ll ans = 0;
    rep(i, n){
        ans += floor(que.top());
        que.pop();
    }

    cout << ans;

    return 0;
}

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

typedef long long ll;

const int MAX_N = 100010;
int par[MAX_N];
int rnk[MAX_N];
int siz[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
        siz[i] = 1;
    }
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    int s = siz[x] + siz[y];
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
    siz[find(x)] = s;
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int size(int x) {
    return siz[find(x)];
}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(M), B(M), ans(M, N * (N - 1) / 2);
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    init(N);
    for (int i = M - 1; i > 0; i--) {
        if (same(A[i], B[i])) {
            ans[i - 1] = ans[i];
        } else {
            ans[i -1] = ans[i] - 1LL * size(A[i]) * size(B[i]);
            unite(A[i], B[i]);
        }
    }
    rep(i, M) {
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 4864
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import qualified Data.Set as ST
import qualified Data.Sequence as SQ
import Data.Array
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.IO
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.Bits
import Data.List
import Data.Tuple
import Data.Functor
import Data.IORef
import Data.STRef
import Control.Applicative
import Control.Monad
import Control.Monad.ST

solve n = 1000 * x + 5 * y
  where
    x = n `div` 500
    y = (n - 500 * x) `div` 5

main = do
  n <- readLn :: IO Int
  print $ solve n


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    pair<int, int> maximum = make_pair(-1000001, 0);
    pair<int, int> minimum =  make_pair(1000001, 0);
    bool is_plus = true;
    bool is_minus = true;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);

        if (a.at(i) > 0) is_minus = false;
        if (a.at(i) < 0) is_plus = false;

        if (a.at(i) > maximum.first) maximum = make_pair(a.at(i), i + 1);
        if (a.at(i) < minimum.first) minimum = make_pair(a.at(i), i + 1);
    }
    
    if (is_plus) {
        cout << n - 1 << endl;
        for (int i = 2; i <= n; i++)
        {
            printf("%d %d\n", i - 1, i);
        }

        return 0;
    }
    
    if (is_minus) {
        cout << n - 1 << endl;
        for (int i = n; i >= 2; i--)
        {
            printf("%d %d\n", i, i - 1);
        }
        
        return 0;
    }

    if (abs(maximum.first) >= abs(minimum.first)) {
        cout << n * 2 - 2 << endl;
        for (int i = 1; i <= n; i++)
        {
            if (i != maximum.second) printf("%d %d\n", maximum.second, i);
        }
        for (int i = 2; i <= n; i++)
        {
            printf("%d %d\n", i - 1, i);
        }
    }
    else {
        cout << n * 2 - 2 << endl;
        for (int i = 1; i <= n; i++)
        {
            if (i != minimum.second) printf("%d %d\n", minimum.second, i);
        }
        for (int i = n; i >= 2; i--)
        {
            printf("%d %d\n", i, i - 1);
        }
    }
}


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

int main(){
	string s;
	cin>>s;
	
	int ans=0;
	
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]=='p'){
				ans--;
			}
		}else{
			if(s[i]=='g'){
				ans++;
			}
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    vector<pair<int, string>> v;
    for (auto it : m)
        v.push_back({it.se, it.fi});
    sort(rall(v));
    int i = 0;
    set<string> res;
    while (i < n && v[i].fi == v[0].fi)
        res.insert(v[i].se), i++;
    for (auto it : res)
        cout << it << endl;
    GAME_OVER;
}

Measured memory_bytes: 37100
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

Ki G;
map<P,int> ans;

void dfs(int pre,int now){
    int c=1;
    for(auto &next:G[now]){
        if(pre==next) continue;
        if(pre!=-1&&c==ans[{pre,now}]) c++;
        ans[{next,now}]=ans[{now,next}]=c;
        dfs(now,next);
        c++;
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    G.resize(n);
    vector<P> ed;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--;b--;
        ed.pb(P(a,b));
        G[a].pb(b);
        G[b].pb(a);
    }

    dfs(-1,0);

    ll memo=0;
    rep(i,n){
        memo=max(memo,(ll)G[i].size());
    }
    cout<<memo<<endl;

    rep(i,n-1){
        cout<<ans[ed[i]]<<endl;
    }
    
    

    
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int a[n], b[n];
	for (int i = 0; i < n; i++) a[i] = ri(), b[i] = ri();
	int c[m], d[m];
	for (int i = 0; i < m; i++) c[i] = ri(), d[i] = ri();
	
	for (int i = 0; i < n; i++) {
		int min = 1000000000;
		int ind = -1;
		for (int j = 0; j < m; j++) {
			int dist = std::abs(c[j] - a[i]) + std::abs(d[j] - b[i]);
			if (dist < min) min = dist, ind = j;
		}
		printf("%d\n", ind + 1);
	}
	
	return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

#define llset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define en '\n'
#define S second
#define F first
#define pll pair<ll,ll>
#define PB push_back

const ll N = 1e6+7;
ll mod = 1e9+7;
#define calncr for(int i=1  ;i<=1e6;i++) fac[i] = (fac[i-1]*i)%mod;
ll fac[N] = {0};

ll gen_base(const ll before, const ll after) {
    auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
    std::mt19937 mt_rand(seed);
    int base = std::uniform_int_distribution<ll>(before+1, after)(mt_rand);
    return base % 2 == 0 ? base-1 : base;
}

ll pow(ll a,ll b)
{
    if(!b)
        return 1;
    ll p = pow(a,b/2);
    if(b%2)
        return (a*((p*p)%mod))%mod;
    else
        return (p*p)%mod;
}

ll modInv(ll a)
{
    //cout<<a<<" "<<mod<<en;
    return pow(a%mod,mod-2);
}

ll nCr(ll n,ll r)
{
    return (fac[n]*modInv((fac[r]*fac[n-r])%mod))%mod;
}

ll hashf(ll r,ll x,ll mod)
{
    return (x+r)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    fac[0] = 1;
    calncr;
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    ll ans=0;
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            for(ll k=j+1;k<n;k++){
                if(arr[i]==arr[j] || arr[j]==arr[k] || arr[i]==arr[k])
                    continue;
                if((arr[i]+arr[j])>arr[k])
                    ans++;
            }
        }
    }
    cout<<ans<<en;
}


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

int main () {
  int A, B;
  cin >> A >> B;
  cout << (A * B - A - B + 1) << endl;
  return 0;
}


Measured memory_bytes: 256