akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b){
  if(a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }

  while(1){
    if(b == 0){
      return a;
    }
    int tmp = a % b;
    a = b;
    b = tmp;
  }
}
  

int main(){
  int n, k;
  int a[100010];
  cin >> n >> k;

  int g = 0, m = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
    g = gcd(a[i], g);
    m = max(m, a[i]);
  }

  if(k % g == 0 && m >= k){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int  maxn = 2e5 + 5;

int n;
bool mat[22][22];
int dp[22][1 << 22];
const int MOD = 1e9 + 7;
int rek(int at, int visited){
    if(__builtin_popcount(visited) == n ) return 1;

    if(at == n){
        return 0;
    }
    if(dp[at][visited] != -1){
        return dp[at][visited];
    }
    int ret = 0;
    for(int i = 0; i < n; i ++){
        if(mat[i][at] and !(visited & (1 << i))){
            int t = visited;
            t |= (1 << i);
            ret += rek(at + 1, t);
            ret %= MOD;
        }
    }
    return dp[at][visited] = ret % MOD;
}
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i ++){
        for(int j = 0; j < n; j ++){
            cin >> mat[i][j];
        }
    }
    memset(dp, -1, sizeof dp);
    cout << rek(0, 0) << endl;
        return 0;
}


Measured memory_bytes: 360832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};


int main(){
	ll n,a,b,i,j;
	cin>>n>>a>>b;
	if(a>b){
		cout<<0<<endl;
	}else if(n==1){
		if(a!=b){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
	}else{
		cout<<(b-a)*(n-2)+1<<endl;
	}
}

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

int main() {
    int h, w; cin >> h >> w;
    char mp[h + 2][w + 2]; 
    fill(mp[0], mp[h + 2], '.');
    for (int i = 1; i <= h; i++) {
        string row; cin >> row;
        for (int j = 1; j <= w; j++) {
            mp[i][j] = row[j - 1];
        }
    }

    int dx[] = {1, 0, -1};
    int dy[] = {1, 0, -1};
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (mp[i][j] == '.') {
                int bombs = 0;
                for (int x : dx)
                    for (int y : dy)
                        if (mp[i + x][j + y] == '#')
                            bombs++;
                cout << bombs;
            } else {
                cout << '#';
            }
        }
        cout << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	string S;
	int Q;
	cin >> S >> Q;
	string front, back;
	bool reverse = false;
	for(int i = 0; i < Q; i++) {
		int T;
		cin >> T;
		if(T == 1)
			reverse = !reverse;
		else {
			int F;
			string C;
			cin >> F >> C;
			if(F == 1) {
				if(!reverse)
					front += C;
				else
					back += C;
			} else {
				if(!reverse)
					back += C;
				else
					front += C;
			}
		}
	}
	if(!reverse) {
		for(int i = front.size() - 1; i >= 0; i--) cout << front[i];
		cout << S << back;
	} else {
		for(int i = back.size() - 1; i >= 0; i--) cout << back[i];
		for(int i = S.size() - 1; i >= 0; i--) cout << S[i];
		cout << front;
	}
	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    ll x;
    cin >> x;

    for(ll a = -118; a <= 119; ++a) {
        ll pow_a = a * a * a * a * a;
        for(ll b = -118; b <= 119; ++b) {
            ll pow_b = b * b * b * b * b;
            if(pow_a - pow_b == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

int main() {
  ll N;
  cin >> N;
  vector<string> words(N);
  for (ll i = 0; i < N; i++) {
    cin >> words[i];
  }

  string ans = "Yes";
  string before = words[0];
  for (ll i = 1; i < N; i++) {
    if (before.back() != words[i].front()) {
      ans = "No";
      break;
    }
    before = words[i];
  }
  sort(begin(words), end(words));
  vector<string> uniqued;
  unique_copy(begin(words), end(words), back_inserter(uniqued));

  if (words.size() != uniqued.size()) {
    ans = "No";
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
strs = list(S)

min_num = 1000
for i in range(len(strs)-2):
    num = int(strs[i]+strs[i+1]+strs[i+2])
    if abs(753-num) < min_num:
        min_num = abs(753-num)
print(min_num)


Measured memory_bytes: 2940
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 1e5 + 10 ;

int n , a [ N ] , X , Y , dp [ N ] ; 

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> X >> Y ;
	for ( int i = 1 ; i <= n ; i++ )
		cin >> a [ i ] ;
	for ( int i = 2 ; i <= n ; i++ ) {
		dp [ i ] = min ( ( a [ i ] - a [ i - 1 ] ) * X , Y ) + dp [ i - 1 ] ;  
	}
	cout << dp [ n ] << '\n' ; 
}


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

int main(){
    string s;
    vector<string> p;
    int k,i;
    cin >> s >> k;

    for( i=1;i<=k;i++){
        for(int j=0;j<s.size()-i+1;j++){
            p.push_back(s.substr(j,i));
           // cout << 0 << endl;
        }
    }
    sort(p.begin(),p.end());
    p.erase(std::unique(p.begin(), p.end()), p.end());

    cout << p.at(k-1) << endl;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cstring>
#include <vector>
#include <cstring>

using namespace std;

int bucket[101];
int ma = 0;

int main()
{
	int a;
	
	memset(bucket, 0, sizeof(bucket));
	
	while(cin>>a, !cin.eof())
	{
		bucket[a]++;
		ma = max( bucket[a], ma);
	}
	
	for( int i = 0; i < 101; i++)
	{
		if(bucket[i] == ma)
			cout << i << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  int N;
  ll A, B;
  cin >> N >> A >> B;
  ll X[N];
  for(int i=0;i<N;i++){
    cin >> X[i];
  }

  ll ans = 0;
  for(int i=0;i<N-1;i++){
    ans += min(A*(X[i+1]-X[i]), B);
  }
  cout << ans <<endl;
  
  return 0;
}






Measured memory_bytes: 1024
if __name__ == '__main__':

    nm = input()
    nm = nm.split()
    n = int(nm[0])
    m = int(nm[1])

    h = input()
    h = h.split()
    h = list(map(int,h))

    AB = []
    ma = [0]*n
    for i in range(m):
        ab = input()
        ab = ab.split()
        ab = list(map(int,ab))
        ma[ab[0]-1] = max(ma[ab[0]-1],h[ab[1]-1])
        ma[ab[1]-1] = max(ma[ab[1]-1],h[ab[0]-1])

    ans = 0
    for i in range(n):
        if h[i] > ma[i]:
            ans += 1
    print(ans)


Measured memory_bytes: 20104
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	K, _ := strconv.Atoi(read())
	if N-K < 0 {
		fmt.Println(1)
	} else {
		N -= K
		fmt.Println((N+(K-2))/(K-1) + 1)
	}
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

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

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
 
using namespace std;
typedef long long ll;

ll ans,mx,sum;
int main(){
	ll n;
	cin>>n;
	ll a[n],b[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int i=0; i<n; i++){
		cin>>b[i];
	}
	for(int i = 0; i<n; i++){
		if(a[i]>b[i]) ans+= a[i]-b[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <utility>
using namespace std;
long long a[100010],b[100010],sum1 = 0,sum2 = 0,ans = 0,c = 0,d = 0;
multiset<long long> s;
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		sum1 += a[i];
	}
	for(i=0;i<n;i++){
		cin >> b[i];
		sum2 += b[i];
	}
	if(sum1<sum2){
		cout << -1 << endl;
		return 0;
	}
	for(i=0;i<n;i++){
		if(a[i]>=b[i]){
			s.insert(a[i] - b[i]);
		}else{
			c += a[i];
			d += b[i];
		}
	}
	while(s.size()){
		auto it = s.begin();
		sum2 += *it;
		if(sum1>=sum2){
			s.erase(it);
			ans++;
		}else{
			cout << n - ans << endl;
			return 0;
		}
	}
	cout << n - ans << endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int a,b,num = 0;
  cin >> a >> b;
  
  for(int i = 0; a <= b; i++) {
    bool flag = 0;
    string s = to_string(a);
    int n = s.size();
    for(int j = 0; j < double(n/2); j++) {
      if(s[j] == s[n-1-j]) 
        flag = 1;
      else {
        flag = 0; 
        break;
      }
    }
    if(flag) num++;
    a++;
  }
  cout << num << endl;
}

Measured memory_bytes: 3768
import heapq

N, K = map(int, input().split())
V = list(map(int, input().split()))

lesser = min(N, K)
ans = 0
for A in range(lesser + 1):
    for B in range(lesser + 1):
        if A + B > lesser:
            continue
        holding = V[:A] + V[N - B:]
        heapq.heapify(holding)
        S = sum(holding)
        CD = K - (A + B)
        for i in range(min(A + B, CD)):
            p = heapq.heappop(holding)
            if p >= 0:
                break
            S -= p
        ans = max(ans, S)
print(ans)


Measured memory_bytes: 51292
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
        int n,i,j;
        ll cnt_0,cnt_1,tmp,ans=0;
        cin >> n;
        vector<ll> a(n);
        for(i=0;i<n;++i) cin >> a.at(i);
        for(i=0;i<60;++i){
                cnt_1=0; cnt_0=0;
                for(j=0;j<n;++j) if((a.at(j)>>i)&1) ++cnt_1;
                cnt_0 = n - cnt_1;
                tmp = (cnt_1*cnt_0)%MOD;
                for(j=0;j<i;++j) tmp = (tmp*2)%MOD;
                ans = (ans+tmp)%MOD;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 5552
from collections import Counter as C;r=range(3)
def s():
	H,W,N,*L=map(int,open(0).read().split());K=[];M=[(H-2)*(W-2)]+[0]*9
	for a,b in zip(*[iter(L)]*2):
		for x in r:
			for y in r:
				if H-1>a-y>0<b-x<W-1:K+=[(a-y)*W+b-x]
	for k,v in C(C(K).values()).items():M[0]-=v;M[k]+=v
	print(*M)
if __name__=="__main__":s()

Measured memory_bytes: 124492
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    long long int sum=0,ma=0,V[500];
    cin >> N >> K;
    
    for(int i=0;i<N;i++)
        cin >> V[i];
    
    for(int k=0;k<=K;k++)
        for(int l=0;l<=min(k,N);l++){
            int r = k-l;
            sum = 0;
            priority_queue<long long int> que;
            que = priority_queue<long long int>();
            for(int j=0;j<l;j++){
                sum += V[j];
                if(V[j] < 0){
                    que.push(-V[j]);
                }
            }
            for(int j=N-1;j>N-1-r && j >= l;j--){
                sum += V[j];
                if(V[j] < 0){
                    que.push(-V[j]);
                }
            }
            for(int i=0;i<K-l-r;i++){
                if(que.empty())
                    break;
                sum += que.top();
                que.pop();
            }
            ma = max(ma,sum);
    }
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n int
	var s string
	Fscan(in, &n, &s)
	if len(s) <= n {
		Fprintln(out, s)
	} else {
		Fprintln(out, s[:n]+"...")
	}
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 1832
def A(test=None):

    if test:
        pass
    else:
        S = input()

    continuous = 0
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            continuous += 1

    if continuous > 0:
        answer = 'Bad'
    else:
        answer = 'Good'

    print(answer)


def B(test=None):

    if test:
        N, L = test
    else:
        N, L = map(int, input().split())

    _sum = int(L * N - N + N * (N + 1) / 2)

    if L <= 0:
        ate = min(0, L + N - 1)
    else:
        ate = max(0, L)

    print(_sum - ate)

def main():
    # A()
    B()


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define bitcount(s) __builtin_popcount(s)
using namespace std;
typedef long long ll;
const ll Mod = (ll)(1e9) + 7;
vector<vector<int>> a;

int getbit(int s,int k){
    return (s >> k) & 1;
}

void add(ll &a,ll b){
    a += b;
    if (a >= Mod) a -= Mod;
}
int n;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    a.resize(n, vector<int> (n));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) cin >> a[i][j];

    
    //dp[mask] la so luong cap sao cho ko ton tai 2 ng o 2 hang hoac 2 cot bat ki
    vector<ll> dp((1 << n));
    dp[0] = 1LL;
    for (int mask = 1; mask < (1 << n); mask++){
        int nn = __builtin_popcount(mask) - 1;
        //cout << nn << '\n';
        //if (nn == n) break;
        for (int i = 0; i < n; i++)
            if ((getbit(mask,i) == 1) && (a[nn][i] == 1)){
                int premask = (mask ^ (1 << i));
                add(dp[mask],dp[premask]);
            }
    }    

    cout << dp[(1 << n) - 1];
    return 0;
}

Measured memory_bytes: 16640
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

const int Maxn = (int) 1e5 + 10;
const int MOD = (int) 1e9 + 7;

vector<ll> divisors(ll n) {
    vector<ll> ret;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.emplace_back(i);
            if (i != n / i) ret.emplace_back(n / i);
        }
    }
    // NOT sorted
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    auto v = divisors(m);
    sort(v.begin(), v.end(), greater<ll>());
    for (auto &i: v) {
        if (m / i >= n){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int N_MAX = 100000;
int main()
{
  int n,h,a=0,t,i,res=0;
  int b[N_MAX];
  cin >> n >> h;
  for(i=0;i<n;i++){
    cin >> t >> b[i];
    a=max(a,t);
  }
  sort(b,b+n,greater<int>());
  for(i=0;i<n&&h>0;i++){
    if(b[i]<a)
      break;
    h-=b[i];
    res++;
  }
  if(h>0)
    res+=(int)ceil((double)h/a);
  cout << res << endl;
  return 0;
}

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

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

const double fiv_t[] = {
    35.5,
    37.5,
    40,
    43,
    50,
    55,
    70
};

const double th_t[] = {
    71,
    77,
    83,
    89,
    105,
    116,
    148
};

const string ss[] = {
    "AAA",
    "AA",
    "A",
    "B",
    "C",
    "D",
    "E"
};

const int inf = 1<<30;

int main(){
    double a, b;
    while(cin>>a>>b){
        int fiv = inf;
        int th = inf;
        rep(i,7)if(a<fiv_t[i]){
            fiv = i;
            break;
        }
        rep(i,7)if(b<th_t[i]){
            th =i;
            break;
        }
        int ans = max(th,fiv);
        if(ans == inf){
            cout <<"NA"<<endl;
        } else {
            cout <<ss[ans]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1236
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/06 09:02:48 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
int				h, w;
vector<string>	field;
const int		dy[4] = {0, 1, 0, -1};
const int		dx[4] = {1, 0, -1, 0};

void	Main()
{
	cin >> h >> w;

	field.resize(h);
	rep(i, h)
		cin >> field[i];
	queue<PII>	que;
	rep(y, h)
	{
		rep(x, w)
		{
			if (field[y][x] == '#')
				que.push(PII(y, x));
		}
	}
	que.push(PII(h, w));
	int	count;

	count = 0;
	while (que.size() > 1)
	{
		int y, x;

		y = que.front().first;
		x = que.front().second;
		que.pop();
		if (y == h && x == w)
		{
			count++;
			que.push(PII(h, w));
			continue;
		}
		rep(dir, 4)
		{
			int ny, nx;

			ny = y + dy[dir];
			nx = x + dx[dir];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w)
				continue;
			if (field[ny][nx] == '#')
				continue;
			field[ny][nx] = '#';
			que.push(PII(ny, nx));
		}
	}
	cout << count << endl;
}
// END

int32_t	main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 17716
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>

#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

// Debug Vector
template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
////    CLion Standard Input for DEBUG
////    --------------------------------------------------------------------------
//    ifstream in("./in.txt");
//    cin.rdbuf(in.rdbuf());
////    ------------------------------------------------------------------------
    int n;
    cin >> n;
    vector<int> as(n);

    for (auto &a : as){
        cin >> a;
    }

    sort(as.begin(), as.end());
    cout << as[n-1] - as[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;
  for (int i = -1000; i < 1000; ++i) {
    for (int j = -1000; j < 1000; ++j) {
      if(pow(i, 5) - pow(j, 5) == x){
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }

}



Measured memory_bytes: 4076
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int ans=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    ans+=s[i]-'0';
  }
  if(ans%9==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3748
'use strict';

function main(input){
    const S = input[0];
    let f=true;
    for(let i=0;i<4;i++){
        let count=S.split('').filter(x => x===S[i]).length
        if(count !== 2){
            f=false;
            break;
        }
    }
    if(f) console.log("Yes");
    else console.log("No");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'))

Measured memory_bytes: 20040
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define rep_(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) rep_(i, 0, n)
#define rev_(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) rev_(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define dump(x) cerr << #x << "=" << x <<endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);

void solve()
{
	/*--------------------------*/

	vi A(3); cin >> A[0] >> A[1] >> A[2];
	set<int> st(all(A));
	if (sz(st) == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	/*--------------------------*/
}

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()?.toLong() ?: return
    var r = n
    var i = 2L
    val divs = mutableListOf<Long>()
    while (i * i <= r) {
        if (r % i == 0L) {
            r /= i
            divs.add(i)
        } else {
            i++
        }
    }
    var count = 0
    if (r != 1L) {
        divs.add(r)
    }
    divs.groupBy { it }
        .forEach { t, u ->
            var c = u.size
            var j = 1
            while (c >= j) {
                c -= j
                j++
                count++
            }
        }

    println(count.toString())
}


Measured memory_bytes: 34576
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    u32 a, b, c;
    std::cin >> a >> b >> c;
    std::cout << (b-a == c-b ? "YES" : "NO") << '\n';
}


Measured memory_bytes: 256
N, M = map(int, input().split())

cutleftfrom = 0
cnt = 0
for a, b in sorted([list(map(int, input().split())) for _ in range(M)], key=lambda x:x[1]):
    if a < cutleftfrom:
        continue
    cutleftfrom = b
    cnt += 1

print(cnt)


Measured memory_bytes: 29852
import java.util.Arrays;
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wnqmw
 */
public class Main {
    public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        int nums = kb.nextInt(), sel = kb.nextInt();

        int[] num = new int[nums];

        int total = 0, totalvotes = 0;
        for(int i = 0; i < nums; i++){
            num[i] = kb.nextInt();
            totalvotes += num[i];
        }

        Arrays.sort(num);
        double req = (double)(totalvotes)/(4*sel);
        for(int i = nums-1; i >= 0; i--){
            if(num[i] >= req){
                total++;
             //   if(total == sel){
             //       break;
             //   }
            }
        }

        if(total < sel){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }


    }
}


Measured memory_bytes: 21844
use std::cmp::min;
fn main() {
    proconio::input! {
        n: usize,
        p: [proconio::marker::Usize1;n*n],
    }
    let mut d = vec![0;n*n];
    for i in 0..n { for j in 0..n {
        d[i*n+j] = min(min(i,n-1-i),min(j,n-1-j));
    }}
    let mut g = vec![1;n*n];
    let mut t = 0;
    for p in p {
        t += d[p];
        g[p]=0;
        f(p,n,&g,&mut d);
    }
    println!("{}",t);
}
fn f(i: usize, n: usize, g: &Vec<usize>, d: &mut Vec<usize>) {
    let c = d[i]+g[i];
    if i>=n {
        let u = i-n;
        if d[u]>c {
            d[u]=c;
            f(u,n,g,d);
        }
    }
    if i<n*(n-1) {
        let u = i+n;
        if d[u]>c {
            d[u]=c;
            f(u,n,g,d);
        }
    }
    let r = i%n;
    if r!=0 {
        let u = i-1;
        if d[u]>c {
            d[u]=c;
            f(u,n,g,d);
        }
    }
    if r!=n-1 {
        let u = i+1;
        if d[u]>c {
            d[u]=c;
            f(u,n,g,d);
        }
    }
}

Measured memory_bytes: 32372
//
// Created by rect0r on 16-02-2020.
//
#include <bits/stdc++.h>
#define ll long long
#define mod1 (1000000009)
#define mod2 (100000007)
#define lim pow(1000000000)
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "w", stdout);
#endif*/
    ll T;
    //cin >> T;
    T = 1;
    while (T--) {
        string s;
        cin>>s;
        vector<char> t;
        ll g=1,p=0;
        t.pb('g');
        ll n=s.length();
        for(ll i=1;i<n;i++){
            if(p==g){
                t.pb('g');
                g++;
            } else {
                t.pb('p');
                p++;
            }
        }
        int ans=0;
        for(int i=0;i<n;i++){
            if(s[i]=='g' && t[i]=='p')
                ans++;
            else if(s[i]=='p' && t[i]=='g')
                ans--;
        }
        cout<<ans;
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 640
sa = input()
sb = input()
sc = input()
players = {"a":sa, "b":sb, "c":sc}
if sa[0] == "a":
	p = "a"
	sa = sa[1:]
elif sb[0] == "b":
	p = "b"
	sb = sb[1:]
else:
	p = "c"
	sc = sc[1:]
while players["a"] or players["b"] or players["c"]:
	if not players[p]:
		print(p.upper())
		exit()
	card = players[p][0]
	players[p] = players[p][1:]
	p = card


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cstdio>
using namespace std;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
typedef complex<double> point;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

vector<point> convex_hull(vector<point> ps) {
  int n = ps.size(), k = 0;
  sort(ps.begin(), ps.end());
  vector<point> ch(2*n);
  for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

int main(){
	int n;
	while(cin >> n && n){
		vector<point> pp(n);
		for(int i=0;i<n;i++){
			scanf("%lf,%lf\n",&pp[i].real(),&pp[i].imag());
		}
		cout << n-convex_hull(pp).size() << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		long t=sc.nextLong(),sum=t,buff=sc.nextLong();
		for(int i=1;i<n;i++) {
			long now=sc.nextLong();
			sum+=Math.min(t, now-buff);
			buff=now;
		}
		System.out.println(sum);
	}
}


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

int main() {
    int N, A;
    cin >> N >> A;
    int x[N];
    for (int i = 0; i < N; i++) {
        cin >> x[i];
        x[i] -= A;
    }
    int l = 2 * 50 * 50 + 1;
    int m = 50 * 50;
    ll dp[N + 1][l]{};
    dp[0][m] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0;j < l; j++) {
            dp[i + 1][j] = dp[i][j];
        }
        for (int j = 0; j < l; j++) {
            if (0 <= j - x[i] && j - x[i] < l) {
                dp[i + 1][j - x[i]] += dp[i][j];
            }
        }
    }
    cout << dp[N][m] - 1<< "\n";
    return 0;
}


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

signed main() {
	int N,K,Q;
	cin>>N>>K>>Q;
	int A[Q];
	for(int i=0;i<Q;i++){
		cin>>A[i];
	}
	int arr[N]={0};
	int operations = Q;
	int increment_final = K-Q;
	
	for(int i=0;i<Q;i++){
		arr[A[i]-1]++;
	}
	// cout<<"Array before increment ";
	// for(int i=0;i<N;i++){
	// 	cout<<arr[i]<<" ";
	// }
	// cout<<endl;
	for(int i=0;i<N;i++){
		arr[i] += increment_final;
	}
	// cout<<"Final arr = ";
	// for(int i=0;i<N;i++){
	// 	cout<<arr[i]<<" ";
	// }
	// cout<<endl;
	for(int i=0;i<N;i++){
		if(arr[i]>0){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	
		
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
const ll mod=1000000007;
ll dp[300][200000];
int main(){
int n,x;
cin>>n>>x;
vector<ll> a(n);
for(ll i=0;i<n;i++)cin>>a[i];
dp[0][x]=1;
sort(all(a),greater<ll>());
for(ll i=0;i<n;i++){
    for(ll j=0;j<=x;j++){
            dp[i+1][j%a[i]]+=dp[i][j];
            dp[i+1][j%a[i]]%=mod;          
            dp[i+1][j]+=dp[i][j]*(n - 1 - i);
            dp[i+1][j]%=mod;
         }
 }
 ll ans=0;
 for(ll i=1;i<=x;i++){
     ans+=dp[n][i]*i;
     ans%=mod;
}
cout<<ans<<endl;
}




Measured memory_bytes: 312064
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int V;
ll d[1000][1000];

void warshallFloyd() {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    while (1) {
        int m, s, g1, g2;
        cin >> V >> m >> s >> g1 >> g2;
        if (V == 0) {
            break;
        }
        for (int i = 0; i < V; i++) {
            fill(d[i], d[i] + V, inf);
        }
        for (int i = 0; i < V; i++) {
            d[i][i] = 0;
        }
        for (int i = 0; i < m; i++) {
            int x, y, z;
            cin >> x >> y >> z;
            d[x - 1][y - 1] = z;
        }
        warshallFloyd();
        ll ans = inf;
        for (int i = 0; i < V; i++) {
            ll num = d[s - 1][i] + d[i][g1 - 1] + d[i][g2 - 1];
            if (num < ans) {
                ans = num;
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
#define N 400005
int a[N],b[N];
bool ok[N];
int ans[N];
int ta[N],tb[N];
int p[N];
bool res[N];
int tans[N];
signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[i]=read();
	for(int i=0;i<n;i++) ok[i]=1;
	for(int k=0;k<30;k++)
	{
//		cout<<k<<endl;
		for(int i=0;i<n;i++) res[i]=0;
		for(int i=1;i<=n;i++) ta[i]=a[i]>>k&1;
		for(int i=1;i<=n;i++) tb[i]=b[i]>>k&1;
		for(int i=1;i<=n-1;i++) ta[i+n]=ta[i];
		tb[n+1]=2;
//		for(int i=1;i<=n+n-1;i++) printf("%d ",ta[i]); cout<<"\n";
//		for(int i=1;i<=n;i++) printf("%d ",tb[i]); cout<<"\n";
		int j=0;
		for(int i=2;i<=n;i++)
		{
			while(j&&tb[j+1]!=tb[i]) j=p[j];
			if(tb[j+1]==tb[i]) j++;
			p[i]=j;
		}
		j=0;
		for(int i=1;i<=n+n-1;i++)
		{
			while(j&&ta[i]!=tb[j+1]) j=p[j];
			if(ta[i]==tb[j+1]) j++;
//			printf("%d %d\n",i,j);
			if(j==n) res[i-n]=1,tans[i-n]=0;
		}
		for(int i=1;i<=n;i++) tb[i]=!tb[i];
		j=0;
		for(int i=2;i<=n;i++)
		{
			while(j&&tb[j+1]!=tb[i]) j=p[j];
			if(tb[j+1]==tb[i]) j++;
			p[i]=j;
		}
		j=0;
		for(int i=1;i<=n+n-1;i++)
		{
			while(j&&ta[i]!=tb[j+1]) j=p[j];
			if(ta[i]==tb[j+1]) j++;
			if(j==n) res[i-n]=1,tans[i-n]=1<<k;
		}
		for(int i=0;i<n;i++)
		{
//			printf("%d %d\n",res[i],tans[i]);
			if(res[i]==0) ok[i]=0;
			else if(ok[i]==1) ans[i]|=tans[i];
		}
	}
	for(int i=0;i<n;i++)
	{
		if(ok[i])
		{
			printf("%d %d\n",i,ans[i]);
		}
	}
#ifdef __LOCAL__
	printf("Time Used : %d\n",clock());
#endif
	return 0;
}



Measured memory_bytes: 13440
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

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

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

	vector<int> x(N);
	rep(i, N)
	{
		cin >> x[i];
	}

	int ans = numeric_limits<int>::max();
	for (int i = 0; i + K - 1 < N; ++i)
	{
		int cand = min(abs(x[i]), abs(x[i+K-1])) + (x[i+K-1] - x[i]);
		ans = min(ans, cand);
	}

	cout << ans << endl;
}

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

#define F first
#define S second
#define ll long long
#define pb push_back
#define endl '\n'

using namespace std;

const int MOD = 1e9 + 7;
const int N = 510;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	if (n >= 30) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 3544
b[5<<17],S[2<<17],q;char*p=S;main(t){for(scanf("%*d%s%*d ",S);*p;)b[++q]=1<<*p++-97;for(;~scanf(~getchar()&1?t=0,"%d%d ":"%d%s ",&q,S);)if(!t){for(int i=q;i<=*S;)t|=b[i++];printf("%d ",__builtin_popcount(t));}else b[q]=1<<*S-97;}

Measured memory_bytes: 2688
SS = list(input())
T = list(input())
list = []

for i in range(len(SS)):
    target = SS[:]
    flg = False
    for j in range(len(T)):
        if i + j == len(SS):
            break
        if i + j == len(SS) or (
            target[i + j] != "?" and target[i + j] != T[j]
        ):
            break
        target[i + j] = T[j]
        if j == len(T) - 1:
            flg = True
    if flg is True:
        list.append("".join(target).replace("?", "a"))

if len(list) == 0:
    print("UNRESTORABLE")
else:
    print(sorted(list)[0])


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

typedef long long ll;

int main()
{
    int i,j;
    string s;
    cin >> s;
    int temp = 0;
    int ans = 0;
    for(i = 0;i < s.size();++i){
        if(s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T'){
            ++temp;
        }else{
            if(temp > ans){
                ans = temp;
            }
            temp = 0;
        }
    }
    if(temp > ans){
        ans = temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll decompositPrime(ll n){

}
int main(){
    ll A,B;  cin>>A>>B;
    ll gcd=__gcd(A,B);
    ll ans=1;
    for(ll i=2;i*i<=gcd;i++){
        if(gcd%i==0){
            ans++;
            while(gcd%i==0){
                gcd/=i;
            }
        }
    }
    if(gcd!=1){
        ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;

int main(){
    string S;
    cin >> S;
    sort(S.begin(),S.end());
    if (S[0]==S[1] && S[2]==S[3] && S[1]!=S[2]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d%d", $n,$m);
  for($i=0; $i<$m; $i++){
      fscanf(STDIN, "%d%d", $a,$b);
      if($b == $n){
          $island[$b][] = $a;
      }else{
          if(isset($island[$b])){
              $island[$b] = min($island[$b],$a);
          }else{
              $island[$b] = $a;
          }
      }
  }
//   print_r($island);
  
  if(isset($island[$n])){
      foreach($island[$n] as $is){
          if($island[$is] == 1){
              echo "POSSIBLE";
              exit;
          }
      }
  }
  echo "IMPOSSIBLE";
  
  

Measured memory_bytes: 17140
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define maxn 200005
#define maxm 2001
#define Rint register int
#define INF 0x3f3f3f3f
using namespace std;
typedef long long lxl;
const lxl mod=1e9+7;

template <typename T>
inline void read(T &x)
{
	x=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	x*=f;
}

int N,A[maxn],B[maxn];
lxl f[(maxm<<1)+5][(maxm<<1)+5],ans;
lxl inv[(maxm<<2)+5],fac[(maxm<<2)+5],inv2[(maxm<<2)+5];

inline void init()
{
	inv[0]=inv[1]=fac[0]=fac[1]=inv2[0]=inv2[1]=1;
	for(int i=2;i<=(maxm<<2);++i)
	{
		inv[i]=(mod-mod/i)*inv[mod%i]%mod;
		fac[i]=fac[i-1]*i%mod;
		inv2[i]=inv2[i-1]*inv[i]%mod;
	}
}

inline lxl C(int n,int m)
{
	return fac[n]*inv2[m]%mod*inv2[n-m]%mod;
}

int main()
{
	read(N);
	init();
	for(int i=1;i<=N;++i)
	{
		read(A[i]),read(B[i]);
		++f[maxm-A[i]][maxm-B[i]];
	}
	for(int i=1;i<=(maxm<<1);++i)
		for(int j=1;j<=(maxm<<1);++j)
			(f[i][j]+=(f[i-1][j]+f[i][j-1])%mod)%=mod;
	for(int i=1;i<=N;++i)
	{
		(ans+=f[maxm+A[i]][maxm+B[i]])%=mod;
		(ans+=mod-C(2*A[i]+2*B[i],2*A[i]))%=mod;
	}
	printf("%lld\n",ans*inv[2]%mod);
	return 0;
}


Measured memory_bytes: 130264
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  ll n, a[5];
  cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  ll mini = a[0];
  for (int i = 1; i < 5; i++){
    mini = min(mini, a[i]);
  }
  cout << (n + mini-1) / mini + 4 << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int A,B,X; cin>>A>>B>>X;
  int ans=0;
  if(A%X==0)
    ans=1;
  int K=B/X;
  int L=A/X;
  cout<<K-L+ans<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool OK = true;
  for (int i = 0; i < s.size(); i++)
  {
    if (i == a)
      continue;
    if (s[i] == '-')
      OK = false;
  }
  if (s[a] != '-')
    OK = false;
  if (OK)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256