akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	str := nextLine()
	ary := strings.Split(str, " ")
	fmt.Println(ary[2], ary[0], ary[1])
}


Measured memory_bytes: 640
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int mod = 1000000007;
        char[][] c = new char[h][w];
        for(int i = 0; i < h; i++){
            String s = sc.next();
            for(int j = 0; j < w; j++){
                c[i][j] = s.charAt(j);
            }
        }
        long[][] dp = new long[h][w];
        dp[0][0] = 1;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i == 0 && j == 0) continue;
                else if(i == 0 && j > 0) dp[i][j] = dp[i][j-1];
                else if(j == 0 && i > 0) dp[i][j] = dp[i-1][j];
                else{
                    dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
                }
                if(c[i][j] == '#') dp[i][j] = 0;
            }
        }
        System.out.println(dp[h-1][w-1]);
    }
}

Measured memory_bytes: 40988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
int main(){
    int n;cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }
    else if(n==2){
        int a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
//#include<map>
//#include<vector>
//#include<algorithm>
#define ll long long
#define endl "\n"
using namespace std;
//map<int,int>m;
/*
bool isprime[500+5];
vector<int>pf;
vector<int>arr;

void sieve()   // O(N lg lg N)
{
    int n=500; //sqrt of 2^31
    for(int i = 0; i <= n; i++)
    {
        isprime[i] = true;
    }
    isprime[0] = isprime[1] = false;
    for(int i = 2; i * i <= n; i++)
    {
        if(isprime[i] == true)
        {
            for(int j = i * i; j <= n; j += i)
            {
                isprime[j] = false;
            }
        }
    }
    for(int i=2; i<=n; i++)
    {
        if(isprime[i])
        {
            pf.push_back(i); //store the prime numbers upto 10^8
        }
    }
} */
bool check(int n)
{
    int r;
    while(n>0)
    {
        r=n%10;
        if(r==7)
        {
            return true;
        }

        n=n/10;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);//NULL;
    // sieve();
    int t;
    cin>>t;
    if(check(t))
 {
     cout<<"Yes"<<endl;
 }
 else
 {
     cout<<"No"<<endl;
 }



}




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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  vector<ll> v(3*N);
  ll sum = 0;
  priority_queue<ll,vector<ll>, greater<ll>> q1;
  priority_queue<ll> q2;

  for(int i = 0; i < 3*N; i++){
    cin >> v[i];
  }

  vector<ll> v1(N+1,0);
  vector<ll> v2(N+1,0);

  ll max_val = 0;
  for(int i = 0; i < 2*N; i++){
    if(i < N - 1 ){
      q1.push(v[i]);
      max_val += v[i];
    } else if(i == N-1){
      q1.push(v[i]);
      max_val += v[i];
      v1[0] = max_val;
    } else {
      ll tmp = q1.top();
      if(tmp < v[i]){
        q1.pop();
        q1.push(v[i]);
        max_val -= tmp;
        max_val += v[i];
      }

      v1[i-N+1] = max_val;
    }
  }

  ll min_val = 0;
  for(int i = 3*N-1; i >= N; i--){
    if(i >= 2 * N){
      min_val += v[i];
      q2.push(v[i]);

      if(i == 2 * N){
        v2[N] = min_val;
      }
    } else { 
      ll tmp = q2.top();
      if(tmp > v[i]){
        min_val -= tmp;
        min_val += v[i];
        q2.pop();
        q2.push(v[i]);
      }

      v2[i - N] = min_val;
    }
  }

  ll ans = -1000000000000000000;

  for(int i = 0; i <= N; i++){
    ll tmp = 0;
    tmp = v1[i] - v2[i];
    ans = max(ans, tmp);
  }
  cout << ans << endl;


}


Measured memory_bytes: 6516
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy

ans = ""
for _ in range(dy):
    ans += "U"
for _ in range(dx):
    ans += "R"
for _ in range(dy):
    ans += "D"
for _ in range(dx):
    ans += "L"
ans += "L"

for _ in range(dy + 1):
    ans += "U"
for _ in range(dx + 1):
    ans += "R"
ans += "D"
ans += "R"

for _ in range(dy + 1):
    ans += "D"
for _ in range(dx + 1):
    ans += "L"
ans += "U"

print(ans)


Measured memory_bytes: 3064
N,K = map(int,input().split())
x = [0 for i in range(N)]
y = [0 for i in range(N)]
p = [0 for i in range(N)]
q = [0 for i in range(N)]
for i in range(N):
    x[i],y[i] = map(int, input().split())
    p[i]=x[i]
    q[i]=y[i]
x.sort()
y.sort()
S = [[0 for i in range(N+1)]for i in range(N+1)]
for n in range(N):
    for i in range(N):
        for j in range(N):
            if p[n]<=x[i] and q[n]<=y[j]:
                S[i+1][j+1]+=1
R=(x[N-1]-x[0])*(y[N-1]-y[0])
for a in range(N):
    for b in range(N):
        for c in range(a,N):
            for d in range(b,N):
                if (S[a][b]+S[c+1][d+1]-S[a][d+1]-S[c+1][b])>=K:
                    if (x[c]-x[a])*(y[d]-y[b])<R:
                        R=(x[c]-x[a])*(y[d]-y[b])
print(R)


Measured memory_bytes: 3192
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
 freopen("input","r",stdin);
 freopen("output","w",stdout);
 */

int cal(ll num) {
    int ans = 0;
    while (num > 0) {
        ans += num % 10;
        num /= 10;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll r = 10;
    vector<pair<ll, ll>> R;
    for (int i = 1;i <= 9;i++) R.push_back(make_pair(i, i));
    while (r < 1E15) {
        for (int i = 0;i <= 135;i++) {
            ll num = r * (i + 1) - 1;
            ll d = cal(num);
            if (num < 1E16) {
                R.push_back(make_pair(num, d));
            }
        }
        r *= 10;
    }
    sort(R.begin(), R.end());
    set<ll> sol;
    for (int i = 0;i < R.size();i++) {
        bool ok = true;
        for (int j = i + 1;j < R.size();j++) {
            if (R[i].first * R[j].second > R[i].second * R[j].first) ok = false;
        }
        if (ok) sol.insert(R[i].first);
    }
    int K;
    cin >> K;
    auto it = sol.begin();
    for (int i = 0;i < K;i++) {
        cout << *it << endl;
        it++;
    }
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000
 
int main() {
    unsigned short *A, *B;
    int C[VMAX + 1];
    int n, i, j;
     
    scanf("%d", &n);
     
    A = (unsigned short *) malloc(sizeof(short) * n + 1);
    B = (unsigned short *) malloc(sizeof(short) * n + 1);
     
    for(i = 0; i <= VMAX; i++) C[i] = 0;
     
    for(i = 0; i < n; i++) {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
     
    for( i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];
     
    for(j = n; j >= 1; j--) {
        B[C[A[j]]] = A[j];
        C[A[j]] --;
    }
     
    for(i = 1; i <= n; i++) {
        if(i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");
     
    return 0;   
     
} 

Measured memory_bytes: 10588
#include<stdio.h>
int main()
{
    int a,b,c,d,flag=0;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while(a>0)
    {
        c=c-b;
        a=a-d;
        if(c<=0)
        {
            flag=1;
            break;
        }
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
#define int long long
int a[1000010],f[1000010],s[1000010];
int max(int a,int b){
    return a>b?a:b;
}
main(){
    int i,j,k,n,m;
    scanf("%lld%lld",&m,&n);swap(n,m);
	memset(f,127,sizeof(f));f[0]=0;
    for(i=1;i<=n;i++)
        scanf("%lld%lld",&s[i],&a[i]);
    for(i=1;i<=n;i++)
        for(j=100000;j>=a[i];j--)
            f[j]=min(f[j-a[i]]+s[i],f[j]);
	for(int i=100000;i;i--)
		if(f[i]<=m)return printf("%lld\n",i),0;
    return 0;
}


Measured memory_bytes: 10496
#include <stdio.h>

int main(){
	int sum = 0;
	char ch;

	while(true)
	{
		while((ch = getchar()) != '\n'){
			sum += ch - '0';
		}
		if(sum == 0)
			break;
		else{
			printf("%d\n",sum);
			sum = 0;
		}
	}
}



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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const long long MOD = 1000000007;
const int MAX_HW = 1000;
int h,w;
string grid[MAX_HW];
ll c[MAX_HW][MAX_HW];
int dx[2] = {1,0};
int dy[2] = {0,1};

ll dfs(int i, int j) {
  if (c[i][j] >= 0) return c[i][j];

  if (i == h-1 && j == w-1) return c[i][j] = 1;

  ll res = 0;

  forn (k,2) {
    int x = i+dx[k], y = j+dy[k];
    if (x < h && y < w && grid[x][y] == '.')
      res = (res + dfs(x,y)) % MOD;
  }

  return c[i][j] = res;
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> h >> w;
  forn(i,h) cin >> grid[i];

  forn(i,h) fill_n(c[i],w,-1);

  cout << dfs(0,0) << endl;

  return 0;
}


Measured memory_bytes: 9344
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long ans = 0;
		for(int i=1; i<=N; i++)
			if(i%3!=0 && i%5!=0)
				ans += i;
		System.out.println(ans);

		sc.close();
	}
}


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

int main(int , char **)
{
	int a,b,c;
	cin >> a >> b >> c;
	if ((a<=c)&&(c<=b)){printf("Yes\n");}else{printf("No\n");}
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIT = lambda: tuple(MI())
MIS = lambda: input().split()



def main():
    N, M = MI()
    shops = []
    for i in range(N):
        heapq.heappush(shops, MIT())
    ans = 0
    while M > 0:
        a, b = heapq.heappop(shops)
        ans += a * min(b, M)
        M -= b
    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 18624
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)n; ++i)

int x[100002], y[100002];

int main(){
	int n;
	scanf("%d", &n);
	f(i, 1, n + 1)scanf("%d", x + i);
	f(i, 1, n + 1)scanf("%d", y + i);
	int an = 1, md = 1e9 + 7;
	f(i, 1, n + 1){
		if (x[i] > x[i - 1] && y[i] < x[i]) { an = 0; break; }
		if (y[i] > y[i + 1] && x[i] < y[i]) { an = 0; break; }
		if (x[i] > x[i - 1] || y[i] > y[i + 1])continue;
		an = (ll)an * min(x[i], y[i]) % md;
	}
	printf("%d\n", an);
}


Measured memory_bytes: 1024
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,m=0,x=0;
    cin>>n>>m;
    vector<bool> ok(n+1,true);
    for(int i=0;i<m;++i)
    {
        cin>>x;
        ok[x]=false;
    }
    vector<lli> dp(n+1);
    dp[0]=1ll;
    for(int i=0;i<n;++i)
        for(int j=i+1;j<=min(n,i+2);++j)
        {
            if(ok[j])
            {
                dp[j]+=dp[i];
                dp[j]%=MOD;
            }
        }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
N,K=gets.split.map(&:to_i)
ls=N.times.map{gets.split.map(&:to_i)}
ans=Float::INFINITY
k=K>=4 ? 4 : K
ls.combination(k) do |a|
    b=a.transpose
    next if k != b[0].uniq.size || k != b[1].uniq.size
    ix,ax=b[0].minmax
    iy,ay=b[1].minmax
    cnt=0
    ls.each do |i|
        x,y=i
        cnt+=1 if ix<=x && x<=ax && iy<=y && y<=ay
    end
    ans = ans > (ax-ix)*(ay-iy) ? (ax-ix)*(ay-iy) : ans if cnt>=K
end
puts ans

Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <string.h>
using namespace std;

int main()
{
    int n;
    while(cin>>n){
        cout<<1110-n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())
angle = H * 30 + M * 0.5 - M * 6
if angle >= 180:
    angle = abs(360 - angle) 
print(math.sqrt( A*A + B*B - 2*A*B*math.cos( angle * math.pi/180 ) ))

Measured memory_bytes: 9496
import sys


read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s_readline = sys.stdin.readline

N = int(readline())
H = list(map(int, readline().split()))


def solve():

    ans = 1
    hmax = H[0]
    for i in range(1, N):
        if hmax <= H[i]:
            ans += 1
        hmax = max(hmax, H[i])

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
/*
typedef pair<long long int, long long int> P;
long long int INF = 1e18;

int main(){
	while(true){
		int n, d;
		cin >> n >> d;
		
		if(n == 0){
			break;
		}
		
		vector<long long int> v[110];
		long long int S[110] = {};
		
		for(int i = 0; i < n; i++){
			int m;
			cin >> m;
			v[i].push_back(INF);
			for(int j = 0; j < m; j++){
				int num;
				cin >> num;
				v[i].push_back(num);
				S[i] += num;
			}
		}
		
		while(true){
			vector<P> vs;
			for(int i = 0; i < n; i++){
				vs.push_back(make_pair(S[i], i));
			}
			sort(vs.begin(), vs.end());
			bool flag = true;
			for(int i = 0; i < n; i++){
				int index = n - 1;
				if(i == vs[n - 1].second){
					index--;
				}
				if(vs[index].first - d <= S[i] - v[i][v[i].size() - 1]){
					S[i] -= v[i][v[i].size() - 1];
					v[i].pop_back();
					flag = false;
				}
			}
			if(flag){
				break;
			}
		}
		
		int SS = 0;
		for(int i = 0; i < n; i++){
			SS += v[i].size();
		}
		
		if(SS == n){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}
*/
char S[80001];
int A[80001], B[11];
 
int char_to_int(char c){
    return (int)c - (int)'0';
}
 
int main(){
    int N, i, j, ans;
    while(1){
        scanf("%s", S);
        for(N = 0; S[N] != '\0'; N++){}
        if(N == 1 && S[0] == '0'){
            return 0;
        }
        for(j = 0; j < 11; j++){
            B[j] = 0;
        }
        B[0] = 1;
        ans = 0;
        A[N] = 0;
        for(i = N - 1; i >= 0; i--){
            if(i % 2 == 0){
                A[i] = (A[i + 1] + char_to_int(S[i])) % 11;
            }
            else{
                A[i] = (A[i + 1] - char_to_int(S[i]) + 11) % 11;
            }
            if(S[i] != '0'){
                ans += B[A[i]];
            }
            B[A[i]]++;
        }
        printf("%d\n", ans);
    }
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;
int dp[1010][1010] = {};

int mod_pow(int x, int n) {
    int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

const int MAXN = 300010;
int fact[MAXN], inv[MAXN];

void init_fact() {
    fact[0] = 1;
    for(int i=1; i<MAXN; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    inv[MAXN - 1] = mod_pow(fact[MAXN - 1], MOD-2);
    for(int i=MAXN - 2; i>=0; i--) {
        inv[i] = (inv[i+1] * (i+1)) % MOD;
    }
}

int comb(int n, int r) {
    if(r < 0 || n < r) return 0;
    return fact[n] * inv[n-r] % MOD * inv[r] % MOD;
}

signed main(){

    init_fact();

    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= n; j++){

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

            // i + 1 人グループは作らない
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= MOD;

            if(a <= i + 1 && i + 1 <= b){
                int dot = 1;
                int rest = n - j;

                // i + 1 人グループを k 個作る
                for(int k = c; k * (i + 1) <= rest && k <= d; k++){
                    
                    int mul = comb(rest, k * (i + 1));
                    mul %= MOD;
                    mul *= fact[k * (i + 1)];
                    mul %= MOD;
                    mul *= inv[k];
                    mul %= MOD;
                    mul *= mod_pow(inv[(i + 1)], k);
                    mul %= MOD;
                    dp[i + 1][j + (i + 1) * k] += mul * dp[i][j];
                    dp[i + 1][j + (i + 1) * k] %= MOD;
                }
            }
        }
    }

    /*for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

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

Measured memory_bytes: 12800
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<map>
using namespace std;
map<int,int>mmp;
int main()
{
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	for(int i=0;i<=n/2;i++)
	{
		int black=m*i;
		for(int k=0;k<=m;k++)
		{
			int sum=black+k*(n-2*i);
			mmp[sum]=1;
		}
	}
	if(mmp[k]==1)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 13056
N = parse(Int32, strip(readline()))
H = map(s -> parse(Int32, s), split(readline()))

result = "Yes"
for i in 1:N
    if i == 1 || H[i - 1] <= H[i] - 1
        H[i] -= 1
    elseif H[i - 1] > H[i]
        global result = "No"
        break
    end
end
println(result)

Measured memory_bytes: 173140
#include <stdio.h>
#include <string.h>
#include <queue>
#include <vector>
#include <functional>
#include <utility>

using namespace std;

#define MOD 1000000007

typedef long long lli;
typedef pair<lli, int> ip;

class e {
public:
	int v, w;
	e(int v, int w)
		:v(v), w(w)
	{}
};

lli d[2][100001];
int n, m;
vector<e> con[100001];

void dij(int to, int s) {
	priority_queue<ip, vector<ip>, greater<ip> > q;
	q.push(ip(0, s));
	memset(d[to], -1, sizeof(d[to]));
	d[to][s] = 0;
	while (!q.empty()) {
		lli dis = q.top().first;
		int u = q.top().second;
		q.pop();
		if (d[to][u] != dis) continue;
		for (int i = 0; i < con[u].size(); i++) {
			int v = con[u][i].v, w = con[u][i].w;
			if (d[to][v]<0 || d[to][v]>dis + w) {
				d[to][v] = dis + w;
				q.push(ip(d[to][v], v));
			}
		}
	}
}

int s, t;

lli dd[100001];

lli f(int k) {
	if (k == s) return 1;
	if (dd[k] >= 0) return dd[k];
	lli res = 0;
	for (int i = 0; i < con[k].size(); i++) {
		int v = con[k][i].v, w = con[k][i].w;
		if (d[0][v] + w == d[0][k]) {
			res += f(v);
			res %= MOD;
		}
	}
	return dd[k] = res;
}

lli ddd[100001];

lli g(int k) {
	if (k == t) return 1;
	if (ddd[k] >= 0) return ddd[k];
	lli res = 0;
	for (int i = 0; i < con[k].size(); i++) {
		int v = con[k][i].v, w = con[k][i].w;
		if (d[1][v] + w == d[1][k]) {
			res += g(v);
			res %= MOD;
		}
	}
	return ddd[k] = res;
}

int main() {
	scanf("%d %d %d %d", &n, &m, &s, &t);
	while (m--) {
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		con[u].push_back(e(v, w));
		con[v].push_back(e(u, w));
	}
	dij(0, s); dij(1, t);
	lli dist = d[0][t];
	memset(dd, -1, sizeof(dd));
	memset(ddd, -1, sizeof(ddd));
	lli res = f(t)*g(s) % MOD;
	for (int i = 1; i <= n; i++) {
		if (d[0][i] == d[1][i] && d[0][i] + d[1][i] == dist) {
			lli w = f(i)*g(i) % MOD;
			w = w*w%MOD;
			res = (res - w + MOD) % MOD;
		}
		else {
			for (int j = 0; j < con[i].size(); j++) {
				int v = con[i][j].v, w = con[i][j].w;
				if (d[0][i]<d[1][i] && d[0][v]>d[1][v] && d[0][i] + d[1][v] + w == dist) {
					lli w = f(i)*g(v) % MOD;
					w = w*w%MOD;
					res = (res - w + MOD) % MOD;
				}
			}
		}
	}
	printf("%lld\n", res);
	return 0;
}

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

using namespace std;

class Node {
public:
  explicit Node(int64_t v) : val(v) {}

  int64_t val;
  uint64_t count = 0;

  Node *left = nullptr;
  Node *right = nullptr;

  uint64_t insert(int64_t n) noexcept {
    if (n < val) {
      ++count;
      return left->insert(n);
    }
    else if (n == val)
      return count++;
    else
      return count + right->insert(n);
  }
};

Node *build(const vector<int64_t> &v, size_t b, size_t e) {

  size_t mid = b + (e - b) / 2;

  Node *ret = new Node(v[mid]);

  if (mid == b)
    return ret;

  ret->left = build(v, b, mid);

  if (mid + 1 < e)
    ret->right = build(v, mid + 1, e);

  return ret;
}

int64_t N;
int64_t K;

int main() {

  cin >> N >> K;

  vector<int64_t> as;
  as.reserve(N);

  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    as.push_back(a - K);
  }

  vector<int64_t> sums = {0};
  sums.reserve(N + 1);

  int64_t sum = 0;
  for (auto a : as) {
    sum += a;
    sums.push_back(sum);
  }

  vector<int64_t> sums_ = sums;
  sort(sums_.begin(), sums_.end());
  auto it = unique(sums_.begin(), sums_.end());
  sums_.resize(distance(sums_.begin(), it));

  Node *node = build(sums_, 0, sums_.size());

  uint64_t ret = 0;
  for (auto s : sums) {
    ret += node->insert(s);
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

int main() {
	string S;
	cin >> S;

	u64 mod = 2019;
	u64 ans = 0;
	vector<bool> search_done(S.size()+1);
	
	for(u64 b=0; b<S.size(); b++) {
		if(search_done[b]) continue;

		u64 tmp_div = 0;
		u64 num_b_variations = 0;
		
		for(u64 e=b; e<S.size(); e++) {
			tmp_div = tmp_div * 10 + S[e] - '0';
			bool is_zero = (tmp_div == 0);
			if(is_zero && search_done[e]) break;

			tmp_div = tmp_div % mod;
			if(!is_zero && tmp_div == 0) {
				num_b_variations++;
				ans += num_b_variations;
				search_done[e+1] = true;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m,w;
    cin>>m;
    for(ll h=1LL;h<=3500LL;h++){
        for(ll n=h;n<=3500LL;n++){
            if((4*h*n-h*m-n*m)&&(h*n*m)%(4*h*n-h*m-n*m)==0LL){
                w=(h*n*m)/(4LL*h*n-h*m-n*m);
                if(w>0LL){
                    cout<<h<<" "<<n<<" "<< w<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


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

typedef long long ll;

const int MOD = (int)1e9 + 7;
int N, M;
vector<int> A, B;

void input_init(void) {
	cin >> N >> M;
	A.resize(N);
	for (int j = 0; j < N; ++j)
		cin >> A[j];
	B.resize(M);
	for (int i = 0; i < M; ++i)
		cin >> B[i];
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	sort(B.begin(), B.end());
	B.erase(unique(B.begin(), B.end()), B.end());
}

int calcu(int n) {
	vector<int>::iterator it_a = lower_bound(A.begin(), A.end(), n);
	vector<int>::iterator it_b = lower_bound(B.begin(), B.end(), n);
	int idx_a = distance(A.begin(), it_a);
	int idx_b = distance(B.begin(), it_b);

	int ret = 0;
	if (*it_a == n && *it_b == n)				// A, B 共に有る
		ret = 1;
	else if (*it_a == n && *it_b != n)			// A のみに有る
		ret = M - idx_b;
	else if (*it_a != n && *it_b == n)			// B のみに有る
		ret = N - idx_a;
	else										// A, B 共に無い
		ret = (M - idx_b) * (N - idx_a) - (N * M - n);

	return ret;
}

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

	input_init();
	ll ans = (ll)0;
	if (A.size() == N && B.size() == M) {
		A.push_back(N * M + 1);
		B.push_back(N * M + 1);
		ans = (ll)1;
		for (int i = N * M; i >= 1; --i) {
			ans *= (ll)calcu(i);
			ans %= (ll)MOD;
		}
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define mod 1000000007
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 2e5 + 5;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };

int main()
{

ll n,i,j,k;
ll a,b,c;
cin>>a>>b>>c;
swap(a, b);
swap(a,c);
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int w,h,c,x,a,b;
	scanf("%d %d %d",&w,&h,&c);
	if(w>h) {
	x=w;
	}
	if(w<h){
	x=h;
	}
	while(1){
		if(h%x==0&&w%x==0){
			break;
		}
		x=x-1;
	}
	a=(h/x)*(w/x);
	b=a*c;
	printf("%d\n",b);
	return 0;
}


Measured memory_bytes: 2700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(11);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  sort(all(a)); sort(all(b));
  
  if (n % 2) {
    ll x = a[n / 2], y = b[n / 2];
    cout << y - x + 1 << endl;
  } else {
    ll x = a[n / 2  - 1] + a[n / 2], y = b[n / 2 - 1] + b[n / 2];
    cout << y - x + 1 << endl;
  }
}


Measured memory_bytes: 6364
from collections import defaultdict
n = int(input())
dics = defaultdict(int)
for i in range(n):
    s = input()
    dics[s] += 1
max_v = max(dics.values())
max_k_list = [kv[0] for kv in dics.items() if kv[1] == max_v]
max_k_list.sort()
print(*max_k_list, sep='\n')

Measured memory_bytes: 34372
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void)
{
        unsigned int i = 0, j = 0;
        long n = 0;
        long h = 0;
        int count=0;




        while(scanf("%ld", &n) != EOF)
        {

                h = n + 21;
                short flag[h];
                for(i = 1; i <= h; i++)
                {
                        flag[i] = 1;
                }
                flag[1] = 0;

                for(i = 2; i <= sqrt(h); i++)
                {
                        for(j = 2; j*i <= h ; j++)
                        {
                                flag[i*j]=0;
                        }
                }
                /*
                for(i = 1; i <= h; i++)
                {
                        if(flag[i] == 1)
                        {
                                printf("%d ",i);
                                count++;
                        }
                }*/
                for(i = n-1; i >= 1; i--)
                {
                        if(flag[i] == 1)
                        {
                                printf("%d ",i);
                                break;
                        }
                }
                for(i = n+1; i <= h; i++)
                {
                        if(flag[i] == 1)
                        {
                                printf("%d\n",i);
                                break;
                        }
                }
                /*
                printf("%d\n",count);*/
                count = 0;
        }

        return 0;
}

Measured memory_bytes: 692
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
using namespace std;

#define SIZE 300000
struct Myconbination {
private:
	ll M = MOD;
	ll fac[SIZE + 1];
	ll ifac[SIZE + 1];
public:
	ll factorial(ll n) {
		return fac[n];
	}
	ll mpow(ll x, ll n) {
		ll ans = 1;
		while (n != 0) {
			if (n & 1) {
				ans = ans * x % M;
			}
			x = x * x % M;
			n = n >> 1;
		}
		return ans;
	}

	ll comb(ll a, ll b) {
		if (a == 0 and b == 0) {
			return 1;
		}
		if (a < b or a < 0) {
			return 0;
		}

		ll temp = ifac[a - b] * ifac[b] % M;

		return temp * fac[a] % M;
	}

	Myconbination() {
		fac[0] = 1; ifac[0] = 1;
		for (ll i = 0; i < SIZE; i++) {
			fac[i + 1] = fac[i] * (i + 1) % M;
			ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M;
		}
	}
};

int main() {
	Myconbination myc;
	int N, M;
	cin >> N >> M;

	if (abs(N - M) >= 2) {
		cout << 0 << endl;
	}
	else if (abs(N - M) == 1) {
		ll ans = myc.factorial(N) * myc.factorial(M) % MOD;
		cout << ans << endl;
	}
	else {
		ll ans = myc.factorial(N) * myc.factorial(M) % MOD;
		ans *= 2;
		ans %= MOD;
		cout << ans << endl;
	}
}


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

int main(void){
    int N; cin >> N;
    int A[N];
    long long ans=2*1000000000;
    long long x=0, y=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        y+=A[i];
    }

    for(int i=0; i<N-1; i++){
        x+=A[i]; y-=A[i];
        ans=min(ans, abs(x-y));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
// Aizu 1109: Fermat's Last Theorem
// 2017.9.12 bal4u@uu

#include <stdio.h>

#define MAX 1111
int tbl[MAX+2];

int bsrch(int a)
{
	int m, l = 0, r = MAX;
    while (l < r) {
        m = (l + r) >> 1;
        if (tbl[m] <= a) l = m + 1; else r = m;
    }
	return tbl[l-1];
}

int main()
{
	int x, y, z, max;

	tbl[1] = 1;	for (x = 1, y = 2; x <= MAX; x++, y++) tbl[y] = tbl[x] + 3*x*y + 1;
	while (scanf("%d", &z) && z) {
		for (max = 0, x = z-1; ; x--) {
			if ((y = bsrch(tbl[z] - tbl[x])) > tbl[x]) break;
			if (tbl[x] + y > max) max = tbl[x] + y;
		}
		printf("%d\n", tbl[z] - max);
	}
	return 0;
}

Measured memory_bytes: 1680
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
using namespace std;
int main() {
    int N,x;
    cin >> N >> x;
    int a;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> a;
        A.at(i) = a;
    }
    sort(A.begin(), A.end());
    int count=0;
    for(int i=0;i<N;i++){
        x = x - A.at(i);
        if((x>0)&&(i!=N-1)){
            count = count + 1;
        }
        else if(x==0){
            count = count + 1;
        }
        
        else{
            break;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3556
C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))

C = [C1, C2, C3]
A = [0] * 3
B = [0] * 3

B = C1
A[1] = C2[0] - B[0]
A[2] = C3[0] - B[0]
flg = True
for i, a in enumerate(A):
    for j, b in enumerate(B):
        if C[i][j] != a + b:
            flg = False

if flg is True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
N, K = map(int, input().split())
V = list(map(int, input().split()))
value = 0

for cd in range(K):
    ab = min(N, K-cd)
    for left_ab in range(ab+1):
        right_ab = ab - left_ab
        if right_ab > 0:
            pick = V[:left_ab] + V[-right_ab:]
        else:
            pick = V[:left_ab]
        pick.sort()
        neg = 0
        while neg < len(pick):
            if pick[neg]<0:
                neg+=1
                continue
            else:
                break
        v = sum(pick[min(neg,cd):])
        value = max(value,v)
        
print(value)

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

template <typename T>

using lim = numeric_limits<T>;

unordered_set<string> tracker;

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

	int n; cin >> n;
	for (int i = 0; i < n; i++){
		string s; cin >> s;
		if (!(tracker.count(s) > 0))
			tracker.insert(s);
	}

	cout << tracker.size() << "\n";
}

Measured memory_bytes: 17724
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine()
                .Split(' ')
                .Select(s => int.Parse(s))
                .ToArray();
            Array.Sort(a);

            int result = 0;
            for (int i = 0; i < a.Length - 1; ++i)
            {
                result += a[i + 1] - a[i];
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11348
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int a[4][13];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    map<char,int> z;
    z['S']=0;
    z['H']=1;
    z['C']=2;
    z['D']=3;
    string astr[4];
    astr[0]="S";
    astr[1]="H";
    astr[2]="C";
    astr[3]="D";
    int i;
    for(i=0; i<n; i++) {
        char str[3]={0}; int tmp;
        scanf("%s%d", str, &tmp);
        a[z[str[0]]][tmp-1]=1;
    }
    int j;
    for(i=0; i<4; i++) {
        for(j=0; j<13; j++) {
            if(a[i][j]==0) printf("%s %d\n", astr[i].c_str(), j+1);
        }
    }

    return 0;
}



Measured memory_bytes: 2740
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int main(){
    string s;cin>>s;
    int k;cin>>k;
    int n=(int)s.size();
    for(int i=0;i<n;++i){
        if(s[i]=='a') continue;
        if(k>=(int)('z'-s[i])+1){
            k-=((int)('z'-s[i])+1);
            s[i]='a';
        }
    }
    s[n-1]=(char)(s[n-1]+k%26);
    cout<<s<<endl;
}

Measured memory_bytes: 3716
//https://atcoder.jp/contests/agc018/tasks/agc018_c?fbclid=IwAR2yYqf2onVd6nZRA8tk4zzGqVcwIocqT85XNWVlxosFA8Ji06B7mU04CC8
#define tasknames "Coins"
#include <iostream>
#include <stdio.h>
#include <queue>
#include <algorithm>
using namespace std;
const int maxn=1e5+2;
int n, x, y, z;
long long ans=0;

struct T
{
    int a, b, c;
};
T t[maxn];
bool lf(const T& p,const T& q)
{
    if(p.b-p.c!=q.b-q.c)return p.b-p.c>q.b-q.c;
    return p.a-p.b>q.a-q.b;
}

struct Tpq
{
    int id, d;
    bool operator <(const Tpq& e)const
    {
        return e.d<d;
    }
};

struct X
{
    long long x, y;
};
X s[maxn];

void Enter()
{
    cin>>x>>y>>z;
    n=x+y+z;
    for(int i=1;i<=n;i++)
        cin>>t[i].a>>t[i].b>>t[i].c;
    sort(t+1,t+n+1,lf);
}

void Solve()
{
    priority_queue<Tpq> l, r;
    long long sumx=0, sumy=0, sumz=0;
    for(int i=1;i<=x+y;i++)
    {
        l.push({i,t[i].b-t[i].a});
        sumy+=t[i].b;
        if(l.size()>y)
        {
            sumx+=t[l.top().id].a;
            sumy-=t[l.top().id].b;
            l.pop();
        }
        s[i]={sumx,sumy};
    }
    sumx=0;
    for(int i=n;i>n-x-z;i--)
    {
        r.push({i,t[i].c-t[i].a});
        sumz+=t[i].c;
        if(r.size()>z)
        {
            sumx+=t[r.top().id].a;
            sumz-=t[r.top().id].c;
            r.pop();
        }
        if(r.size()==z)
            ans=max(ans,sumx+sumz+s[i-1].x+s[i-1].y);
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    if(fopen(tasknames".INP","r"))
    {
    	freopen(tasknames".INP","r",stdin);
        freopen(tasknames".OUT","w",stdout);
    }
    Enter();
    Solve();
}


Measured memory_bytes: 6708
#include "stdio.h"
 
int main()
{
  int A, B, C;
  scanf("%4i %4i %4i%*[^\n]", &A, &B, &C);
  getchar();
  if (A == B) printf("%i\n", C);
  else if (A == C) printf("%i\n", B);
  else printf("%i\n", A);
  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<vector<int32>> cnt(10, vector<int32>(10,0));
    FOR(i,1,n+1){
        int32 j = i;
        int32 x;
        while(j > 0){
            x = j % 10;
            j /= 10;
        }
        cnt[i%10][x]++;
        // cout << j % 10 << " " << x << endl;
    }
    int64 ans = 0;
    FOR(i,1,10){
        FOR(j,1,10){
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    ANS(ans);
    return 0;
}

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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

template<class T, int SZ> struct BIT
  {
    T bit[SZ+1] ;
    BIT() { memset(bit, 0, sizeof bit) ; }
    void init() { memset(bit, 0, sizeof bit) ; }
    void update(int k, T val)  { for( ; k<=SZ ; k+=(k&-k)) bit[k]+=val ; }
    T getSum(int k)
      {
        T temp=0 ;
        for ( ; k>0 ; k-=(k&-k)) temp+=bit[k] ;
        return temp ;
      }
    T query(int l, int r) { return getSum(r)-getSum(l-1) ; }
  } ;

lli n, x, l=inf, r, m, ans, f1, f2 ;
vlli a, pre(100010) ;
BIT<lli, 200010> tree ;

bool check(lli x)
  {
    f1=0 ;
    f2=(n*(n+1)/4) ;
    tree.init() ;
    pre[0]=n+1 ;
    tree.update(n+1, 1) ;
    for(int i=1 ; i<=n ; i++)
      {
        pre[i]=pre[i-1] ;
        if(a[i]>=x) pre[i]++ ;
        else pre[i]-- ;
      }
    for(int i=1 ; i<=n ; i++)
      {
        f1+=tree.getSum(pre[i]) ;
        tree.update(pre[i], 1) ;
      }
    return f1>=f2 ;
  }

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    cin>> n ;
    a.resize(n+1) ;
    for(int i=1 ; i<=n ; i++) cin>> a[i], l=min(l, a[i]), r=max(r, a[i]) ;
    while(l<=r)
      {
        m=(l+r)/2 ;
        if(check(m)) l=m+1, ans=m ;
        else r=m-1 ;
      }
    cout<< ans ;
  }


Measured memory_bytes: 3328
#include <stdio.h>

int yuk(int, int);

int main(){
  int x,y;

  scanf("%d%d",&x,&y);
  if(y > x) printf("%d\n",yuk(y,x));
  else printf("%d\n",yuk(x,y));

  return 0;
}

int yuk(int x, int y){
  int v;

  v = y;
  y = x % y;
  x = v;

  if(y == 0) return x;
  else return yuk(x,y);
}



Measured memory_bytes: 2144
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n;
    cin>>n;
    int a=n/500;
    int b=n%500;
    int c=b/5;
    int ans=a*1000+c*5;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(); // 文字列

		if (s.indexOf("RRR") != -1) {
			System.out.println(3);
		} else if (s.indexOf("RR") != -1) {
			System.out.println(2);
		} else if (s.indexOf("R") != -1) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    int a, b;
    cin >> a >> b;
    a = a - 1;
    b = b - 1;
    if (b % a == 0)
    {
        cout << b / a << endl;
    }
    else
    {
        cout << b / a + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
template<typename T>inline void rd(T&x){int fl=0,ch;while(ch=getchar(),ch<48||57<ch)fl^=!(ch^45);x=(ch&15);while(ch=getchar(),47<ch&&ch<58)x=x*10+(ch&15);if(fl)x=-x;}
template<typename T>inline void pt(T x){if(x<0)putchar('-'),x=-x;if(x>9)pt(x/10);putchar(x%10+48);}
template<typename T>inline void pt(T x,int ch){pt(x),putchar(ch);}
template<typename T>inline T max(const T&x,const T&y){return x<y?y:x;}
template<typename T>inline T min(const T&x,const T&y){return x<y?x:y;}
const int N=100005;
int n,a[N],s;
signed main(){
	rd(n);
	rep(i,1,n)rd(a[i]),s^=a[i];
	if(s==0)puts("Yes");else puts("No");
	return 0;
}

Measured memory_bytes: 896
#ABC131B - Bite Eating
N, L = list(map(int,input().split()))
a = L
b = L + N-1
taste = 0
for i in range(N):
    taste += L + i
if b < 0:
    print(taste - b)
elif a <= 0 and b >= 0:
    print(taste - 0)
elif a > 0:
    print(taste-a)

Measured memory_bytes: 3060
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left

N=int(input())
Pn=list(map(int, input().split()))
p_min = [10**5 + 7 for i in range(N+1)]

cnt = 1
p_min[0] = Pn[0]
for i in range(1, N):
    p_i = Pn[i]
    p_j = min(p_i, p_min[i-1])
    p_min[i] = p_j
    if p_i <= p_j:
        cnt += 1
print(cnt)

Measured memory_bytes: 25476
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  int score = 0;
  rep(i,N-1){
    if (S[i] == S[i+1]) score++;
  }
  int ans = min(score+2*K, N-1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
 
signed main(){
	int w,h,x,y;
	cin>>w>>h>>x>>y;

	int OK=(w%2==0 && w/2==x)&&(h%2==0 && h/2==y);

	printf("%.9f %d\n",(double)h*w/2,OK);


}


Measured memory_bytes: 256