akhauriyash/Code-Regression huggingface dataset:
import java.lang.Math

val ord = mutableListOf<Pair<Int, Int>>()
val tree = mutableMapOf<Int, MutableMap<Int, Int>>()

fun main(args: Array<String>)
{
    val n = readLine()!!.toInt()

    for (i in 1 until n) {
        val (a, b) = readLine()!!.split(" ").map{ it.toInt() }
        ord.add(Pair<Int, Int>(a, b))

        if (!tree.containsKey(a)) {
            tree.put(a, mutableMapOf(b to -1))
        } else {
            tree[a]!!.put(b, -1)
        }
        if (!tree.containsKey(b)) {
            tree.put(b, mutableMapOf(a to -1))
        } else {
            tree[b]!!.put(a, -1)
        }
    }

    // println("find max color")

    var colorNum = 0
    for (key in tree.keys) {
        colorNum = Math.max(tree[key]!!.count(), colorNum)
    }

    // coloring(ord[0].first, -1, -1)
    coloring(ord[0].first, -1)

    println(colorNum)
    for (i in 0 until n-1) {
        println(tree[ord[i].first]!![ord[i].second])
    }
}

// fun coloring(current: Int, parent: Int, previousColor: Int){
//     var col = 1
//     for (key in tree[current]!!.keys) {
//         if (key == parent) continue
//         if (col == previousColor) col++

//         tree[current]!![key] = col
//         tree[key]!![current] = col
//         coloring(key, current, col)
//         col++
//     }
// }

fun coloring(parent: Int, previousColor: Int) {
    val children = tree[parent]
    var col = 1
    for (key in children!!.keys) {
        if (children[key] == -1) {
            // println("coloring from $parent to $key")
            if (col == previousColor) col++

            children[key] = col
            tree[key]!![parent] = col

            coloring(key, col)
            col++
        }
    }
}


Measured memory_bytes: 124840
#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();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}

vector<pair<char, int>> run_length_compress(string S)
{
    vector<pair<char, int>> res;
    int n = S.size(), cnt = 1;
    for (int i = 0; i < n - 1; i++)
    {
        if (S[i] == S[i + 1])
        {
            cnt++;
        }
        else
        {
            res.push_back({S[i], cnt});
            cnt = 1;
        }
    }
    res.push_back({S.back(), cnt});
    return res;
}
int main()
{
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--;
    B--;
    C--;
    D--;
    string S;
    cin >> S;
    for (int i = A; i + 1 < max(C, D); i++)
    {
        if (S[i] == S[i + 1] and S[i] == '#')
        {
            cout << "No";
            return 0;
        }
    }
    if (C < D)
    {
        cout << "Yes";
        return 0;
    }
    else
    {
        for (int i = B; i <= D; i++)
        {
            if (S[i - 1] == S[i] and S[i - 1] == S[i + 1] and S[i] == '.')
            {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}



int main() {
  string S;
  cin>>S;
  int K=input();
  bool ss=true;
  string x;
  for(int i=0;i<K;i++){
    if(S.at(i)!='1'){
      ss=false;
      x=S.at(i);
      break;
    }

  }
  if(ss){
    cout<<1<<endl;
  }else{
    cout<<x<<endl;
  }

  



  
  
  

  


}


Measured memory_bytes: 256
import sys
count = [0 for _ in range(ord("a"), ord("z") + 1)]
for line in sys.stdin:
    for c in list(line.lower()):
        if "a" <= c <= "z":
            count[ord(c) - ord("a")] += 1
for i, n in enumerate(count):
    print("{ch} : {cnt}".format(ch = chr(ord("a") + i), cnt = n))




Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
long long n,m,dp[302][302][302],ans,mod=1000000007;
vector<pair<long long,long long> > lim[302];
//vector<pair<long long,pair<long long,long long> > > v;
bool check(int x,int y,int z){
	int i,k=max(x,max(y,z));
	for (i=0;i<lim[k].size();i++){
		if ((x>=lim[k][i].first)+(y>=lim[k][i].first)+(z>=lim[k][i].first)!=lim[k][i].second) return 0;
	}
	return 1;
}
/*long long dfs(int x,int y,int z){
	if (dp[x][y][z]!=-1) return dp[x][y][z];
	if (!check(x,y,z)) return dp[x][y][z]=0;
	if (max(x,max(y,z))==0) return dp[x][y][z]=1;
	int i;
	dp[x][y][z]=0;
	if (max(x,max(y,z))==x) for (i=0;i<x;i++)if (i==0||(i!=y&&i!=z))(dp[x][y][z]+=dfs(i,y,z))%=mod;
	if (max(x,max(y,z))==y) for (i=0;i<y;i++)if (i==0||(i!=x&&i!=z))(dp[x][y][z]+=dfs(x,i,z))%=mod;
	if (max(x,max(y,z))==z) for (i=0;i<z;i++)if (i==0||(i!=y&&i!=z))(dp[x][y][z]+=dfs(x,y,i))%=mod;
	return dp[x][y][z];
}*/
/*bool cmp(pair<long long,pair<long long,long long> > x,pair<long long,pair<long long,long long> > y){
	return max(x.first,max(x.second.first,x.second.second))<max(y.first,max(y.second.first,y.second.second));
}*/
int main(){
	int i,j,k;
	cin>>n>>m; 
	for (i=1;i<=m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		lim[y].push_back(make_pair(x,z));
	}
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	for (i=0;i<=n;i++){
		for (j=0;j<=n;j++)if (i==0||j==0||i!=j){
			for (k=0;k<=n;k++)if ((i==0||k==0||i!=k)&&(j==0||k==0||j!=k)){
				if (check(i,j,k)){
					int x,y,z;
					x=i;y=j;z=k;
					int kk=max(x,max(y,z));
					(dp[kk+1][y][z]+=dp[x][y][z])%=mod;
					(dp[x][kk+1][z]+=dp[x][y][z])%=mod;
					(dp[x][y][kk+1]+=dp[x][y][z])%=mod;
					if (max(x,max(y,z))==n) (ans+=dp[x][y][z])%=mod;
				}
			}
		}
	}
	/*return -1;
	sort(v.begin(),v.end(),cmp);*/
	/*for (i=0;i<=n;i++){
		for (j=0;j<=n;j++)if (i==0||j==0||i!=j){
			for (k=0;k<=n;k++)if ((i==0||k==0||i!=k)&&(j==0||k==0||j!=k)){
				if (!check(i,j,k)) dp[i][j][k]=0;
				cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<endl;
			}
		}
	}*/
	cout<<ans<<endl;
	return 0;
}

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

using I = long long;
using U = unsigned long long;

using F = long double;

template <typename T> using Vec = vector<T>;
template <typename K, typename V> using HashMap = unordered_map<K, V>;
template <typename T> using HashSet = unordered_set<T>;
template <typename T> using PQueue = priority_queue<T>;
template <typename T> using Uq = unique_ptr<T>;

using StrView = string_view;

auto solve(I const A, I const B) -> void { cout << A * B << "\n"; }

auto main() -> int {
  I A;
  scanf("%lld", &A);
  I B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 3684
#include <stdio.h>

typedef struct
{
  char name[16];
  int time;
} proc;

#define QUEUE_SIZE (200000)
proc queue[QUEUE_SIZE];

int main(void)
{
  int n, q;
  proc tmp;
  int front, rear;
  int current;
  int i;

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

  for (i = 0; i < n; i++){
    if(i < n)break;
  }
  
  for (i = 0; i < n; i++){
    scanf("%s %d", tmp.name, &tmp.time);
    queue[i] = tmp;
  }

  front = 0;
  rear = n;
  current = 0;
  while (front != rear){
    tmp = queue[front];
    front = (front + 1) % QUEUE_SIZE;

    if (tmp.time <= q){
      current += tmp.time;
      printf("%s %d\n", tmp.name, current);
    }
    else {
      current += q;
      tmp.time -= q;
      queue[rear] = tmp;
      rear = (rear + 1) % QUEUE_SIZE;
    }
  }

  return 0;
}



Measured memory_bytes: 5424
package main

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

func main() {
	n := readI()
	a := make([]int, n)
	for i := 0; i < n-1; i++ {
		a[readI()-1]++
	}
	for _, v := range a {
		fmt.Println(v)
	}
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-3.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 6200
def min(a, b):
    if a >= b:
        res = a - b
    elif a < b:
        res = b - a
    return res

n,k = map(int, input().split())
if n%k == 0:
    print(0)
    quit()
else:
    n = n%k

min_num = float('inf')
res_list = []
while(1):
    res = min(n, k)
    if res < min_num:
        min_num = res
    if res == 0:
        break
    if res in res_list:
        break
    n = res
    res_list.append(res)

print(min_num)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cstring>
#define ll long long
const int mod = 1e9 + 7;
const int MAXN = 2e5+5;
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    for(int a = 0;a<=100;a++)
    {
        for(int b = 0;b<=100;b++)
        {
            if( (a+b) == x && 2*a + 4*b == y) return cout<<"Yes"<<endl,0;
        }
    }
    cout<<"No"<<endl;

}


Measured memory_bytes: 3576
A=int(input())
l=input()
ans=0
for i in range(1000):
   s=str(i).zfill(3)
   x=l.find(s[0])
   y=l.find(s[1],x+1)
   z=l.find(s[2],y+1)
   if all([x <= y <= z,x!=-1,y!=-1,z!=-1]):
      ans+=1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int e1 = sc.nextInt();
            int e2 = sc.nextInt();
            int e3 = sc.nextInt();
            int e4 = sc.nextInt();
            
            if(e1==e2&&e3==e4 || e1==e3&&e2==e4 || e1==e4&&e2==e3){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }
    }
}

           


Measured memory_bytes: 26324
n,a,b,c,d = map(int,input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1

def rockcheck(l,r):
    rock = 0
    for i in range(l,r+1):
        if s[i] == "#":
            rock += 1
            if rock == 3:
                print("No")
                exit()
        else: rock = 0
rockcheck(a,c)
rockcheck(b,d)

ans = "No"
if c < d: ans = "Yes"
else:
    for i in range(b,d+1):
        if s[i] == "#": continue
        if s[i-1] == "." and s[i+1] == ".":
            ans = "Yes"
            break
print(ans)

Measured memory_bytes: 9428
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, N, T[110], ans, g;
int main()
{
    cin >> N;
    for(i=0;i<N;i++)
        cin >> T[i];
    ans = T[0];
    for(i=1;i<N;i++)
    {
        g = __gcd(ans,T[i]);
        ans = (ans/g)*T[i];

    }
    cout << ans << endl;
}


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

int main() {
  int N, T, A;
  int H;
  cin >> N >> T >> A;
  int res = 0;
  int cc = 1 << 30;
  for (int i = 1; i <= N; i++) {
    cin >> H;
    int d = (T * 1000 - H * 6) - A * 1000;
    if (d < 0) {
      d = -d;
    }
    if (cc > d) {
      cc = d;
      res = i;
    }
  }
  cout << res << endl;
}


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

using namespace std;
int main()
{
    string S, T;

    cin >> S >> T;

    if (strcmp(S.c_str(), T.substr(0, S.length()).c_str()) == 0)
    {
        if (S.length()+1 == T.length())
        {
            std::cout << "Yes" << std::endl;
        }
        else
        {
            std::cout << "No" << std::endl;
        }
    }
    else
    {
        std::cout << "No" << std::endl;
    }
}

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

int main()
{
	string s;
	cin>>s;
	int ans=s.size(); 
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]!=s[i+1])
			ans=min(ans,max(i+1,int(s.size())-i-1));
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#define REPA(i, n) for(int i=1;i<=N;++i)
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    if(K&1){
        long long d = N / K;
        cout << d * d * d << endl;
        return 0;
    }
    long long ans = 0;
    long long d = N / K;
    ans = d * d * d;
    d = (N + K / 2) / K;
    ans += d * d * d;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    ll n, k;
    cin>>n>>k;
    if(k > 1)cout<<n - k<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  int cnt = 0;
  while(N>0) {
    N /= K;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define pb push_back
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
#define all(s) s.begin(),s.end()
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define _max(v) *max_element(v.begin(), v.end())
#define _min(v) *min_element(v.begin(), v.end())
#define ms(s, n) memset(s, n, sizeof(s))
ll raised(ll x,  ll y){ll res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
ll raisedmod(ll x, ll y, ll p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a % b);} 
ll fact(ll n){ll res = 1; for (ll i = 2; i <= n; i++) res = res * i; return res; } 
ll nCr(ll n, ll r){ return fact(n) / (fact(r) * fact(n - r));} 


int main() 
{
    io;
    ll t; //cin >> t;
    t=1;
    while(t--)
    {
       string s;
       cin >> s;
       if(s[s.size()-1]=='s')
       cout<< s<< "es"<< endl;
       else cout<< s<< "s"<< endl;
    }
	return 0;
}


Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
def main():
    N = input().rstrip()
    if N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
        print("pon")
    elif N[-1] == "3":
        print("bon")
    else:
        print("hon")
if __name__ == "__main__":
    main()

Measured memory_bytes: 61884
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N = 1e7 + 2;

short int d[N];

void divisorCount() {
    for (int i = 1; i <= N; ++i) d[i] = 1;
    for (int i = 2; i <= N; ++i) {
        for (int j = i; j <= N; j+=i) ++d[j];
    }
}

int main() {
    divisorCount();
    ull n;
    cin >> n;
    ull ans = 0ll;
    for (int i = 1; i <= n; ++i) {
        ans += (ull) d[i]*i;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 23140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, q; cin >> n >> m >> q;
  vector<string> S(n); rep(i, n) cin >> S[i];
  vector<vector<int>> cntV(n+1, vector<int>(m+1));
  rep(i, n) rep(j, m) cntV[i+1][j+1] = (S[i][j]=='1');
  rep(i, n) rep(j, m) cntV[i+1][j+1] += cntV[i+1][j];
  rep(j, m) rep(i, n) cntV[i+1][j+1] += cntV[i][j+1];
  vector<vector<int>> cntEc(n+1, vector<int>(m+1));
  rep(i, n) rep(j, m) cntEc[i+1][j+1] += (j && S[i][j]-'0' && S[i][j-1]-'0');
  rep(i, n) rep(j, m) cntEc[i+1][j+1] += cntEc[i+1][j];
  rep(j, m) rep(i, n) cntEc[i+1][j+1] += cntEc[i][j+1];
  vector<vector<int>> cntEr(n+1, vector<int>(m+1));
  rep(j, m) rep(i, n) cntEr[i+1][j+1] += (i && S[i][j]-'0' && S[i-1][j]-'0');
  rep(i, n) rep(j, m) cntEr[i+1][j+1] += cntEr[i+1][j];
  rep(j, m) rep(i, n) cntEr[i+1][j+1] += cntEr[i][j+1];
  while(q--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--; // x2--; y2--;
    int v = cntV[x2][y2] - cntV[x1][y2] - cntV[x2][y1] + cntV[x1][y1];
    int ec = cntEc[x2][y2] - cntEc[x1][y2] - cntEc[x2][y1+1] + cntEc[x1][y1+1];
    int er = cntEr[x2][y2] - cntEr[x1+1][y2] - cntEr[x2][y1] + cntEr[x1+1][y1];
    cout << v-(ec+er) << "\n";
  }
  return 0;
}


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

using namespace std;

#define ll long long




void solve() {

	
	int n;
	cin >> n;
	int total = 0;
	int arr[n];
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		total += arr[i];
	}
	int left = 0;
	int mn = 1e9;
	for(int i = 0; i < n; i++) {
		left += arr[i];
		total -= arr[i];
		if(abs(total - left) < mn) {
			mn = abs(total - left);
		}
	}
	cout << mn;



	
}

int main() {

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

	return 0;
}

Measured memory_bytes: 3644
//unsolved list
//CODE FESTIVAL 2017 qual A-D
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-7;
const int N=500+10,maxn=60000+10,inf=0x3f3f3f;

int n,m,k;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>k;
    string s[2];
    s[0]="RB";s[1]="GY";
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            int x=(i+j+1e9)/k,y=(i-j+1e9)/k;
            cout<<s[x%2][y%2];
        }
        cout<<endl;
    }
    return 0;
}
/********************

********************/


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<fstream>
#include<sstream>
#include<vector>
#include<set>
#include<deque>
#include<cstring>
#include<queue>
#include<stdio.h>
#include<set>
#include<stack>
#include<numeric>
#include<map>
#include<cstdio>
#include<bitset>
#include<array>
#include<list>
using namespace std;
#define ll long long 
const ll mod = 1e9 + 7;

ifstream f1;
ofstream f2;

vector<stack<ll>> res;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	f1.open("INP.txt");
	f2.open("OUT.txt");
	ll n;
	cin >> n;
	stack<ll> hold;
	for (ll i = 0; i < n; i++) {
		ll x;
		cin >> x;
		hold.push(x);
		if (i == 0) {
			res.push_back(hold);
			continue;
		}
		ll sub = -1;
		ll l = 0, r = res.size() - 1;
		while (l <= r) {
			ll mid = (l + r) / 2;
			if (res[mid].top() < x) {
				r = mid - 1;
				sub = mid;
			}
			else {
				l = mid + 1;
			}
		}
		if (sub < 0) {
			res.push_back(hold);
		}
		else {
			res[sub].push(x);
		}
		hold.pop();
	}
	cout << res.size() << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 90508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main() {
int n,m;
cin>>n>>m;
int X,Y;
cin>>X>>Y;
vector<int> x(n);
vector<int> y(m);
    REP(i,n) cin>>x[i];
    REP(i,m) cin>>y[i];

sort(x.begin(),x.end(),greater<int>());
sort(y.begin(),y.end());
    int ans=0;
    for(int i=X+1; i<=Y; i++)
    {
        if(x[0]<i&&y[0]>=i) ++ans;
    }
    if(ans!=0) cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}

Measured memory_bytes: 256
import math
A = int(input())
i = 0
S = 0
B = int(math.sqrt(A))
while i == 0:
    S = 0
    B = int(math.sqrt(A))
    for n in range(2,B + 1):
        if A % n == 0:
            A += 1
            S = 1
            break
    if S == 0:
        print(A)
        exit()

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScan in = new MyScan(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, MyScan in, PrintWriter out) {
            int n = in.nextInt();
            int[] data = in.na(n);
            boolean v = data[0] == 0;
            long ans = 0;
            int next = 1;
            for (int s = n - 1; s >= 0; s--) {
                next--;
                int cur = data[s];
                if (cur == next) continue;
                if (cur < next) v = false;
                if (cur > next) {
                    ans += cur;
                    next = cur;
                }
            }
            if (!v) {
                out.println(-1);
                return;
            }

            out.println(ans);
        }

    }

    static class MyScan {
        private final InputStream in;
        private byte[] inbuf = new byte[1024];
        public int lenbuf = 0;
        public int ptrbuf = 0;

        public MyScan(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

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

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 24020
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long
#define PLL pair<ll, ll>
#define SZ(X) (int)X.size()
#define INF 0x3f3f3f3f
using namespace std;

ll x, k, d;
int main(void) {
	IOS
	cin >> x >> k >> d;
	if(x < 0) {
		x = -x;
	}
	ll tmp = x / d;
	if(k <= tmp) {
		cout << x - k * d << endl;
		return 0;
	} 
	if((k - tmp) % 2 == 0) {
		cout << x % d << endl;
	} else {
		cout << d - x % d << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;
 
 
int main() {
    int a,b,c;
    cin>>a>>b>>c;

    int can=false;
    for(int i=1; i<=b*a; ++i) {
        if((b*i+c)%a==0) can=true;
    }
    if(can) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int N, K;
vector<Int> A, S;
Int recur(int i, int j)
{
    if (j - i <= 0) return 0;
    if (j - i == 1) return A[i] >= K;
    vector<Int> B, C;
    int mid = (i + j) / 2;
    for (int t = i; t < mid; t++) B.push_back(S[mid] - S[t] - K*(mid-t));
    for (int t = mid+1; t <= j; t++) C.push_back(S[t] - S[mid] - K*(t-mid));
    sort(begin(B), end(B));
    sort(rbegin(C), rend(C));
    int u = 0;
    Int ans = 0;
    for (int t = 0; t < B.size(); t++) {
        while (u < C.size() && B[t] + C[u] >= 0) u++;
        ans += u;
    }
    return ans + recur(i, mid) + recur(mid, j);
}
int main()
{
    cin >> N >> K;
    A.resize(N);
    S.resize(N+1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        S[i+1] = S[i] + A[i];
    }
    cout << recur(0, A.size()) << '\n';
    return 0;
}

Measured memory_bytes: 6712
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
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 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())

const int MAX = 510000;
const int MOD = 1000000007;

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

int main(){
  ll N,K;cin>>N>>K;
  vector<ll> a(N);
  rep(i,N) cin>>a[i];

  ll tmp = gcd(a[0], a[1]);
  rep(i,N){
    tmp = gcd(tmp,a[i]);
  }

  ll m = 1;
  rep(i,N) m = max(m,a[i]);

  if(K%tmp == 0 and K <= m){
    cout<<"POSSIBLE"<<endl;
  }
  else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 1024
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let s = io.chars();
    let t = io.chars();

    let sn = s.len();
    let tn = t.len();
    let mut dp = vec![vec![0; tn + 1]; sn + 1];
    for i in 0..sn {
        for j in 0..tn {
            dp[i + 1][j + 1] = if s[i] == t[j] {
                max(dp[i][j] + 1, max(dp[i][j + 1], dp[i + 1][j]))
            } else {
                max(dp[i][j + 1], dp[i + 1][j])
            };
        }
    }
    let mut ans: Vec<char> = Vec::new();
    let mut nowi = sn;
    let mut nowj = tn;
    if dp[sn][tn] == 0 {
        io.writeln("");
        return;
    }
    while nowi >= 1 && nowj >= 1 && dp[nowi][nowj] > 0 {
        while nowj > 0 && dp[nowi][nowj] == dp[nowi][nowj - 1] {
            nowj -= 1;
        }
        while nowi > 0 && dp[nowi][nowj] == dp[nowi - 1][nowj] {
            nowi -= 1;
        }
        if nowi > 0 {
            ans.push(s[nowi - 1]);
        }
        nowi -= 1;
        nowj -= 1;
    }
    ans.reverse();
    for &c in ans.iter() {
        io.write(c);
    }
    io.writeln("");
}

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


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

int main() {
    int n,k=0;
    cin >> n;
    for (int x = 1; x <= n; x += 2) {
        int c = 0;
        for (int i = 1; i <= n; i++) {
            if (x%i == 0) {
                c++;
            }
        }
        if (c==8)k++;
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 205000;

int n;
int a[MAXN];
vector <int> pos[30];
long long ans = 0;

int main() {

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 20; j++) {
      if ((a[i] & (1 << j))) {
        pos[j].push_back(i);
      }
    }
    int l = 0;
    for (int j = 0; j < 20; j++) {
      if (sz(pos[j]) >= 2) {
        int prev = pos[j][sz(pos[j]) - 2];
        l = max(l, prev + 1);
      }
    }
    ans += (i - l + 1);
  }

  cout << ans << endl;

  return 0;
}


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


void solve(string S){
    bool yy1 = false;
    bool yy2 = false;
    bool mm1 = false;
    bool mm2 = false;
    if(S.substr(0,2) >= "00" && S.substr(0,2) <= "99"){
        yy1 = true;
        if(S.substr(2,2) >= "01" && S.substr(2,2) <= "12"){
            mm2 = true;
        }
    }
    if(S.substr(0,2) >= "01" && S.substr(0,2) <= "12"){
        mm1 = true;
        if(S.substr(2,2) >= "00" && S.substr(2,2) <= "99"){
            yy2 = true;
        }
    }
    
    //cout << yy1 << mm2 << mm1 << yy2 << endl;
    if((yy1 && mm2) && (mm1 && yy2)) cout << "AMBIGUOUS" << endl;
    else{
        if(yy1 && mm2) cout << "YYMM" << endl;
        else if(mm1 && yy2) cout << "MMYY" << endl;
        else cout << "NA" << endl;
    }
}

int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PB push_back

int main()
{
    ll N;
    cin >> N;
    map<ll, ll> value_count;
    map<ll, ll> ans;
    vector<ll> A(N);
    rep(i, N){
        cin >> A.at(i);
        if(value_count.count(A.at(i))){
            value_count[A.at(i)]++;
        }
        else{
            value_count[A.at(i)]=1;
            ans[A.at(i)]=0;
        }
    }
    ll all_conbination=0;
    for(auto i=value_count.begin(); i!=value_count.end(); i++){
        all_conbination+=i->S*(i->S-1)/2;
    }
    for(int i=0; i<N; i++){
        cout << all_conbination-value_count[A.at(i)]+1 << endl;
    }

}

Measured memory_bytes: 18944
# -*- coding: utf-8 -*-
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

N = int(input())
An = list(map(int, input().split()))
Bn = list(map(int, input().split()))
Cn = list(map(int, input().split()))

An.sort()
Bn.sort()
Cn.sort()

# print(An)
# print(Bn)
# print(Cn)

# B
C_cnt = []
C_sum = 0
j = 0
for i in range(N):
    while j < N:
        if Bn[i] < Cn[j]:
            C_cnt.append(N - j)
            C_sum += N - j
            break
        else:
            j += 1


B_cnt = []
temp_sum = 0
for cnt in C_cnt:
    B_cnt.append(C_sum - temp_sum)
    temp_sum += cnt

A_cnt = 0
j = 0
for i in range(N):
    while j < N:
        if An[i] < Bn[j]:
            if j < len(B_cnt):
                A_cnt += B_cnt[j]
            break
        else:
            j += 1

# print(C_cnt)
# print(B_cnt)
print(A_cnt)


Measured memory_bytes: 23956
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();
		//array = new int[h+1][w+1];
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//Collections.reverse(list);
		int n = sc.nextInt();
		for(int i=0;n>i;i++) {
			int a = sc.nextInt();
			list.add(a);
		}
		int count=0;
		int min = 1000000;
		for(int i=0;n>i;i++) {
			int a = list.get(i);
			if(min>a) {
				min=a;
				count++;
			}
		}/*
			else
				continue loop;
			for(int j=0;i>j;j++) {
				if(list.get(j)<a)
					continue loop;
			}
			count++;
		}*/
		System.out.println(count);
	}
}


Measured memory_bytes: 88048
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	ss := make([]string, 0, a)
	for i := 0; i < a; i++ {
		var s string
		fmt.Scanf("%s", &s)
		ss = append(ss, s)
	}
	sort.Strings(ss)
	for _, s := range ss {
		fmt.Print(s)
	}
	fmt.Println("")
}


Measured memory_bytes: 512
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int i,j,k;
	int n,m;
	while(scanf("%d%d",&n,&m),n||m){
		int a[100][100]={};
		for(i=0;i<m;++i){
			int p,q,r;
			scanf("%d%d%d",&p,&q,&r);
			--p;
			--q;
			a[p][q]=a[q][p]=r;
		}
		bool b[100][100]={};
		for(i=0;i<n;++i){
			for(j=0;j<n;++j){
				if(!a[i][j])
					continue;
				for(k=0;k<n;++k){
					if(a[j][k])
						b[i][k]=true;
				}
			}
		}
		int c[100][2];
		fill(c[0],c[0]+100*2,1<<30);
		c[0][0]=0;
		priority_queue<pair<pair<int,int>,int>,vector<pair<pair<int,int>,int> >,greater<pair<pair<int,int>,int> > > d;
		d.push(make_pair(make_pair(0,0),0));
		for(;;){
			int p=d.top().first.first;
			int q=d.top().first.second;
			int r=d.top().second;
			if(q==n-1)
				break;
			d.pop();
			for(i=0;i<n;++i){
				if(!a[q][i]||c[i][r]<=p+a[q][i])
					continue;
				c[i][r]=p+a[q][i];
				d.push(make_pair(make_pair(p+a[q][i],i),r));
			}
			if(r)
				continue;
			for(i=0;i<n;++i){
				if(!b[q][i]||c[i][1]<=p)
					continue;
				c[i][1]=p;
				d.push(make_pair(make_pair(p,i),1));
			}
		}
		printf("%d\n",d.top().first.first);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#define LoveLive long long
#define lc cur << 1
#define rc cur << 1 | 1
#define N 200005
int n, q, A, B, x, l;
LoveLive M[200005 << 2], M1[200005 << 2], M2[200005 << 2], tg[200005 << 2];
const LoveLive inf = 0x3f3f3f3f3f3f3f3f;
namespace std {
	inline LoveLive abs(LoveLive x) { return x > 0 ? x : -x; }
	inline LoveLive min(LoveLive x, LoveLive y) { return x < y ? x : y; }
}
void pushdown(int cur) {
	if (tg[cur]) {
		M[lc] += tg[cur], M1[lc] += tg[cur], M2[lc] += tg[cur], tg[lc] += tg[cur];
		M[rc] += tg[cur], M1[rc] += tg[cur], M2[rc] += tg[cur], tg[rc] += tg[cur];
		tg[cur] = 0;		
	}
}
void pushup(int cur) {
	 M[cur] = std::min( M[lc],  M[rc]);
	M1[cur] = std::min(M1[lc], M1[rc]);
	M2[cur] = std::min(M2[lc], M2[rc]);
}
void modify(int cur, int l, int r, int pos, LoveLive num) {
	if (l == r) {M[cur] = num, M1[cur] = num + l, M2[cur] = num - l; return; }
	pushdown(cur);
	int mid = l + r >> 1;
	if (pos <= mid) modify(lc, l, mid, pos, num);
	else modify(rc, mid + 1, r, pos, num);
	pushup(cur);
}
void modify(LoveLive num) {
	M[1] += num, M1[1] += num, M2[1] += num, tg[1] += num;
}
LoveLive query(int cur, int l, int r, int pos) {
	if (l == r) return M[cur];
	pushdown(cur);
	int mid = l + r >> 1;
	if (pos <= mid) return query(lc, l, mid, pos);
	else return query(rc, mid + 1, r, pos);
}
LoveLive query0(int cur, int l, int r, int L, int R) {
	if (L <= l && R >= r) return M1[cur];
	pushdown(cur);
	int mid = l + r >> 1; LoveLive ans = inf;
	if (L <= mid) ans = std::min(ans, query0(lc, l, mid, L, R));
	if (R > mid) ans = std::min(ans, query0(rc, mid + 1, r, L, R));
	return ans;
}
LoveLive query1(int cur, int l, int r, int L, int R) {
	if (L <= l && R >= r) return M2[cur];
	pushdown(cur);
	int mid = l + r >> 1; LoveLive ans = inf;
	if (L <= mid) ans = std::min(ans, query1(lc, l, mid, L, R));
	if (R > mid) ans = std::min(ans, query1(rc, mid + 1, r, L, R));
	return ans;
}
signed main() {
	scanf("%d%d%d%d", &n, &q, &A, &B);
	memset(M, 0x3f, sizeof M);
	memset(M1, 0x3f, sizeof M1);
	memset(M2, 0x3f, sizeof M2);
	scanf("%d", &x); l = x;
	modify(1, 1, n, A, std::abs(B - x));
	modify(1, 1, n, B, std::abs(A - x));
	while (0 <-- q) {
		scanf("%d", &x);
		LoveLive t  = query (1, 1, n, l) + std::abs(x - l), 
				 w1 = query0(1, 1, n, x, n) - x, 
				 w2 = query1(1, 1, n, 1, x) + x;
		LoveLive T = std::min(t, std::min(w1, w2));
		modify(std::abs(x - l));
		modify(1, 1, n, l, T);
		l = x;
	}
	printf("%lld\n", M[1]);
	return 0;
}

Measured memory_bytes: 25216
/// Updated! https://www.youtube.com/watch?v=U07_n9xGIlM
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int maxn = 2e5+100;

const ll inf = 1e18;


int main()
{
    fast;
    int a , b , c;
    cin >> a >> b >> c;
    swap(a,b);
    swap(a,c);
    cout << a << " " << b << " " << c << endl;
    return 0;
}
/*



*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
//	    int t = in.nextInt();
//	   
//		for(int a0 = 0; a0 < t; a0++) {
			int d = in.nextInt();
			int t = in.nextInt();
			int s = in.nextInt();
			
			double time = (double) d / s;
			
			if(time <= t) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
		//}
		
		in.close();
	}
		
	
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << newl;

    return 0;
}

Measured memory_bytes: 3684
#include<stdio.h>
#include<string.h>
int main(){
    double amount = 0;
    int n;
    char c[3] = "BTC";
    scanf("%d",&n);
    for(int i = 0; i < n; i++){
        char s[3];
        double m;
        scanf("%lf",&m);
        scanf("%s",s);
        if(strcmp(s,c)){
            amount += m;
        }else{
            amount += 380000 * m;
        }
    }
    printf("%f",amount);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
main(void){
    int n,t;
    cin>>n;
    t=n;
    int s=0;
    while(n!=0){
        s+=n%10;
        n/=10;
    }
    if(t%s) puts("No");
    else puts("Yes");
}


Measured memory_bytes: 256
s = input()

m = 0
for i in range(len(s)-1, -1, -1):
    tmp = s[:-i]
    len_tmp = len(tmp)
    if len_tmp % 2 != 0:
        continue
    center = len_tmp // 2
    former = tmp[:center]
    latter = tmp[center:]
    if former == latter:
        m = max(m, len_tmp)
print(m)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s,t;
	cin>>s;
	t=s;
	reverse(t.begin(),t.end());
	ll ans=0;
	for(ll i=0;i<s.size()/2;i++){
		if(t[i]!=s[i]){
			ans++;
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 3612
N,A,B = map(int,input().split())
if(abs(A-B)%2 == 0):
  print(abs(A-B)//2)
else:
  print(min( A + (abs(A-B) - 1)// 2,  N - B + 1 + (abs(A-B)-1)//2  ))

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

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

class BipartiteMatching {
  int V;
  vector<vector<int>> g;
  vector<int> match;
  vector<bool> used;
  bool dfs(int v) {
    used[v] = true;
    for (int u: g[v]) {
      int w = match[u];
      if (w < 0 || (!used[w] && dfs(w))) {
        match[v] = u; match[u] = v;
        return true;
      }
    }
    return false;
  }
public:
  BipartiteMatching (int v) : V(v), g(v), match(v), used(v) {}
  void add_edge(int u, int v) {
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int maximum_matching(void) {
    int res = 0;
    fill (ALL(match), -1);
    REP(v, V) {
      if (match[v] < 0) {
        fill (ALL(used), 0);
        if (dfs(v)) res++;
      }
    }
    return res;
  }
};

int main()
{
  int n;
  cin>>n;
  vector<int> a(n), b(n), c(n), d(n);
  REP(i,n) cin>>a[i]>>b[i];
  REP(i,n) cin>>c[i]>>d[i];
  BipartiteMatching bm(2*n);
  REP(i,n)REP(j,n) {
    if (a[i] < c[j] && b[i] < d[j]) {
      bm.add_edge(i, n+j);
    }
  }
  cout << bm.maximum_matching() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        int length = s.size();
        for(int i = k; i < length; i++){
            s.pop_back();
        }
        cout << s << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;

    int in_N;

    int                     cnt;
    HashMap<String, String> word;
    String                  last;
    boolean                 ans;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));
      word      = new HashMap<String, String>();

      /*----------------
       * 引数
       *----------------*/
      in_str = new String(in_stream.readLine());
      in_N   = Integer.parseInt(in_str);

      ans    = true;
      last = new String(in_stream.readLine());
      word.put(last, "a");
      for(cnt=1; cnt<in_N; cnt++)
      {
        in_str = new String(in_stream.readLine());

        if(null == word.get(in_str))
        {
          if( !(last.substring(last.length()-1, last.length()).equals(in_str.substring(0, 1))) )
          {
            ans = false;
            break;
          }

          last = in_str;
          word.put(last, "a");
        }
        else
        {
          ans = false;
          break;
        }
      }

      /*----------------
       * 計算
       *----------------*/
      if(ans)
      {
        System.out.println("Yes");
      }
      else
      {
        System.out.println("No");
      }
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <math.h>

using namespace std;
int get_taste(int i,int L){
	int taste;
	taste = L+i-1;
	return taste;
}

int main(){
	int N,L,i,sum=0,min_taste=100;
	float ave=0;

	cin >> N;
	cin >> L;

	for(i=1;i<=N;i++){
		sum += get_taste(i,L);
		if(abs(min_taste) > abs(get_taste(i,L)))
			min_taste = get_taste(i,L);
	}

	sum -= min_taste;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256