akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! trace {
    ($x:expr) => {
        #[cfg(debug_assertions)]
        eprintln!(">>> {} = {:?}", stringify!($x), $x)
    };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut ps: Vec<(i64, i64)> = (0..n)
        .map(|_| {
            let x = sc.cin();
            let y = sc.cin();
            (x, y)
        })
        .collect();
    let mut cands = vec![];
    ps.sort_by_key(|&(x, y)| x + y);
    cands.push(ps[0]);
    cands.push(ps[n - 1]);
    ps.sort_by_key(|&(x, y)| x - y);
    cands.push(ps[0]);
    cands.push(ps[n - 1]);

    fn dist(a: &(i64, i64), b: &(i64, i64)) -> i64 {
        (a.0 - b.0).abs() + (a.1 - b.1).abs()
    }

    // trace!(&cands);
    let mut ans = 0;
    for &p in cands.iter() {
        for &q in cands.iter() {
            ans = max!(ans, dist(&p, &q));
        }
    }

    put!(ans);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


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

using namespace std;
typedef long long int ll;

const ll mod = 1e9 + 7;


void solve()
{
	string s;
	cin >> s;
	char c;
	for(int i = 0; i < s.size(); i++) c=  s[i];
	if(c == 's') cout << s + "es" << "\n";
	else cout << s + "s" << "\n";
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
}


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

const int N = 205;
typedef long long LL;

int n, a[N], ans;

int main() {
	cin>>n;
	for(int i = 1; i <= 2*n; i++)
	   cin>>a[i];
	sort(a + 1, a + 2*n + 1);
	for(int i = 1; i <= 2*n - 1; i += 2) 
	    ans += a[i];
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  float a, b;
  int c;
  float d;
  cin >> a >> b;
  d = (a + b) / 2;
  c = d;
  if (c < d) {
    c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int N, M;

int S[2000], T[2000];

ll dp[2001][2001];
ll ruisekiwa[2002][2002];

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++)cin >> S[i];
	for (int i = 0; i < M; i++)cin >> T[i];
	dp[0][0] = 0;
	
	ll ans = 1;

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (S[i - 1] == T[j - 1]) {
				dp[i][j] = 1 + (ruisekiwa[i - 1][j - 1]);
				dp[i][j] %= MOD;
				ans += dp[i][j];
				ans %= MOD;
				
			}
			ruisekiwa[i][j] = (ruisekiwa[i - 1][j] + ruisekiwa[i][j - 1] - ruisekiwa[i - 1][j - 1]
				 + MOD + dp[i][j]) % MOD;
			
		}

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

Measured memory_bytes: 62720
#include<bits/stdc++.h>
using namespace std;
int main()
{
     ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);
     map<int,int> cnt;
     int n,ans=0,a;
     cin>>n;

     for(int i=0;i<n;i++)
     {
         cin>>a;
         cnt[a]++;
     }
     for(auto u : cnt)
     {
         if(u.second>u.first) ans+=u.second-u.first;
          if(u.second<u.first) ans+=u.second;

     }
     cout <<ans<<endl;





}


Measured memory_bytes: 8112
k = int(input())

num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

ans = num_list[k - 1]

print(ans)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
thres = 10**18
res = A[0]
if 0 in A:
    print(0)
    exit()
for i in range(N-1):
    res *= A[i+1]
    if res > thres:
        res = -1
        break
print(res)

Measured memory_bytes: 21576
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

int N,M;
int input[NUM],table[NUM],dp[NUM];


int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i <= N; i++){

		table[i] = 0;
		dp[i] = 0;
	}

	//区間数の計上
	scanf("%d",&input[0]);
	int pre = input[0];

	for(int i = 1; i < M; i++){

		scanf("%d",&input[i]);
		table[(input[i]-pre)-1]++;
		pre = input[i];
	}
	table[N-pre]++;

	dp[N] = table[N];

	//累積和
	for(int i = 1; i <= N; i++){

		table[i] += table[i-1];
	}

	for(int len = N-1; len >= 1; len--){

		dp[len] = dp[len+1] + (table[N]-table[len-1]);
	}

	int Q,count;
	scanf("%d",&Q);

	int L,R,mid,ans;

	for(int loop = 0; loop < Q; loop++){

		scanf("%d",&count);

		count -= input[0]-1; //必ずinput[0]-1回の損失発生

		L = 1,R = N,mid = (L+R)/2,ans = -1;

		while(L <= R){

			if(dp[mid] <= count){

				ans = mid;
				R = mid-1;

			}else{

				L = mid+1;
			}

			mid = (L+R)/2;
		}

		printf("%d\n",ans);
	}

	return 0;
}



Measured memory_bytes: 4372
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, k, s;

int main () {
    fastIO;
    cin >> n >> k >> s;
    while(k --) cout << s << " ", n --;
    while(n --) {
        if(s == 2 || s == 1) cout << "3 ";
        else cout << s - 1 << " ";
    }
}


Measured memory_bytes: 1280
//package abc125.B;

import java.util.Scanner;

public class Main {

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

}


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

typedef long long LL;

typedef vector<pair<LL,LL>>   vect_LL_LL;
typedef vector<pair<int,int>> vect_i_i;

bool compare(pair<int,int> p1, pair<int,int> p2)
{
    if (p1.first != p2.first)
        return p2.first > p1.first;
    else
        return p2.second > p1.second;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, N;
    scanf("%d %d %d", &H, &W, &N);
    int x, y;
    vect_i_i obstacles;

    for (int i=0; i<N; i++)
    {
        scanf("%d %d", &x, &y);
        if (x >= y)
            obstacles.push_back({x, y});
    }
    sort(obstacles.begin(), obstacles.end(), compare);

    int offset = 0;
    for (int i = 0; i < obstacles.size();i++)
    {

        if (obstacles[i].first > obstacles[i].second + offset)
        {
            printf("%d\n", obstacles[i].first - 1);
            return 0;
        }
        else if (obstacles[i].first == obstacles[i].second + offset)
            offset++;
    }
    printf("%d\n", H);
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    string s; cin>>s;
    int ans=0;
    for(int i=0; i<s.size(); i++) s[i]=='+'?ans++:ans--;
    cout << ans << endl;
}

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

#define N 100010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pii pair <int, int>
#define PI 3.1415926535897932384626433832795

using namespace std;

int n, m;
int a, b;
int v[N];
int vis[N];
set <int> S;
vector <int> E[N], IN;

void dfs(int x)
{
	S.insert(v[x]);
	IN.pb(x);
	vis[x] = 1;
	
	for(auto i: E[x])
		if(vis[i] == 0)
			dfs(i);
}

int main()
{
	cin >> n >> m;
	
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	
	while(m--) {
		cin >> a >> b;
		
		E[a].pb(b);
		E[b].pb(a);
	}
	
	for(int i = 1; i <= n; i++)
		if(vis[i] == 0) {
			IN.clear(), S.clear(), dfs(i);
			
			for(auto h: IN)
				if(S.find(h) != S.end())
					v[h] = h, S.erase(h);
		}
	
	int ans = 0;
	for(int i = 1; i <= n; i++)
		if(i == v[i]) ans++;
	
	cout << ans;
}

Measured memory_bytes: 14584
N, A, B = map(int, input().split())
ans = 0

def FindSumOfDigits(x):
    count = 0
    while x>0:
        count += x%10
        x = x//10

    return count

for n in range(1, N+1):
    count = FindSumOfDigits(n)
    if A<= count <=B:
        ans += n

print(ans) 

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

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

  a = n/1000; 
  n %= 1000;
  b = n/100;
  n %= 100;
  c = n/10;
  d = n%10;

  if(a == b && b == c) cout << "Yes" << endl;
  else if(b == c && c == d) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3584
A,B=map(int,input().split())

def oddsolve(a):
    return ((a+1)/2)%2
def solve(a):
    if (a%2==1):
        return oddsolve(a)
    else:
        return int(oddsolve(a+1)) ^ (a+1)
#print(type(oddsolve(A)))
#print(oddsolve(A))
print(int(solve(B)) ^ int(solve(A-1)))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S;
    cin >> S;
    if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;
 
int main() {
  ll Q;
  cin >> Q;
  priority_queue<ll> l;
  priority_queue<ll,vec,greater<ll>> r;
  ll ans=0;
  while(Q--) {
    ll q;
    cin >> q;
    if(q==1) {
      ll a,b;
      cin >> a >> b;
      ans+=b;
      l.push(a);
      r.push(a);
      ll x=l.top();
      l.pop();
      ll y=r.top();
      r.pop();
      if(x>y) {
        ll tmp=x;
        x=y;
        y=tmp;
      }
      ans+=y-x;
      l.push(x);
      r.push(y);
    }
    else {
      cout << l.top() << " " << ans << endl;
    }
  }
}

Measured memory_bytes: 4588
s = input()

n = len(s)

stack = [ s[0] ]

rem = 0
# print(stack)

# 0 search

ss = len(stack)

for i in range(1,n):


    if ss==0 or stack[-1] == s[i]:

        stack.append(s[i])
        ss+=1
        
        continue


    
    stack.pop()
    ss -= 1
    i+=1
    rem +=2


print(rem)

        


Measured memory_bytes: 3956
/*https://atcoder.jp/contests/abc071/tasks/abc071_b*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	string s, alpha = "abcdefghijklmnopqrstuvwxyz";
	cin >> s;
	sort(s.begin(), s.end());
	for (int i = 0; i < 26; i++)
	{
		int flag = 0;
		for (int j = 0; j < s.size(); j++)
			if (s[j] == alpha[i]) flag = 1;
		if (flag == 0)
		{
			cout << alpha[i];
			return 0;
		}
	}
	cout << "None";

}

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

#define int long long

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

signed main()
{
    int i=0, j=0, k=0, ans=0;
    string N;
    cin>>N;
    int n=size(N);

    for(i=0;i<n;i++){
        if(N[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    ll s = 0;
    for(int a = 1; a <= k; a++) {
        for(int b = 1; b <= k; b++) {
            for(int c = 1; c <= k; c++) {
                s += gcd(gcd(a, b), c);
            }
        }
    }
    cout << s << endl;
    return 0;
}


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

using namespace std;
#define INFS (1LL<<28)
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
#define all(n) n.begin(),n.end()

signed main(){
	int a,b;
	cin>>a>>b;
	int d=a+b;
	d/=2;
	if(d*2!=(a+b))cout<<"IMPOSSIBLE"<<endl;
	else cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
// NOT MY CODE
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;

void split(int n, string const & t, unordered_map<string, int> & f) {
    REP (x, 1 << n) {
        string a, b;
        REP (i, n) {
            (x & (1 << i) ? a : b) += t[i];
        }
        f[a + "/" + b] += 1;
    }
}

int main() {
    // input
    int n; cin >> n;
    string s; cin >> s;

    // solve
    string t1 = s.substr(0, n);
    string t2 = s.substr(n);
    reverse(ALL(t2));
    unordered_map<string, int> f, g;
    split(n, t1, f);
    split(n, t2, g);
    ll cnt = 0;
    for (auto const & it : f) {
        if (g.count(it.first)) {
            cnt += (ll)it.second * g[it.first];
        }
    }

    // output
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 68468
s=list(input().split())
x=int(s[0])
a=int(s[1])
b=int(s[2])
ave=(a+b)/2
if ave>x:
  if b>a:
    print('A')
  else:
    print('B')
else:
  if b>a:
    print('B')
  else:
    print('A')

Measured memory_bytes: 38256
#include <iostream>#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main()
{
    
    string s;
    int t=0;
    
    cin >> s;
    
    if(s[0]=='1') t++;
    
    if(s[1]=='1') t++;
    
    if(s[2]=='1') t++;
    
    cout << t << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a, b;
	char op;

	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		int value;
		if (op == '+') value = a + b;
		else if(op == '-') value = a - b;
		else if(op == '*') value = a * b;
		else if(op == '/') value = a / b;
		else break;

		printf("%d\n", value);
	}

    return 0;
}


Measured memory_bytes: 2036
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
ab = [map(int, input().split()) for _ in range(m)]
uf = UnionFind(n)
for a, b in ab:
    a -=1
    b -=1
    uf.union(a, b)

print(uf.group_count()-1)






Measured memory_bytes: 102024
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

int main()
{
    string s;
    int n;
    vector<int> d;
    vector<int> ans;

    cin >> s;

    n = s.size();

    d.resize(n);
    ans.resize(n, 0);

    int cur_d = 0;
    for(int i = 1; i < n; ++i)
    {
        if(s[i] == 'L')
        {
            ++cur_d;
            d[i] = cur_d;
        }
        else
        {
            cur_d = 0;
        }
    }
    
    cur_d = 0;
    for(int i = n - 2; i >= 0; --i)
    {
        if(s[i] == 'R')
        {
            ++cur_d;
            d[i] = cur_d;
        }
        else
        {
            cur_d = 0;
        }
    }

    int p;
    for(int i = 0; i < n; ++i)
    {
        if(s[i] == 'L')
        {
            p = i - d[i];
            p += d[i] % 2;
        }
        else
        {
            p = i + d[i];
            p -= d[i] % 2;
        }

        ++ans[p];
    }

    cout << ans[0];
    for(int i = 1; i < n; ++i)
    {
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007

int main() {
	int n;

	cin >> n;
	int ret = 0;
	REP(i, n) {
		int k;
		scanf("%d", &k);
		ret += k - 1;
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int H;
	int W;
	int iCount;
	int iCount1;
	int iCount2;
	int iPutNum = 0;
	int iH[1000];
	int iW[1000];

	//Hの入力
	scanf("%d", &H);
	//Wの入力
	scanf("%d", &W);

	while (H != 0 || W != 0)
	{

		iH[iPutNum] = H;
		iW[iPutNum] = W;
		//Hの入力
		scanf("%d", &H);
		//Wの入力
		scanf("%d", &W);
		iPutNum++;

	}

	//長方形を書く部分
	for (iCount = 0; iCount < iPutNum; iCount++)
	{
		//縦のループ
		for (iCount1 = 0; iCount1 < iH[iCount]; iCount1++)
		{
			//フレーム部分
			if (iCount1 == 0 || iCount1 == iH[iCount]-1)
			{

				//横のループ
				for (iCount2 = 0; iCount2 < iW[iCount]; iCount2++)
				{
					printf("#");
				}
				printf("\n");
			}
			//フレームの中身
			else
			{
				//横のループ
				for (iCount2 = 0; iCount2 < iW[iCount]; iCount2++)
				{
					if (iCount2 == 0 || iCount2 == iW[iCount] - 1)
					{
						printf("#");
					}
					else
					{
						printf(".");
					}
					
				}
				printf("\n");
			}
			
		}
		printf("\n");
	}

}


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

int editDistance(string a,string b){
  int n=a.size();
  int m=b.size();
  vector< vector< int > > dp;
  dp.resize(n+1);

  for(int i=n;i>=0;i--){
    dp[i].resize(m+1);
    
    for(int j=m;j>=0;j--){
      if(i==n){
        dp[i][j]=m-j;
      }else if(j==m){
        dp[i][j]=n-i;
      }else{
        dp[i][j]=1e9;
        if(a[i]==b[j])dp[i][j]=dp[i+1][j+1];
        else dp[i][j]=min(dp[i+1][j+1],min(dp[i][j+1],dp[i+1][j]))+1;
      }
    }
  }
  return dp[0][0];
}


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

Measured memory_bytes: 7016
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    swap(A, B);
    auto ans = make_v<ll>(0, H, W);
    for(ll i = 0; i < H - A; i++) for(ll j = 0; j < W - B; j++) ans[i][j] = 1;
    for(ll i = H - A; i < H; i++) for(ll j = W - B; j < W; j++) ans[i][j] = 1;
    for(auto &&v : ans) {
        for(ll e : v) cout << e;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 9088
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


int main()
{

	int A, B, C;
	int maxnum = max(max(A, B), C);
	cin >> A >> B >> C;
	vector<int> v{ A,B,C };
	sort(v.begin(), v.end());
	
	int remainder = v[2] - v[1] + v[2] - v[0];
	if (remainder % 2 == 0)
		cout << remainder / 2;
	else
		cout << remainder / 2 + 2;


	return 0;
}

Measured memory_bytes: 256
main = do
  [_,t] <- map read . words <$> getLine :: IO [Int]
  ts <- map read . words <$> getLine :: IO [Int] 
  print $ solve ts t

solve :: [Int] -> Int -> Int
solve [_] t = t
solve (x:y:xs) t
  | (y-x) >= t = t + solve (y:xs) t
  | otherwise = (y-x) + solve (y:xs) t

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

using namespace std;

int main()
{
    long n, k;
    cin >> n >> k;
    long x;
    long res = 1000000000000000001;
    long t = n % k;
    long mmm = min(n % k, k - (n%k));
    cout << mmm << endl;
    return 0;
    if (n % k == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    // if ( n % k )

    x = n;
    while(true)
    {
        x = abs(x - k);
        // cout << x << endl;
        if (x >= res) break;
        res = x;
        
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

const int MAX_N = 100000005;
int n;
int a[MAX_N];

ll check(ll sum, ll ans){
    // cout << "---- " << sum << endl;
    for(int i=1; i<n; i++){
        ll t = sum + a[i];
        if((sum>=0 && t<0) || (sum<0 && t>=0)){
            sum = t;
            if(sum == 0){
                sum = 1;
                ans++;
            }
            continue;
        }

        ll at;
        if(sum >= 0) at = -1 - sum;
        else at = 1 - sum;

        // cout << i << " " << a[i] << " " << at << endl;

        ans  = ans + abs(a[i] - at);

        sum = sum + at;
    }
    // cout << ans << endl;
    return ans;
}

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

    ll ta, s;
    ta = a[0];
    s = 0;
    if(ta == 0){
        ta = 1;
        s = 1;
    }

    ll another;
    if(a[0] >= 0)another = -1;
    else another = 1;

    ll a1 = check(ta, s);
    ll a2 = check(another, abs(a[0]-another));

    ll ans = min(a1, a2);

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  if (N==25){
    cout<<"Christmas";
  }
  else if (N==24){
    cout<<"Christmas Eve";
  }
  else if (N==23){
    cout<<"Christmas Eve Eve";
  }
  else{
    cout<<"Christmas Eve Eve Eve";
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    ll n, m;
    cin >> n >> m;
    vl l(m), r(m);
    for (int i = 0; i < m; ++i) {
        cin >> l[i] >> r[i];
    }
    ll mi = 1;
    ll ma = n;
    for (int i = 0; i < m; ++i) {
        chmax(mi, l[i]);
        chmin(ma, r[i]);
    }
    cout << max(0LL, ma - mi + 1) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
    int a,b,d,r;
    double f;

    scanf("%d %d",&a,&b);

    d = a / b;
    r = a % b;
    f = 1.0*a / b;

    printf("%d %d %f\n",d,r,f);

    return 0;
}

Measured memory_bytes: 636
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      continue
    cnt = 0
    for n in range(8):
      ni = i + dx[n]
      nj = j + dy[n]
      if ni < 0 or H <= ni or nj < 0 or W <= nj:
        continue
      if S[ni][nj] == '#':
        cnt += 1
    S[i][j] = str(cnt)


    
for i in range(H):
    print("".join(S[i]))

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int d=sc.nextInt();
			int ans=0;
			for(int i=1;i<600/d;i++){
				ans+=d*d*d*i*i;
			}
			System.out.println(ans);
		}
		sc.close();
	}
}

Measured memory_bytes: 17192
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
const int N = 1e5+7;

int main(){
    int n;
    scanf("%d", &n);
    int cnt = (1<<n), tp;
    vector<int> p;
    for(int i = 0 ; i < cnt ; i++){
        scanf("%d", &tp);
        p.push_back(tp);
        //printf("%d ", p[i]);
    }
    //puts("");
    sort(p.begin(), p.end());
    queue<int> q;
    vector<int>::iterator it = p.end();
    --it;
    q.push(*it);
    it = p.erase(it);
    while( !p.empty() ){
        int&& ct = q.size();
        while( ct-- ){
            int u = q.front();q.pop();
            it = lower_bound(p.begin(), p.end(), u);
            if( it != p.begin() ){
                --it;
            }else{
                return 0*puts("No");
            }
            q.push(u);
            q.push(*it);
            it = p.erase(it);
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 2420
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<usize>();
    let b = read::<usize>();
    println!("{}", if a <= 8 && b <= 8 { "Yay!" } else { ":(" });
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
    mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
    mint operator+(const mint a) const {mint res(*this); return res+=a;}
    mint operator-(const mint a) const {mint res(*this); return res-=a;}
    mint operator*(const mint a) const {mint res(*this); return res*=a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

const int cmax = 2000010;
mint fac[cmax],finv[cmax],inv[cmax];

void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<cmax; i++) {
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

mint com(int n, int k) {
    if (n<k) return 0;
    if (n<0||k<0) return 0;
    mint ret=fac[n]*finv[k]*finv[n-k];
    return ret;
}

mint path(int r, int c) {
	return com(r + c + 2, c + 1) - 1;
}

int main() {
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	mint ans = 0;
	com_init();
	ans = path(r2, c2) - path(r1 - 1, c2) - path(r2, c1 - 1) + path(r1 - 1, c1 - 1);
	cout << ans.x << endl;
}


Measured memory_bytes: 47104
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, a, ans = 0;
	cin >> num;
	vector<int> d(num);
	rep(i, num)
		cin >> d[i];
	rep(i, num) {
		cin >> a;
		if (d[i] > a)
			ans += d[i] - a;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3560
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int M=sc.nextInt();	//数字の種類
		int N=sc.nextInt();	//部分和にしたい数
		int[] A=new int[N];	//数字
		int[] C=new int[N];	//数字の個数
		int[] dp=new int[M+1];
		if(N==1) {
			System.out.println(M);
			System.exit(0);
		}
		int max=0;
		//boolean[] kousin=new boolean[M+1];		//値の更新を無限回行わないようにすでに更新を行ったか？のフラグ
		Arrays.fill(dp, -1); 	//dpを0で埋めると0枚で払えると混同する（工夫すれば0フィルでも行けそうだけど）
		for(int i=0; i<N; i++) {
			A[i]=sc.nextInt();
			max=Math.max(max,A[i] );
		}
		for(int i=0; i<N; i++) {
			if(A[i]==1) {
				C[i]=max;
			}
			else {
				C[i]=(M+A[i]-1)/A[i];
			}
		}
		if(M%max==0) {
			System.out.println(M/max);
			System.exit(0);
		}
		dp[0]=0;	//いつもの
		for(int i=0; i<N; i++) {
			for(int j=M; j>=0; j--) {		//すでにお金の払い方として成立する場合で、払う枚数の最小を更新する時に、更新した値で更に更新しないように高い値から処理していく
				if(dp[j]>=0) {
					int roop=Math.min(C[i],(M-j)/A[i]);
					for(int k=roop; k>=0; k--) {	//使用限度を守っていてなおかつ求めたい額よりも少ない
						if(dp[j+k*A[i]]==-1) {	//いままでのお金だと払えなかった時
							dp[j+k*A[i]]=dp[j]+k;
						}
						else if(dp[j+k*A[i]]>=0) {	//より少ない枚数でお金をちょうど出せるか？
							dp[j+k*A[i]]=Math.min(dp[j+k*A[i]], dp[j]+k);
							//kousin[j+k*A[i]]=true;	//すでにお金の払い方として成立するので更新には入らない
						}
					}
				}
			}
		}
		/*int cnt=0;
		for(int i=1; i<=M; i++) {
			if(dp[i]>=0) {
				//System.out.println(i+" "+dp[i]);
				cnt++;
			}
		}*/
		System.out.println(dp[M]);
	}
}


Measured memory_bytes: 27756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	string s,t;
	cin >> s >> t;
	vector<char> sv(s.length());
	vector<char> tv(t.length());
	for (int i = 0; i < (int)s.length(); ++i) {
		sv[i] = s[i];
	}
	for (int i = 0; i < (int)t.length(); ++i) {
		tv[i] = t[i];
	}
	sort(sv.begin(),sv.end());
	sort(tv.begin(),tv.end());

	for (int i = 0; i < (int)s.length(); ++i) {
		s[i] = sv[i];
	}
	for (int i = 0; i < (int)t.length(); ++i) {
		t[i] = tv[t.length()-i-1];
	}

	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
    deque<pair<int,int>>two;
    vector<vector<bool>>edge(n,vector<bool>(n,true));
    if(n%2==0){
        rep(i,n/2){
            two.push_back(make_pair(i,n-i-1));
            edge[i][n-i-1]=edge[n-i-1][i]=false;
            //cout<<i<<" "<<n-i-1<<endl;
        }
    }else{
        rep(i,n/2){
            two.push_back(make_pair(i,n-i-2));
            edge[i][n-i-2]=edge[n-i-2][i]=false;
            //cout<<i<<" "<<n-i-2<<endl;
        }
    }
    deque<pair<int,int>>ans;
    
    rep(i,n)rep(j,n){
        if(edge[i][j]&&i!=j){
            
            ans.push_back(make_pair(i+1,j+1));
            edge[i][j]=edge[j][i]=false;
        }
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size()){
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    }
}

Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().rstrip().split()]
max = 0
count = 0
node = H[0]
for i in H[1:len(H)]:
    #print(i)
    if node >= i:
        count += 1
        node = i
    else:
        if count > max:
            max = count
        count = 0
        node = i
        
if count > max:
    max = count

print(max)

Measured memory_bytes: 14252
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (b > a + w) {
			pr.println(b - (a + w));
		} else if (b + w < a) {
			pr.println(a - (b + w));
		} else {
			pr.println(0);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23764
//08, 09, 2018, 09:33:13 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    ll x;

    cin >> n >> x;
    ll g = 0;

    for(int i = 0 ; i < n ; i++){
        ll a;

        cin >> a;

        g = __gcd(g, abs(x - a));
    }

    cout << g << endl;
    
    return 0;
}

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

#define itn long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define debug(x) cout << #x << "=" << (x) << endl;
const ll MOD=1e9+7;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
  int N;
  cin>>N;
  int st=0;
  rep(i,N){
    string s;
    cin>>s;
    if(s=="A")
      st++;
    else st--;
    if(st<0)fail("NO");
  }
  if(st)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
int n;
int a[220000];
// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
int n;
vector<T> d;
BIT(int n=0):n(n),d(n+1) {}
void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
    d[i] += x;
    }
}
T sum(int i) { //[0,i]のsum
    T x = 0;
    for (i++; i; i -= i&-i) {
    x += d[i];
    }
    return x;
}
T sum(int l, int r) { // [l,r)のsum
    return sum(r-1) - sum(l-1);
}
};
signed main(){
    int n,k;cin >>n >>k;
    
    rep(i,n)cin >> a[i+1];
    rep(i,n)a[i+1] += a[i];
    vector<P> res;
    rep(i,n+1){
        res.emplace_back(a[i] - i*k,i);
    }
    sort(res.begin(),res.end());
    BIT<int> bit(n+1);
    int ans = 0;
    rep(i,n+1){
        auto hoge = res[i];
        int ind = hoge.second;
        ans += bit.sum(ind);
        bit.add(ind,1);

    }
    cout <<ans << endl;



    return 0;
}

Measured memory_bytes: 7920
#include <iostream>
#include <fstream>
#define Nmax 100005

using namespace std;

ifstream f("1.in");

int n, a[Nmax];
long long dp[Nmax][3];// dp[i][0]-suma maxima pana la poz i, ultimul termen fiind neschimbat
                // dp[i][1]-suma maxima pana la poz i, ultimul termen fiind schimbat

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];

    dp[1][0]=a[1];
    dp[1][1]=-a[1];

    for (int i = 2; i <= n; i++)
    {
        dp[i][0]=max(dp[i-1][0]+a[i], dp[i-1][1]-a[i]);
        dp[i][1]=max(dp[i-1][1]+a[i], dp[i-1][0]-a[i]);
    }
    cout << dp[n][0];

    return 0;
}


Measured memory_bytes: 2944
N,K = map(int,input().split())
A = list(map(int,input().split()))

L = [0]*N

for i in range(N) :
    a = A[i]
    for j in range(N) :
        b = A[j]
        if a > b :
            if i > j :
                L[i] += ((K-1)*K)//2
                L[i] %= 10**9+7
            else :
                L[i] += ((K+1)*K)//2
                L[i] %= 10**9+7
ans = sum(L)%(10**9+7)
print(ans)



Measured memory_bytes: 3188
#include <iostream>
#include <math.h>
#include <cstdio>
#include <iomanip>

int main(){
    int n;
    std::cin >> n;
    int x[n],y[n];
    for(int i=0;i<n;++i){
        std::cin >> x[i] >> y[i];
    }
    long double sum=0;
    
    for(int i=0;i<n-1;++i){
        for(int j=i+1;j<n;++j){
            sum+=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
        }
    }
    long double ans=sum*2/n;
    
    std::cout << std::fixed << std::setprecision(10) << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int N,M;


int main(int argc, char const *argv[]) {
  cin >> N >> M ;

  int answer[M];
  for (int i = 0; i < M; i++){
    answer[i] = 0;
  }
  int k;
  cin >> k;
  //the first person
  for (int i = 0; i < k; i++){
    int a;
    cin >> a;
    answer[a-1] = 1;
  }

  if ( N == 1){
    int ans = 0;
    for (int i = 0; i < M; i++){
      if (answer[i] == 1) ans++;

    }
    cout << ans << endl;
  }

  else{
  for (int i = 1; i < N; i++){
    int K;
    cin >> K;
    int array[M];
    for (int j = 0; j < K; j++){
      int a;
      cin >> a;
      array[a-1] = 1;
    }
    for (int num=0; num < M; num++){
      if (answer[num] == 1 && array[num] != 1){
        answer[num] = 0;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < M; i++){
    if (answer[i] == 1) ans++;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
	unsigned long int N, count = 0;
	vector <long int> V, C;
	
	cin >> N;
	V.resize(N);
	C.resize(N);
	
	for(int i = 0 ; i < N ; i++){
	    cin >> V[i];
	}
	for(int i = 0 ; i < N ; i++){
	    cin >> C[i];
	    if(V[i] - C[i] > 0){
	        count += (V[i] - C[i]);
	    }
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

string s;
int dp[100010][4];

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    dp[0][0]=1;
    rep(i,s.size()){
        rep(j,4){
            if(s.at(i)=='?')dp[i+1][j]=(dp[i+1][j]+dp[i][j]*3)%mod;
            else dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
        }
        if(s.at(i)=='A' or s.at(i)=='?')dp[i+1][1]=(dp[i+1][1]+dp[i][0])%mod;
        if(s.at(i)=='B' or s.at(i)=='?')dp[i+1][2]=(dp[i+1][2]+dp[i][1])%mod;
        if(s.at(i)=='C' or s.at(i)=='?')dp[i+1][3]=(dp[i+1][3]+dp[i][2])%mod;
    }
    cout<<dp[s.size()][3]<<endl;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    char c; cin >> c;
    c++;
    cout << c;
}

Measured memory_bytes: 256
n = int(input())
a = input().split()
a = [int(i) for i in a]

def f2(a):
    for i in a:
        if i % 2==0:
            if (i % 3!=0) and (i % 5 != 0):
                print("DENIED")
                return
    print("APPROVED")
    return
f2(a)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 2e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

vector <vector <int> > adj(MAXN);
int n;
vector <int> in(MAXN), out(MAXN), vec;

void dfs(int i, int p = -1){
  vec.pb(i);
  in[i] = vec.size()-1;
  for(auto j:adj[i])
    if(j!=p) dfs(j,i);
  out[i] = vec.size()-1;
}



int main(){
  fio();
  int q; cin>>n>>q;
  for(int i=0;i<n-1;i++){
    int u,v; cin>>u>>v;
    adj[u].pb(v);
    adj[v].pb(u);
    } 
  dfs(1);
  vector <LL> an(n+5);
  while(q--){
    LL u,x; cin>>u>>x;
    an[in[u]]+=x;
    an[out[u]+1]-=x;
  }
  for1(i,n)
    an[i]+=an[i-1];
  for1(i,n) 
    cout<<an[in[i]]<<" ";
  cout<<endl;
  return 0;
}



Measured memory_bytes: 26744
import math
K = int(input())
if K == 7 or K == 1:
  print(1)
elif math.gcd(K,10) != 1:
  print(-1)
else:
  if K % 7 == 0:
    K //= 7
  cnt = 1
  res = 10
  while True:
    cnt += 1
    res *= 10
    res %= (9 * K)
    if res == 1:
      break
  print(cnt)

Measured memory_bytes: 63316
#include<bits/stdc++.h>
using namespace std;
void f(int n,int m)
{
    for(int i=0;i<=2000;i++){
        for(int j=0;j+i<=2000&&j+i<=n;j++){
            if(i*10000+j*5000+(n-i-j)*1000==m){
                cout<<i<<' '<<j<<' '<<n-i-j<<endl;
                return;
            }
        }
    }
    cout<<-1<<' '<<-1<<' '<<-1<<endl;
}
int main()
{
    int x,y;
    cin>>x>>y;
    f(x,y);
    return 0;
}

Measured memory_bytes: 256