akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <unordered_map>
using namespace std;
int fib(int);
unordered_map<int, int> memoFib;

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

int fib(int n) {
  if(memoFib.count(n)) return memoFib[n];
  int a;
  a = memoFib[n] = n == 0 || n == 1 ? 1 : fib(n - 1) + fib(n - 2);
  return a;
}

Measured memory_bytes: 1208
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while (true) {
			int m = scanner.nextInt();
			int f = scanner.nextInt();
			int r = scanner.nextInt();
			
			if (m == -1 && f == -1 && r == -1)
				break;
			
			char grade = 'F';
			
			if (m < 0 || f < 0) {
				grade = 'F';
			} else if (m + f >= 80) {
				grade = 'A';
			} else if (m + f >= 65) {
				grade = 'B';
			} else if (m + f >= 50) {
				grade = 'C';
			} else if (m + f >= 30) {
				if (r < 50) {
					grade = 'D';
				} else {
					grade = 'C';
				}
			} else {
				grade = 'F';
			}
			
			System.out.println(grade);
		}

	}

}



Measured memory_bytes: 26072
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 3e18 + 7;

signed main()
{
	IO_OP;
	
	int n, a, b;
	cin >> n >> a >> b;
	if((b-a)%2 == 0) cout << (b-a) / 2 << endl;
	else {
		int ans = INF;
		ans = min(ans, (b-a-1)/2+a);
		int aa = a, bb = b;
		a = n+1 - bb, b = n + 1 - aa;
		ans = min(ans, (b-a-1)/2+a);
		cout << ans << endl;
	}

}





Measured memory_bytes: 256
N,K = map(int,input().split())
A = list(map(int,input().split()))
pos = 0
visit = [0] * N
move = []
roop = []
while visit[pos]!=2:
    if visit[pos]==0:
        move.append(pos)
    else:
        roop.append(pos)
    visit[pos] += 1
    pos = A[pos] - 1
if len(move)>K:
    print(move[K]+1)
else:
    print(roop[(K-(len(move)-len(roop)))%len(roop)]+1)


Measured memory_bytes: 32840
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

class BIT():
    # A1 ... AnのBIT(1-indexed)
    def __init__(self, n):
        self.n = n
        self.BIT = [0] * (n + 2)

    # A1 ~ Aiまでの和 O(logN)
    def query(self, idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx & (-idx)
        return res_sum

    # Ai += x O(logN)
    def update(self, idx, x):
        # print(idx)
        while idx <= self.n:
            # print(idx)
            self.BIT[idx] += x
            idx += idx & (-idx)
        return

    def show(self):
        print(self.BIT)


def solve():
    n, k = getList()
    lis = [0] + getList()
    for i in range(n):
        lis[i+1] += lis[i]

    ka = []
    for i in range(n):
        for j in range(i+1, n+1):
            ka.append(lis[j]-lis[i])

    ans = 0
    for rui in range(50, -1, -1):
        ok = []
        tgt = pow(2, rui)
        for kaka in ka:
            if kaka & tgt == tgt:
                ok.append(kaka)
        if len(ok) >= k:
            ans += tgt
            ka = ok

    print(ans)





def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

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

int main() {
	int64_t n;
	cin >> n;
	int64_t a[n];
	for (auto &i : a) {
		cin >> i;
	}
	auto sum = accumulate(a, a + n, int64_t(0));
	if (sum % (n * (n + 1) / 2)) {
		cout << "NO" << endl;
		return 0;
	}
	int64_t k = sum / (n * (n + 1) / 2), d[n];
	for (int i = 0; i < n; i++) {
		d[i] = a[(i + 1) % n] - a[i];
	}
	for (auto &i : d) {
		if (k < i || (i - k) % n) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int A, B;
  cin >> A >> B;

  cout << std::max({(A + B), A + A - 1, B + B - 1}) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INF 1000000009

int N, M;
int D[1000];
int C[1000];

int memo[1024][1024];

int search(int pos, int day) {
	int ret = INF;
	int idousuru, idousinai;
	if (pos >= N) return 0;
	if (day >= M) return INF;
	if (memo[pos][day] > 0) return memo[pos][day] - 1;
	idousuru = search(pos + 1, day + 1) + D[pos] * C[day];
	idousinai = search(pos, day + 1);
	if (idousuru <= idousinai) {
		ret = idousuru;
	} else {
		ret = idousinai;
	}
	memo[pos][day] = ret + 1;
	return ret;
}

int main(void) {
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &D[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		if (scanf("%d", &C[i]) != 1) return 1;
	}
	printf("%d\n", search(0, 0));
	return 0;
}

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

const int MAXN = 5005;
int t[2][3], n, g, s, b;
long long dp[MAXN * MAXN];

int main() {
	cin >> n;
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 3; j++)
			cin >> t[i][j];
	dp[0] = 0;
	for (int i = 1; i < MAXN; i++) {
		if (i >= t[0][0])
			dp[i] = max(dp[i], dp[i - t[0][0]] + t[1][0]);
		if (i >= t[0][1])
			dp[i] = max(dp[i], dp[i - t[0][1]] + t[1][1]);
		if (i >= t[0][2])
			dp[i] = max(dp[i], dp[i - t[0][2]] + t[1][2]);
		dp[i] = max(dp[i], dp[i - 1] + 1);
	}
	int k = dp[n];
	fill_n(dp, MAXN * MAXN, 0);
	swap(t[0], t[1]);
	for (int i = 1; i < MAXN * MAXN; i++) {
		if (i >= t[0][0])
			dp[i] = max(dp[i], dp[i - t[0][0]] + t[1][0]);
		if (i >= t[0][1])
			dp[i] = max(dp[i], dp[i - t[0][1]] + t[1][1]);
		if (i >= t[0][2])
			dp[i] = max(dp[i], dp[i - t[0][2]] + t[1][2]);
		dp[i] = max(dp[i], dp[i - 1] + 1);
	}
	cout << dp[k];
}

Measured memory_bytes: 195968
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n,W,totalval=0;
  cin>>n>>W;
  vector<ll> w(n),v(n);
  forn(i,0,n){
    cin>>w[i]>>v[i];
    totalval+=v[i];
  }
  const ll INF = 1e15;
  vector<ll> dp(totalval+1,INF), old_dp(totalval+1,INF);
  dp[0]=0; old_dp[0]=0;
  forn(i,0,n){
    forn(val,0,totalval+1){
      ll q1=INF,q2=INF;
      if(val-v[i]>=0)
        q1 = old_dp[val-v[i]]+w[i];
      q2 = old_dp[val];
      dp[val] = min(q1,q2);
    }
    old_dp=dp;
  }
  ll ans=0;
  forn_d(i,totalval,0){
    if(dp[i]<=W){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if (u == s) a--; else b--;
	cout << a << ' ' << b << '\n';
}



Measured memory_bytes: 256
# Edit: 2014/11/15
# Lang: Python3
# Time: 00.xxs

# File: pc0021.py


if __name__ == "__main__":

    nset = int(input())

    for i in range(0, nset):

        x1, y1, x2, y2, x3, y3, x4, y4 = list(map(float, input().strip("\n").split(" ")))
        vABx = x2 - x1
        vABy = y2 - y1
        vCDx = x4 - x3
        vCDy = y4 - y3

        #mx = vCDx / vABx
        #my = vCDy / vABy

        #if abs(mx - my) < 1e-10:
        if abs(vABx*vCDy - vCDx*vABy) < 1e-10:
            print("YES")
        else:
            print("NO")
        #print(mx-my)

#

Measured memory_bytes: 6748
num = int(input())
words = []
while True:
    try:
        word = input()
        words.append(word)
    except EOFError:
        break

operation_num = 0

for i in range(len(words[0])):
    frequency = {}
    for word in words:
        frequency.setdefault(word[i], 0)
        frequency[word[i]] += 1
    if len(frequency) > 1:
        most_frequent_count = sorted(frequency.items(), key=lambda x : x[1])[-1][1]
        operation_num += len(words) - most_frequent_count

print(operation_num)

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

int main(){
	int n,k;
	string s;
	cin>>n>>s>>k;
	char c2r = s[k-1];
	for(int i=0;i<n;i++){
		if(s[i] != c2r){
			s[i] = '*';
		}
	}
	cout<<s<<"\n";
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

constexpr ll INF = TEN(18);

int main() {
    int N, K;
    cin >> N >> K;
    V<int> P(N), C(N);
    rep(i, N) cin >> P[i], --P[i];
    rep(i, N) cin >> C[i];

    ll ans = -INF;

    rep(i, N) {
        int v = i;
        ll cycle_sum = 0;
        int cycle_cnt = 0;

        while (true) {
            cycle_cnt++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i) break;
        }

        ll path = 0;
        int cnt = 0;
		v = i ;
        while (true) {
            cnt++;
            path += C[v];

            if (cnt > K) break;

            int num = (K - cnt) / cycle_cnt;
            ll score = path + max(0ll, cycle_sum) * num;
            chmax(ans, score);

            v = P[v];
            if (v == i) break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3680
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int n = in.nextInt();
		
		int left = in.nextInt();
		int center = in.nextInt();
		int ans = 0;
		for(int i=2; i<n; i++) {
			int right = in.nextInt();
			if(Math.min(left, Math.min(center, right))!=center && Math.max(left,  Math.max(center, right))!=center) {
				ans++;
			}
			left = center;
			center = right;
		}
		System.out.println(ans);
		
		
		in.close();
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 1111111


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

  cin >> n;
  cin >> s;
  s = " " + s;
  ll q;
  cin >> q;
  while (q--) {
    cin >> m;
    cnt = 0; ans = 0;
    ll a = 0, b = 0;
    FOR(i, 1, n + 1) {
      if (i > m) {
        if (s[i - m] == 'D') {
          cnt -= b; a--;
        }
        if (s[i - m] == 'M') b--;
      }

      if (s[i] == 'D') {
        a++;
      }
      if (s[i] == 'M') {
        b++;
        cnt += a;
      }
      if (s[i] == 'C') {
        ans += cnt;
      }
    }
    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 2332
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vi d(N);
    REP(i, N) cin >> d[i];

    sort(ALL(d));

    print(d[N/2] - d[N/2 - 1]);
    
}


Measured memory_bytes: 3728
# 第6回 ドワンゴからの挑戦状 予選: A – Falling Asleep
N = int(input())
s, t = [], []
for _ in range(N):
    tmp = input().split()
    s.append(tmp[0])
    t.append(int(tmp[1]))
X = input()

idx = s.index(X)
print(sum(t[idx + 1:]))

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

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


ll gcd(ll a, ll b) {
    ll r = a % b;
    while(r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}




int main() {

    int k; cin >> k;
    int ans = 0;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            for (int c = 1; c <= k; ++c) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }
    out(ans);


    return 0;
}






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

int A[100009];

int main() {
  int N, ans = 0; scanf("%d", &N);
  for(int i=1; i<=N; i++) scanf("%d",&A[i]);
  for(int i=1; i<=N; i++) if(A[i] == i) ++ans, ++i;
  printf("%d",ans);
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();
            if (S[0] == S[1] && S[1] == S[2])
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }

        }
        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int main()
{
  int a, b, num, lank;

  while (scanf("%d %d", &a, &b) > 0) {
    num = a + b;
    lank = 1;
    while (num /= 10) {
      lank++;
    }
    printf("%d\n", lank);
  }

  return 0;
}

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

#define rep(i, n)     for (int i = 0; i < n; ++i)
#define rep1(i, n)    for (int i = 1; i < n + 1; ++i)
#define repN(i, m, n) for (int i = m; i < n; ++i)
#define repR(i, n)    for (int i = n - 1; i >= 0; --i)

using namespace std;

int main() {
	string s, t;
	int max = 0;
	cin >> s >> t;

	rep(i, s.length() - t.length() + 1) {
		int l  = 0;
		int ti = i;
		rep(j, t.length()) {
			if (s[ti] == t[j]) {
				++l;
			}
			++ti;
		}
		if (max < l) {
			max = l;
		}
	}

	cout << t.length() - max;

	return 0;
}


Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)
	D := make([][2]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d%d", &D[i][0], &D[i][1])
	}
	for i := 0; i < N-2; i++ {
		if D[i][0] == D[i][1] && D[i+1][0] == D[i+1][1] && D[i+2][0] == D[i+2][1] {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
	return
}


Measured memory_bytes: 1840
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(int x){write(x);putchar('\n');}
const int MAXN=200005;
const int mod=1e9+7;
int pow_mod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)ret=1LL*ret*a%mod;
		a=1LL*a*a%mod;b>>=1;
	}
	return ret;
}
int pre[MAXN],inv[MAXN],bin[MAXN],invb[MAXN];
int C(int n,int m){return 1LL*pre[n]*inv[m]%mod*inv[n-m]%mod;}
int B,W;
int ans;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
void dl(int &x,int y){x-=y;if(x<0)x+=mod;}
int main()
{
	bin[0]=1;for(int i=1;i<MAXN;i++)bin[i]=1LL*bin[i-1]*2%mod;
	invb[MAXN-1]=pow_mod(bin[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)invb[i]=1LL*invb[i+1]*2%mod;
	pre[0]=1;for(int i=1;i<MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN-1]=pow_mod(pre[MAXN-1],mod-2);
	for(int i=MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	B=read();W=read();
	if(B==1)
	{
		for(int i=1;i<B+W;i++)pr2(pow_mod(pow_mod(2,i),mod-2));
		pr2(pow_mod(pow_mod(2,W),mod-2));
		return 0;
	}
	if(W==1)
	{
		for(int i=1;i<B+W;i++)pr2((1-pow_mod(pow_mod(2,i),mod-2)+mod)%mod);
		pr2((1-pow_mod(pow_mod(2,B),mod-2)+mod)%mod);
		return 0;
	}
	for(int i=1;i<=W;i++)ad(ans,1LL*C(B+W-i-2,W-i)*invb[B+W-i]%mod);
	for(int i=1;i<B;i++)ad(ans,1LL*C(B+W-i-2,W-1)*invb[B+W-i]%mod);
	pr2(ans);
	for(int i=2;i<=B+W;i++)
	{
		int ps=B+W-i+1;
 		if(ps<=W+1)
 		{
 			dl(ans,1LL*C(i-2,W-ps)*invb[i-1]%mod);
 			if(ps-1)dl(ans,1LL*C(B+W-(ps-1)-2,W-(ps-1))*invb[B+W-(ps-1)]%mod);
			if(ps-1)ad(ans,1LL*C(i-1,W-ps+1)*invb[i]%mod);
 		}
		if(ps==B)
		{
			dl(ans,1LL*C(B+W-(B-1)-2,W-1)*invb[B+W-(B-1)]%mod);
			ad(ans,invb[i-1]);
		}
		if(ps<B)
		{
			if(ps-1)dl(ans,1LL*C(B+W-(ps-1)-2,W-1)*invb[B+W-(ps-1)]%mod);
			ad(ans,1LL*invb[i-1]*C(i-2,W-1)%mod);
		}
		pr2(ans);
	}
	return 0;
}

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

void countingSort( vector<int>& a, vector<int>& b, int k ) {
	int n = (int)a.size() - 1;

	vector<int> c( k+1 );
	for( int i = 1; i <= n; ++i ) {
		c[a[i]] += 1;
	}

	for( int i = 1; i <= k; ++i ) {
		c[i] = c[i] + c[i-1];
	}

	for( int i = n; i > 0; --i ) {
		b[c[a[i]]] = a[i];
		c[a[i]] -= 1;
	}
}

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;

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

	vector<int> b( n+1 );
	countingSort( a, b, 10000 );

	for( int i = 1; i < b.size(); ++i ) {
		cout << b[i] << "\n "[i < b.size()-1];
	}

	return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> arr(N);
  for (int i = 0; i < N; i++) cin >> arr[i];
  sort(arr.begin(),arr.end());
  int alice = 0;
  int bob = 0;
  int cnt = 0;
  for (int i =N-1; i >= 0; i--) {
    if (cnt % 2 == 0) alice += arr[i];
    else bob += arr[i];
    cnt++;
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;

ll xs[] = {-1, 1, 0, 0};
ll ys[] = {0, 0, -1, 1};

ll recur(ll x){
	if(x == 1)
		return 1;
	return 1 + 2*recur(x/2);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t;
	cin >> t;
	cout << recur(t);
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
std::vector<int>V[100010];
bool judge[100010];
int dp[100010][2];
std::vector<int>G[100010];
int solve(int now,int color){
    if(dp[now][color]!=-1)return dp[now][color];
    int res=1;
    if(color){
        for(auto x:G[now]){
            res*=solve(x,0);
            res%=mod;
        }
    }
    else{
        for(auto x:G[now]){
            res*=(solve(x,0)+solve(x,1));
            res%=mod;
        }
    }
    return dp[now][color]=res;
}
signed main(void){
    rep(i,100010)rep(j,2)dp[i][j]=-1;
    int n;cin>>n;
    int fr,to;
    rep(i,100010)judge[i]=false;
    rep(i,n-1){
        cin>>fr>>to;fr--;to--;
        V[fr].push_back(to);
        V[to].push_back(fr);
    }
    queue<int>Q;Q.push(0);judge[0]=true;
    while(!Q.empty()){
        fr=Q.front();Q.pop();
        for(auto x:V[fr]){
            if(judge[x])continue;
            G[fr].push_back(x);
            Q.push(x);
            judge[x]=true;
        }
    }
    cout<<(solve(0,0)+solve(0,1))%mod<<endl; 
}

Measured memory_bytes: 19840
let () = Scanf.scanf "%d %d\n" @@ fun n l ->
  let a =
    Array.init n @@ fun _ ->
      Scanf.scanf "%d " @@ fun a -> a in
  try
    Array.init (n - 1) (fun i -> i)
    |> Array.to_list
    |> List.find (fun i -> l <= a.(i) + a.(i + 1))
    |> fun k ->
        print_endline "Possible";
        for i = 0 to k - 1 do
          Printf.printf "%d\n" @@ i + 1
        done;
        for i = n - 2 downto k do
          Printf.printf "%d\n" @@ i + 1
        done
  with Not_found -> print_endline "Impossible"

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    int a,b; cin >> a >> b;
    cout <<(a <= b*2?0:a-b*2) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long ans = n/(a+b)*a;
        ans += Math.min(a,n%(a+b));
        System.out.println(ans);
    }
}


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

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

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

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

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

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

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

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


Measured memory_bytes: 21332
alpha2num = lambda c: ord(c) - ord('a') + 1
num2alpha = lambda c: chr(c+ord('a')-1)
S = list(map(alpha2num, input()))
K = int(input())
#まず左からaにできるか
for i in range(len(S)):
    if K <= 0:
        break
    if S[i] == 1:
        continue
    elif 27 - S[i] <= K:
        K -= (27 - S[i])
        S[i] = 1
# 残りのKを処理
if K >= 1:
    S[-1] = (S[-1] + K) % 26
    if S[-1] == 0:
        S[-1] = 26
S = list(map(num2alpha, S))
print(*S, sep='')


Measured memory_bytes: 6924
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int x, a,b;
int main()
{
	scanf("%d%d%d",&x,&a,&b);
	if(abs(x - a) < abs(x - b)) printf("A\n");
	else printf("B\n");
}

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

using namespace std;

#define INPUT  "input.txt"
#define OUTPUT "output.txt"
#define ll long long
#define ld long double

void fileio()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	if (fopen(INPUT, "r")){
		freopen(INPUT, "r", stdin);
		freopen(OUTPUT, "w", stdout);
	}
}

int a, b;
int h[1000];

int main() {
    fileio();

    h[1] = 1;
    for (int i = 2; i < 1000; i++) h[i] = h[i - 1] + i;

    cin >> a >> b;
    for (int i = 2; i < 1000; i++) {
        if ((h[i] - b) == (h[i - 1] - a)) {
            cout << (h[i] - b);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

def main():
    n = int(input())
    a = list(map(int, input().split()))

    def gcd(a, b):
        while True:
            if b == 0:
                return a
            a, b = b, a % b

    lcm = 1
    for i in a:
        g = gcd(lcm, i)
        lcm *= i // g

    ans = 0
    mod = 10**9 + 7
    for i in a:
        ans += lcm // i
    ans %= mod
    print(ans)

main()


Measured memory_bytes: 4084
n = int(input())
s = []
for i in range(n):
  a = int(input())
  s.append(a)
s.sort()
if sum(s)%10!=0:
  print(sum(s))
else:
  for i in range(n):
    m=s[i]
    if m%10!=0:
      """min%10!=0 なるminを探してsum(s)からminを減算すれば良い"""
      print(sum(s)-m)
      exit()
  print(0)
  

  

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    ll ans = a[0];
    int tmp = n-2;
    int idx = 1;
    while(tmp > 0) {
        if (tmp == 1) {
            ans += a[idx];
            --tmp;
        }
        else {
            ans += a[idx]*2;
            ++idx;
            tmp -=2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4820
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long N, x;
    cin >> N >> x;
    vector<long long> a(N, 0);
    for (long long i = 0; i < N; ++i) {
        cin >> a[i];
    }

    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] > x) {
            ans += a[i] - x;
            a[i] = x;
        }
    }

    for (int i = 1; i < N; ++i) {
        if (a[i - 1] + a[i] > x) {
            long long diff = a[i - 1] + a[i] - x;
            ans += diff;
            a[i] -= diff;
            //if (a[i - 1] >= a[i]) {
            //    ans += diff;
            //    a[i] -= diff;
            //}
            //else {
            //    ans += diff;
            //    a[i - 1] -= diff;
            //}
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC160 {
    class C {
        static void Main(string[] args) {
            var s = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long k = s[0];


            long[] inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            long prevHouse = inputs.Last() - k;
            long sum = 0;
            long farest = 0;
            foreach(var a in inputs) {
                var distance = a - prevHouse;
                sum += distance;
                if (farest < distance) farest = distance;

                prevHouse = a;
            }
            
            Console.WriteLine(sum-farest);
        }
    }
}


Measured memory_bytes: 36132
import sys
readline=sys.stdin.readline

DIV=10**9+7

N,K=map(int,readline().split())

E=[[] for i in range(N)]

for i in range(N-1):
  a,b=map(int,readline().split())
  E[a-1].append(b-1)
  E[b-1].append(a-1)
  
ans=1
stack=[]
# 頂点, 親, Kから引く数, Kから引く数のベースとなる数
stack.append([0,-1,0,0])
while stack:
  v,parent,minus,base=stack.pop()
  ans = (ans%DIV * (K-(minus+base))%DIV) % DIV
  if base < 2:
    base += 1
  cnt=0
  for child in E[v]:
    if child == parent:
      continue
    stack.append([child,v,cnt,base])
    cnt+=1
  
print(ans)  
  
  


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

ll N;
ll M;
vector<ll> a, a_sum;

ll check(ll x){

  ll ret = 0, cnt = N-1;

  for(ll i = 0; i < N; i++){
    while(cnt >= 0 && a[i] + a[cnt] < x){
      cnt--;
    }
    ret += cnt + 1;
  }

  return ret;
}

void solve(){

  sort(a.begin(), a.end(), greater<ll>());

  for(ll i = 0; i < N; i++){
    a_sum[i+1] = a_sum[i] + a[i];
  }

  ll left = 0, right = 200001;
  while(right - left > 1){
    ll mid = (right + left) / 2;
    if(check(mid) >= M) left = mid;
    else right = mid;
  }

  ll cnt = N-1, total = 0;
  ll ans = 0;

  for(ll i = 0; i < N; i++){
    while(cnt >= 0 && a[i] + a[cnt] < right){
      cnt--;
    }
    if(cnt >= 0) ans += a_sum[cnt+1] + a[i] * (cnt + 1);
    total += cnt + 1;
  }
  ans += left * (M - total);

  cout << ans << endl;
}


int main() {

  cin >> N >> M;
  a = vector<ll>(N);
  a_sum = vector<ll>(N+1);
  a_sum[0] = 0;

  for(ll i = 0; i < N; i++){
    cin >> a[i];
    a_sum[i+1] = a_sum[i] + a[i];
  }
  
  solve();
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

typedef long long LL;

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

const int N = 20 + 2;
const int INF = 1000000;

int n, m;
int ret;
int color[N][N];

int ok(int x, int y)
{
	static int c[4];
	c[0] = color[x][y];
	c[1] = color[x + 1][y];
	c[2] = color[x][y + 1];
	c[3] = color[x + 1][y + 1];
	for(int i = 0; i < 4; ++ i)
		for(int j = i + 1; j < 4; ++ j)
			if (c[i] == c[j])
				return true;
	return false;
}

int ok(int xa, int ya, int xb, int yb)
{
	if (color[xb][yb] >= 0) return false;
	if (color[xa][ya] >= 0) return false;
	color[xa][ya] = color[xb][yb] = INF;
	for(int cx = xa - 1; cx <= xb; ++ cx) {
		for(int cy = ya - 1; cy <= yb; ++ cy) {
			if (! ok(cx, cy)) {
				color[xa][ya] = color[xb][yb] = -1;
				return false;
			}
		}
	}
	color[xa][ya] = color[xb][yb] = -1;
	return true;
}

set<vector<vector<int> > > ss;

void dfs(int cur)
{
	if (cur * 2 == n * m) {
		vector<vector<int> > vec;
		for(int i = 1; i <= n; ++ i) {
			vector<int> row;
			for(int j = 1; j <= m; ++ j) {
				int value = 0;
				if (i + 1 <= n && color[i][j] == color[i + 1][j])
					value = 1;
				if (j + 1 <= m && color[i][j + 1] == color[i][j])
					value = 2;
				row.push_back(value);
			} 
			vec.push_back(row);
		}
		ss.insert(vec);
		++ ret;
		return;
	}
	int ways = 5, rx, ry;
	for(int i = 1; i <= n; ++ i) {
		for(int j = 1; j <= m; ++ j) {
			if (color[i][j] >= 0) continue;
			int curWays = 0;
			if (i + 1 <= n && ok(i, j, i + 1, j)) {
				++ curWays;
			}
			if (j + 1 <= m && ok(i, j, i, j + 1)) {
				++ curWays;
			}
			if (i - 1 >= 1 && ok(i - 1, j, i, j)) {
				++ curWays;
			}
			if (j - 1 >= 1 && ok(i, j - 1, i, j)) {
				++ curWays;
			}
			if (curWays < ways) {
				ways = curWays;
				rx = i;
				ry = j;
			}
		}
	}
	if (ways == 0 || ways == 5) {
		return;
	}
	int i = rx, j = ry;
	if (i + 1 <= n && ok(i, j, i + 1, j)) {
		color[i][j] = color[i + 1][j] = cur;
		dfs(cur + 1);
		color[i][j] = color[i + 1][j] = -1;
	}
	if (i - 1 >= 1 && ok(i - 1, j, i, j)) {
		color[i - 1][j] = color[i][j] = cur;
		dfs(cur + 1);
		color[i - 1][j] = color[i][j] = -1;
	}
	if (j + 1 <= m && ok(i, j, i, j + 1)) {
		color[i][j] = color[i][j + 1] = cur;
		dfs(cur + 1);
		color[i][j] = color[i][j + 1] = -1;
	}
	if (j - 1 >= 1 && ok(i, j - 1, i, j)) {
		color[i][j - 1] = color[i][j] = cur;
		dfs(cur + 1);
		color[i][j - 1] = color[i][j] = -1;
	}
}

void solve() {
	memset(color, -1, sizeof color);
	if (n * m & 1) {
		cout << 0 << endl;
		return;
	}
	ret = 0;
	ss.clear();
	dfs(0);
	cout << ss.size() << endl;
/*	for(set<vector<vector<int> > >::iterator it = ss.begin(); it != ss.end(); ++ it) {
		for(int i = 0; i < n; ++ i) {
			for(int j = 0; j < m; ++ j) {
				cout << (*it)[i][j] << ' ';
			}
			cout << endl;
		}
		cout << endl << endl;
	}*/
}

int main() {
	for( ; cin >> n >> m && (n || m); ) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1388
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int a,b;
    cin>>a>>b;
    long long int dif=b-a;

    long long int sum=1;
    long long int ase=n-2;
    sum+=ase*dif;
    if(sum<0)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<sum<<endl;
    }

}


Measured memory_bytes: 3620
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long ans = 0;
        HashMap<String, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            String s = scanner.next();
            char sa[] = s.toCharArray(); 
            Arrays.sort(sa);
            String sorted = new String(sa);
            ans += map.getOrDefault(sorted, 0);
            map.put(sorted, map.getOrDefault(sorted, 0)+1);
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 53592
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>

using namespace std;

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

  double prob = 0;
  
  for (int n=1; n<=N; ++n) {
    int need_front = max(0,(int)ceil(log2((double)K/n)));
    prob += pow((double)0.5,need_front)/N;
  }
  
  cout << setprecision(15) << prob << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main() {
	char s[101], t[101];
	int N;
	int loop;
	int len;
	int Ls;
	int i;
	int max = -1;
	int flag = 1;

	scanf("%d", &N);
	scanf("%s %s", s, t);

	len = strlen(s) + strlen(t);
	Ls = strlen(s);
	for (loop = 0; loop < N; loop++) {
		flag = 1;
		for (i = 0; i <= loop; i++) {
			if (s[Ls - loop - 1 + i] != t[i])flag = 0;
		}
		if (flag)max = loop;
	}
	printf("%d\n", len - max - 1);
	return 0;
}

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

public class Main {

	private static long max = (long) Math.pow(10.0, 18.0);

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

		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			long next = sc.nextLong();
			if (next == 0) {
				System.out.println(0);
				return;
			}
			a[i] = next;
		}
		sc.close();

		long result = 1L;
		for (int i = 0; i < n; i++) {
			try {
				result = Math.multiplyExact(result, a[i]);
			} catch (ArithmeticException e) {
				System.out.println(-1);
				return;
			}
			if (result > max) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 50192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	if(n%1000==0) cout<<0<<'\n';
	else cout<<1000-(n%1000)<<'\n';
}


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

int main(void)
{
    const int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin>>k;
    cout<<a[k-1]<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define f first
#define s second

using namespace std;

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

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


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,a,b,c,d;
    string si;

    cin>>n>>a>>b>>c>>d;
    cin>>si;


    if(c < a || d < b){
    	cout<<"No";
    	return 0;
    }
    a--;b--;c--;d--;
    //if there are any two consecutive rock then they can't do it
    bool cons1 = false;
    for(int i = a;i<c-1;i++)
    {
    	if(si[i] == '#' && si[i+1] == '#')
    	{
    		cons1 = true;
    		break;
    	}
    }


    bool cons2 = false;
    for(int i = b;i<d-1;i++)
    {
    	if(si[i] == '#' && si[i+1] == '#')
    	{
    		cons2 = true;
    		break;
    	}
    }

    if(cons1 || cons2)
    {
    	cout<<"No";
    	return 0;
    }

   	if(c<d){
   		cout<<"Yes";
   		return 0;
   	}
   	else
   	{
   		bool three = false;
   		for(int i =b;i<=d;i++)
   			if(i-1 > 0 && i+1<n)
   			if(si[i-1] == '.' && si[i] == '.' && si[i+1] == '.')
   				{three = true;
   				break;   		}

   		if(three == false){
   			cout<<"No";
   			return 0;
   		}

   		cout<<"Yes";
   		return 0;
	}

   	}

Measured memory_bytes: 592
#include <iostream>
     
    int main(void)
    {
    int x, a,b;
    std::cin >> x >> a >> b;
    if(b <= a){ std::cout << "delicious" << std::endl;
    } else if(b <= a+x){ std::cout << "safe" << std::endl;
    } else { std::cout << "dangerous" << std::endl; }
    return 0;
    }

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAX_N = 100000;
int n;
int a[MAX_N];
int b[MAX_N];

i64 ceil_div(i64 a, i64 b)
{
  return a / b + (a % b != 0 ? 1 : 0);
}

i64 count_inv(vi &a)
{
  int n = a.size();
  if (n <= 1) return 0;

  vi b(a.begin(), a.begin()+n/2);
  vi c(a.begin()+n/2, a.end());

  i64 r = count_inv(b) + count_inv(c);

  int bi = 0, ci = 0;
  for (int ai = 0; ai < n; ai++) {
    if (bi < (int)b.size() && (ci == (int)c.size() || b[bi] <= c[ci])) {
      a[ai] = b[bi++];
    } else {
      a[ai] = c[ci++];
      r += bi;
    }
  }

  return r;
}

bool f(int x)
{
  vi psum(n+1);
  psum[0] = 0;
  for (int i = 1; i <= n; ++i) {
    psum[i] = psum[i-1] + (x <= a[i-1] ? 1 : -1);
  }
  i64 r = count_inv(psum);

  return r >= ceil_div((i64)(n+1) * n / 2, 2);
}

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

  sort(b,b+n);

  int l = -1, r = n;
  while (r - l > 1) {
    int m = (r+l)/2;
    if (f(b[m])) {
      l = m;
    } else {
      r = m;
    }
  }

  cout << b[l] << endl;

  return 0;
}


Measured memory_bytes: 2252
n,*a=map(int,open(0).read().split())
dp=[0]*(n+1)
dp[0]=1
for i,x in enumerate(a):
	if dp[i]<x:
		print(-1)
		exit()
	if i<n:
		dp[i+1]=(dp[i]-x)*2
dp[-1]=a[-1]
for i in range(n,0,-1):
	if dp[i-1]>a[i-1]+dp[i]:
		dp[i-1]=a[i-1]+dp[i]
print(sum(dp))

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// For modular arithmetic when a modular is specified per input case.
// Verified: ABC129F
struct ModInt {
 private:
  static int64 M;
  int64 x;
 public:
  static void SetMod(int64 mod) {
    M = mod;
  }
  ModInt(int64 input_x) : x(input_x % M) {}
  ModInt() : x(0) {}
  int64 Value() { return x; }
  inline ModInt operator+(ModInt o) {
    ModInt r(*this); r += o; return r;
  }
  inline ModInt operator-(ModInt o) {
    ModInt r(*this); r -= o; return r;
  }
  inline ModInt operator* (ModInt o) {
    ModInt r(*this); r *= o; return r;
  }
  inline void operator+= (ModInt o) { x = (x + o.x) % M; }
  inline void operator-= (ModInt o) { x = (x + M - o.x) % M; }
  inline void operator*= (ModInt o) { x = (x * o.x) % M; }
};
int64 ModInt::M = 1;  // Do not forget to add this line.

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

  int n, k;
  cin >> n >> k;
  ModInt::SetMod(k);

  vector<ModInt> xs(n);
  for (int i = 0; i < n; i++) {
    int64 x;
    cin >> x;
    xs[i] = ModInt(x);
  }

  map<int64, int> map;
  ModInt base = 0;

  int64 ans = 0;
  vector<ModInt> ys(n);
  for (int i = 0; i < n; i++) {
    base += xs[i] - 1;
    ys[i] = xs[i] - base;
    map[ys[i].Value()] += 1;
    if (i >= k - 1) {
      map[ys[i - (k - 1)].Value()] -= 1;
    }
    ModInt key = ModInt(1) - base;
    ans += map[key.Value()];
    // cout << "i: " << i << " ans: " << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 15872