akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

x, y, z = Is()
print("{} {} {}".format(z, x, y))


Measured memory_bytes: 65388
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(System.in);

    int x = scanner.nextInt();
    int y = scanner.nextInt();

    final int[] A = new int[] {1,3,5,7,8,10,12};
    final int[] B = new int[] {4,6,9,11};
    final int[] C = new int[] {2};
    final int[][] ARRAYS = new int[][] {A, B, C};

    for(int[] array : ARRAYS) {
      if(Arrays.binarySearch(array, x) >= 0) {
        if(Arrays.binarySearch(array, y) >= 0) {
          System.out.println("Yes");
          scanner.close();
          System.exit(0);
        } else {
          System.out.println("No");
          scanner.close();
          System.exit(0);
        }
      }
    }
    System.out.println("No");

    scanner.close();
  }
}


Measured memory_bytes: 21844
# (A ~ B までの個数) - (Cで割り切れるもの + Dで割り切れるもの - CDの最小公倍数で割り切れるもの)
A,B,C,D = list(map(int, input().split()))

def euc(a, b):
    a, b = [max(a, b), min(a, b)]
    if b == 0:
        return a
    else:
        return euc(b, a % b)

Cdiv = (B // C) - ((A-1) // C)
Ddiv = (B // D) - ((A-1) // D)
E = (C * D) // euc(C, D)
CDdiv = (B // E) - ((A-1) // E)

print((B - A + 1) - (Cdiv + Ddiv - CDdiv))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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




int main(){
    int n, k; cin >> n;
    string s; cin >> s >> k;
    char c = s[k-1];
    REP(i, n)
        if(s[i] != c) s[i] = '*';
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=0;i<10;i++)
	{
		c*=a;
		c-=b;
		cout<<c<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
s = input()
t = input()
n = len(t)
sl = len(s)
mmax= 0
for i in range(sl):
    cnt=0
    for y in range(n):
        #print(s[i+y],t[y])
        if i+y>=sl:
            cnt=0
            break
        if s[i+y]==t[y]:
            cnt+=1
    mmax = max(mmax,cnt)
print(n-mmax)


Measured memory_bytes: 9084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;

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



Measured memory_bytes: 256
/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll mod=1e16;
const ll MAXN=100200;
ll i,j,mask,test;
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
ll n,k;
cin>>n>>k;
ll p=1;
while(n--)
{
    p=min(p*2,p+k);
}
cout<<p;
return 0;
}


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

int main(){
    string s;
    cin >> s;
    vector<char> ans;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='0'||s[i]=='1'){
            ans.push_back(s[i]);
        }else if(s[i]=='B'){
            if(!ans.empty()){
                ans.pop_back();
            }
        }
    }
    for(auto it=ans.begin(); it!=ans.end(); ++it){
        cout << *it;
    }
    cout << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i = 0; i < N; i++){
    cin >> s.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> t(M);
  for(int i = 0; i < M; i++){
    cin >> t.at(i);
  }
  
  vector<int> ans(N);
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(s.at(i) == s.at(j)){
        ans.at(i)++;
      }
    }
    for(int j = 0; j < M; j++){
      if(s.at(i) == t.at(j)){
        ans.at(i)--;
      }
    }
  }
  
  sort(ans.begin(), ans.end());
  
  if(ans.at(N - 1) < 0){
    cout << 0 << endl;
  }
  
  else{
    cout << ans.at(N - 1) << endl;
  }
  
}

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

int main()
{
    int N, M;
    vector<int> start;
    vector<int> goal;

    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        if (x == 1)
        {
            start.push_back(y);
        }
        else if (y == N)
        {
            goal.push_back(x);
        }
    }
    sort(start.begin(), start.end());
    sort(goal.begin(), goal.end());

    for (int i = 0; i < start.size(); i++)
    {
        if (binary_search(goal.begin(), goal.end(), start[i]))
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 1276
A,B,C,D = map(int,input().split())
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
E = C * D // gcd(C,D)

dif = B - A + 1
rc = B//C + (-A//C) + 1
rd = B//D + (-A//D) + 1
re = B//E + (-A//E) + 1
x = dif - rc - rd + re
print(x)

Measured memory_bytes: 3060
W,H,N = map(int,input().split())
li = [[0]*W for i in range(H)]

for i in range(N):
    X,Y,a = map(int,input().split())
    if a == 1:
        for i in range(H):
            for j in range(X):
                li[i][j] = 1
    elif a == 2:
        for i in range(H):
            for j in range(X,W):
                li[i][j] = 1
    elif a == 3:
        for i in range(Y):
            li[i] = [1]*W
    else:
        for i in range(Y,H):
            li[i] = [1]*W

counter = 0
for i in range(H):
    counter += li[i].count(0)

print(counter)            


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

int main(){
  int N,A[100],key,j;
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
    for(int i=1;i<=N;i++){
      for(int l=0;l<N;l++){
        if(l!=N-1)cout<<A[l]<<" ";
        else cout<<A[l]<<endl;
      }
      key=A[i];
      j=i-1;
      while(j>=0 && A[j]>key){
        A[j+1]=A[j];
        j--;
      }
      A[j+1]=key;
    }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

constexpr lnt MOD = 1e9+7;
struct mint
{
	lnt v;
	mint():v(0){}
	mint(lnt v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(lnt k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(lnt n, lnt k) { if(n-k<k) k=n-k; mint num(1), dom(1); for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; } return num/dom; }
	static std::vector<mint> construct_comb(int n) {
		std::vector<mint> c(n+1); mint a = 1; c[0] = a; for(int i=1;i<=n;i++) { a = a*mint(n+1-i)/i; c[i] = a; } return c;
	}
	static std::vector<mint> construct_fact(int n) { std::vector<mint> f(n+1,1); for(int i=2;i<=n;i++) f[i]=f[i-1]*i; return f; }
};
std::istream& operator>>(std::istream&i,mint&a){ lnt t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


int main() {
	lnt k;
	std::string s;
	std::cin >> k >> s;
	lnt n=s.size()+k;
	lnt N=26;
	mint base=mint(N).pow(n)-mint(N-1).pow(n);
	lnt m=s.size();
	auto nC=mint::construct_comb(n);
	for(int i=1;i<m;i++) {
		base-=nC[i]*mint(N-1).pow(n-i);
	}
	print(base);
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int R = input(), C = input(), K = input();
    auto vs = make_vector(R + 1, C + 1, i64(0));
    range(i, 0, K) {
        i64 r = input(), c = input(), v = input();
        vs[r][c] = v;
    }

    auto dp = make_vector(C + 1, 4, i64(0));
    range(i, 1, R + 1) {
        range(j, 1, C + 1) {
            chmax(dp[j][1], dp[j][0] + vs[i][j]);
        }

        range(j, 1, C + 1) {
            range(cnt, 0, 4) {
                if (cnt) chmax(dp[j][cnt], dp[j - 1][cnt - 1] + vs[i][j]);
                chmax(dp[j][cnt], dp[j - 1][cnt]);
            }
        }

        auto ndp = make_vector(C + 1, 4, i64(0));
        range(j, 1, C + 1) range(cnt, 0, 4) {
            chmax(ndp[j][0], dp[j][cnt]);
        }

        dp = ndp;
    }

    i64 ans = 0;
    range(cnt, 0, 4) chmax(ans, dp[C][cnt]);
    
    cout << ans << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 74344
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::cmp::{max, min, Ordering};

struct Input {
    data: Vec<String>,
}

impl Input {
    pub fn new() -> Input {
        Input{data: Vec::new()}
    }

    fn read(&mut self) {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        self.data = line.split_whitespace().rev().map(|s| s.parse::<String>().unwrap()).collect::<Vec<_>>();
    }

    pub fn pop(&mut self) -> String {
        if self.data.len() == 0 {
            self.read();
        }
        return self.data.pop().unwrap();
    }
}

impl<T: core::str::FromStr> std::ops::Shr<&mut T> for Input {
    type Output = Input;

    fn shr(mut self, rhs: &mut T) -> Input {
        *rhs = self.pop().parse::<T>().ok().unwrap();
        return self;
    }
}

fn main() {
    let mut cin = Input::new();

    let (mut N, mut M) = (0, 0);
    cin = cin >> &mut N >> &mut M;

    let mut A = vec![0; M];

    for i in 0..M {
        cin = cin >> &mut A[i];
    }
    let mut S = 0;
    for a in A {
        S += a;
    }

    let ans = max(-1, N - S);
    println!("{}", ans);
}


Measured memory_bytes: 2604
import java.io.*;
public class Main {

    public static void main(String[] args)throws IOException{
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader bf = new BufferedReader(is);

        String str=bf.readLine();
        str=str.replaceAll("apple","?????????");
        str=str.replaceAll("peach","??¢?????????");
        str=str.replaceAll("?????????","peach");
        str=str.replaceAll("??¢?????????","apple");
        System.out.println(str);
    }
}

Measured memory_bytes: 16912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author k16069kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException{
        
        int a = 0; 
        int b = 0;
        String op = null;
        int answer = 0;
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while((line = br.readLine()) != null){
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()){
                a = Integer.parseInt(st.nextToken());
                op = st.nextToken();
                b = Integer.parseInt(st.nextToken());
            }
            switch (op) {
                case "+":
                    answer = a + b;
                    break;
                case "-":
                    answer = a - b;
                    break;
                case "*":
                    answer = a * b;
                    break;
                case "/":
                    answer = a / b;
                    break;
            }
            if(op.equals("?")) break;
            System.out.println(answer);
        }
    }
}



Measured memory_bytes: 24428
#include<bits/stdc++.h>
#define SIZE 200005
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
struct BIT
{
	int bit[SIZE];
	
	void init()
	{
		memset(bit,0,sizeof(bit));
	}
	void add(int k,int x)
	{
		k++;
		while(k<SIZE)
		{
			bit[k]+=x;
			k+=k&-k;
		}
	}
	int get(int k)
	{
		k++;
		int ret=0;
		while(k>0)
		{
			ret+=bit[k];
			k-=k&-k;
		}
		return ret;
	}
	int get(int s,int t)
	{
		return get(t)-get(s-1);
	}
	int pos(int k)//k 番目
	{
		int l=0,r=SIZE;
		while(r-l>1)
		{
			int m=(l+r)/2;
			if(get(m)<k) l=m;
			else r=m;
		}
		return r;
	}
};
BIT bit;
ll sum[SIZE];
 
int main()
{
	int n;
	ll K;
	scanf("%d %lld",&n,&K);
	int sz=0;
	sum[sz++]=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&sum[sz]);
		sum[sz]-=K;
		sum[sz]+=sum[sz-1];
		sz++;
	}
	vector <ll> vx;
	for(int i=0;i<sz;i++) vx.push_back(sum[i]);
	sort(vx.begin(),vx.end());
	vx.erase(unique(vx.begin(),vx.end()),vx.end());
	ll ret=0;
	for(int i=0;i<sz;i++)
	{
		int pos=lower_bound(vx.begin(),vx.end(),sum[i])-vx.begin();
		ret+=bit.get(pos);
		bit.add(pos,1);
	}
	printf("%lld\n",ret);
	return 0;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    cin >> N;
    cout << N*(N+1)/2 << endl;
    return 0;
}



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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    ll h, n;
    ll sum=0;
    cin >> h >> n;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        sum+=x;
    }
    if(sum>=h) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] and p[i] < p[i + 1]:
        ans = ans + 1
    if p[i - 1] > p[i] and p[i] > p[i + 1]:
        ans = ans + 1
print(ans)

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

void solve(long long N, std::vector<long long> B){
    ll ans = B[0] + B[N-2];
    for(int i = 0; i < N-2; ++i) ans += min(B[i], B[i+1]);
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> B(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(B));
    return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int max = 0, mid = 0, min = 0;
    if(a > b && a > c) {
        max = a;
        if(b > c) {
            mid = b;
            min = c;
        } else {
            mid = c;
            min = b;
        }
    }else if(b > a && b > c){
        max = b;
        if(a > c){
            mid = a;
            min = c;
        }else{
            mid = c;
            min = a;
        }
    }else if(c > a && c > b) {
        max = c;
        if(a > b) {
            mid = a;
            min = b;
        } else {
            mid = b;
            min = a;
        }
    }else{
        max = a;
        mid = b;
        min = c;
    }
    cout << max*10+mid+min << 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;

int main() {
    set<int> st;
    rep(i, 3) {
        int a; cin >> a;
        st.insert(a);
    }
    cout << (st.size() == 2 ? "Yes" : "No") << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define rev(r) reverse(r.begin(),r.end())
#define SORT(ar) sort(ar.begin(), ar.end())
#define sz(x) (int)(x).size()
#define len(x) (int)x.length()
#define in(a) scanf("%d",&a)
#define pr(x) printf("%d ",x)
#define endl '\n'
#define read(v,n) for(int h=0;h<n;h++) cin>>v[h];
#define fo(i,a,b) for(i=a;i<b;i++)
#define fi(i,a,b) for(i=a;i>=b;i--)
#define mo 1000000007
#define N 300007
ll dp[101][100001];

int main()
{
    ll n,k,i,j;
    cin>>n>>k;
    ll a[n+1];
    fo(i,1,n+1) cin>>a[i];
    dp[0][0]=1;
    fo(i,1,n+1)
    {
        fo(j,0,k+1)
        {
            dp[i][j]=(dp[i][max(0ll,j-1)]+dp[i-1][j])%mo;
            if(j>a[i]) dp[i][j]=(dp[i][j]-dp[i-1][j-a[i]-1])%mo;
            dp[i][j]=(dp[i][j]+mo)%mo;
        }
    }
    cout<<dp[n][k]<<endl;
}


Measured memory_bytes: 78336
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {
	int n, m;
	cin >> n >> m;
	if (m<n*2)cout << m/2 << endl;
	else cout << n + (m - n * 2) / 4 << endl;
	ll
}

Measured memory_bytes: 256
N,K = map(int,input().split())
li = list(map(int,input().split()))
rim = min(N,K)
mans = 0
for A in range(rim+1):
    for B in range(rim-A+1):
        ansl = sorted(li[:A]+ li[N-B:])
        ans = sum(ansl)
        if ansl ==[]:continue
        #負の宝石を入れ直す
        for i in range(min(K-A-B,len(ansl))):
            if min(ansl) < 0 :
                ans -= min(ansl)
                ansl.remove(min(ansl))
            else:
                break;
        if ans > mans:
            mans = ans
print(mans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
char str[N];
int main(){
    scanf("%s",str+1);
    int len=strlen(str+1);

    bool flag=true;
    for(int i=2;i<=len;i++){
        if(str[i]==str[i-1]){
            printf("%d %d\n",i-1,i);
            flag=false;
            break;
        }
        else if(i>2&&str[i]==str[i-2]){
            printf("%d %d\n",i-2,i);
            flag=false;
            break;
        }
    }
    if(flag)
        printf("-1 -1\n");

    return 0;
}

Measured memory_bytes: 384
import sys


def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    DP = [[None, None] for _ in range(N)]
    DP[0][0] = -A[0]
    DP[0][1] = -10 ** 20
    for i in range(1, N):
        DP[i][0] = DP[i-1][0] - A[i]
        DP[i][1] = max(DP[i-1][1] + A[i], DP[i-1][0] + A[i])
    print(DP[N-1][1])
    flip = N
    for i in reversed(range(1, N)):
        if DP[i][1] - DP[i-1][1] != A[i]:
            flip = i
            break
    else: flip = 1
    sumA = A[0]
    for i in range(flip, N-1):
        print(sumA, A[i])
        sumA -= A[i]
    print(A[N-1], sumA)
    sumA = A[N-1] - sumA
    for i in range(1, flip):
        print(sumA, A[i])
        sumA -= A[i]

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 28340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  ll N, A, B;
  cin >> N >> A >> B;
  ll d, m, ans;
  d = N / (A + B);
  m = N % (A + B);
  ans = A * d;
  if (m > A)
    ans += A;
  else
    ans += m;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
typedef pair<P,vector<P> >P2;
bool used[51][51];
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
string s[51];
int a[51][51][3],x,y;
int cx,cy,c,h,w,Q,ans;
int main(){
  vector<int>V[3000];
  cin>>h>>w>>Q;
  r(i,h)cin>>s[i];
  r(k,3)r(i,h)r(j,w)cin>>a[i][j][k];
  cin>>cy>>cx;
  V[cy*51+cx].push_back(0);
  r(i,Q-1){
    cin>>y>>x;
    queue<P2>q;
    vector<P>v,ans;
    v.push_back(P(cx,cy));
    memset(used,0,sizeof(used));
    used[cy][cx]=1;
    q.push(P2(P(cx,cy),v));
    while(!q.empty()){
      P2 pt=q.front();q.pop();
      int ax=pt.first.first;
      int ay=pt.first.second;
      if(ax==x&&ay==y)ans=pt.second;
      r(j,4){
        int yy=ay+dy[j];
        int xx=ax+dx[j];
        if(yy<0||xx<0||yy>=h||xx>=w)continue;
        if(s[yy][xx]=='#')continue;
        if(used[yy][xx])continue;
        vector<P>v2=pt.second;
        v2.push_back(P(xx,yy));
        used[yy][xx]=1;
        q.push(P2(P(xx,yy),v2));
      }
    }
    cx=x;
    cy=y;
    r(j,ans.size()-1){
      V[ans[j+1].second*51+ans[j+1].first].push_back(++c);
    }
  }
  r(i,51)r(j,51){
    r(k,(int)V[i*51+j].size()-1){
      int x1=V[i*51+j][k];
      int x2=V[i*51+j][k+1];
      ans+=min(a[i][j][1]+a[i][j][2],(x2-x1)*a[i][j][0]);
    }
    if(V[i*51+j].size())ans+=a[i][j][1]+a[i][j][2];
  }
  cout<<ans<<endl;
}

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

vector<int> dp;

int q(int x) {
	if (dp[x]) return dp[x];
	cout << x << endl;
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	if (s == "Male") return dp[x] = -1;
	return dp[x] = 1;
}

bool f(int s, int t) {
	int o = (s - t) & 1;
	if (o) return q(s) == q(t);
	return q(s) != q(t);
}

int main() {
	int N;cin >> N;
	dp.resize(N);
	vector<int> v(2*N);
	for (int i = 0; i < N; i++) v[i] = v[i+N] = i;
	int s = 0, t = N / 2;
	if (!f(s, t)) swap(s, t);
	for (;;) {
		if (s > t) {
			int m = v[(s+t+N)/2];
			if (f(s, m)) t = m;
			else s = m;
		} else {
			int m = (s+t)/2;
			if (f(s, m)) t = m;
			else s = m;
		}
	}
}

Measured memory_bytes: 2004
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] x = new int[n];
        int[] y = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        double sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j) {
                    double length = Math.sqrt(Math.pow(x[i] - x[j], 2) + Math.pow(y[i] - y[j], 2));
                    sum += length;
                }
            }
        }

        double result = sum / n;

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <iomanip>
#include <iterator>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <numeric>
#include <bitset>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>

using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define FORi(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FOR(i,n) FORi(i,1,n)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;
using pii=pair<int, int>;
using pdd=pair<double, double>;
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
    os<<'[';
    for(auto& p: c) os << p << " ";
    return os<<']';
}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
    print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}


template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
    os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
    print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
    print_tuple<0,Args...>(os<<'(',t);
    return os<<')';
}


constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;
constexpr int maxw=31;
constexpr int maxn=1001;

ll n, m, k;
bool solve() {
	if(k %n == 0 || k %m == 0) return true;
	rep(i, n+1) rep(j, m+1) {
		if((i*m + j*n - i*j*2) == k) return true;
	}
	return false;
}

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

	while(cin>>n>>m>>k) {
		cout << (solve()? "Yes":"No") << endl;
	}
	return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

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


int main() {
  int n;cin>>n;
  map<string,int> s;
  rep(i,n){
    string ss;cin>>ss;
    s[ss]=1;
  }
  cout<<s.size();
}



Measured memory_bytes: 19120
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int inputN = scanner.nextInt();
		int inputD = scanner.nextInt();
		int inputX = scanner.nextInt();
		int[] inputAs = new int[inputN];
		for (int i = 0; i < inputN; i++) {
			inputAs[i] = scanner.nextInt();
		}
		scanner.close();

		int eatNum = 0;
		for (int inputA : inputAs) {
			int eatDay = 1;
			while (eatDay <= inputD) {
				eatNum++;
				eatDay += inputA;
			}
		}
		System.out.println(eatNum + inputX);

	}
}


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

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

    int n;cin >> n;
    ll t; cin >> t;
    ll ary[n+1];
    rep(i,n) cin >> ary[i];
    ary[n] = INF;

    ll ans = 0;
    rep(i,n)
    {
        if (ary[i+1]-ary[i]>=t)
        {
            ans += t;
        }
        else
        {
            ans += ary[i+1] - ary[i];
        }
    }
    cout << ans << endl;

}




Measured memory_bytes: 1792
import sys 
N = int(input())
 
t = []
cordinate = []
 
#　リストtに時間の情報、二次元配列のcordinateにx,y座標を入れる
for i in range(N):
    time,x,y = map(int, input().split())
    t.append(time)
    cordinate.append([x,y])
 
# 初期の時間と初期座標
time = 0
x,y = 0,0
 
 
for i in range(len(t)):
    
    # 移動先への移動にかけて良い時間
    time = abs(time - t[i])
    
    #移動先のx,y座標
    objx = cordinate[i][0]
    objy = cordinate[i][1]
    
 
    
    #移動できる時間より距離が長い場合はアウト
    if time < abs((objx - x) + (objy - y)):
        print("No")
        sys.exit()
    
    #偶奇の判定
    if (abs((objx - x) + (objy - y)))%2 != time % 2:
        print("No")
        sys.exit()
 
    x,y = objx,objy
    time = t[i]
 
print("Yes")

Measured memory_bytes: 20400
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 510;
const int mod = 1e9+7;
void nextcordinate(int x,int y,int &x1,int &y1,int n,int m){
	if(x&1){
		if(y==m){
			x1=x+1;
			y1=y;
		}
		else{
			x1=x;
			y1=y+1;
		}
	}
	else{
		if(y==1){
			x1=x+1;
			y1=y;
		}
		else{
			x1=x;
			y1=y-1;
		}
	}
}
int arr[upperlimit][upperlimit];
int answer[1000000][4];
int main() {
	int n,m,x1,y1;
	sd(n);sd(m);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			sd(arr[i][j]);
		}
	}
	int cnt=0;
	int i=1,j=1;
	int endc;
	if(n&1) endc=m;
	else endc=1;
	while((i!=n)||(j!=endc)){
		nextcordinate(i,j,x1,y1,n,m);
		if(arr[i][j]&1){
			arr[i][j]--;
			arr[x1][y1]++;
			cnt++;
			answer[cnt][0]=i;
			answer[cnt][1]=j;
			answer[cnt][2]=x1;
			answer[cnt][3]=y1;
		}
		i=x1;j=y1;
	}
	pdn(cnt);
	for(int i = 1; i <= cnt; i++){
		pds(answer[i][0]);pds(answer[i][1]);pds(answer[i][2]);pdn(answer[i][3]);
	}
	return 0;
}

Measured memory_bytes: 6400
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            pq.add(a);
        }
        Map<Integer, Long> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            if (map.containsKey(c)) {
                map.put(c, map.get(c) + b);
            } else {
                map.put(c, (long) b);
            }
        }

        // 主処理
        List<Integer> keySet = new ArrayList<>(map.keySet());
        Collections.sort(keySet, Collections.reverseOrder());
        for (int key : keySet) {
            long b = map.get(key);
            int c = key;
            for (long j = 0; j < b; j++) {
                int a = pq.peek();
                if (a < c) {
                    pq.poll();
                    pq.add(c);
                } else {
                    break;
                }
            }
        }
        sc.close();

        long result = pq.stream().mapToLong(i -> i).sum();

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 71820
#include <iostream>

int main()
{
    int a, b, c, d;
    std::cin >> a >> b >> c;

    if ( a < b && b < c) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;

}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef map<string,int>M;
int main(void)
{
	string s,t;
	string ss,tt;
	int nn,mm,cnt;
	int i;
	int lMAX,sMAX;
	M mp;
	getline(cin,s);
	s+=' ';
	for(i=0;i<(int)s.size();i++){
		//cout<<s[i]<<endl;
		if(s[i]==' '){
			//cout<<t<<endl;
			mp[t]++;
			t="";
		}
		else	t+=s[i];
	}
	lMAX=sMAX=-1;
	for(auto it=mp.begin();it!=mp.end();it++){
		//cout<<it->first<<" "<<it->second<<endl;
		s=it->first;
		cnt=it->second;
		if(sMAX<cnt){
			sMAX=cnt;
			ss=s;
		}
		if(lMAX<(int)s.size()){
			lMAX=(int)s.size();
			tt=s;
		}
	}
	cout<<ss<<" "<<tt<<endl; 
	return 0;
}
		
		


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

using P = pair<int,int>;

bool solve(){
    int n;
    cin >> n;
    if(n == 0) return false;
    set<P> points;
    for(int i=0;i<n;i++){
        int x, y;
        cin >> x >> y;
        points.insert(P(x,y));
    }
    int ans = 0;
    for(auto p : points){
        for(auto q : points){
            if(p==q) continue;
            int px = p.first, py = p.second;
            int qx = q.first, qy = q.second;
            int dx = qx-px, dy = qy-py;
            int rx = px-dy, ry = py+dx;
            int sx = rx+dx, sy = ry+dy;
            if(points.count(P(rx,ry)) && points.count(P(sx,sy))){
                ans = max(ans, dx*dx+dy*dy);
            }
        }
    }
    cout << ans << endl;
    return true;
}

int main(){
    while(solve());
    return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

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


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

int main(){
    int x,y;
    
    while(1){
        cin >> x >> y;
        if(x==0 && y==0)break;
        if(y>x) cout << x <<" "<< y <<endl;
        else cout << y <<" "<< x <<endl;
        
    }
    return 0;
}


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

#define pb push_back
#define debug(args...) fprintf(stderr,args)
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define REP(i,a,b) for(int i = a; i >= b; --i)

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

const int maxn = 1e5 + 10;

int n;
vector<int>g[maxn];
int grundy[maxn];

void dfs(int v, int par){
	for(auto u: g[v])
		if(u != par){
			dfs(u,v);
			grundy[v] ^= (grundy[u]+1);
		}
}

int main(){
	scanf("%d",&n);
	FOR(i,1,n-1){
		int a, b;
		scanf("%d%d",&a,&b);
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(1,-1);
	if(grundy[1]) printf("Alice\n");
	else printf("Bob\n");
	return 0;
}

Measured memory_bytes: 12288
from collections import deque

def bfs(i):
    q = deque()
    q.append(i)
    dist = [0] * n
    dist[i] = 1
    maxdist = 1
    while q:
        p = q.popleft()
        for j in G[p]:
            if dist[j] == 0:
                dist[j] = dist[p] + 1
                maxdist = max(maxdist, dist[j])
                q.append(j)
            elif dist[p] == dist[j]:
                return
    global ans
    ans = max(ans, maxdist)
    return

n = int(input())
s = [list(input()) for _ in range(n)]
G = [[] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if s[i][j] == "1":
            G[i].append(j)
ans = -1
for i in range(n):
    bfs(i)
print(ans)

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

int main(void)
{
    long long a, b, c, d;
    long long ans;
    cin >> a >> b >> c >> d;

    if (b > 0 && d > 0)
    {
        ans = max(b * d, a * c);
    }
    else if (b <= 0 && d <= 0)
    {
        ans = a * c;
    }
    else if (b > 0 && d <= 0)
    {
        if (a >= 0)
            ans = a * d;
        else
            ans = a * c;
    }
    else if (b <= 0 && d > 0)
    {
        if (c >= 0)
            ans = c * b;
        else
            ans = c * a;
    }

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

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	int *A = new int[N];
	int *B = new int[N];
	int *C = new int[N];

	for (int i = 0; i < N; i++)
		cin >> A[i];

  	B[0] = A[0];
	for (int i = 1; i < N; i++) {
     	if (B[i - 1] < A[i])
        	B[i] = A[i];
      	else
          	B[i] = B[i - 1];
    }
   	
  	C[N - 1] = A[N - 1];
  	for (int i = N - 2; i >= 0; i--) {
     	if (C[i + 1] < A[i])
        	C[i] = A[i];
      	else
          	C[i] = C[i + 1];
    }

	for (int i = 0; i < N; i++) {
      	int tmp = 0;
      	if (i == 0)
          	tmp = C[i + 1];
      	else if (i == N - 1)
          	tmp = B[i - 1];
      	else
          	tmp = max(B[i - 1], C[i + 1]);
		cout << tmp << endl;
	}
  
  	delete A;
  	delete B;
  	delete C;

	return 0;
}

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

using namespace std;

bool found[200005];
vector<int> positions[200005];

int main()
{
    int N;
    cin >> N;
    for(int i=0; i<N; i++)
    {
        int x;
        cin >> x;
        positions[x].push_back(i);
        found[x] = true;
    }
    if(!found[1])
    {
        cout << -1;
        return 0;
    }
    int ans = N-1, pos = positions[1][0];
    for(int i=2; i<=N; i++)
    {
        if(!found[i])
        {
            break;
        }
        int temp = positions[i].size();
        while(temp > 0 && positions[i][temp-1] > pos)
        {
            temp--;
        }
        if(temp == positions[i].size())
        {
            break;
        }
        else
        {
            ans--;
            pos = positions[i][temp];
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 11392
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <string>
#include <stdio.h>

#define max(a,b) a > b ? a : b
#define min(a,b) a < b ? a : b

using namespace std;

const int N_max = 200;
int main()
{
    int N, M;

    cin >> N >> M;

    int num;
    if (N == 0)
    {
        num = M * (M - 1) / 2;
    }
    else if (M == 0)
    {
        num = N * (N - 1) / 2;
    }
    else
    {
        num = N * (N - 1) / 2 + M * (M - 1) / 2;
    }

    cout << num << endl;
}

Measured memory_bytes: 256