akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <numeric>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
typedef pair<int, int> P;

typedef long long ll;
const int MOD = 1000000007;

int main(){  
    int N,count = 0;
    int a[100000];
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];
    sort(a,a+N);
    cout << a[N/2] - a[N/2-1];
}



Measured memory_bytes: 640
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;
ll a[100000009];
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		ll x;
		priority_queue<ll> q;
		for(int i =1;i<=n;++i)
		{
			cin>>x;
			q.push(x);
		}
		while(m)
		{
			x = q.top();
			q.pop();
			x = x/2;
			q.push(x);
			m--; 
		}
		ll sum = 0;
		while(!q.empty())
		{
			x = q.top();
			sum+=x;
			q.pop(); 
		}
		cout<<sum<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 1528
#include <iostream>

using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int N ;
int Q ;
string S;


int main(){
	cin >> N >> Q >> S;
	int l,r;
	int ans[N+1]={};
	ans[0] =0;
	REP(i,N){
		ans[i+1] = ans[i];
		if((S[i] =='A' ) && (S[i+1] =='C')){
			ans[i+1] ++;
		}
		
	}
	/*for (int i = 0; i < N ; i++) {
		ans[i + 1] = ans[i];
		if (S[i] == 'A' && S[i + 1] == 'C') {
			ans[i + 1]++;
		}
	}*/
	
	REP(i,Q){
		cin >> l >> r;
		cout << ans[r-1] -ans[l-1]<< endl;
		
	}
	

	return 0;
}

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

int main() {
    int a, b, c;
    cin>>a>>b>>c;
    int d, e, f;
    d=abs(a-b);
    e=abs(b-c);
    f=abs(c-a);
    int maxi=max(max(d, e), f);
    cout<<d+e+f-maxi<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

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

        TreeSet<Long> shrines = new TreeSet<>();
        TreeSet<Long> temples = new TreeSet<>();

        int a = sc.nextInt();
        int b = sc.nextInt();
        int q = sc.nextInt();

        for (int i = 0; i < a; i++) {
            shrines.add(sc.nextLong());
        }

        for (int i = 0; i < b; i++) {
            temples.add(sc.nextLong());
        }

        for (int i = 0; i < q; i++) {
            long x = sc.nextLong();
            long min = Long.MAX_VALUE;

            for (int first = 0; first < 2; first++) {
                for (int sides = 0; sides < 4; sides++) {
                    TreeSet<Long> firstVisit = first == 0 ? shrines : temples;
                    TreeSet<Long> secondVisit = first == 0 ? temples : shrines;

                    Long f = null;
                    Long s = null;
                    if (sides == 0) {
                        f = firstVisit.floor(x);
                        if (f != null) {
                            s = secondVisit.floor(f);
                        }
                    } else if (sides == 1) {
                        f = firstVisit.ceiling(x);
                        if (f != null) {
                            s = secondVisit.ceiling(f);
                        }
                    } else if (sides == 2) {
                        f = firstVisit.floor(x);
                        if (f != null) {
                            s = secondVisit.ceiling(f);
                        }
                    } else {
                        f = firstVisit.ceiling(x);
                        if (f != null) {
                            s = secondVisit.floor(f);
                        }
                    }

                    if (f != null && s != null) {
                        min = Math.min(min, Math.abs(x - f) + Math.abs(s - f));
                    }
                }
            }

            System.out.println(min);
        }
    }
}

Measured memory_bytes: 114272
import heapq

N, M = map(int,input().split())
As = list(map(int,input().split()))
As = [-1*e for e in As]
heapq.heapify(As)
for i in range(M):
    value = -heapq.heappop(As)
    heapq.heappush(As,-(value//2))
print(-sum(As))






Measured memory_bytes: 14180
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{

int a,b,c,d;
cin>>a>>b>>c>>d;

int i=0;
while(true)
{
	if(i%2==0)
	{
		c-=b;
		if(c<=0)
		{
			cout<<"Yes";
			break;
		}
	}
	else
	{
		a-=d;
		if(a<=0)
		{
			cout<<"No";
			break;
		}
	}
	i++;
}












}return 0;}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int n, m; cin >> n >> m;
    vector<set<int>> graph(n);
    for (int i = 0; i < m; i++)
    {   
        int s, t; cin >> s >> t;
        s--;
        t--;
        graph[s].insert(t);
        graph[t].insert(s);
    }   
    bool ok = false;
    for (const auto& next : graph[0])
    {   
        ok |= graph[n - 1].find(next) != graph[n - 1].end();
    }   
    if (ok) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
    return 0;
}

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

void solve(int H, int W, std::vector<std::string> a){
    vector<bool> row(H, false);
    vector<bool> col(W, false);
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if(a[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }
    for(int i = 0; i < H; ++i){
        if(row[i]){
            for(int j = 0; j < W; ++j){
                if(col[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }
}

int main(){
    int H, W;
    cin >> H >> W;
    vector<std::string> a;
    std::string s;
    for(int h = 0; h < H; ++h){
        cin >> s; a.push_back(s);
    }
    solve(H, W, std::move(a));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int N, M;
const int MAX_N = 1.0e6 + 10;
int A[MAX_N];

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) cin >> A[i];
    int ans = N;
    for (int i = 0; i < M; i++) {
        ans -= A[i];
    }

    if (ans < 0) cout << -1 << endl;
    else cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3636
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
t = readl()
mx = t[-1]
for i in reversed(range(n)):
    if mx >= t[i]:
        mx = t[i]
    else:
        k = t[i] - 1
        if mx >= k:
            mx = k
        else:
            print("No")
            exit()
print("Yes")



Measured memory_bytes: 16652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int T = 200 + 9;
const double EPS = 1e-9;

ll n, d;

void read(){
  cin >> d >> n;
}

void solv(){
  if(n == 100)
    n++;

  ll pw = 1;
  for(int i = 0; i < d; i++)
    pw *= 100;

  cout << n * pw << '\n';
}

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

  #ifdef DEBUG
    freopen("in.txt", "r", stdin);
  #endif

  read();
  solv();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<algorithm>
#include<set>
#include<vector>
#include<cstdio>
#include<cmath>
#include<queue>
#include<functional>
#include<stack>
using namespace std;
typedef long long LL;
int main()
{
    int n;
    cin >> n;
    vector<int> vc(n + 1);
    int flag=1;
    for (int i=1; i <= n; i++)
    {
        cin >> vc[i];
        if(vc[i] % 2==0)
        {
            if(vc[i] % 3 && vc[i] % 5)flag=0;
        }
    }
    if(flag)
    {
        cout<<"APPROVED\n";
    }else
    {
        cout<<"DENIED\n";
    }
    
        

}

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

const int DIM = 1e5 + 5;

int arr[DIM], psm[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    sort( arr + 1, arr + n + 1 );
    
    int pos = 1;
    for( int i = 1; i <= n; i ++ ) {
        psm[i] = min( arr[n], psm[i - 1] + arr[i] );
        
        if( i < n && psm[i] * 2 < arr[i + 1] )
            pos = i + 1;
    }
    
    cout << n - pos + 1 << endl;
    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    var N = readLine()!!.toInt()
    var input = readLine()!!.split(" ").map(String::toInt)
    var list : MutableList<Int> = mutableListOf()
    val max_v = input.max()!!
    val min_v = input.min()!!
    var sum = 0
    for(vv in min_v..max_v){
        sum = 0
        for(v in input){
            sum += (v - vv) * (v - vv)
        }
        list.add(sum)
    }
    println(list.min()!!)
}

Measured memory_bytes: 37816
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main(){
	IOS;
	int n, d, dist = 0, count = 0;
	cin >> n >> d;

	int arr[n][d];

	for(int i = 0; i < n; i++){
		for(int j =0 ; j< d; j++){
			cin >> arr[i][j];
		}
	}	

	for(int j = 0; j < n; j++){
		for(int i = j+1; i < n; i++){
			dist = 0;
			for(int k= 0; k < d; k++){
				 dist += (arr[j][k] - arr[i][k])*(arr[j][k] - arr[i][k]);
			}
			int x = sqrt(dist);
			if((x * x == dist))
				count++;

		}
	}
	cout << count << endl;



	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
  int i,A[N],a,v,j,b;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<a;i++){
    for(b=0;b<a;b++){
      if(b==a-1)printf("%d\n",A[b]);
      else printf("%d ",A[b]);
    }
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }
  }
    for(b=0;b<a;b++){
      if(b==a-1)printf("%d\n",A[b]);
      else printf("%d ",A[b]);
    }
  return 0;
}




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

int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    for(int i = A, j = 0;i >= 1;i--){
        if(A % i == 0 && B % i == 0){
            if(++j == K){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int h, w;
string sv[405];
bool used[405][405];

bool grid_inside(int y, int x) {
  if(0 <= y && y < h && 0 <= x && x < w) return true;
  else return false;
}

PLL bfs(int y, int x) {
  queue<P> que;
  que.push(P(y, x));

  ll b = 0, w = 0;
  used[y][x] = true;
  while(!que.empty()) {
    P p = que.front(); que.pop();
    char now = sv[p.first][p.second];
    if(sv[p.first][p.second] == '#') b++;
    else w++;

    REP(i, 4) {
      int ny = p.first + dy4[i], nx = p.second + dx4[i];
      if(grid_inside(ny, nx) && !used[ny][nx] && now != sv[ny][nx]) {
        used[ny][nx] = true;
        que.push(P(ny, nx));
      }
    }
  }

  return PLL(b, w);
}

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

  cin >> h >> w;
  REP(i, h) cin >> sv[i];

  ll ans = 0;
  REP(i, h) REP(j, w) {
    if(!used[i][j]) {
      PLL p = bfs(i, j);
      ans += p.first * p.second;
    }
  }
  cout << ans << endl;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(all(a));
    cout << abs(a[0] - a[n - 1]) << endl;
}


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

int mintime(int x);
int main(){
	int x;
	cin >> x;
	int t=mintime(x);

	cout << t << endl;
	return 0;
}

int mintime(int x){
	int a=sqrt(x*2);
	if(a*(a+1) >= x*2) return a;
	else return a+1;
}

Measured memory_bytes: 256
// Problem : B - Multiplication 2
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n];
		int x = 1;
		bool flag = true;
		for(int i=0;i<n;++i)
		{
			cin>>arr[i];
			if(arr[i]==0)
			flag = false;
			
		}
		if(!flag)
		{
			cout<<0;
			return 0;
		}
		for(int i=0;i<n;++i)
		{
			if(x>(inf/arr[i]))
			{
				cout<<-1;
				return 0;
			}
			x*=arr[i];
		}
		cout<<x;
		    	
    }
    return 0;
}


Measured memory_bytes: 4388
#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 n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  if (h.size() <= k) {
    cout << 0 << endl;
    return 0;
  }
  sort(h.begin(), h.end(), greater<int>());
  h.erase(h.begin(), h.begin() + k);
  ll ans = 0;
  rep(i,h.size()) ans += ll(h[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
int mp[100005];
int a[100005];
int n,q;
signed main()
{
	cin>>n;
	int ans=0;
	for (int i=0;i<n;i++)  cin>>a[i],mp[a[i]]++,ans+=a[i];
	cin>>q;
	while (q--){
		int a,b;
		cin>>a>>b;
		cout<<ans-mp[a]*a+mp[a]*b<<'\n';
		ans=ans-mp[a]*a+mp[a]*b;
		mp[b]+=mp[a];
		mp[a]=0;
	}
	re 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(int argc, char*argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int N;
	cin >>N;
	int a[N+1];
	a[0] = 1e+5;
	for (int i = 1; i <= N ; ++i)
		cin >> a[i];
	int dp[N+1];
	dp[0] = 0;
	dp[1] = 0;
	for (int i = 2; i<=N; ++i)
	       dp[i] = min(dp[i-2] + abs(a[i]-a[i-2]) , dp[i-1] + abs(a[i]-a[i-1]));
	cout << dp[N];
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    deque<int> d;
    int ans = 0;
    rep(i, n) {
        int p = lower_bound(all(d), a[i])-d.begin();
        if (p == 0) {
            d.push_front(a[i]);
            ans++;
        } else d[p-1] = a[i];
    }
    cout << ans << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,L;
vector<pair<int,int>> E[303];

ll dp[303];
int cost[303][303];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>L;
	FOR(i,M) {
		cin>>x>>y>>r;
		if(r<=L) {
			E[x-1].push_back({y-1,r});
			E[y-1].push_back({x-1,r});
		}
	}
	
	FOR(x,N) FOR(y,N) cost[x][y]=(x==y?0:10000);
	
	MINUS(dp);
	FOR(x,N) {
		FOR(y,N) dp[y]=-1;
		dp[x]=L;
		priority_queue<pair<ll,int>> PQ;
		PQ.push({-L,x});
		while(PQ.size()) {
			ll f=-PQ.top().first;
			int cur=PQ.top().second;
			PQ.pop();
			if(dp[cur]!=f) continue;
			
			FORR(e,E[cur]) if(f-e.second>dp[e.first]) {
				dp[e.first]=f-e.second;
				PQ.push({-dp[e.first],e.first});
			}
		}
		FOR(y,N) if(dp[y]>=0) cost[x][y]=1;
	}
	
	
	FOR(r,N) FOR(x,N) FOR(y,N) cost[x][y]=min(cost[x][y],cost[x][r]+cost[r][y]);
	
	int Q;
	cin>>Q;
	while(Q--) {
		cin>>x>>y;
		x--,y--;
		if(cost[x][y]>=1000) cout<<-1<<endl;
		else cout<<cost[x][y]-1<<endl;
		
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<math.h>
using namespace std;

int x;

int main(){
    cin >> x;
    int ans = 1, i = 1, j = 2, m = 1;
    while(pow(i, j) <= x){
        ans = pow(i, j);
        if(ans > m) m = ans;
        j++;
        if(pow(i, j) > x | i == 1){
            j = 2;
            i++;
        } 
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define lli long long int 
#define ull unsigned long long
#define mod 1000000007
#define endl "\n"
#define GIO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{ GIO;
  ll n;
  cin>>n;
  ll A[2*n];
  for(ll i=0;i<2*n;i++)
  {
  	cin>>A[i];
  }
  sort(A,A+(2*n));
  ll mi=0;
  for(ll i=0;i<2*n-1;i=i+2)
  {
  mi+=min(A[i],A[i+1]);
  }
  cout<<mi<<"\n";
  
return 0;
}




Measured memory_bytes: 256
#!/usr/bin/perl

use strict;
use warnings;
use Memoize;

my ($n, $a, $b);
{
    my $in = <STDIN>;
    ($n, $a, $b) = split(" ", $in);
}
my $MOD = 10 ** 9 + 7;
sub power
{
    my ($a, $b) = @_;
    if ($b == 0)
    {
        1;
    }
    elsif ($b % 2 == 0)
    {
        power($a ** 2 % $MOD, $b / 2);
    }
    else{
        $a * power($a, $b - 1) % $MOD;
    }
}
sub inv
{
    my $n = shift;
    power($n, $MOD - 2) % $MOD;
}
sub combination
{
    my ($n, $k) = @_;
    my $a = 1;
    my $b = 1;
    for (my $i=0; $i<$k; $i++)
    {
        $a *= $n - $i;
        $a %= $MOD;
        $b *= $i + 1;
        $b %= $MOD;
    }
    $a * inv($b) % $MOD;
}
memoize('power');
memoize('inv');
memoize('combination');
my $ans = power(2, $n) - 1;
$ans += $MOD - combination($n, $a);
$ans += $MOD - combination($n, $b);
print ($ans % $MOD), "\n";

Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var hist = new Dictionary<long, long>();

        for(int i = 1; i <= n; i++)
        {
            hist[i] = 0;
        }

        for(int i = 0; i < a.Length; i++)
        {
            hist[a[i]] = hist[a[i]] + 1;
        }

        for(int i = 1; i <= n; i++)
        {
            Console.WriteLine(hist[i]);
        }
    }
}

Measured memory_bytes: 56888
import sys,math,collections,itertools
input = sys.stdin.readline
m=10**9+7
"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    i=2
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        arr.append([i, cnt])
            
    for i in range(3, int(-(-n**0.5//1))+1,2):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])    

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N=int(input())
A=list(map(int,input().split()))
d = collections.defaultdict(int)
for a in A:
    arr = factorization(a)
    for ar in arr:
        if d[ar[0]]<ar[1]:
            d[ar[0]]=ar[1]

gcd = 1
for key,val in d.items():
    gcd = gcd*pow(key,val)

ans = 0
for a in A:
    ans = ans+gcd//a
print(ans%m)


Measured memory_bytes: 76280
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n,m,q;
	cin>>n>>m>>q;
	vvi a(n+1,vi(n+1,0));
	rep(i,m){
	    int l,r;
	    cin>>l>>r;
	    a[l][r]++;
	}

	rep(i,n+1)rep(j,n)a[i][j+1]+=a[i][j];
	rep(j,n+1)rep(i,n)a[i+1][j]+=a[i][j];

	rep(i,q){
	    int p,q;
	    cin>>p>>q;
	    p--;
	    cout<<a[q][q]-a[p][q]-a[q][p]+a[p][p]<<endl;
	}
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int N,Q;
  cin >> N >> Q;
  vector<vector<int>> e(N);

  for(int i = 1;i <= N - 1;i++){
    int a,b;
    cin >> a >> b;
    e[a].push_back(b);
  }


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

  for(int i = 0;i < Q;i++){
    ll p,x;
    cin >> p >> x;
    v[p]+=x;
  }

  for(int i = 1;i <= N;i++){
    cout << v[i]  << ' ';
    if(i == N)return 0;
    for(int j = 0;j < e[i].size();j++){
      int v_index = e[i][j];
      v[v_index] += v[i];
    }
  }


}


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

int main() {
    long long s, c;
    cin >> s >> c;
    if (s >= c / 2) {
        cout << c / 2 << '\n';
    } else {
        long long ans= s;
        c -= s * 2;
        ans += c / 4;
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 3568
#include<set>
using namespace std;
#include<iostream>
int	main(){

/*	int N, C, c[100], n;
	cin >> N;
	C = 0;
	n = 0;

	for (int i = 0; i <N; i++ ){
		cin >> c[i];
		C+= c[i];
	}

	for (int i = 0; i <N; i++ ){
		if (c[i] <= 0.1*C){
			n+= 30;
		}
	}
	cout << n << endl;
}
	/*
	while(true){
	
	int A,B,C,D,E,F,G,H,I,J,answer;
		
	cin >> A;
	if(A == 0) return 0;
	cin >> B >> C >> D >> E >> F >> G >> H >> I >> J;
	answer = A - B - C - D-E-F-G-H-I-J;
	cout << answer << endl;

	}
	*/
	/*
	int A,B,C,D,E,F;

	cin >> A, B, C, D;
	if(A < B, C, D){ 
		cout << B + C + D << endl;
	}
	
	else if(B < A, C, D){
		cout << A + C + D << endl;
	}

	else if(C < A && C < B && C < D){
		cout << A + B + D << endl;
	}

	else if(D < A && D < B && D < C){
		cout << A + B + C << endl;
	}

	if(E < F){
		cout << F << endl;
	}

	else{
		cout << E << endl;
	}
	
	return 0;
}*/
	/*
	int N, M;
	cin >> N >> M;
	cout << N + M << endl << N - M << endl << N * M << endl << N / M << endl;
}*/

/*int N, M; 
	cin >> N >> M;
	cout << N % M << endl;
}*/

/*	int N;
	cin >> N;
	cout << -(N % 2)+1 ;
}*/

	/*int A, B, C, D, E ;
	cin >> A >> B >> C >> D >> E;
	cout << (A + B + C + D + E) / 5 ;
}*/

	/*int A, B, C, D ;
	cin >> A >> B >> C >> D;
	cout << (A + B + C + D) / 60 << endl << (A + B + C + D) % 60 << endl;
	*/

/*	int A,B;
	cin >> A >> B;
	cout << ( A + B ) / 2 << endl;*/

/*	int m, f, b;
	cin >> m >> f >> b;

	if ( m + f >= b && m <= b ){
		cout << b - m << endl;
	}
	
	if ( m + f > b && m > b ){
		cout << 0 << endl;
	}


	if ( m + f < b ){
		cout << "NA" << endl;
	}*/

/*	int X , x ;
	cin >> X ;

	x = X % 7 ;

	if ( x == 2 ){
		cout << "sat" << endl;
	}

	if ( x == 3 ){
		cout << "sun" << endl;
	}

	if ( x == 4 ){
		cout << "mon" << endl;
	}

	if ( x == 5 ){
		cout << "tue" << endl;
	}

	if ( x == 6 ){
		cout << "wed" << endl;
	}

	if ( x == 0 ){
		cout << "thu" << endl;
	}

	if ( x == 1 ){
		cout << "fri" << endl;
	}*/

	/*int a , b , N ;
	cin >> a >> b >> N ;

	int s[100] , f[100];
	for ( int i=0 ; i<N ; i++ ){
		cin >> s[i] >> f[i];
	
		if (( s[i] <= a && a < f[i]) || s[i] < b && b <= f[i] || s[i] >= a && f[i] <= b ){
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}*/

	/*int N, A, B, C;
	vector <int> a;
	vector <int> dp;

	int pizza (int C){
		if (C == N) return 0;
		if (dp[C]! = -1) return dp[C];
		dp[C] = max (pizza(C+1); pizza(C+1)+a[C]);
		return dp[C];
	}

		int main(){
			cin >> N;
			for(int i = 0; i<N; i++){
				int tmp;
				cin >> tmp;
				a.push_back(tmp);
				dp.push_back(-1);
			}
			cout << pizza(0) << endl;

			return 0;
	}
		cout << C[i]/(A+B);*/
	
/*	int main(){
		int N, A, B, C, a, dp, i;

		dp[i+1] = max(dp[i], dp[i]+a[]), C[0] = 0;
	}*/

/*	long long N;
	cin >> N;
	cout << 264 + 52 * N << endl;
}*/

	/*int H, W;
	cin >> H >> W;
	if (H * 4 == W * 3){
		cout << "YOKO" << endl;
	}

	else{
		cout << "TATE" << endl;
	}


	}*/

	/*int i, m, s, e, I, M, S, E;
	cin >> i >> m >> s >> e >> I >> M >> S >> E;

	if(i + m + s + e >= I + M + S + E){
		cout << i + m + s + e << endl;
	}

	else{
		cout << I + M + S + E << endl;
	}*/
	/*cout << "Hello World" << endl;*/

	int x;
	cin >> x;
	cout << x*x*x << endl;


}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    

    ll plus1, plus2, minus;
    plus1 = minus = 0LL;
    plus2 = 0LL;
    rep(i, 0, n)
    {
        if (a[i] > b[i])
            minus += (ll) a[i] - b[i];
        else
        {
            plus1 += (b[i] - a[i])%2;
            plus2 += ((b[i] - a[i])/2) * 2;
        }
    }

    bool f1 = minus * 2 <= plus2;
    if (f1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 384
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

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

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	B := []int{}
	for i := N - 1; i >= 0; i-- {
		num := A[i]
		l := -1
		r := len(B)
		for abs(r-l) > 1 {
			mid := (r + l) / 2
			if B[mid] > num {
				r = mid
			} else {
				l = mid
			}
		}
		//fmt.Fprintln(wtr, i, num, r, B)
		if r == len(B) {
			B = append(B, num)
		} else {
			B[r] = num
		}
	}

	fmt.Fprintln(wtr, len(B))
}


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    ll n,k,x,y;
    cin>>n>>k>>x>>y;
    k=min(k,n);
    cout<<k*x+(n-k)*y<<endl;
    return 0;
}


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

int main() {
  string s; cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {cout << "Bad" << endl;}
  else {cout << "Good" << endl;}
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;
 
#define EPS 1e-6
#define INF 1e8
typedef complex<double> P;
 
double dot(P a,P b){
  return real(conj(a)*b);
}
 
double cross(P a,P b){
  return imag(conj(a)*b);
}
 
struct Point{
  double x,y;
};
 
int main(){
  double D;
 
  while(true){
    Point v,p;
 
    scanf("%lf",&D);
    if(D == 0.0) break;
     
    scanf("%lf%lf%lf%lf",&p.x,&p.y,&v.x,&v.y);
    P np = P(p.x,p.y), nv = P(v.x,v.y);
    double dist = INF;
 
    if(abs(cross(np,nv)) < EPS){
      if(dot(np,nv) < -EPS){
        dist = abs(np);
      }else{
        dist = 2-abs(np);
      }
    }
    
    if(dist < D - EPS){
      printf("%.8f\n",dist);
    }else{
      printf("impossible\n");
    }
  }
  
  return 0;
}

Measured memory_bytes: 1268
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		vector<vector<char> >in(5,vector<char>(n));
		rep(i,n)rep(j,5){
			int q;
			cin>>q;
			in[j][n-1-i]=q+'0';
		}
		//rep(i,5)rep(j,n)cout<<in[i][j]<<" ";
		int out=0;
		while(1){
			rep(i,n){
				char tmp=in[2][i];
				if(tmp=='#')continue;
				string s="";
				rep(j,5)s+=in[j][i];
				string tmps="";
				rep(j,3)tmps+=tmp;
				if(s.find(tmps)!=string::npos){
					rep(j,5){
						if(((j==0&&in[1][i]==tmp)||j==1||j==2||j==3||(j==4&&in[3][i]=='!'))&&in[j][i]==tmp)
							in[j][i]='!';
					}
					rep(j,5)if(in[j][i]=='!')out+=tmp-'0';
				}
			}
			bool h=false;
			rep(i,5)for(int j=0;j<n;j++)if(in[4-i][j]=='!'){
				in[4-i].erase(in[4-i].begin()+j);
				in[4-i].pb('#');
				j--;
				h=true;
			}
			if(!h)break;
		}
		cout<<out<<endl;
	}
}

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

int main(){
    string S; cin >> S;
    int index = 0;
    int N = S.size();
    string S1 = "dream";
    string S2 = "dreamer";
    string S3 = "erase";
    string S4 = "eraser";
    while(N>index){
        if(S.substr(N-S1.size()-index,S1.size()) == S1)index += 5;
        else if(S.substr(N-S3.size()-index,S3.size()) == S3)index += 5;
        else if(S.substr(N-S4.size()-index,S4.size()) == S4)index += 6;
        else if(S.substr(N-S2.size()-index,S2.size()) == S2)index += 7;
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  int N, M;
  cin >> N >> M;
  //u:iが1から定期便1つで行ける島のときu[i] = true, v:Nから〃
  vector<bool> u(N+1, false), v(N+1, false);

  REP(i, M){
    int a,b;
    cin >> a >> b;
    if(a == 1) u[b] = true;
    if(b == N) v[a] = true;
  }

  FOR(i, 2, N){
    if(u[i] && v[i]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }

  cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#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;
typedef long long ll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define loop(i, n) for(ll i = 0; i < n; i++)
#define pl pair<ll, ll>
#define vl vector<ll>
#define endl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

int main()
{

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    string s, t;
    cin >> s >> t;
    ll ans = 0;
    for (int i = 0; i < s.size(); i++)
        if (s[i] != t[i]) ans++;
    cout << ans << endl;

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif

    return 0;
}

Measured memory_bytes: 3912
def sumOfDigits(n):
    sum = 0
    while(n > 0):
        sum += n % 10
        n //= 10
    return sum

N, A, B = map(int, input().split())

sum = 0
for n in range(N + 1):
    wa = sumOfDigits(n)
    if A <= wa and B >= wa:
        sum += n
print(sum)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

ll n,k,v[110],ans;

void input(){
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>v[i];
	return;
}

void solve(){
	for(int i=0;i<=n;i++){
		for(int j=i;j<=n;j++){
			if(i+(n-j)>k)continue;
			vector<int>s;
			s.clear();
			ll sum=0;
			for(int l=0;l<i;l++)s.eb(v[l]),sum+=v[l];
			for(int l=j;l<n;l++)s.eb(v[l]),sum+=v[l];
			sort(ALL(s));
			int left=k-i-(n-j);
			for(int l=0;l<left;l++){
				if(l==s.size())break;
				if(s[l]<0)sum-=s[l];
			}
			ans=max(ans,sum);
		}
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}

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

#define ll int64_t

ll health_left(ll n)
{
    if (n == 1) return 1;
    return health_left(n/2)*2+1;
}

int main()
{
 //   freopen("test.in","r",stdin);
   // freopen("test.ok","w",stdout);
    int64_t h,x=1;
    cin >> h;
    /* if (h==1) cout << "1";
    else  
    {
    do
    {
        h=h/2;
        x=x*2;
    }
    while (h>1);
    cout << x*3+1; */
    cout << health_left(h) << "\n";
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)
#define MAXN       200005

ll parent[MAXN],cnt[MAXN];

void reset(ll n)
{
    f(i,1,n+1)
    {
        parent[i]=i;
        cnt[i]=1;
    }
}

ll find(ll u)
{
    if(u==parent[u]) return u;
    return parent[u]=find(parent[u]);
}

void Union(ll u,ll v)
{
    ll p=find(u);
    ll q=find(v);
    if(p!=q)
    {
        parent[q]=p;
        cnt[p]+=cnt[q];
    }
}

int main()
{
    ll n,m,k,g,mx,mn,res,c,x,y,z,w,p,q,r,l,s,t;
    ci>>n>>m;
    reset(n);
    f(i,0,m)
    {
        ci>>x>>y;
        Union(x,y);
    }
    res=0;
    f(i,1,n+1) res=max(res,cnt[i]);
    co<<res;
    return 0;
}

Measured memory_bytes: 6708
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> vec(n,0);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    vec[a]++;
    vec[b]++;
  }

  rep(i,n) cout << vec[i] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int a[100005], cnt[100005], tmp[100005];
int main(){
    int n, ans = 1;
    scanf("%d", &n);
    bool ok = 1;
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        cnt[a[i]]++;
        tmp[a[i]]++;
        if(tmp[a[i]] > 3) ok = 0;
        if(a[i] > 0){
            ans = ans*1ll*cnt[a[i]-1]%mod;
            cnt[a[i]-1]--;
        }
    }
    if(!ok) printf("0\n");
    else{
        if(tmp[0] == 1) ans = ans*1ll*3%mod;
        else ans = ans*1ll*6%mod;
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 4972
#include<stdio.h>
int main(){
  double a,b,c,d,e,f;
  while(scanf("%lf %lf %lf %lf %lf %lf",
	      &a,&b,&c,&d,&e,&f)!=EOF){
    double x,y;
    x=(c*e-b*f)/(a*e-b*d);
    y=(a*f-c*d)/(a*e-b*d);
    // printf("%.3f\n",0.0004);
    //printf("%.3f",-0.0004);
    if(-0.0005<x&&x<=0)x=0;
    if(-0.0005<y&&y<=0)y=0;
    printf("%.3f %.3f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 652
#include "bits/stdc++.h"
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define pl pair<long long, long long>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

ll wt[200002] = {0};
ll nodes[200002] = {0};
ll root(ll node) {
	ll copy_node = node;
	while(node != nodes[node]) {
		nodes[node] = nodes[nodes[node]];
		node = nodes[node];
	}
	nodes[copy_node] = node;
	return node;
}
bool find(ll p, ll q) {
	ll root_p = root(p);
	ll root_q = root(q);
	if(root_p == root_q) return true;
	return false;
}
void do_union(ll p, ll q) {
	ll root_p = root(p);
	ll root_q = root(q);
	if(root_p != root_q) {
		if(wt[root_p] >= wt[root_q]) {
			wt[root_p] += wt[root_q];
			nodes[root_q] = root_p;
		}
		else {
			wt[root_q] += wt[root_p];
			nodes[root_p] = root_q;
		}
	}
}
int main(){
	fio;
	ll n, m, a, b;
	cin >> n >> m;
	For(i, 1, n+1) {
		nodes[i] = i;
		wt[i] = 1;
	}
	For(i, 0, m) {
		cin >> a >> b;
		do_union(a, b);
	}
	ll ans = 0;
	For(i, 1, n + 1) {
		if(nodes[i] == i)
			ans = max(ans, wt[i]);
	}
	cout << ans ;
}

Measured memory_bytes: 6780
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(input[0] + input[1] / 2);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	char ch;
	cin>>ch;
	cout<<(char)(ch+1)<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	int x = c - a; 
	int y = d - b;
	printf ("%d %d %d %d\n", c - y , d + x , a - y , b + x);
}


Measured memory_bytes: 128