akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(a-b >= 0) cout << "delicious" << endl;
  else if(b <= a+x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int a,b;
  string op;
  cin >> a >> op >> b;
  if(op=="+")
  {
    cout << a+b << endl;
  }
  else
  {
    cout << a-b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val Array(m, n) = io.StdIn.readLine().split(" ").map(_.toInt)
    println(power(m, n))
  }
  def power(m: Int, n: Int): BigInt = {
    def loop(m: BigInt, n: Int, acc: BigInt): BigInt = n match {
      case 0 => acc
      case _ if n % 2 == 0 => loop((m * m) % 1000000007, n / 2, acc)
      case _ => loop(m, n - 1, (m * acc) % 1000000007)
    }
    loop(m, n, 1)
  }
}

Measured memory_bytes: 43992
import numpy as np

N, K = map(int, input().split())
A = tuple(map(int, input().split()))

dp_left = np.zeros((N + 1, K), dtype=bool)
dp_right = np.zeros((N + 1, K), dtype=bool)
dp_left[0, 0] = 1
dp_right[N, 0] = 1

for i in range(N):
    dp_left[i + 1] = dp_left[i]
    dp_right[N - i - 1] = dp_right[N - i]
    if (a := A[i]) < K:
        dp_left[i + 1, a:] |= dp_left[i, :-a]
    if (a := A[N - i - 1]) < K:
        dp_right[N - i - 1, a:] |= dp_right[N - i, :-a]

ans = 0
for i, a in enumerate(A):
    left_true = np.nonzero(dp_left[i])[0]
    right_true = np.nonzero(dp_right[i + 1])[0]

    ss = np.searchsorted(right_true, K - left_true) - 1
    if all(right_true[ss] + left_true + a < K):
        ans += 1

print(ans)


Measured memory_bytes: 76484
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  int ans=0;
  string s;
  cin >> s;
  if(s=="RRR")ans = 3;
  else if(s == "SSS")ans = 0;
  else if(s =="RRS" || s == "SRR")ans=2;
  else ans=1;
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 3624
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace AtcoderExpress
{


    class Program2
    {
        static long mod = 1000000007;
        static void Main(string[] args)
        {
            //var HWK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var S = Console.ReadLine();

            if(S[2] == S[3] && S[4] == S[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }
    }
}



Measured memory_bytes: 13140
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
double v[MAX_N];

int main(void)
{
  cin >> N;
  REP(i, N) cin >> v[i];

  priority_queue<double, vector<double>, greater<double>> q;
  REP(i, N) q.push(v[i]);

  double ans = 0;
  while (!q.empty()) {
    double a = q.top();
    q.pop();
    if (q.empty()) {
      ans = a;
      break;
    }
    double b = q.top();
    q.pop();
    double c = (a + b) / 2.0;
    q.push(c);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n, q; cin >> n >> q;
    string s; cin >> s;
    
    vector<int>AC(n);
    int cnt=0;
    AC[0] = 0;
    for(int i=1;i<n;i++){
        if(s[i-1] == 'A' && s[i] == 'C'){
            cnt++;
        }
        AC[i] = cnt;
    }
    int l, r;
    for(int i=0;i<q;i++){
        cin >> l >> r;
        cout << AC[r-1] - AC[l-1] << endl;
    }
    
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,ans=0;
    cin>>n;
    vi a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(all(a));
    vector<bool> c(a[n-1]+1,true);
    lli rec=INF;
    rep(i,n){
        if(a[i]==rec) {
            c[a[i]]=false;
            continue;
        }
        if(!c[a[i]]) continue;
        else{
            lli j=2;
            while(j*a[i]<=a[n-1]){
                c[j*a[i]]=false;
                j++;
            }
        }
        rec=a[i];
    }
    rep(i,n){
        if(c[a[i]]) ans++;
    }
    out(ans);
}

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

using namespace std;

int main() {
    int n, m;
    vector<int> h;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int th;
        cin >> th;
        h.push_back(th);
    }
    vector<int> ans = h;
    for (int i = 0; i < m; i++) {
        int ta, tb;
        cin >> ta >> tb;
        if (h[ta - 1] < h[tb - 1]) {
            ans[ta - 1] = 0;
        } else if (h[ta - 1] == h[tb - 1]) {
            ans[ta - 1] = 0;
            ans[tb - 1] = 0;
        } else {
            ans[tb - 1] = 0;
        }
    }
    int n_count = count(ans.begin(), ans.end(), 0);
    cout << n - n_count << endl;
    return 0;
}


Measured memory_bytes: 4204
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Ord


r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    n <- readLn :: IO Int 
    ps <- r'
    let triples = zip ps (zip (tail ps) (tail (tail ps)))
    let r = length $ filter (\(a,(b,c)) -> let [x,y,z] = sort [a,b,c] in y == b) triples
    print r

Measured memory_bytes: 508
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;

int main(){

    int x,y; cin >> x >> y;
    int k=0,t=0;


    if(y==0||x==0){
        cout << "No" << endl;
        return 0;
    }

    for(k=0;k<=x; k++){
        for(t=0; t<=x-k;t++){
            if(4*k+2*t==y&&k+t==x){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
     return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	while(1){
		double n,ganri=0,num=0;
		cin>>n;
		if(n==0) return 0;
		double y;
		cin>>y;
		for(int i=0;i<n;i++){
			double b,t,r,tmp=1;
			cin>>b>>r>>t;
			if(t==1){
				tmp=1+y*r*0.01;
			}
			if(t==2){
				for(int j=0;j<y;j++){
					tmp*=1+r*0.01;
				}
			}
			if(ganri<tmp){
				ganri=tmp;
				num=b;
			}
		}
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 3224
#include <stdio.h>
#include <iostream>

using namespace std;

int main(void)
{
	string S;
	char s1, s2, s3, s4;

	cin >> S;

	s1 = S[0];
	s2 = S[1];
	s3 = S[2];
	s4 = S[3];

	if(s1 == s2) {
		if(s3 == s4 && s1 != s3) {
			cout << "Yes";
		} else {
			cout << "No";
		}

	} else if(s1 == s3) {
		if(s2 == s4 && s1 != s2) {
			cout << "Yes";
		} else {
			cout << "No";
		}

	} else if(s1 == s4) {
		if(s2 == s3 && s1 != s2) {
			cout << "Yes";
		} else {
			cout << "No";
		}
	} else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;

  return 0;
}

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

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

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    cout << min({a*x + b*y, c*2*max(x, y), x < y ? x*c*2 + (y-x)*b : y*c*2 + (x-y)*a}) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int x[5] = {}, y[5] = {};
   cin >> x[1] >> y[1] >> x[2] >> y[2];
   x[3] = x[2] - y[2] + y[1];
   y[3] = y[2] + x[2] - x[1];
   x[4] = x[3] - y[3] + y[2];
   y[4] = y[3] + x[3] - x[2];
   cout << x[3] << " " << y[3] << " " << x[4] << " " << y[4] << endl;
   return 0;
}


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

n = int(input())
acc_e = [0]
acc_w = [0]

for (i,s) in enumerate(list(input())):
    if s=="W":
        acc_w.append(acc_w[i]+1)
        acc_e.append(acc_e[i])
    else:
        acc_w.append(acc_w[i])
        acc_e.append(acc_e[i]+1)

#print(acc_w)
#print(acc_e)

ret = 999999
for i in range(n):
    r = acc_w[i] + (acc_e[-1]-acc_e[i+1])
    if r<ret:
        ret = r

print(ret)


Measured memory_bytes: 20300
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, W := sc.nextInt(), sc.nextInt()
	V := int(1e+6)
	w := make([]int, N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		w[i] = sc.nextInt()
		v[i] = sc.nextInt()
	}
	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, V+1)
	}
	dp[0][0] = W + 1
	for i := 1; i <= N; i++ {
		for j := 0; j <= V; j++ {
			if j >= v[i-1] && dp[i-1][j-v[i-1]] >= w[i-1]+1 {
				dp[i][j] = dp[i-1][j-v[i-1]] - w[i-1]
			}
			dp[i][j] = max(dp[i][j], dp[i-1][j])
		}
	}

	for i := V; i >= 0; i-- {
		if dp[N][i] > 0 {
			fmt.Fprintln(wtr, i)
			break
		}
	}
	wtr.Flush()
}


Measured memory_bytes: 808320
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

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

N = getN()
now = 0
ans = 0
S = input()

for st in S:
    if st == "I":
        now += 1
    else:
        now -= 1
    ans = max(ans, now)
print(ans)

Measured memory_bytes: 63980
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int n,k,ans=0;
    cin>>n>>k;
    int x[n];
    for(int i=0;i<n;i++){
        cin>>x[i];
        ans+=min(2*x[i],2*(k-x[i]));
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <bitset>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

using namespace std;
typedef long long ll;

ll dp[60][5200];
constexpr int OFFSET = 2600;

int main()
{
  int N, A;
  cin >> N >> A;
  vector<int> x(N);
  REP(i, N) {
    cin >> x[i];
    x[i] -= A;
  }

  dp[0][OFFSET] = 1;
  REP(i, N) {
    REP(j, 5200) {
      dp[i + 1][j] += dp[i][j];
      if (0 <= j + x[i] && j + x[i] < 5200)
        dp[i + 1][j + x[i]] += dp[i][j];
    }
  }

  cout << dp[N][OFFSET] - 1 << endl;
  return 0;
}

Measured memory_bytes: 2304
#include <cstdio>
#include <iostream>
#include <set>

using namespace std;

int main() {
    string s, s_temp;
    int k;
    cin >> s >> k;
    set<string> se;
    for (int i = 0; i < s.length(); i++) {
        s_temp = "";
        for (int j = i; j < s.length(); j++) {
           s_temp += s[j];
           //cout << s_temp << endl;
           if (s_temp.length() <= 5) se.insert(s_temp);
           else break;
        }
    }
    int i = 0;
    for(auto f: se) {
       i++;
       if (i == k) cout << f << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
s = list(input())
n = int(input())

reverse_flag = False
s_head = list()

for i in range(n):
    line = list(map(str, input().split()))
    if line[0] == '1':
        if reverse_flag:
            reverse_flag = False
        else:
            reverse_flag = True
    elif line[0] == '2':
        if line[1] == '1':
            if reverse_flag:
                s.append(line[2])
            else:
                s_head.append(line[2])
        elif line[1] == '2':
            if reverse_flag:
                s_head.append(line[2])
            else:
                s.append(line[2])

if reverse_flag:
    ans = s[::-1]
    ans.extend(s_head)
    print(''.join(ans))
else:
    ans = s_head[::-1]
    ans.extend(s)
    print(''.join(ans))


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

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))

    sum = 0
    before = 1000
    for i in a:
        sum += b[i - 1]

        if (i - before) == 1:
            sum += c[i - 2]

        before = i

    print(sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n = 0;
    int cookie[1000];
    int x = 0;
    int count = 0;
    cin >> n >> x;
    for (int i = 0; i < n; ++i) {
        cin >> cookie[i];
    }

    for (int j = 0; j < n; ++j) {
        x = x - cookie[j];
        count++;
    }

    sort(cookie,cookie + n);

    while(x >= 0){
        x = x - cookie[0];
        if (x >= 0) {
            count++;
        }
    }

    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>a(3 * n);
	priority_queue<int>pq2;
	priority_queue<int, vector<int>, greater<int>>pq1;
	repp(i, 0, 3 * n) cin >> a[i];
	ll maxv=-INF;
	vector<ll>sum1(2*n, 0), sum2(3*n, 0);
	sum1[0] = a[0]; sum2[0] = a[3 * n - 1];
	repp(i, 1, n){
		sum1[i] =sum1[i-1]+a[i]; sum2[i]=sum2[i-1]+ a[3* n - i-1];
	}
	for (int i = 0; i < n; ++i)pq1.push(a[i]);
	for (int i = 2*n; i < 3 * n; ++i)pq2.push(a[i]);
	for (int i = n; i < 2*n; ++i) {
		pq1.push(a[i]);
		sum1[i] += sum1[i-1]+a[i];
		sum1[i] -= pq1.top(); pq1.pop();
	}
	for (int i = n; i < 2 * n;++i) {
		pq2.push(a[3*n-i-1]);
		sum2[i] += sum2[i-1] + a[3*n-i-1];
		sum2[i] -= pq2.top(); pq2.pop();
	}
	repp(i, n-1, 2 * n)maxv = max(maxv, sum1[i] - sum2[3*n-i-2]);
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 6520
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mo 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
int main()
{
    ll n;cin >> n;
    string x;cin >> x;
    ll c = 0;
    for(ll i=0;i<n;i++)
    {
        if(x[i]=='1') c++;
    }
    //2 cases c+1 or c-1
    ll ml = 0;
    ll mh = 0;
    for(ll i=0;i<n;i++)
    {
        if(x[i]=='1') mh = mh + power(2,n-i-1,c+1);
        mh = mh%(c+1);
    }
    if(c-1>=1)
    {
        for(ll i=0;i<n;i++)
        {
            if(x[i]=='1') ml = ml + power(2,n-i-1,c-1);
            ml = ml%(c-1);
        }
    }
    //cout << ml << mh << endl;
    for(ll i=0;i<n;i++)
    {
        ll rem;
        if(x[i]=='0') 
        {
            rem = mh;
            rem = rem+power(2,n-1-i,c+1);
            rem = rem%(c+1);
            if(rem<0) rem = rem + c+1;
            ll cnt = 1;
            while(rem>0)
            {
                rem = rem % (__builtin_popcountll(rem));
                cnt++;
            }
            cout << cnt << endl;
            continue;
        }
        if(x[i]=='1' && c-1>=1)
        {
            rem = ml;
            rem = rem-power(2,n-1-i,c-1);
            rem = rem%(c-1);
            if(rem<0) rem = rem + c-1;
            ll cnt = 1;
            while(rem>0)
            {
                rem = rem % (__builtin_popcountll(rem));
                cnt++;
            }
            cout << cnt << endl;
            continue;
        }
        if(x[i]=='1' && c==1)
        {
            cout << 0 << endl;
            continue;
        }
    }
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll S,W;
  cin>>S>>W;
  if(S>W) {
cout<<"safe"<<endl;
  }
else {
cout<<"unsafe"<<endl;
}
  
}

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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}
string str;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll n,i,sm = 0;

	cin >> str;
	n = str.size();
	for(i=0;i<n;++i)
		sm += str[i]-'0';
	if(sm%9)
		cout << "No" << "\n";
	else
		cout << "Yes" << "\n";
}

Measured memory_bytes: 3744
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

L = [int(v) for v in input().split()]

if L[1] - L[0] <= L[2]:
    L[2] = L[1] - L[0]

    for v in range(L[0], L[1] + 1):
        print(v)
    exit()

s = set()
for v in range(L[0], L[0] + L[2]):
    s.add(v)
for v in range(L[1] - L[2] + 1, L[1] + 1):
    s.add(v)

for v in sorted(s):
    print(v)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long

int main() {
  int a;
  cin >>a;
  
  cout << (a/2)*(a-a/2) << endl;
}


Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
  
 int main()
 {
   int N;
   cin>>N;
   while(N--)
   {
     int arr[10];
     int left[10],right[10];
     bool flag=true;
     int cnt1,cnt2;
     cnt1=cnt2=0;
     for(int i=0;i<10;i++) cin>>arr[i];
     for(int i=0;i<10;i++)
     {
       if(i==0) left[cnt1++]=arr[i];
       else
       {
         if(cnt2==0)
         {
           if(left[cnt1-1]<arr[i]) left[cnt1++]=arr[i];
           else right[cnt2++]=arr[i]; 
         }
         else
         {
           int left_win=arr[i]-left[cnt1-1];
           int right_win=arr[i]-right[cnt2-1];
           if(arr[i]<min(left[cnt1-1],right[cnt2-1]))
           {
             flag=false;
             break;                                          
           }    
           else if(arr[i]>left[cnt1-1]&&arr[i]<right[cnt2-1]) left[cnt1++]=arr[i];
           else if(arr[i]<left[cnt1-1]&&arr[i]>right[cnt2-1]) right[cnt2++]=arr[i];
           else
           {
             if(right_win>left_win) left[cnt1++]=arr[i];
             else right[cnt2++]=arr[i];    
           }
         }   
       }        
     }
     if(flag) cout<<"YES"<<endl;
     else cout<<"NO"<<endl;
   }
   //while(1);     
   return 0;  
 }
 

Measured memory_bytes: 3104
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    w=list(input())
    l=[0]*26
    alphabets=list(chr(ord('a')+i) for i in range(26))
    for i in w:
        l[alphabets.index(i)]+=1
    ans='Yes'
    for j in l:
        if j%2!=0:
            ans='No'
            break
    print(ans)
resolve()

Measured memory_bytes: 3060
n,k = gets.chomp.split(' ').map(&:to_i)

p = gets.chomp.split(' ').map(&:to_i)
#a = []
a = p.each_with_index.min(k).map{|i| i [1]}

sum = 0
for j in a do
 sum += p[j]
end

puts sum


Measured memory_bytes: 14336
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  long long N;
  long long K;
  cin >> N >> K;
  long long a = 0;
  long long b = 0;
  static long long a_array[1000000];
  long long b_tmp = 0;
  long long result = 0;

    for(int i = 0; i < N; i++)
    {
      cin >> a >> b;
      a_array[a - 1] += b;
    }

    for(long long i = 0; i < 1000000; i++)
    {
      b_tmp += a_array[i];
      if(b_tmp >= K)
      {
        result = i + 1;
        break;
      }
    }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include <cstdio>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int n, m, c;
int b[20];

int main(void) {
	cin >> n >> m >> c;
	for (int i = 0; i < m; i++)
		cin >> b[i];

	int ret = 0;
	for (int i = 0; i < n; i++) {
		int point = c;
		for (int j = 0; j < m; j++) {
			int aj;
			cin >> aj;
			point += aj * b[j];
		}

		if (point > 0)
			ret++;
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;

vector<int> edges[100007];
int dp[100007];

int path(int x){
  if(dp[x]!=-1) return dp[x];
int cost=0;
  for(int i=0;i<edges[x].size();i++){
    cost=max(cost,path(edges[x][i])+1);
  }

dp[x]=cost;
return cost;

}



int main(){
  int n,m,x,y;
  cin>>n>>m;
  for(int j=0;j<n;j++) dp[j]=-1;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    x=x-1;
    y=y-1;
    edges[x].push_back(y);
  }
int cost=0;
  for(int i=0;i<n;i++){
    cost=max(cost,path(i));
  }
  cout<<cost;
  return 0;
}


Measured memory_bytes: 8192
n,q=map(int,input().split())
some=input()
lists=[]
for _ in range(q):
    add=list(map(int,input().split()))
    lists.append(add)

emptylists=[0]

for _ in range(n-1):
    numbers=emptylists[-1]
    if some[_ : _+2]=="AC":
        numbers=1+emptylists[-1]        
        emptylists.append(numbers)
    else:
        emptylists.append(numbers)

for j in range(q):
    print(emptylists[lists[j][1]-1]-emptylists[lists[j][0]-1])

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

ll mod = 1e9+7;

ll modpower(ll a, ll r){ //a^r
    ll x = 1;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a){
    return modpower(a, mod-2);
}

int main(){
    int N;
    cin >> N;
    vector<vector<int>> edge(N+1, vector<int>());
    for (int i = 0; i < N-1; i++) {
        int A, B;
        cin >> A >> B;
        edge[A].push_back(B);
        edge[B].push_back(A);
    }
    vector<int> parent(N+1, 0);
    vector<vector<int>> child(N+1, vector<int>());
    queue<int> q;
    vector<int> ts;
    ts.push_back(1);
    q.push(1);
    while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (int nxt : edge[now]) {
            if (nxt == parent[now]) continue;
            parent[nxt] = now;
            child[now].push_back(nxt);
            q.push(nxt);
            ts.push_back(nxt);
        }
    }
    vector<ll> rs(N+1, 0);
    for (int i = N-1; i >= 0; i--) {
        rs[ts[i]] = 1;
        for (int t : child[ts[i]]) {
            rs[ts[i]] += rs[t];
        }
    }
    vector<ll> pow(N+1, 1);
    for (int i = 1; i <= N; i++) pow[i] = pow[i-1]*2%mod;
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ll t = pow[N-1]-1;
        t += mod-(pow[N-rs[i]]-1);
        for (int c : child[i]) {
            t += mod-(pow[rs[c]]-1);
        }
        ans += t;
        ans %= mod;
    }
    cout << ans*modinv(pow[N])%mod << endl;
    return 0;
}


Measured memory_bytes: 26228
# https://atcoder.jp/contests/agc043/tasks/agc043_a
h, w = map(int, input().split())
matrix = []
for _ in range(h):
    row = list(input())
    matrix.append(row)

dp = [[float('inf')] * w for _ in range(h)]
dp[0][0] = 0
if matrix[0][0] == '#':
    dp[0][0] += 1

for i in range(h):
    for j in range(w):
        if i + 1 < h:
            if matrix[i][j] == matrix[i + 1][j]:
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
            else:
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1)
        if j + 1 < w:
            if matrix[i][j] == matrix[i][j + 1]:
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j])
            else:
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1)

ans = (dp[-1][-1] + 1) // 2
print(ans)

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

const int INF = 1e9+7;

int main() {
	int n;
	cin >> n;
	vector<int> x(n+1);
	for(int i=0; i<n+1; i++){
		x.at(i) = 0;
	}
	for(int i=2; i<n+1; i++){
		int num = i;
		for(int j=2; j<=n; j++){
			while(num%j == 0){
				x.at(j)++;
				num /= j;
			}
		}
	}
	long long ans = 1;
	for(int i=2; i<=n; i++){
		ans *= x.at(i)+1;
		ans %= INF;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b, h; cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N;
	std::cin >> N;
	int min = -1;
	for (int i : boost::irange(0, N))
	{
		int a;
		std::cin >> a;
		if (min > a)
		{
			std::cout << "No" << std::endl;
			return;
		}
		else if (min <= a - 1)
		{
			min = a - 1;
		}
		else
		{
			min = a;
		}
	}
	std::cout << "Yes" << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define   MAX 100000
#define C_MAX 300100

int cmpfunc( const void * n1, const void * n2 ){
    
    int m1 = *(int *)n1;
    int m2 = *(int *)n2;
    
    if (m1 < m2)      return 1;
    else if (m1 > m2) return -1;
    else              return 0;
}

// * main function * //
int main()
{
    int x, y, a, b, c;
    int p[MAX], q[MAX], r[C_MAX];
    
    scanf("%d %d %d %d %d",&x,&y,&a,&b,&c);
    for ( int i=0; i<a; i++ ) scanf("%d",&p[i] );
    for ( int i=0; i<b; i++ ) scanf("%d",&q[i] );
    for ( int i=0; i<c; i++ ) scanf("%d",&r[i] );
    
    qsort( p, a, sizeof(p[0]), cmpfunc );
    qsort( q, b, sizeof(q[0]), cmpfunc );
    
    //printf("sorted p :");
    //for ( int i=0; i<a; i++ ) printf("%d ",p[i] );
    //printf("\nsorted q :");
    //for ( int i=0; i<b; i++ ) printf("%d ",q[i] );
    //printf("\nsorted r :");
    //for ( int i=0; i<c; i++ ) printf("%d ",r[i] );
    //printf("\n");
    
    for ( int i=0; i<x; i++ ) r[c+i] = p[i];
    for ( int i=0; i<y; i++ ) r[c+x+i] = q[i];
    
    qsort( r, x+y+c, sizeof(r[0]), cmpfunc );
    
    //printf("\nsorted pqr :");
    //for ( int i=0; i<c+x+y; i++ ) printf("%d ",r[i] );
    //printf("\n");
    
    long long max = 0ll;
    for ( int i=0; i<x+y; i++ ) max += r[i];
    
    printf("%lld\n",max);
    
}


Measured memory_bytes: 3572
n = gets.chomp.to_i
x = gets.chomp.split(" ").map{|item| item.to_i}
y = gets.chomp.split(" ").map{|item| item.to_i}

dp_1 = 0.0
dp_2 = 0.0
dp_3 = 0.0
dp_inf = 0.0

n.times{ |idx|
    d = (x[idx]-y[idx]).abs
    dp_1+=d.to_f
    dp_2+=d.to_f**2
    dp_3+=d.to_f**3
    if dp_inf < d.to_f
        dp_inf = d.to_f
    end
}
dp_2=dp_2**(1/2.0)
dp_3=dp_3**(1/3.0)

puts dp_1,dp_2,dp_3,dp_inf

Measured memory_bytes: 8872
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int R,G,B,n;
    cin>>R>>G>>B>>n;
    int ans=0;
    for(int r=0;r<=n/R;r++){
        for(int g=0;g<=n/G;g++){
            if((n-r*R-g*G)%B==0&&(n-r*R-g*G)>=0){
                ans++;
                //cout<<"R:"<<r<<",G:"<<g<<",B"<<(n-r*R-g*G)/B<<endl;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class Program {

    static void Main (string[] args) {
        var Stemp = Console.ReadLine ().Split (' ');
        long A = long.Parse (Stemp[0]);
        long B = (long) (Decimal.Parse (Stemp[1]) * 100);

        Console.WriteLine ((long) Math.Floor ((Decimal) (A * B) / 100));
    }

    //1000000007
}
//dotnet run --project test

Measured memory_bytes: 27544
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "KMULT"
#define pll pair<ll, ll>
#define pii pair< ll, pair< ll, ll > >
#define fi first
#define se second

using ll = long long;
using ld = long double;
using ull = unsigned long long;
const ll mod = 998244353;
using namespace std;
const int N = 6e5+5;
ll m, n, k, t, T, ans, u, v, tong;
ll a[N], b[N], st[N*4], lazy[N*4];
string s;
vector<ll> kq;
struct dang
{
    ll l, r, pos;
} p[N];
bool cmp(const dang& X, const dang& Y)
{
    return (X.r < Y.r) || (X.r == Y.r && X.l < Y.l);
}
void sol()
{
    cin >> n;
    pll q;
    for(int i = 1; i <= n; i ++)
    {
        cin >> p[i].l >> p[i].r;
        if(p[i].l > q.fi)
        {
            q.fi = p[i].l;
            q.se = p[i].r;
        }
        else if(p[i].l == q.fi && p[i].r > q.se)q.se = p[i].r;
    }
    sort(p+1, p+1+n, cmp);
    ans = p[1].r - p[1].l + 1;
    for(int i = 1; i <= n; i ++)a[i] = max(a[i-1], p[i].l);
    for(int i = 2; i <= n; i ++)
    {
        if(p[i].r <= q.se)
        {
            ans = max(ans, max((ll)0, p[i].r - q.fi + 1) + max((ll)0, p[1].r - a[i-1] +1 ) );
        }
        if(p[i].l != q.fi || p[i].r != q.se)ans = max(ans, max(p[1].r - q.fi + 1, (ll)0) + p[i].r - p[i].l + 1);
    }
    cout << ans;

}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".INP", "r"))
    {
		freopen(task".INP","r",stdin);
		freopen(task".OUT","w",stdout);
    }
    sol();
    //cout << chap(4, 3);
}


Measured memory_bytes: 6748
import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	a, b, t = read()
	print(int((t+.5)//a)*b)


	





		

if __name__ == "__main__":
	solve()

Measured memory_bytes: 64500
#include<iostream>

int main() {
    int N;
    std::cin >> N;
    if(N%2==0){
        std::cout << N*(N-2)/2 << std::endl;
        for(int i=1;i<N;i++){
            for(int j=i+1;j<=N;j++){
                if(i+j!=N+1){
                    std::cout << i << " " << j << std::endl;
                }
            }
        }
    }
    if(N%2==1){
        std::cout << (N-1)*(N-1)/2 << std::endl;
        for(int i=1;i<N;i++){
            for(int j=i+1;j<=N;j++){
                if(i+j!=N){
                    std::cout << i << " " << j << std::endl;
                }
            }
        }
    }
}

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

int main(){
    string S;
    cin >> S;
    int nch;
    nch = (int) 'z' - 'a' + 1;
    int list[nch]={};
    for(int i=0; i<S.size(); i++){
        int ich;
        ich = (int) S[i] - 'a';
        list[ich] += 1;
        if( list[ich] >= 2 ){
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long LL;
LL fun(LL n, LL m)
{
    if((m / 2) < n) return  m / 2;
    LL ans = n;
    m = m - n * 2;
    ans = ans + m / 4;
    return ans;
}
int main()
{
    LL n, m;
    scanf("%lld%lld", &n, &m);
    LL ans = fun(n, m);
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  bool ans = false;
  for (int i = 0; i < S.size(); ++i) {
    if (S == T) {
      ans = true;
      break;
    }
    S = S.back() + S.substr(0, S.size() - 1);
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int m, n, M = 7368792, t;
  vector<bool> E(M, true);
  while (cin >> m >> n, m) {
    while (n > 0) {
      if (E[m]) {
	--n;
	for (int i = 2; i < (M+m-1)/m; ++i) E[i*m] = false;
      }
      E[m] = true;
      ++m;
    }
    t = m;
    while (!E[m]) ++m;
    cout << m << endl;
    for (int i = t; i < M; ++i) E[i] = true;
  }
  return 0;
}

Measured memory_bytes: 3440
import java.io.*;

class Main{
 public static void main(String[] args) throws Exception{
  int x, ans;
  
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  x = Integer.parseInt(br.readLine());

  ans = x*x*x;
  System.out.println(ans);
 }
}

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

ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
int main(){
  string S; cin >> S;
  
  ll ans = 0;
  for(int i = 0; i < S.size() - 1; i++){
      if(S.at(i) != S.at(i+1)) ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 512
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for k in range(n)]
ans = "No"

for i in range(3):
    for j in range(3):
        if b.count(a[i][j]) != 0:
            a[i][j] = 0

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == 0:
        ans = "Yes"

for j in range(3):
    if a[0][j] == a[1][j] == a[2][j] == 0:
        ans = "Yes"

if a[0][0] == a[1][1] == a[2][2] == 0 or a[0][2] == a[1][1] == a[2][0] == 0:
    ans = "Yes"

print(ans)


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

static const double pi = 3.141592653589793;
int n;
struct coordinate{double x; double y;};

void print(coordinate p) {
    printf("%.8f %.8f\n", p.x, p.y);
    return;
}

void Koch(coordinate p1, coordinate p2, int d) {
    coordinate s, t, u;
    if(d == n) return;
    s.x = (p2.x +  2 * p1.x) / 3.0;
    s.y = (p2.y + 2 * p1.y) / 3.0;
    t.x = (2 * p2.x + p1.x) / 3.0;
    t.y = (2 * p2.y + p1.y) / 3.0;
    u.x = s.x + (t.x - s.x) * cos(pi/3) - (t.y - s.y) * sin(pi/3);
    u.y = s.y + (t.x - s.x) * sin(pi/3) + (t.y - s.y) * cos(pi/3);
    Koch(p1, s, d+1);
    print(s);
    Koch(s, u, d+1);
    print(u);
    Koch(u, t, d+1);
    print(t);
    Koch(t, p2, d+1);
}

int main() {
    cin >> n;
    coordinate p1 = {0.,0.}, p2 = {100., 0.};
    print(p1);
    Koch(p1, p2 ,0);
    print(p2);    
    return 0;
}


Measured memory_bytes: 3160
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 20000000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, m, a[1010][1010], ans[N];
ll k;

int mul(int a, int b){
	return a * 1ll * b % MOD;
}

int add(int a, int b){
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

int minu(int a, int b){
	a -= b;
	if (a < 0) a += MOD;
	return a;
}

int POW(int a, int b){
	int res = 1;
	while (b){
		if (b & 1) res = mul(res, a);
		b >>= 1;
		a = mul(a, a);
	}
	return res;
}

int inv(int a){
	return POW(a, MOD - 2);
}

map<int, int> DP;

int Solve(int len, int x, int y){
//	cout << len << endl;
	if (DP.count(len)) return DP[len];
	if (len == 1) return x + y;
	if (len == 0) return 1;
	int md = (len / 2);
	int R = Solve(len - md, x, y);
	int res = mul(R, POW(x, md));
	int L = Solve(md - 1, x ,y);
	res = add(res, mul(L, POW(y, len - md + 1)));
	DP[len] = res;
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
//	if (k >= 20000000) assert(0);
	ans[0] = 1;
	bool R = 0, C = 0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			char c;
			cin >> c;
			a[i][j] = (c == '#');
		}
	}
	for (int i = 1; i <= n; i++) if (a[i][1] == a[i][m] && a[i][1] == 1) R = 1;
	for (int j = 1; j <= m; j++) if (a[1][j] == a[n][j] && a[1][j] == 1) C = 1;
	if (R & C) return cout << 1, 0;
	if (!(R | C)){
		int cnt = 0;
		for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cnt += a[i][j];
		cout << POW(cnt, k - 1);
		return 0;
	}
	ans[1] = 1;
	int moj = 0, kol = 0, cnt = 0;
	if (R){
		for (int i = 1; i <= n; i++) if (a[i][1] == a[i][m] && a[i][1] == 1) cnt++;
		for (int i = 1; i <= n; i++) for (int j = 1; j < m; j++) if (a[i][j] == 1 && a[i][j + 1] == 1) moj++;
		for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) kol += a[i][j]; 
	}else{
		for (int j = 1; j <= m; j++) if (a[1][j] == a[n][j] && a[1][j] == 1) cnt++;
		for (int i = 1; i < n; i++) for (int j = 1; j <= m; j++) if (a[i][j] == a[i + 1][j] && a[i][j] == 1) moj++;
		for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) kol += a[i][j];
	}
//	cout << POW(4, 2) << '\n';
	if (k == 1 || k == 0) return cout << 1, 0;
	if (k == 2) return cout << kol - moj, 0;
	int ans2 = kol - moj;
	ans2 = mul(ans2, POW(kol, k - 2));
	int res = Solve(k - 2, cnt, kol);
	res = minu(res, POW(kol, k - 2));
	res = mul(moj, res);
	ans2 = minu(ans2, res);
	cout << ans2;






	return 0;
}


Measured memory_bytes: 11548
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	string s;
	cin >> s;
	ll center_len = 0;
	if (s.size() % 2 == 0) {
		while (true) {
			if (center_len >= s.size()) {
				break;
			}
			char c = s[s.size()/2];
			char r = s[s.size()/2 + center_len/2];
			char l = s[s.size()/2 - 1 - center_len/2];
			if (c != r || c != l) {
				break;
			}
			center_len += 2;
		}
	} else {
		center_len = 1;
		while (true) {
			if (center_len >= s.size()) {
				break;
			}
			char c = s[s.size()/2];
			char r = s[s.size()/2 + 1 + center_len/2];
			char l = s[s.size()/2 - 1 - center_len/2];
			if (c != r || c != l) {
				break;
			}
			center_len += 2;
		}
	}
	cout << (s.size() - center_len) / 2 + center_len << endl;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if (a % 2 == 1 && b % 2 == 1 ){
    cout << "Odd" << endl;
  }else{
    cout << "Even" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256