akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
using namespace std;

int main(){
while(1){
	
	int n=0,d[103] = {0};
	scanf("%d",&n);
	if(n == 0)break;
	n+=1;
	
	for(int i = 1;i <= n;i++){
	scanf("%d",&d[i]);
	}
	
	for(int i = 1;i <= n;i++){ 
	int sa = 0;
	int nau;
	
	if(i == 1){
	sa = d[3] - d[2];
	nau = d[2];
	}else if(i == 2){
	sa = d[4] - d[3];
	nau = d[1];
	}else{
	sa = d[2] - d[1];
	nau = d[1];
	}
	
	
		for(int j = 1;j <= n;j++){
		if(i == j) continue;
		if(d[j] != nau) goto out;
		nau += sa;
		}
		printf("%d\n",d[i]);
		break;
		out:
		;
	}
	}
	return 0;
}


Measured memory_bytes: 1028
#include<iostream>

using namespace std;

const int maxn = 51;
int n, x, a[maxn];
long long dp[maxn][maxn * maxn][maxn], ans;

int main() {
    ios::sync_with_stdio(0);
    cin >> n >> x;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0][a[0]][1] = 1;
    for(int i = 0; i < n; i++) {
        dp[i][0][0] = 1;
    }
    for(int i = 1; i < n; i++) {
        for(int j = 0; j <= maxn * maxn; j++) {
            for(int k = 1; k <= i + 1; k++) {
                dp[i][j][k] += a[i] <= j ? dp[i - 1][j - a[i]][k - 1] + dp[i - 1][j][k] : dp[i - 1][j][k];
            }
        }
    }
    for(int k = 1; k <= n; k++) {
        ans += dp[n - 1][x * k][k];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 51072
#include <stdio.h>

struct nyan {
	int next;
	int diff;
};

/* pos(uf[p].next) = pos(p) + uf[p].diff */
struct nyan uf[100001];

struct nyan find_group(int p) {
	struct nyan res;
	if (uf[p].next == 0) {
		res.next = p;
		res.diff = 0;
	} else {
		struct nyan next = find_group(uf[p].next);
		res.next = next.next;
		res.diff = next.diff + uf[p].diff;
		uf[p] = res;
	}
	return res;
}

int is_same(int a, int b) {
	struct nyan an, bn;
	an = find_group(a);
	bn = find_group(b);
	return an.next == bn.next;
}

/* return pos(b) - pos(a) */
int get_diff(int a, int b) {
	struct nyan an, bn;
	an = find_group(a);
	bn = find_group(b);
	return an.diff - bn.diff;
}

void merge(int a, int b, int diff) {
	struct nyan an, bn;
	an = find_group(a);
	bn = find_group(b);
	uf[an.next].next = bn.next;
	uf[an.next].diff = bn.diff + diff - an.diff;
}

int main(void) {
	int N, M;
	int L, R, D;
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d%d%d", &L, &R, &D) != 3) return 1;
		if (is_same(L, R)) {
			if (get_diff(L, R) != D) {
				puts("No");
				return 0;
			}
		} else {
			merge(L, R, D);
		}
	}
	puts("Yes");
	return 0;
}


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

int main(){
  int N;
  cin >> N;

  int sum = 0;
  
  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;

    int number = r - l + 1;
    sum += number;
  }

  cout << sum << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(b, d) - max(a, c);
    cout << (ans > 0 ? ans : 0) << endl;
}


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

using namespace std;

#define endl '\n'
#define cw(x) cout << (x) << endl
#define cww(x,y) cout << (x) << ' ' << y << endl
#define cwa(x) for(auto a:x) cout << a << ' ';cout << endl
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef unordered_set<int> usi;
typedef vector<pi> vpi;

string js[] = {"AC","WA","TLE","RE"}, c;
int n,cs[4];

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

    for(cin >> n;n--;){
        cin >> c;
        cs[distance(js, find(js,js+4, c))]++;
    }

    for(n=0;n<4;n++) cout << js[n] << " x " << cs[n] << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>

using namespace std;
int n,A[50];

int zentan(int i,int m){
	if(m == 0)return 1;
	if(i >= n)return 0;
	int res = zentan(i + 1,m)||zentan(i+1,m-A[i]);
	return res;
}

int main(){
	int q,M;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin>>A[i];
	}

	cin >> q;
	for(int i = 0;i<q;i++){
		cin >> M;
		if(zentan(0,M)) cout << "yes" <<endl;
		else cout << "no" << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
# B - Frog 2
N,K = map(int,input().split())
h = list(map(int,input().split()))

# 無限大の値
INF = 10**10

# DP テーブル
dp = [0]*(100010)

# DP テーブル全体を初期化
for i in range(100010):
    dp[i] = INF 

# 初期条件
dp[0] = 0

for v in range(1,N):
    for k in range(1,K+1):
        # 遷移元の足場がないとき
        if v-k < 0:
            continue
        # 足場 v-k から足場 v に移動する
        dp[v] = min(dp[v], dp[v-k] + abs(h[v]-h[v-k]))
print(dp[N-1])

Measured memory_bytes: 84744
/* ******* MD Imran Hosen *******
     *******  BSMRSTU  *******
                :)
                (:
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<iterator>
#include<stdio.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main()
{
    long long int n1=0,n=0,a=0,b=0,c=0,i,j=0,k,m=0,m1=0,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,x=0,y=0;
    string s;
    cin>>s;
    n=s.size();
    m=n/2;

    for(i=0,j=n-1;i<m;i++,j--)
    {
        if(s[i]!=s[j])
        {
            a1++;
        }
    }
    cout<<a1<<endl;


    return 0;


}


Measured memory_bytes: 256
from collections import deque

h,w = map(int, input().split())
# 場外を追加
A = [['*']*(w+2)] + [['*']+[s for s in input()]+['*'] for _ in range(h)] + [['*']*(w+2)]
visited = [[0]*(w+2) for _ in range(h+2)]

dq = deque()
n=0
directions = [[0,1],[1,0],[0,-1],[-1,0]]
# 初期配置の黒をキューに追加
for hi in range(1,h+1):
    for wi in range(1,w+1):
        if A[hi][wi] == '#':
            dq.append([hi,wi,n])
            visited[hi][wi] = 1
# キューが空になるまで
while dq:
    hi,wi,n = dq.popleft()

    for d in directions:
        new_hi, new_wi = hi+d[0],wi + d[1]
        # 「黒くしてない白マス」をキューに追加
        if visited[new_hi][new_wi] == 0 and A[new_hi][new_wi] == '.':
            dq.append([new_hi,new_wi,n+1])
            visited[new_hi][new_wi] = 1
print(n)


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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    string s;

    cin >> s;

    l = 0;
    lint maxl = 0;

    rep0(i,3)
    {
        if(s[i] == 'R') l ++;
        else l = 0;

        maxl = max(maxl, l);
    }


    cout << maxl << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main() {
	long long int n,x, a[200005] = {}, result = 0,memo;
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);

	}
	if (a[0] != 0) { printf("-1"); return 0; }
	for (int i = 1; i < n; i++) {
		if(a[i]>a[i-1]+1){ printf("-1"); return 0; }
		if (a[i] == a[i - 1] + 1) { result++; }
		else { result += a[i]; }
	}
	printf("%lld", result);
}


Measured memory_bytes: 1664
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int32_t main(){_
    //freopen("input","r",stdin);
    int r,g;
    cin >> r >> g;
    rc((g * 2) - r);
}


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

ll factorial(ll num)
{
    ll sum = 1;
    for (ll i = 1; i <= num; ++i) {
        sum = sum * i % MOD;
    }
    return sum;
}
int main()
{
    ll N, M;
    cin >> N >> M;
    if (abs(N - M) > 1) {
        cout << 0 << endl;
    } else if (N != M) {
        cout << factorial(N) * factorial(M) % MOD << endl;
    } else {
        cout << 2 * factorial(N) * factorial(M) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int X;
  cin >> X;
  vector<bool> expo(X + 1);
  expo[1] = 1;
  for (int b = 2; b <= X; b++)
  {
    int v = b * b;
    while (v <= X)
    {
      expo[v] = 1;
      v *= b;
    }
  }
  for (int i = X; i >= 1; i--)
    if (expo[i])
    {
      cout << i << endl;
      return 0;
    }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int touyama_nao;
	int suzuki_minori;
	if (scanf("%d", &touyama_nao) != 1) return 1;
	suzuki_minori = (12 * 60) * touyama_nao / 360;
	printf("%d %d\n", suzuki_minori / 60, suzuki_minori % 60);
	return 0;
}



Measured memory_bytes: 2140
# -*- coding: utf-8 -*-
N,T=map(int,raw_input().split())
A=map(int,raw_input().split())

minv=A[0]
interval=0
cnt=0
for i in A[1:]:
    if i < minv:
        minv=i
    if i-minv > interval:
        interval=i-minv
        cnt=1
    elif i-minv == interval:
        cnt=cnt+1
print(cnt)


Measured memory_bytes: 11304
nu = gets.chomp.split("").map(&:to_i)
plus = [0, 0, 0]
count = 0
ans = 0
for i in 0..7
  count = i
  ans = nu[0]
  for j in 0..2
    plus[j] = count % 2
    count /= 2
  end
  for j in 0..2
    if plus[j] == 0
      ans -= nu[j + 1]
    else
      ans += nu[j + 1]
    end
  end
  if ans == 7
    print nu[0]
    if plus[0] == 0
      print "-"
    else
      print "+"
    end
    print nu[1]
    if plus[1] == 0
      print "-"
    else
      print "+"
    end
    print nu[2]
    if plus[2] == 0
      print "-"
    else
      print "+"
    end
    print nu[3]
    print "=7"
    exit
  end
end


Measured memory_bytes: 1788
import sys
input = sys.stdin.buffer.readline

# 足す時はi番目に足し、返すのは累積和
class sumBIT():
    def __init__(self, N):
        self.N = N
        self.bit = [0 for _ in range(self.N+1)]
    
    def __str__(self):
        ret = []
        for i in range(1, self.N+1):
            ret.append(self.__getitem__(i))
        return "[" + ", ".join([str(a) for a in ret]) + "]"

    def __getitem__(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.N:
            self.bit[i] += x
            i += i & -i

N, Q = map(int, input().split())
C = list(map(int, input().split()))
LR = [list(map(int, input().split())) for _ in range(Q)]

Toask = [[] for _ in range(N+1)]
for i, (l, r) in enumerate(LR):
    Toask[l].append((r, i))

bit = sumBIT(N+3)
ans = [-1]*Q

Color = [-1]*(N+1)
for l in reversed(range(1, N+1)):
    c = C[l-1]
    if Color[c] != -1:
        last = Color[c]
        bit.add(last, -1)
    bit.add(l, 1)
    for r, ind in Toask[l]:
        ans[ind] = str(bit[r])
    Color[c] = l

print("\n".join(ans))

Measured memory_bytes: 249752
#include <bits/stdc++.h>
//#pragma comment(linker, "/STACK: 2000000")

using namespace std;

const int N = 1e6 + 5;


long long n , m , now , pro , sol , a[N] , b[N],p[N] ,A[N] , B[N] , AA[N];

int main() {
    cin>>n>>m;

    for(int i = 0;i<n;i++)
    {
        cin>>a[i]>>b[i];
        if(i)B[i]=b[i]+B[i-1];
        else B[i] = b[i];
    }
    p[n-1] = b[n-1];
    for(int i = n-2;i>=0;i--)
    {
        p[i]=p[i+1]+b[i];
    }
    for(int i = 0;i<n;i++)
    {
        pro+=b[i] - (a[i]-now);
        now= a[i];
        sol = max(sol , pro);
    }
    pro = 0;
    now = m;
    for(int i = n-1;i>=0;i--)
    {
        pro+=b[i] - abs(a[i]-now);
        now = a[i];
        sol = max(sol , pro);
    }


    long long pp =0;
    for(int i = n-1;i>=0;i--)
    {
        pp+=b[i];
        A[i] = max(A[i+1] , pp - (m - a[i]) );
    }
    for(int i = 1;i<n;i++)
    {
        AA[i] = max( (i?AA[i-1]:0ll) , B[i] -  a[i] );
    }
    long long ac = 0;

    for(int i = 0;i<n-1;i++)
    {
        sol = max(sol , B[i] - 2*a[i] + A[i+1] );
    }
    ac = 0;
    for(int i = 1;i<n;i++)
    {
        sol = max(sol , (B[n-1] - B[i-1]) - 2*(m-a[i]) + AA[i-1] );
    }

    cout<<sol;
    return 0;
}


Measured memory_bytes: 15360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] get = br.readLine().split(" ");
		int a = Integer.parseInt(get[0]);
		int b = Integer.parseInt(get[1]);
		int c = Integer.parseInt(get[2]);
		int x = Integer.parseInt(get[3]);
		int y = Integer.parseInt(get[4]);

		int money = (int)Math.pow(10, 10);

		money = Math.min((a*x) + (b*y),Math.max(x, y)*2*c);
		int add = 0;

		if(x>y)add = (y*2*c) + ((x-y)*a);
		else add = (x*2*c) + ((y-x)*b);

		money = Math.min(money,add);

		System.out.println(money);
	}

}


Measured memory_bytes: 22740
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 1007, MOD = 1e9 + 7;
int n, m, g[N][N], dp[N][N];

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            char c;
            cin >> c;
            if (c == '.') {
                g[i][j] = 1;
            }
        }
    }
    dp[1][1] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (i == 1 && j == 1) {
                continue;
            }
            if (g[i][j]) {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
    }
    cout << dp[n][m];
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


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

using namespace std;

#define MAXH 10100

int H, n;
vector<int> dmg;
vector<int> cost;
int dp[MAXH];


int solve(int p) {
	if (p <= 0) return 0;
	if (dp[p] != -1) return dp[p];
	dp[p] = INT_MAX;
	for (int i = 0; i < n; i++) {
		dp[p] = min(dp[p], solve(p - dmg[i]) + cost[i]);
	}
	return dp[p];
}

int main() {
	ios::sync_with_stdio(false);
	memset(dp, -1, sizeof(dp));
	cin >> H >> n;
	dmg.resize(n);
	cost.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> dmg[i] >> cost[i];
	}
	cout << solve(H) << endl;
	
	return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<map>
using namespace std;

map<string,int> table;

int main()
{
	string word, frequent, longest;
	size_t N=0;
	
	while(cin>>word){
		table[word]++;
		if(table[word]>N){
			N=table[word];
			frequent=word;
		}
		if(word.size()>longest.size()){
			longest=word;
		}
	}

	cout<<frequent<<" "<<longest<<endl;
	
	return 0;
}

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


const long long MAXVAL = (long long) 1e18 + 1;
const long long MOD = 1000000007;
const int INF = 1000000000 + 1;

long long poww(int x, long long pow) {
  if (pow == 0ll ) return 1;
  if (pow == 1ll) return x % MOD;
  long long ans = poww(x, pow >> 1) % MOD;
  ans = (ans * ans) % MOD;
  if ((pow & 1) == 1) {
    ans = (ans * x ) % MOD;
  }
  return ans % MOD;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q = 1;
  //cin >> q;

  while (q-- >0) {
    int a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if (v == w) cout << "NO\n";
    else {
      if (abs(b - a) > ((v - w) * 1ll * t)) {
        cout << "NO\n";
      } else {
        cout << "YES\n";
      }
    }

  }
  return 0;
}



Measured memory_bytes: 3640
# -*- coding: utf-8 -*-

def main():

	while True:
		x,y = map(int,raw_input().split())
		if x == y == 0:
			break
		if x > y:
			temp = x
			x = y
			y = temp
		print('%d %d' % (x,y))

if __name__ == "__main__":

	main()


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

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

using namespace std;

int main(){
	int a,b,c,d,e,k; cin>>a>>b>>c>>d>>e>>k;
	cout<<(e-a>k?":(":"Yay!")<<endl;

	return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 1e5+1;
int x, y, n, m, p, a[N], b[N], c[N];
long res = 0;

int main()
{
  fastio;
  cin >> x >> y >> n >> m >> p;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) cin >> b[i];
  for (int i = 1; i <= p; i++) cin >> c[i];
  sort(a + 1, a + 1 + n); reverse(a + 1, a + 1 + n);
  sort(b + 1, b + 1 + m); reverse(b + 1, b + 1 + m);
  sort(c + 1, c + 1 + p); reverse(c + 1, c + 1 + p);
  priority_queue <int, vector <int>, greater <int> > Pr;
  for (int i = 1; i <= x; i++){
    Pr.push(a[i]); res += a[i];
  }
  for (int i = 1; i <= y; i++){
    Pr.push(b[i]); res += b[i];
  }
  for (int i = 1; i <= p; i++){
    int cur = Pr.top();
    if (cur > c[i]) break;
    else {
      res -= cur - c[i];
      Pr.pop(); Pr.push(c[i]);
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
bool bn,bw,bs,be;
char s[10001];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for (int i=0;i<len;i++)
	{
		if (s[i]=='N') bn=true;
		if (s[i]=='W') bw=true;
		if (s[i]=='S') bs=true;
		if (s[i]=='E') be=true;
	}
	if (bn==bs&&bw==be) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{
  int n, q,i,z,count=0;
  int left=0,right=0,mid;
  int s[100000], t[50000];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &s[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &t[i]);
  }
  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left < right){
      mid= (left+ right )/2;
      if(s[mid]==t[i]){
	count++;
	break;
      }
      else if(t[i]<s[mid]){
	right = mid;
      }
      else {
	left=mid+1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2316
use proconio::input;
 
fn main() {
  input! {
    n: usize,
    mut vals: [isize;n]
  }
  
  for i in 1..=n {
    vals[i-1] = vals[i-1] - (i as isize);
  }
  vals.sort();
  
  let targets = if n % 2 == 1 {
    vec![vals[n/2]]
  } else {
    vec![vals[n/2]-1, vals[n/2], vals[n/2]+1]
  };
  
  let mut min = isize::max_value();
  for v in targets {
    let mut temp = 0;
    for i in 0..n {
      temp += (vals[i] - v).abs();
    }
    min = std::cmp::min(min, temp);
  }
  
  println!("{}", min);
}

Measured memory_bytes: 6056
#include <stdio.h>

int main(void){

    int time;
    int hour = 0;
    int min = 0;
    int sec = 0;

    scanf("%d", &time);
    if(0<=time && time<86400){
        hour = time/3600;
        time = time - 3600*hour;
        min = time/60;
        time = time - 60*min;
        sec = time;
        printf("%d:%d:%d\n", hour, min, sec );
    }
    else{
        printf("Input should be no less than 0 and less than 86400\n");
    }

    return 0;
}


Measured memory_bytes: 2052
N = int(input())
A = [int(i) for i in input().split()]

c = 0

for i in A:
    if i < 0:
        c += 1

s = [abs(i) for i in A]

if c % 2 == 0:
    print(sum(s))
else:
    print(sum(s)-2*min(s))

Measured memory_bytes: 14412
#include <cstring>
#include <iostream>

using i64 = long long;

const i64 MOD = 1000000007;
const int N = 25000 + 7, K = 400 + 7;

i64 pow(i64 a, i64 k) {
	i64 t = 1;
	for (; k; a = a * a % MOD, k >>= 1)
		if (k & 1) t = t * a % MOD;
	return t;
}

int n, m, k;
int a[N];
int cnt[K];
i64 f[N][K], g[N][K], p[N][K], q[N][K];

void dp(i64 f[N][K], i64 g[N][K]) {
	for (int j = k - 1; j; --j)
		g[0][j] = g[0][j + 1] + f[0][j];
	for (int i = 1; i <= n; ++i)
		for (int j = k - 1; j; --j)
			( f[i][j] = f[i - 1][j - 1] * (k - j + 1) + g[i - 1][j] ) %= MOD,
			( g[i][j] = g[i][j + 1] + f[i][j] ) %= MOD;
}

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d%d%d", &n, &k, &m);
	if (k > n) return printf("0"), 0;
	for (int i = 1; i <= m; ++i) scanf("%d", a + i);
	i64 ans = pow(k, n - m) * (n - m + 1) % MOD;
	if (m >= k) {
		for (int i = 1; i < k; ++i) ++cnt[a[i]];
		for (int i = k, j; i <= m; ++i) {
			++cnt[a[i]], --cnt[a[i - k]];
			for (j = 1; j <= k && cnt[j]; ++j);
			if (j > k) return printf("%lld\n", ans), 0;
		}
	}
	for (int i = 1; i <= m; ++i) ++cnt[a[i]];
	int rep = 0;
	for (int i = 1; i <= k; ++i) rep |= cnt[a[i]] > 1;
	if (rep) {
		int ext = 0;
		memset(cnt, 0, sizeof cnt);
		for (int i = 1; i <= m; ++i) {
			if (cnt[a[i]]++) break;
			++ext;
		}
		f[0][ext] = 1, dp(f, g);
		ext = 0;
		memset(cnt, 0, sizeof cnt);
		for (int i = m; i; --i) {
			if (cnt[a[i]]++) break;
			++ext;
		}
		p[0][ext] = 1, dp(p, q);
		for (int i = 0; i + m <= n; ++i)
			( ans -= g[i][1] * q[n - m - i][1] ) %= MOD;
		return printf("%lld", (ans + MOD) % MOD), 0;
	} else {
		f[0][0] = 1, dp(f, g);
		for (int i = 1; i <= n; ++i) {
			for (int j = k - 1; j; --j)
				( p[i][j] = p[i - 1][j - 1] * (k - j + 1) + q[i - 1][j] ) %= MOD;
			for (int j = m; j <= k; ++j)
				( p[i][j] += f[i][j] ) %= MOD;
			for (int j = k - 1; j; --j)
				( q[i][j] = q[i][j + 1] + p[i][j] ) %= MOD;
		}
		i64 res = q[n][1];
		for (int i = k - m + 1; i <= k; ++i) res = res * pow(i, MOD - 2) % MOD;
		return printf("%lld", (ans - res + MOD * 2) % MOD), 0;
	}
}


Measured memory_bytes: 318336
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod = 1000000007;
//const int mod = 998244353;

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

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

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> frac, ifrac;
    combination(int n):frac(n+1), ifrac(n+1) {
        assert(n < mod);
        frac[0] = 1;
        for (int i = 1; i <= n; ++i) frac[i] = frac[i-1]*i;
        ifrac[n] = frac[n].inv();
        for (int i = n; i >= 1; --i) ifrac[i-1] = ifrac[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return frac[n]*ifrac[k]*ifrac[n-k];
    }
} c(2005);

int main() {
    int n, k;
    cin >> n >> k;

    rep(i, k) {
        int i_ = i+1;
        mint ans;
        ans = c(k-1, i);
        ans *= c(n-k+1, i_);
        cout << ans << '\n';
    }
}

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

int main() {
    int n;
    cin >> n;
    int count_ac=0,count_wa=0,count_tle = 0,count_re=0;
    for(int i=0;i<n;i++){
        string x;
        cin >> x;
        if(x == "AC")
        count_ac++;
        else if(x == "WA")
        count_wa++;
        else if(x == "TLE")
        count_tle++;
        else
        count_re++;
    }
    
    cout << "AC" << " "  << "x" << " " << count_ac  << endl;
    cout << "WA" << " "  << "x" << " " << count_wa  << endl;
    cout << "TLE" << " " << "x" << " " << count_tle << endl;
    cout << "RE" << " "  << "x" << " " << count_re  << endl;

}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int maxn = 300, link = 101, inf = ~0U >> 2;

int a, b, d[11][11], d2[11][11];
int n, m, x[link + 1], y[link + 1];
pair<pair<int, int>, int> edge[1000000];

void AddEdge(int u, int v, int c) {
  edge[m++] = {{u, v}, c};
}

int main(void) {
  scanf("%d%d", &a, &b);
  for (int i = 1; i <= a; ++i) {
    for (int j = 1; j <= b; ++j) {
      scanf("%d", d[i] + j);
    }
  }
  n = 2;
  x[0] = 0;
  for (int i = 1; i <= link; ++i) {
    x[i] = n++;
    AddEdge(x[i - 1], x[i], -1);
  }
  y[0] = 1;
  for (int i = 1; i <= link; ++i) {
    y[i] = n++;
    AddEdge(y[i], y[i - 1], -2);
  }
  for (int i = 1; i <= a; ++i) {
    for (int j = 1; j <= b; ++j) {
      d2[i][j] = inf;
    }
  }
  for (int dx = 0; dx <= link; ++dx) {
    for (int dy = 0; dy <= link; ++dy) {
      int delta = -inf;
      for (int i = 1; i <= a; ++i) {
        for (int j = 1; j <= b; ++j) {
          delta = max(delta, d[i][j] - dx * i - dy * j);
        }
      }
      if (delta >= 0 && delta <= 100) {
        AddEdge(x[dx], y[dy], delta);
        for (int i = 1; i <= a; ++i) {
          for (int j = 1; j <= b; ++j) {
            d2[i][j] = min(d2[i][j], dx * i + dy * j + delta);
          }
        }
      }
    }
  }
  for (int i = 1; i <= a; ++i) {
    for (int j = 1; j <= b; ++j) {
      if (d2[i][j] != d[i][j]) {
        puts("Impossible");
        return 0;
      }
    }
  }
  puts("Possible");
  printf("%d %d\n", n, m);
  for (int i = 0; i < m; ++i) {
    printf("%d %d ", edge[i].first.first + 1, edge[i].first.second + 1);
    if (edge[i].second == -1) {
      puts("X");
    } else if (edge[i].second == -2) {
      puts("Y");
    } else {
      printf("%d\n", edge[i].second);
    }
  }
  puts("1 2");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll              long long int
#define int             int64_t
#define ff              first
#define ss              second
#define pb              push_back
#define mpair           make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define sbits(x)      __builtin_popcountll(x)
#define zbits(x)      __builtin_popcountlliltin_ctzll(x)
#define w(t)            int t;cin>>t;while(t--)
#define uset            unordered_set
#define en              cout<<endl
using namespace std;
void fast(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout<<fixed<<setprecision(10);}
int max2(int a,int b){ if(a>b) return a;return b;}
int min2(int a,int b){ if(a<b)return a;return b;}
int max3(int a,int b,int c){ return max2(a,max2(b,c));}
int min3(int a,int b,int c){ return min2(a,min2(b,c));}
void system_output(){
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
}
void solve(){
      int P;
      cin>>P;
      double r = 1.01;
      int count=0;
      int A = 100;
      while(A<P){
        count++;
         A = A*r;
      }
      cout<<count<<endl;    
}
signed main(void)
{
      fast();
    //  w(t)
      solve();

}


Measured memory_bytes: 3652
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

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

func getMin(x ...int) int {
	min := math.MaxInt64
	for i := 0; i < len(x); i++ {
		if x[i] < min {
			min = x[i]
		}
	}
	return min
}

func getMax(x ...int) int {
	max := math.MinInt64
	for i := 0; i < len(x); i++ {
		if x[i] > max {
			max = x[i]
		}
	}
	return max
}

func pow(x, pow int) int {
	ans := x
	for i := 1; i < pow; i++ {
		ans = ans * x
	}
	return ans
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)

	t := nextString()

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	for i := 0; i < len(t); i++ {
		if t[i] == '?' {
			fmt.Fprintf(w, "%c", 'D')
		} else {
			fmt.Fprintf(w, "%c", t[i])
		}
	}

	fmt.Fprintln(w, "")
}


Measured memory_bytes: 2488
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:],i8)", cache=True)
def binary_search(a, key):
    """Meguru type binary search"""
    ng = -1
    ok = len(a)

    def is_ok(a, key, idx):
        if key <= a[idx]:
            return True
        else:
            return False

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(a, key, mid):
            ok = mid
        else:
            ng = mid

    return ok


@nb.njit("i8[:](i8,i8[:],i8[:],i8[:])", cache=True)
def solve(Q, S, T, X):
    ans = np.zeros(shape=Q, dtype=np.int64)
    INF = 10 ** 11
    for q, x in enumerate(X):
        min_dist = INF
        # x --> s --> t
        i = binary_search(S, x)
        if 0 < i:
            l_s = S[i - 1]
            dist_s = abs(x - l_s)
            j = binary_search(T, l_s)
            l_t, r_t = T[j - 1], T[j]
            dist_t = min(abs(l_s - l_t), abs(r_t - l_s)) if 0 < j else abs(r_t - l_s)
            min_dist = min(min_dist, dist_s + dist_t)
        r_s = S[i]
        dist_s = abs(r_s - x)
        j = binary_search(T, r_s)
        l_t, r_t = T[j - 1], T[j]
        dist_t = min(abs(r_s - l_t), abs(r_t - r_s)) if 0 < j else abs(r_t - r_s)
        min_dist = min(min_dist, dist_s + dist_t)

        # x --> t --> s
        i = binary_search(T, x)
        if 0 < i:
            l_t = T[i - 1]
            dist_t = abs(l_t - x)
            j = binary_search(S, l_t)
            l_s, r_s = S[j - 1], S[j]
            dist_s = min(abs(l_t - l_s), abs(r_s - l_t)) if 0 < j else abs(r_s - l_t)
            min_dist = min(min_dist, dist_s + dist_t)
        r_t = T[i]
        dist_t = abs(r_t - x)
        j = binary_search(S, r_t)
        l_s, r_s = S[j - 1], S[j]
        dist_s = min(abs(r_t - l_s), abs(r_s - r_t)) if 0 < j else abs(r_s - r_t)
        min_dist = min(min_dist, dist_s + dist_t)

        ans[q] = min_dist
    return ans


def main():
    A, B, Q = map(int, input().split())
    S = np.zeros(shape=A, dtype=np.int64)
    T = np.zeros(shape=B, dtype=np.int64)
    X = np.zeros(shape=Q, dtype=np.int64)
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    for i in range(Q):
        X[i] = int(input())

    ans = solve(Q, S, T, X)
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 118492
N = int(input())
n = N if N % 2 == 0 else N-1
M = (n-2) * n // 2
if N % 2 == 1:
    M += n
print(M)
for i in range(1, N):
    for j in range(i+1, n+1):
        if i+j == n+1:
            continue
        else:
            print(str(i) + ' ' + str(j))
if N % 2 == 1:
    for i in range(1, N):
        print(str(i) + ' ' + str(N))

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

bool isOK(int index, int key, const vector<int> &v) {
    if (v.at(index) < key) return true;
    else return false;
}

int binary_search(int key, const vector<int> &v) {
    int ng = -1;
    int ok = (int)v.size();

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

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    vector<int> color;
    for (int i = 0; i < n; i++) {
        int index = binary_search(a.at(i), color);
        
        if (index == (int)color.size()) color.push_back(a.at(i));
        else color.at(index) = a.at(i);
    }

    cout << color.size() << endl;
}   

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

int main(){
  int k;
  cin >>k;
  string s;
  cin >>s;
  if(s.size()<=k) cout << s<<endl;
  else {
    for(int i=0;i<k;i++){
      cout <<s[i] ;
    }
    cout <<"..." <<endl;
  }
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>

void dfs(std::vector<std::vector<char>> &vector, const int &x, const int &y, const char type) {
	if (0 <= y && vector.size() > y && vector.at(y).at(x) == type) {
		vector.at(y).at(x) = '\0';
		for (const auto &p : { std::make_pair(x + 1, y), std::make_pair(x - 1, y), std::make_pair(x, y + 1), std::make_pair(x, y - 1) }) {
			dfs(vector, p.first, p.second, type);
		}
	}
}
int main() {
	int h, w;
	while (std::cin >> h >> w && h != 0 && w != 0) {
		std::vector<std::vector<char>> vector(h, std::vector<char>(w + 2, '\0'));
		char *arg = new char[w + 2];
		for (auto i = 0; i < h; ++i) {
			std::cin >> arg;
			for (auto j = 0; j < w; ++j) {
				vector.at(i).at(j + 1) = arg[j];
			}
		}
		delete[] arg;
		int count = 0;
		for (auto y = 0; y < h; ++y) {
			for (auto x = 1; x <= w; ++x) {
				if (vector.at(y).at(x) != '\0') {
					++count;
					dfs(vector, x, y, vector.at(y).at(x));
				}
			}
		}
		std::cout << count << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3900
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const long long SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


priority_queue<long long>p;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<long long>v(a), vv(b), vvv(c), ans;
	for (int i = 0; i < a; ++i) { cin >> v[i]; }
	for (int i = 0; i < b; ++i) { cin >> vv[i]; }
	for (int i = 0; i < c; ++i) { cin >> vvv[i]; }

	sort(all(v));
	sort(all(vv));
	sort(all(vvv));
	reverse(all(v));
	reverse(all(vv));
	reverse(all(vvv));

	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			for (int k = 0; k < c; ++k) {
				if ((i + 1)*(j + 1)*(k + 1) <= d) { ans.push_back(v[i] + vv[j] + vvv[k]); }
				else { break; }
			}
		}
	}
	sort(all(ans)); reverse(all(ans));
	for (int i = 0; i < d; ++i) { cout << ans[i] << endl; }
}

Measured memory_bytes: 1404
N = int(input())
val = [int(i) for i in input().split()]
dif = []
for i in range(N-1):
    if val[i+1] - val[i] <= 0 :
        dif.append(1)
    else:
        dif.append(0)
ans = 0
a = 0
for i in range(N-1):
    if dif[i] == 1 :
        a += 1
    if dif[i] == 0 :
        a = 0
    ans = max(a,ans)
print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;


ll cnt_p(vector<ll> &v, ll num) {
	//nv:greater,pv:lesser
	int n = v.size();



	int i = 0;
	int j = n - 1;
	ll cnt = 0;
	while (i < j) {
		if (v[i] * v[j] <= num) {


			cnt += j - i;
			i++;


		}
		else {
			j--;
		}
	}

	//cout << cnt << " ";
	return cnt;
}
ll cnt_n(vector<ll> &nv, vector<ll> &pv, ll num) {
	//nv:greater,pv:lesser
	int n_nv = nv.size();
	int n_pv = pv.size();


	int i_nv = 0;
	int i_pv = n_pv - 1;
	ll cnt = 0;
	while (i_nv < n_nv) {
		if (nv[i_nv] * pv[i_pv] <= num) {
			if (i_pv > 0) {
				i_pv--;
			}
			else {
				cnt += n_pv;
				i_nv++;
			}
		}
		else {
			cnt += (n_pv - i_pv) - 1;
			i_nv++;
		}

	}

	return cnt;

}

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


	sort(a.begin(), a.end());


	vector<vector<ll>> b(3);


	for (int i = 0; i < n;i++) {
		if (a[i] < 0) {

			b[0].emplace_back(a[i]);
		}
		else if (a[i] == 0) {
			b[1].emplace_back(a[i]);
		}
		else {
			b[2].emplace_back(a[i]);
		}


	}


	ll k_m = b[0].size()*b[2].size();
	ll k_0 = k_m + 1LL * ((2 * n - b[1].size() - 1) * b[1].size()) / 2;

	sort(b[0].begin(), b[0].end(), greater<ll>());
	if (k <= k_m) {
		if (cnt_n(b[0], b[2], -BIG_NUM) >= k) {
			cout << -BIG_NUM << endl;
		}
		else {

			ll l = -BIG_NUM;
			ll r = 0;
			ll mid = (l + r) / 2;
			while (r > mid) {
				if (cnt_n(b[0], b[2], mid) < k) {
					l = mid;
				}
				else {
					r = mid;
				}

				mid = (r + l) / 2;

			}

			cout << mid << endl;
		}

	}
	else if (k <= k_0) {
		cout << 0 << endl;
	}
	else {

		if (cnt_p(b[0], BIG_NUM-1) + cnt_p(b[2], BIG_NUM-1) < k -k_0) {
			cout << BIG_NUM << endl;
		}
		else {

			ll r = BIG_NUM;
			ll l = 0;
			ll mid = (l + r) / 2;
			while (l < mid) {
				//cout << mid << endl;
				if (cnt_p(b[0], mid) + cnt_p(b[2], mid) < k - k_0) {
					l = mid;
				}
				else {
					r = mid;
				}

				mid = (r + l) / 2;

			}

			cout << mid + 1 << endl;
		}

	}
}



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

using namespace std;

int main() {
  int W, a, b;
  cin >> W >> a >> b;

  int ar = a + W;
  int br = b + W;
  if (ar < b) {
    cout << b - ar << endl;
  } else if (br < a) {
    cout << a - br << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

bool isPalindrome(int n){
  int rev = 0 , temp , digit;
  temp = n ;

  while(temp){
    digit = temp%10 ;
    rev = (rev*10) + digit ;
    temp/=10 ;
  }

  if(rev == n) return true ;
  return  false ;
}

int main() {
  int a , b , count = 0 ;
  scanf("%d %d", &a, &b) ;

  for(int i = a ; i<=b ; i++)
    count+=isPalindrome(i) ;

  cout << count << endl ;

	
  return 0 ;
}

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

int main() {
    ll h,w;
    cin >> h >> w;
    vector<string> grid(h);
    for (ll i = 0; i < h;i++)
        cin >> grid[i];
    queue<pair<ll, ll>> cue;
    cue.push({0, 0});
    vector<vector<ll>> dist(h, vector<ll>(w, -1));
    dist[0][0] = 0;
    ll cnt = 0;
    for (ll i = 0; i < h; i++)
    {
        for (ll j = 0; j < w;j++){
            if(grid[i][j]=='#')
                cnt++;
        }
    }

        ll dx[4] = {1, -1, 0, 0};
    ll dy[4] = {0, 0, 1, -1};
    while(cue.size()){
        ll y = cue.front().first;
        ll x = cue.front().second;
        cue.pop();
        for (ll i = 0; i < 4;i++){
            ll newy = y + dy[i];
            ll newx = x + dx[i];
            if(newx>=w||newy>=h||newx<0||newy<0)
                continue;
            if(grid[newy][newx]=='#')
                continue;
            if (dist[newy][newx]!=-1)
                continue;
            dist[newy][newx] = dist[y][x] + 1;
            cue.push({newy, newx});
        }
    }

if(dist[h-1][w-1]==-1)
    cout << "-1" << endl;
else
    cout << (h * w - (dist[h - 1][w - 1] + 1) - cnt) << endl;
}


Measured memory_bytes: 256
// 

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  int a[105];
  int al = 0, bo = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  for(int i = 0; i < n; i++){
    if(i % 2 == 0) al += a[i];
    else bo += a[i];
  }
  cout << al - bo << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

#include <bits/stdc++.h>
 
using namespace std;

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

typedef long long ll;
typedef long double ld;

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll res = 0;
    if(n & 1){
        res = b[n >> 1] - a[n >> 1] + 1;
    }
    else{
        ll r = b[n >> 1] + b[(n >> 1) - 1];
        ll l = a[n >> 1] + a[(n >> 1) - 1];
        res = r - l + 1;
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

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

int main() {
  int N, M, n;
  long total = 0;
  priority_queue<int> A;
  cin >> N >> M;

  for (int i = 0; i < N; i++){
    cin >> n;
    A.push(n);
  }

  for (int i = 0; i < M; i++){
    A.push(A.top() / 2);
    A.pop();
  }

  while (!A.empty()){
    total += A.top();
    A.pop();
  }

  cout << total << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <queue>
using i64 = long long;
using P = std::pair<i64, int>;

int main() {
    constexpr i64 inf = std::numeric_limits<i64>::max();
    int n;
    std::cin >> n;
    std::vector<std::pair<std::string, i64>> v;
    for (int i = 0; i < n; i++) {
        std::string s;
        i64 c;
        std::cin >> s >> c;
        v.emplace_back(s, c);
    }

    std::vector<int> ss { 0 };
    for (const auto &e : v) ss.push_back(ss.back() + e.first.size());

    const int slen = ss.back(), s = 2 * slen, t = s + 1;
    std::vector<std::vector<std::pair<int, i64>>> g(t + 1);
    std::vector<i64> dist(t + 1, inf);
    dist[s] = 0;

    for (int i = 0; i < n; i++) {
        std::string_view si = v[i].first;
        const int ilen = si.size();
        g[s].emplace_back(ss[i], v[i].second);
        g[s].emplace_back(slen + ss[i], v[i].second);

        for (int j = 0; j < n; j++) {
            const std::string_view sj = v[j].first;
            const int jlen = sj.size();
            const i64 cost = v[j].second;

            for (int l = 0; l < ilen; l++) {
                // i: prefix, j: suffix
                int p = 0;
                while (l + p < ilen && p < jlen && si[l + p] == sj[jlen - 1 - p]) p++;
                bool lf = l + p == ilen, rf = p == jlen;
                if (lf && rf) g[ss[i] + l].emplace_back(t, cost);
                else if (lf) g[ss[i] + l].emplace_back(slen + ss[j] + p, cost);
                else if (rf) g[ss[i] + l].emplace_back(ss[i] + l + p, cost);

                // i: suffix, j: prefix
                p = 0;
                while (l + p < ilen && p < jlen && si[ilen - 1 - l - p] == sj[p]) p++;
                lf = l + p == ilen, rf = p == jlen;
                if (lf && rf) g[slen + ss[i] + l].emplace_back(t, cost);
                else if (lf) g[slen + ss[i] + l].emplace_back(ss[j] + p, cost);
                else if (rf) g[slen + ss[i] + l].emplace_back(slen + ss[i] + l + p, cost);
            }
        }
    }

    std::priority_queue<P, std::vector<P>, std::greater<>> q;
    q.emplace(0, s);
    while (!q.empty()) {
        const auto [d, v] = q.top();
        q.pop();
        if (dist[v] < d) continue;
        for (const auto [to, cost] : g[v]) {
            const i64 nd = d + cost;
            if (dist[to] <= nd) continue;
            dist[to] = nd;
            q.emplace(nd, to);
        }
    }

    auto judge = [](std::string_view s) {
        const int len = s.size();
        for (int i = 0; i < len; i++) if (s[i] != s[len - 1 - i]) return false;
        return true;
    };

    i64 ret = dist[t];
    for (int i = 0; i < n; i++) {
        const std::string_view s = v[i].first;
        const int len = s.size();
        for (int j = 0; j < len; j++) {
            // prefix
            if (judge(s.substr(j)) && ret > dist[ss[i] + j]) ret = dist[ss[i] + j];
            // suffix
            if (judge(s.substr(0, len - j)) && ret > dist[slen + ss[i] + j]) ret = dist[slen + ss[i] + j];
        }
    }

    std::cout << (ret == inf ? -1 : ret) << std::endl;

    return 0;
}


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


struct node{
    int value=-1;
    vector<int> neighbor;
};

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

    int n;
    cin >> n;
    node tree[100001];

    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        tree[a].neighbor.push_back(b);
        tree[b].neighbor.push_back(a);
    }
    vector<int> c;
    for(int i=0;i<n;i++){
        int c_;
        cin >> c_;
        c.push_back(c_);
    }
    sort(c.rbegin(), c.rend());
    int64_t sum = -c[0];
    int addr=0;

    int st = 1;
    if(tree[st].neighbor.size()==1) st=tree[st].neighbor[0];
    queue<int> q;
    static bool used[100001];
    used[st] = true;
    q.push(st);
    while(!q.empty()){
        int t = q.front();
        q.pop();
        tree[t].value = c[addr];
        sum += c[addr];
        addr++;
        for(int nei : tree[t].neighbor){
            if(used[nei]) continue;
            used[nei] = true;
            q.push(nei);
        }        
    }

    cout << sum << endl;
    for(int i=1;i<=n;i++) cout << tree[i].value << " \n"[i==n];
    return 0;
}

Measured memory_bytes: 3968