akhauriyash/Code-Regression huggingface dataset:
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let n:usize;
    input!(n);
    let mut v=vec![];
    for _ in 0..n{
        let (a,b):(isize,isize);
        input!(a,b);
        v.push((a+b,a-b));
    }
    v.sort();
    let mut lim=-999999999;
    let mut ans=0;
    for i in 0..n{
        if v[i].1 >= lim{
            ans+=1;
            lim=v[i].0;
        }
    }
    println!("{}",ans);


}


Measured memory_bytes: 6396
import java.io.*;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] word = input.readLine().trim().split("");
        Arrays.sort(word);
        System.out.println(!(word[1].equals(word[2])) && word[0].equals(word[1]) && word[2].equals(word[3]) ? "Yes" : "No");
    }
}


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

#ifdef _DEBUG
#define debug(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL9_MOD = 1000000009LL;
static constexpr ll LL7_MOD = 1000000007LL;
static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll dp[110][100010];

int main(int argc, char* argv[]) {
  INFILE;

  ll n, k;
  cin >> n >> k;

  vector<ll> candies(n);
  scan(candies);

  REP(i, 0, n + 1) {
    REP(j, 0, k + 1) {
      if (j == 0) {
        dp[i][j] = 1;
        continue;
      }

      if (i == 0) {
        dp[i][j] = 0;
        continue;
      }

      int index = j - candies[i - 1] - 1;
      ll v = index < 0 ? 0 : dp[i - 1][index];

      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - v + LL7_MOD) % LL7_MOD;
    }
  }

  cout << dp[n][k] << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[100], n, i, s, j;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		s=0;
		for(j=0;j<n;j++){
			if(i==j){
			}
			else{
				s=s+a[j];
			}
		}
		if(a[i]>=s){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

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

#define llint long long int

using namespace std;

int main(){
    int H, N;

    cin >> H >> N;

    vector<int> A(N);

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

    for(int i = 0; i < N; i ++){
        sum += A[i];
    }
    if(H <= sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

x1, y1, x2, y2 = map(int, input().split())
e1 = (x2 - x1, y2 - y1)
e2 = (-e1[1], e1[0])
x3 = x2 + e2[0]
y3 = y2 + e2[1]
x4 = x1 + e2[0]
y4 = y1 + e2[1]
print(x3, y3, x4, y4)

Measured memory_bytes: 38384
// #include <bits/stdc++.h>
#include <iostream>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

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

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

ll n, k, x, buf;
int main() {
    cin >> n >> k;
    REP(i, n) {
        cin >> buf;
        if (buf == 1)
            x = buf;
    }
    cout<<(x+k-2)/(k-1)+(n-x-1)/(k-1)<<endl;
    return 0;
}


Measured memory_bytes: 764
import itertools
n = int(input())
L = tuple((map(int,input().split())))
M = tuple(map(int,input().split()))
a = 0
b = 0
K = [i for i in range(1,n+1)]
PER = list(itertools.permutations(K))
for i in range(len(PER)):
  if PER[i] == L:
    a = i
  if PER[i] == M:
    b = i
print(abs(a-b))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    string s;
    cin>>s;

    string t="CODEFESTIVAL2016";
    int cnt=0;
    REP(i,s.size()){
        if(s[i]!=t[i])cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
//Created by Vadim Chernetsov.
#include <iostream>
#include <vector>
using namespace std;
const int size=4000;
bool visited[size][size];
int distances[size][size];
vector<int> graph[size];
int number, diameter;
void dfs(int root, int start, int distance)
{
	//commandsBeforeRecursion.
	visited[root][start]=true;
	distances[root][start]=distance;
	for(int next : graph[start])
	{
		if(!visited[root][next])
		{
			dfs(root, next, distance+1);
		}
	}
	//commandsAfterRecursion.
	return;
}
void usingDFS()
{
	int vertex0, vertex1;
	cin>>number>>diameter;
	for(int i=1; i<number; ++i)
	{
		cin>>vertex0>>vertex1;
		graph[vertex0].push_back(vertex1);
		graph[vertex1].push_back(vertex0);
	}
	for(int point=1; point<=number; ++point)
	{
		dfs(point, point, 0);
	}
	if(diameter%2==0)
	{
		int counter, minValue=4000;
		for(int i=1; i<=number; ++i)
		{
			counter=0;
			for(int j=1; j<=number; ++j)
			{
				if(distances[i][j]>diameter/2)
				{
					++counter;
				}
			}
			minValue=min(minValue, counter);
		}
		cout<<minValue<<endl;
	}
	else
	{
		int counter, minValue=4000, temporaryValue;
		for(int i=1; i<=number; ++i)
		{
			for(int j=1; j<=number; ++j)
			{
				if(distances[i][j]==1)
				{
					counter=0;
					for(int k=1; k<=number; ++k)
					{
						temporaryValue=min(distances[k][i], distances[k][j]);
						if(temporaryValue>diameter/2)
						{
							++counter;
						}
					}
					//cout<<counter<<", ";
					minValue=min(minValue, counter);
				}
			}
		}
		cout<<minValue<<endl;
	}
	return;
}
int main()
{
	usingDFS();
	return 0;
}

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

typedef long long ll;

const int mod = (int)1e9 + 7;
const int maxn = 101;
const int maxk = 100001;
int n, k, upper;
int dp[maxk];

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

    cin >> n >> k;
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> upper;
        vector<int> sum(k + 1);
        for (int j = k; j >= 0; --j) { // prev j
            int cur = min(upper, k - j); // cur max
            int tmp = dp[j];
            int l = j + 1;
            int r = j + cur;
            if (cur > 0) {
                sum[l] = (sum[l] + tmp) % mod;
                if (r < k) {
                    sum[r + 1] = (sum[r + 1] - tmp + mod) % mod;
                }
            }
        }
        int psum = 0;
        for (int j = 0; j <= k; ++j) {
            psum = (psum + sum[j]) % mod;
            dp[j] = (dp[j] + psum) % mod;
        }
    }
    cout << dp[k] << endl;

    return 0;
}

Measured memory_bytes: 1024
// gacha
#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[i];
    }
    
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
   
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 9596
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

int main()
{
   int N;
   cin>>N;
   for(int i = 1;i<=9;i++)
   {
       for(int j=1;j<=9;j++)
       {
           if(i*j==N)
           {
               cout<<"Yes"<<endl;
               return 0;
           }
       }
   }
   cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

char a[111][111];
int b[111][111];
int bh[111], bw[111];

int main()
{
  int h, w;
  cin>>h>>w;

  REP(i,h) {
    REP(j,w) {
      cin>>a[i][j];
      b[i][j] = a[i][j] == '.' ? 0 : 1;
    }
  }

  REP(i,h) {
    REP(j,w) {
      bh[i] |= b[i][j];
    }
  }
  REP(j,w) {
    REP(i,h) {
      bw[j] |= b[i][j];
    }
  }

  /*REP(i,h) {
    REP(j,w)
        cout<<(bh[i] & bw[j]);

    cout<<endl;
  }*/

  REP(i,h) {
    REP(j,w) {
      if (bh[i] && bw[j]) {
        cout<<a[i][j];
      }
    }
    if (bh[i])
      cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};


template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

int main(){
    int n,q; cin >> n >> q;
    vector<pair<pair<int,int>,int> > v;
    for(int i = 0; i < n; i++){
        long long s,t,x; cin >> s >> t >> x;
        s -= x; t -= x;
        v.push_back({{s,t},x});
    }
    sort(v.begin(),v.end());

    int id = 0;
    priority_queue<pair<int,int> > w;
    for(int i = 0; i < q; i++){
        long long d; cin >> d;

        //add
        while(id < n && v[id].first.first <= d){
            w.push({-v[id].second, v[id].first.second});
            id++;
        }
        //delete
        while(!w.empty() && w.top().second <= d) w.pop();

        if (w.size()) cout << -w.top().first << endl;
        else cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 7536
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()

	// for N = 100000; N <= 1000000; N += 100000 {

	// 123456
	//1466409
	memo := []int{0, 1166714, 2472071, 3829761, 5221424, 6638407, 8075420, 9529244, 10997400, 12478098, 13969985}
	cnt := memo[N/100000]
	s := N % 100000
	//cnt := 0
	// out(s, N, cnt)
	for i := 1; i <= s; i++ {
		n := N - i
		for j := 1; j*j <= n; j++ {
			if n%j == 0 {
				cnt++
				if n/j != j {
					cnt++
				}
				// out(i, j, n/j)
			}
		}
	}
	out(cnt)
	// }
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc, out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out){
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int res = 0;
		
		for(int i = 1; i <= n; i++) {
			String s = Integer.toString(i);
			
			int j =  0;
			
			for(char c : s.toCharArray()) {
				j+=Integer.parseInt(Character.toString(c));
			}
			
			if(j >= a && j <= b) {
				res+=i;
			}
		}
		out.println(res);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    if(x==3||x==5||x==7){
      cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var input = Console.ReadLine().Split();
            var nums = (string[])input.Clone();
            var nums2 = (string[])nums.Clone();
            
            BubbleSort(ref nums);
            SelectionSort(ref nums2);

            Console.WriteLine(string.Join(" ",Array.ConvertAll(nums,x=>x.ToString())));
            Console.WriteLine(IsStable(Array.AsReadOnly(input), Array.AsReadOnly(nums)) ? "Stable":"Not stable");
            Console.WriteLine(string.Join(" ", Array.ConvertAll(nums2, x => x.ToString())));
            Console.WriteLine(IsStable(Array.AsReadOnly(input), Array.AsReadOnly(nums2)) ? "Stable" : "Not stable");
        }

        private static bool IsStable(System.Collections.ObjectModel.ReadOnlyCollection<string> source, 
                                     System.Collections.ObjectModel.ReadOnlyCollection<string> target)
        {
            for (int i = 0; i < target.Count-1; i++)
            {
                if (target[i][1] == target[i + 1][1])
                {
                    for (int j = 0; j < source.Count; j++)
                    {
                        if (source[j][1] == target[i][1])
                        {
                            if (source[j][0] == target[i + 1][0]) return false;
                            else if (source[j][0] == target[i][0]) break;
                        }
                    }
                }
            }
            return true;
        }


        private static void SelectionSort(ref string[] nums2)
        {
            for (int i = 0; i < nums2.Length; i++)
            {
                var min = i;
                for (int j = i + 1; j < nums2.Length; j++)
                {
                    if (nums2[min][1] > nums2[j][1])
                    {
                        min = j;
                    }
                }
                Swap(ref nums2[min], ref nums2[i]);
            }
        }


        private static void BubbleSort(ref string[] nums)
        {
            for (int i = 0; i < nums.Length - 1; i++)
            {
                for (int j = nums.Length - 1; j > i; j--)
                {
                    if (nums[j - 1][1] > nums[j][1])
                    {
                        Swap(ref nums[j - 1] , ref nums[j]);
                        
                    }
                }
            }
        }

        private static void Swap<T>(ref T p1, ref T p2)
        {
            var temp = p1;
            p1 = p2;
            p2 = temp;
        }
    }
}

Measured memory_bytes: 5364
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    int N; cin >> N;
    int a[N]; rep(i,N) cin >> a[i];
    ll ans = 0;
    for (int i = 1; i < N; ++i) {
        if (a[i-1] > a[i]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }

    out(ans);


    return 0;
}





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

int main() {
	int N,A,B;
	cin >> N >> A;
	cout << (A<=N?10:0);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

}


Measured memory_bytes: 21844
N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

answer = 0
for i in range(1, N+1, 2):
    if len(make_divisors(i)) == 8:
        answer += 1
print(answer)

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

int main() {
int w,n;
cin>>w>>n;
int tate[w+1];
for (int k=0;k<=w;k++){
	tate[k]=k;
}
for (int l=0;l<n;l++){
	int a,b,c;
	char pp;
	cin>>a>>pp>>b;
	c=tate[a];
	tate[a]=tate[b];
	tate[b]=c;
}
for (int ll=1;ll<=w;ll++){
	cout<<tate[ll]<<endl;
}
	return 0;
}

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

using namespace std;

int main(){
  int n;
  while(cin >> n, n){
    int w, h;
    cin >> w;
    cin >> h;

    int area[100][100];
    fill(area[0], area[99], 0);
    int x, y;
    for(int i = 0 ; i < n ; i++){
      cin >> x;
      cin >> y;
      area[x-1][y-1] = 1;
    }

    int s, t, sum = 0, ans = 0;
    cin >> s;
    cin >> t;
    
    for(int i = 0 ; i < (h - t + 1) ; i++){
      for(int j = 0 ; j < (w - s + 1); j++){
	for(int k = 0 ; k < t ; k++){
	  for(int l = 0 ; l < s ; l++){
	    if(area[j + l][i + k] == 1) sum++;
	  }
	}
	ans = max(ans, sum);
	sum=0;
      }
    }
    
    cout << ans << '\n';
  }
}

Measured memory_bytes: 1196
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	a := [][]int{}
	for i := 0; i < n; i++ {
		a = append(a, []int{})
		for j := 0; j < m; j++ {
			var k int
			fmt.Scan(&k)
			a[i] = append(a[i], k)
		}
	}
	b := []int{}
	for i := 0; i < m; i++ {
		var j int
		fmt.Scan(&j)
		b = append(b, j)
	}
	for i := 0; i < n; i++ {
		cnt := 0
		for j := 0; j < m; j++ {
			cnt += a[i][j] * b[j]
		}
		fmt.Println(cnt)
	}
}



Measured memory_bytes: 2000
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
pair<ll,int> p[100005];
int main(){
	ll n,x; cin >> n >> x;
	vector<ll> b(n),l(n),u(n);
	for(int i=0;i<n;i++){
		cin >> b[i] >> l[i] >> u[i];
	}
	ll sum=0;
	for(int i=0;i<n;i++){
		p[i]=pair<ll,int>((x-b[i])*u[i]+b[i]*l[i],i);
		sum-=b[i]*l[i];
	}
	sort(p,p+n);
	ll ret=0;//満点を取る教科を数える
	int last=0;
	for(int i=n-1;i>=0;i--){
		if(sum+p[i].first>=0){
			ret+=(ll)(n-i-1)*(ll)x;//満点を取る教科はn-i-1個である
			last=i+1;
			break;
		}
		sum+=p[i].first;
	}
	ll Min=x;//中途半端に解く科目の得点の最小値
	sum=-sum;
	for(int i=0;i<last;i++){
		int v=p[i].second;
		Min=min(Min,(sum+l[v]-1)/l[v]);//中途半端に解く科目に最小の重みをつけた場合
		ll nsum=sum+b[v]*(u[v]-l[v]);//最大の重みをつける場合には更にディスアドバンテージが広がる
		Min=min(Min,(nsum+u[v]-1)/u[v]);
	}
	//貪欲に見ると満点を取る科目になる科目のうち中途半端に解くものを探索する場合、
	//満点を取る科目としてi=last-1も追加される
	for(int i=last;i<n;i++){
		int v=p[i].second;
		ll nsum=sum+p[i].first-p[last-1].first;
		Min=min(Min,(nsum+l[v]-1)/l[v]);
		ll nsum2=nsum+b[v]*(u[v]-l[v]);
		Min=min(Min,(nsum2+u[v]-1)/u[v]);
	}
	cout << ret+Min << endl;
}

Measured memory_bytes: 4096
#include <iostream>

int main()
{
    using namespace std;
    int32_t K, S;
    cin >> K >> S;
    
    int32_t count = 0;
    
    for (auto X = 0; X <= K; ++X) {
        for (auto Y = 0; Y <= K; ++Y) {
            auto Z = S - X - Y;
            if (0 <= Z && Z <= K) {
                count += 1;
            }
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int H, W;
    int i, j, k;

    while (1)
    {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
            break;

        for (i = 0; i < H; i++)
        {
            for (j = 0; j < W; j++)
            {
                if (((i + j) % 2) == 0)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2612
#include<cstdio>
using namespace std;
int N,K;
long long ans;
long long po(int now){
	long long n=now;
	return n*n*n;
}
int main(){
	scanf("%d%d",&N,&K);
	if(K % 2 == 0)	ans+=po((N/(K/2)+1)/2);
	ans+=po(N/K);
	printf("%lld",ans); 
}

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

using namespace std;

int main ()
{
	int n;
	cin >> n;
	double x[n], y[n], cur, sum = 0;
	for (int i=0; i<n; i++){
		cin >> x[i] >> y[i] ;
	}
	for (int i=0; i<n-1; i++){
		for (int j=i+1; j<n; j++){
			double dx = x[i] - x[j];
			double dy = y[i] - y[j];
			cur = pow(dx * dx + dy * dy, 0.5);
			sum += cur * 2 / n;
		}
	}
	cout << fixed << setprecision(10) << sum << endl;
}

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

int main(){

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

	 long long w,a,b;

	 cin>>w>>a>>b;

	 if(a>b) swap(a,b);

	 if(b-a-w>0) cout<<b-a-w;

	 else cout<<0;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(1000000)

n = int(input())
d = [0] * n
a = []
b = []
connected = [[] for _ in range(n)]
for i in range(n - 1):
    ai, bi = list(map(int, input().split()))
    d[ai-1] += 1
    d[bi-1] += 1
    a.append(ai-1)
    b.append(bi-1)
    connected[ai-1].append(bi-1)
    connected[bi-1].append(ai-1)
# 次数
c = list(map(int, input().split()))
parents = [-1] * n
result = [0] * n
sortedc = sorted(c, reverse=True)

def dfs(current, parent):
    parents[current] = parent
    parent = parents[current]
    for i in connected[current]:
        if i != parent:
            dfs(i, current)

# 深さ+次数優先
def ddfs(current):
    result[current] = sortedc.pop(0)
    nexts = []
    for i in connected[current]:
        if parents[current] != i:
            nexts.append((i, d[i]))
    sortedNexts = sorted(nexts, reverse=True, key=lambda x: x[1])

    for nxt, _ in sortedNexts:
        ddfs(nxt)

def main():

    dandi = []
    for i, di in enumerate(d):
        dandi.append((i, di))
    sortedd = sorted(dandi, reverse=True, key=lambda x: x[1])

    root = sortedd[0][0]
    dfs(root, -1)
    ddfs(root)

    resultSum = 0
    for i in range(n-1):
        resultSum += min(result[a[i]], result[b[i]])
    print(resultSum)
    print(' '.join(map(str, result)))



if __name__ == '__main__':
    main()


Measured memory_bytes: 15060
#include "bits/stdc++.h"
using namespace std;
int x;
int sum;
int ans;
int main(){
    cin >> x;
    sum = 0;
    ans = 0;
    for(int i = 1 ; sum < x ; ++i){
        sum += i;
        ++ans;
    }
    printf("%d\n" , ans);
}

Measured memory_bytes: 384
//#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define em emplace_back
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pii pair<int,int>
#define Rosario ios::sync_with_stdio(0),cin.tie(0);
#define pll pair<ll,ll> 
//#define lb(x) (x&-x)

int n,x,now=1;
int main(){Rosario
    cin>>n;
    REP(i,n){
        cin>>x;
        if(now==x) now++;
    }
    cout<<(now==1?-1:n-now+1)<<"\n";
//    system("pause");
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 200005;
const i64 INF = 1e18;
const int MOD = 323232323;

int a[N];

int main ()
{
    i64 ans = 0;
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
    for (int i = n; i >= 2; --i) {
        if (a[i] == a[i - 1] + 1) {
            ans += 1;
        }
        else if (a[i] <= a[i - 1]) {
            ans += a[i];
        }
        else {
            puts("-1");
            return 0;
        }
    }
    if (a[1]) {
         puts("-1");
         return 0;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    v[0]--;
    for(int i=1;i<n;i++){
        if(v[i-1]<v[i])v[i]--;
    }
    rep(i,n-1){
        if(v[i]>v[i+1]){
            fin("No");
            return 0;
        }
    }
    fin("Yes");
}

Measured memory_bytes: 640
s = input()
t = input()
ans = 0


for ch in t:
    if ch not in s:
        print('-1')
        exit()

x = s
for ch in t:
    p = x.find(ch) + 1
    if p == 0:
        ans += len(x)
        p = s.find(ch) + 1
        x = s
    ans += p
    
    x = x[p:]

print(ans)



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

ll mpow(ll a, ll n) {
    ll r = 1;
    while(n--) {
        r *= a;
    }
    return r;
}

vector<vector<ll>> memo(55, vector<ll>(55, -1));
ll comb(ll n, ll r) {
    if (memo[n][r] == -1) {
        if (n == 1 || n == r) memo[n][r] = 1;
        else if (r == 1) memo[n][r] = n;
        else memo[n][r] = comb(n-1, r-1) + comb(n-1, r);
    }
    return memo[n][r];
}

int main() {
    int N, P; cin >> N >> P;
    ll od = 0, ev = 0;
    int A(N); for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a % 2 == 0) ev++;
        else od++;
    }
    ll ans = 0;
    ll temp = 0;
    for (int i = 0; i * 2 + 1 <= od; i++) {
        temp += comb(od, i*2+1);
    }
    ans = mpow(2, ev) * temp;
    if (P == 1) cout << ans << endl;
    else cout << mpow(2, N) - ans << endl;
}


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

#define fio() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 6;
const ll N = 1e2 + 2;
const ll inf = 1e12;
const ld eps = 1e-6;

ll n, k, arr[maxn], col[maxn];

// if ans > x

void print() {
	for (int i = 0; i < k; i++)
		cout << col[i] << " ";
	cout << endl;	
}

bool solve(ll x) { 
	for (int i = 0; i < k; i++) {
		if (arr[i] > x)
			col[i] = 1;
		else
			col[i] = 0;
	}
//	print();
	for (int i = 1; i < n; i++) {
		if (col[n - i - 1] == col[n - i]) 
			return col[n - i];
		if (col[n + i - 1] == col[n + i - 2]) 
			return col[n + i - 1];
	}
	return col[0];
}

int main() {
	fio();
	cin >> n;
	k = 2 * n - 1;
	for (int i = 0; i < k; i++) 
		cin >> arr[i];	
	ll L = 0, R = k - 1, M;
	while (L < R) {
		//cout << L << " " << R << endl;
		M = (L + R) / 2;
		if (solve(M)) 
			L = M + 1;
		else
			R = M;
	}
	cout << L << endl;
	return 0;
}


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

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
char dc[] = "RDLU";

int main() {
	int g[11][11] = {};
	char c;
	for (int i=1; i<10; ++i) {
		int k = i % 2; // 0=vertical, 1=horizontal
		for (int j=1+k; j<=9-k; j+=2) {
			cin >> c;
			g[i][j] |= c - '0';
			g[i-1+k][j-k] |= c - '0';
			g[i+1-k][j+k] |= c - '0';
		}
	}
	int x=1, y=1, d=0;
	do {
		for (int t=d+3; ; ++t) {
			if (g[y + dy[t%4]][x + dx[t%4]]) {
				d = t%4;
				break;
			}
		}
		x += dx[d] * 2;
		y += dy[d] * 2;
		cout << dc[d];
	} while (x != 1 || y != 1);
	cout << endl;
	return 0;
}

Measured memory_bytes: 1132
#include<stdio.h>
#define mod 1000000007
long long ans=0;
long long a[1005];
long long s[3000][2000]={0};

int main(){
	int n;int i,j;
	a[0]=1;
	for (int i=1;i<=1000;i++)
	  a[i]=a[i-1]*i%mod;
	scanf("%d",&n);
    for (i=3;i<=n;i++){
     s[i][1]=1;
     for (j=2;j<=i/3;j++)
     	for (int k=i-3;k>=0;k--){
     		s[i][j]=(s[i][j]+s[k][j-1])% mod;
     		if (s[k][j-1]==0) break;
		 }
		 }	 
	long long ans=0;	 
    for (i=1;i<=n/3;i++){
    	long long temp=(s[n][i])%mod;
    	ans=(ans+temp)%mod;
	}
	printf("%lld",ans);
}
	 

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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const char c[] = {'M', 'A', 'R', 'C', 'H'};

int n;
int cnt[5];

int main() {    

    scanf("%d\n", &n);

    string s;
    for (int i = 0; i < n; i++) {
        getline(cin, s);
        for (int j = 0; j < 5; j++) 
            if (s[0] == c[j]) {
                cnt[j]++;
            }
    }

    long long ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += 1ll * cnt[i] * cnt[j] * cnt[k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  string up, down;
  cin >> up;
  cin >> down;
  if(up[0] == down[2] && up[1] == down[1] && up [2] == down[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

D, G = inpl()
P = []
C = []
for _ in range(D):
    p, c = inpl()
    P.append(p)
    C.append(c)

ans = 10000

for c in range(2**D):
    score = 0
    solved = 0
    remain = []
    for i, b in enumerate(format(c, "b").zfill(D)):
        if b == "1":
            score += P[i]*100*(i+1) + C[i]
            solved += P[i]
        else:
            remain.append(i)
    if score < G:
        R = G - score
        j = remain[-1]
        if (P[j] - 1)*(j+1)*100 < R:
            continue
        solved += -(-R//(100*(j+1)))
    ans = min(solved, ans)
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a,b;
int main(){ cin>>a>>b; cout<<6-a-b<<endl;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define INF 2147483647
pair<int,int> data[4000001];
int n,_n;
void init(int n){
  _n=1;
  while(_n<1100000)_n*=2;
}
void update(int i,int x){
  int p=i;
  i+=_n-1;
  data[i].f+=x;
  data[i].s=p+1;
  while(i>0){
    i=(i-1)/2;
    if(data[2*i+1].f==data[2*i+2].f){
      if(data[2*i+1].s<data[2*i+2].s)
        data[i]=data[2*i+1];
      else data[i]=data[2*i+2];
    }
    else if(data[2*i+1].f>data[2*i+2].f)
      data[i]=data[2*i+1];
    else data[i]=data[2*i+2];
  }
}
int main(){
  int q;
  cin>>n>>q;
  init(n);
  while(q--){
    int a,b;
    cin>>a>>b;
    update(a-1,b);
    cout<<data[1].second<<' '<<data[1].first<<endl;
  }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

const long long INF=1LL<<61;

int main(){
	int n;
	lint x; scanf("%d%lld",&n,&x);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	vector<lint> cost(n,INF);

	lint ans=INF;
	rep(t,n){
		rep(i,n) cost[i]=min(cost[i],a[(i-t+n)%n]);
		ans=min(ans,t*x+accumulate(cost.begin(),cost.end(),0LL));
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
// #include <string>
// #include <map>
// #include <algorithm>
// #include <set>
// #include <cmath>

using namespace std;
// typedef unsigned long long ull;

void display_base(int n, int b) {
    vector<int> v;
    int n_ = n;
    while(n_ > 0) {
        v.push_back(n_ % b);
        n_ /= b;
    }
    cout << n << "(" << b << ") = ";
    for (int i = v.size()-1; i >= 0; i--) {
        cout << v[i];
    }
    cout << endl;
}

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}

int dfs(int idx, unsigned int visited, const vector<vector<int>>& C) {
    visited |= (1 << idx);

    int N = C.size();
    if (visited == ((1 << N) - 1)) {
        return 1;
    }

    // cout << "idx = " << idx << endl;
    // display_base(visited, 2);

    int ret = 0;
    for (int to : C[idx]) {
        if (!((visited >> to) & 1)) {
            // cout << "to: " << to << endl;
            // ret += dfs(to, visited, C);
            int tmp = dfs(to, visited, C);
            ret += tmp;
            // cout << "to: " << to << "  tmp: " << tmp << endl;
        }
    }
    return ret;
}

int main(int argc, char const *argv[]) {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> C(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        C[a-1].push_back(b-1);
        C[b-1].push_back(a-1);
    }

    // cout << C << endl;

    cout << dfs(0, 0, C) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,count;
  count=1;
  cin>>N;
  vector<int> vec(N);
  for (int i=0;i<N;i++)
    cin>>vec.at(i);
  sort (vec.begin(),vec.end());
  reverse (vec.begin(),vec.end());
  if(N==1)
    cout<<1<<endl;
  else{
    for (int i=0;i<N-1;i++){
      if(vec.at(i)>vec.at(i+1))
        count++;
      else
        continue;
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

ll K;
vector<ll> A;
bool isOK(ll start, ll goal) {
    for(int i = 0; i < K; i++) {
        start -= start % A[i];
    }
    if(start >= goal)
        return true;
    else
        return false;
}

ll binary_search(int key) {
    ll ng = 1;        //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll ok = longinf;  // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;

        if(isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

int main() {
    cin >> K;
    A.resize(K);
    for(int i = 0; i < K; i++) cin >> A[i];
    ll small = binary_search(2), large = binary_search(3);
    if(small >= large)
        cout << -1;
    else
        cout << small << " " << large - 1 << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(void)
{
    int n, i;
    double sum = 0;
    while(1){
        scanf("%d", &n);
        if(n == 0){
            break;
        }
        double m = 0;
        double s[n];
        for(i = 0; i < n; i++){
            scanf("%lf", &s[i]);
        }
        for(i = 0; i < n; i++){
            sum += s[i];
        }
        m = sum / n;
        sum = 0;
        double s2[n];
        for(i = 0; i < n; i++){
            s2[i] = pow((s[i] - m), 2);
            sum += s2[i];
        }
        double a2 = sum / n;
        double a = sqrt(a2);
        sum = 0;

        printf("%f\n", a);
    }
    
    return 0;
}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ods;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

void solve(ll t)
{
    // cout<<"Case #"<<t<<":\n";
    ll r;
    cin>>r;
    ld PI=3.141592653589793;
    ld ans=2*PI*r;
    cout<<fixed<<setprecision(6)<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    ll tt=1;
    while(t--)
    {
        solve(tt);
        tt++;
    }
}     


Measured memory_bytes: 3804
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end());
#define fill(a,x) memset(a,x,sizeof(a))
#define zero(a) fill(a,0)
#define minus(a) fill(a,-1)
#define dbg(x) cout << #x"=" << x << endl

const int INF=INT_MAX/3;
const int LIMIT=100;

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

ll n;
string s;
int ans;

int main(){
    cin>>n;
    cout<<int(sqrt(n))*int(sqrt(n))<<endl;
    return 0;
}

Measured memory_bytes: 256