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

#define int long long int 

vector<int> rabin_karp(string const& s, string const& t) {
    const int p = 31; 
    const int m = 1e9 + 9;
    int S = s.size(), T = t.size();

    vector<long long> p_pow(max(S, T)); 
    p_pow[0] = 1; 
    for (int i = 1; i < (int)p_pow.size(); i++) 
        p_pow[i] = (p_pow[i-1] * p) % m;

    vector<long long> h(T + 1, 0); 
    for (int i = 0; i < T; i++)
        h[i+1] = (h[i] + (t[i] - 'a' + 1) * p_pow[i]) % m; 
    long long h_s = 0; 
    for (int i = 0; i < S; i++) 
        h_s = (h_s + (s[i] - 'a' + 1) * p_pow[i]) % m; 

    vector<int> occurences;
    for (int i = 0; i + S - 1 < T; i++) { 
        long long cur_h = (h[i+S] + m - h[i]) % m; 
        if (cur_h == h_s * p_pow[i] % m)
            occurences.push_back(i);
    }
    return occurences;
}
int32_t main()
{
  string s,t;
  cin>>s>>t;
  t+=t;

  cout<<(rabin_karp(s,t).size()>0?"Yes":"No")<<endl;
  
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  ll ans = min(N % K, K - N % K);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
put_s = input()
count = 0
f_half, s_half = put_s[:len(put_s)//2], put_s[(len(put_s)+1)//2:]
if f_half == reversed(s_half):
    print(count)
else:
    for x in range(len(f_half)):
        if f_half[x] != s_half[len(s_half)-x-1]:
            count += 1
    print(count)

Measured memory_bytes: 3060
// atcoder/abc156/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> reverse(pair<P, Q> p) { return make_pair(p.second, p.first); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;
constexpr int N = 2 * 1e5 + 5;

namespace math {
  lli fact[N], finv[N], inv[N];

  void init()
  {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < N; i++){
      fact[i] = fact[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  lli mod_comb(int n, int k)
  {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fact[n] * (finv[k] * finv[n - k] % mod) % mod;
  }
};

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  math::init();

  lli n, k;
  while (cin >> n >> k) {
    lli sum = 0;
    for (lli i = 0; i <= min(n - 1LL, k); ++i) {
      lli x = math::mod_comb(n, i) * math::mod_comb(n - 1, n - i - 1);
      (sum += x % mod) %= mod;
    }
    cout << sum << endl;
  }

  return 0;
}


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

int main(){
  int a,b,c,x;
  cin >> a >> b;
  c=0;
  x=a;
  bool u=true;
  
  for(int i=0;x<b+1;i++){
    u=true;
    if(x/10000!=x%10)
      u=false;
    if((x/1000)%10!=(x/10)%10)
      u=false;
    if(u)
      c++;
    x++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
def xgcd(a, b)
  b > 0 ? q=v=w=x = 1 : a=x = 0
  y = 0
  while b > 0
    v -= q*x; w -= q*y
    q,a = a.divmod b
    a,b,v,w,x,y = b,a,x,y,v,w
  end
  [a,x,y]
end
N,A,B = gets.split.map &:to_i
n,s,P = 1,2,10**9+7
30.times {|i| n*=s and n%=P if N[i]>0; s*=s; s%=P}
a,b = [A,B].map{|r| N < r+r ? N-r : r}.sort
s=t=u = 1
F =->(x,y){ x.upto(y){|i| t*=N+1-i; u*=i; t%=P; u%=P}; s += t*xgcd(u,P)[1]%P }
F[1,a]; F[a+1,b]
p (n<s ? P+n-s : n-s) % P

Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <queue>
using namespace std;
stack<int > d;

int tag[50005];

int main()
{
    char a[100];
    int x,y;
    while(cin>>a)
    {
        if(a[0]=='-')
        {
            x=d.top();d.pop();
            y=d.top();d.pop();
            d.push(y-x);
        }
        else if(a[0]=='+')
        {
            x=d.top();d.pop();
            y=d.top();d.pop();
            d.push(x+y);
        }
        else if(a[0]=='*')
        {
            x=d.top();d.pop();
            y=d.top();d.pop();
            d.push(x*y);
        }
        else if(a[0]=='/')
        {
            x=d.top();d.pop();
            y=d.top();d.pop();
            d.push(x/y);
        }
        else d.push(atoi(a));
    }
    cout<<d.top()<<endl;



}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if (b <= a){
        cout << "delicious" << endl;
    } else {
        if (b - a <= x){
            cout << "safe" << endl;
        } else {
            cout << "dangerous" << endl;
        }
    }




    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <bitset>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
// namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
// using mpi = mp::cpp_int;
// using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
// ll mod(long long val) {
//     long long res = val % MOD;
//     if (res < 0) res += MOD;
//     return res;
// }
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }
int num_verex, E, s, t, d;
vector<vector<int>> dist;
vector<vector<int>> dp;

// v: current node
// S: all visited nodes
// dp[S][v]: Minimum total cost from current node v to node 0 given visited nodes
// answer: dp[(1<<V)-1][0];
const int INF = 1e9;
int tsp(int S, int v) {
    if (S == (1 << num_verex) - 1) return v == 0 ? 0 : INF;
    if (dp[S][v] >= 0) return dp[S][v];
    int ret = INF;
    for (int u = 0; u < num_verex; ++u) {
        if (dist[u][v] == INF || (S>>u)&1) continue;
        ret = min(ret, tsp(S | (1 << u), u) + dist[u][v]);
    }
    return dp[S][v] = ret;
}

int main() {
    cin >> num_verex >> E;
    dist = vector<vector<int>>(num_verex, vector<int>(num_verex,INF));
    for (int i = 0; i < E; ++i) {
        cin >> s >> t >> d;
        dist[s][t] = d;
    }
    dp = vector<vector<int>>(1<<(num_verex+2), vector<int>(num_verex + 5, -1));
    int ans = tsp(0, 0);
    cout << ((ans != INF) ? ans : -1) << endl;
    return 0;
}


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

using namespace std;

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

  int n, m, a, b;
  cin >> n >> m;
  vector<set<int>> adj(n);
  vector<pair<int, int>> edges(m);
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    a--; b--;
    adj[a].insert(b);
    adj[b].insert(a);
    edges[i] = {a, b};
  }
  int res = 0;
  for (int i = 0; i < m; ++i) {
    a = edges[i].first;
    b = edges[i].second;
    adj[a].erase(b);
    adj[b].erase(a);
    vector<int> q(1, a);
    vector<bool> seen(n, false);
    seen[a] = true;
    int cnt = 0;
    while (!q.empty()) {
      int v = q.back();
      ++cnt;
      q.pop_back();
      for (auto &x: adj[v]) {
        if (!seen[x]) {
          q.push_back(x);
          seen[x] = true;
        }
      }
    }
    if (cnt < n) ++res;
    adj[a].insert(b);
    adj[b].insert(a);
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){

 ll d,t,s;
 cin>>d>>t>>s;
 
 if( d<= t*s){
	 cout<<"Yes";
 }
 else
 cout<<"No";
 
 





return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3644
cnt = int(input())
values = []
for i in range(cnt):
    values.append([int(x) for x in input().split()])

for x, y, z in values:
    if z ** 2 == x ** 2 + y ** 2:
        print('YES')
    elif x ** 2 == y ** 2 + z ** 2:
        print('YES')
    elif y ** 2 == x ** 2 + z ** 2:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 7808
#include<stdio.h>
int main(){
    int n,a[100000],i,t=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        t=a[t]-1;
        if(t==1){
            printf("%d\n",i+1);
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int n; cin >> n;
	if(n%2==0) cout << n << endl;
	else cout << n*2 << endl;
}

Measured memory_bytes: 256
#import <stdlib.h>
#import <Foundation/Foundation.h>

int main(){
    int N;
    scanf("%d", &N);
    int *numbers = (int*)malloc(N * sizeof(int));
    
    int n;
    int i = 0;
    int max = 0;
    while (scanf("%d", &n) != EOF) {
        numbers[i] = n;
        max = MAX(max,n);
        i++;
    }
    
    int count = 0;
    for (int value=max;value>=1;value--) {
        BOOL flag  = NO;
        for (i=0;i<N;i++) {
            if (numbers[i]==value) {
                if (!flag) {
                    count++;
                    flag = YES;
                }
                numbers[i]--;
            } else {
                flag = NO;
            }
        }
    }
    
    printf("%d", count);
    free(numbers);
}


Measured memory_bytes: 7504
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <iomanip>
using namespace std;

int main(int argc, char const *argv[]) {
  char c;
  cin >> c;
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;
typedef pair<int, int> pii;

int main(){
	int h, w; cin >> h >> w;
	int cnt = 0;
	int prevcnt = 0;
	char mp[h][w];
	queue<pii> q;
	for( int i = 0; i < h; ++i ){
		for( int j = 0; j < w; ++j ){
			cin >> mp[i][j];
			if( mp[i][j] == '#' ){
				q.emplace(i, j);
				++prevcnt;
			}
		}
	}
	vector<pii> bw = {pii(-1, 0), pii(1, 0), pii(0, -1), pii(0, 1)};
	int ans = 0;
	bool flag = false;
	while( !q.empty() ){
		flag = false;
		int cnt = 0;
		while( prevcnt-- ){
			pii pos = q.front(); q.pop();
			int x = pos.first;
			int y = pos.second;
			for( auto d : bw ){
				int dx = x + d.first;
				int dy = y + d.second;
				if( 0 <= dx && dx < h && 0 <= dy && dy < w && mp[dx][dy] == '.' ){
					mp[dx][dy] = '#';
					q.emplace(dx, dy);
					flag = true;
					++cnt;
				}
			}
		}
		if( flag ) ++ans;
		prevcnt = cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9360
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <unordered_set>

using namespace std;
const int MAXN = 100001;
int A[MAXN];
int B[MAXN];
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    B[0] = 0;
    B[1] = abs(A[1]-A[0]);
    for(int i = 2; i < n; i++) B[i] = min(B[i-1]+abs(A[i]-A[i-1]),B[i-2]+abs(A[i]-A[i-2]));
    cout << B[n-1];
}

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

int main() {
  int n;
  cin >> n;
  long long m=0, a=0, r=0, c=0, h=0;
  for(int i=0; i<n; i++){
    string str;
    cin >> str;
    char ch = str[0];
    if(ch == 'M') m++;
    if(ch == 'A') a++;
    if(ch == 'R') r++;
    if(ch == 'C') c++;
    if(ch == 'H') h++;
  }
  long long sum = 0;
  sum+=m*a*r;
  sum+=m*a*c;
  sum+=m*a*h;
  sum+=m*r*c;
  sum+=m*r*h;
  sum+=m*c*h;
  sum+=a*r*c;
  sum+=a*r*h;
  sum+=a*c*h;
  sum+=r*c*h;
  cout << sum << endl;
  return 0;
}
  
  


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  vector<vector<int>>xy(4,vector<int>(2,0));
  
  cin >> xy[0][0] >> xy[0][1] >> xy[1][0] >> xy[1][1];
  
  xy[2][0] = xy[1][0] + xy[0][1] - xy[1][1];
  xy[2][1] = xy[1][1] + xy[1][0] - xy[0][0];
  
  xy[3][0] = xy[0][0] + xy[0][1] - xy[1][1];
  xy[3][1] = xy[0][1] + xy[1][0] - xy[0][0];
  
  cout << xy[2][0] << " " << xy[2][1] << " " << xy[3][0] << " " << xy[3][1] << endl;
  
  return 0;
}


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



void solve(){
  int a,b;
  int c; 
  cin >> a >> b;
  if(a==b) {c=2*a;}
  else { c=max(a,b)*2-1; }
  cout << c << endl;
}

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		scanner.nextLine();
		HashSet<String> set1 = new HashSet<>(Arrays.asList(scanner.nextLine().split(" ")));
		scanner.nextLine();
		int count=0;
		for(String str: scanner.nextLine().split(" ")) {
			if(set1.contains(str)) {
				count++;
			}
		}
		System.out.println(count);

	}

}



Measured memory_bytes: 75496
<?php

# a b
fscanf(STDIN, "%d %d", $a, $b);

$val = $a . $b;

$c = sqrt($val);

if (preg_match('/^[0-9]+$/', $c)) {
  echo "Yes" . "\n";
} else {
  echo "No" . "\n";
}

?>

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

int main() {
    int n;
    cin >> n;
    vector<int> X(n);
    int ave1,ave2,sum = 0;
    for (int i = 0; i < n ; i ++){
        cin >> X.at(i);
        sum += X.at(i);
    }
    ave1 = sum / n;
    ave2  =sum / n + 1;
    int sum1 = 0,sum2 = 0;
    for (int j = 0; j < n ; j ++){
        sum1 += pow(ave1 - X.at(j),2);
        sum2 += pow(ave2 - X.at(j),2);
    }
    cout << min(sum1,sum2) << endl;
}


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

int list[1000000] = {};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	while(cin >> n){
	
	if(list[n] != 0){
		cout << list[n] << endl;
		continue;
	}
		
	int cnt = 0;
	for(int i = 2; i <= n; ++i){
		bool check = true;
		for(int j = 2; i >= j * j; ++j){
			if(i % j == 0){
				check = false;
				break;
			}
		}
		if(check)
			cnt++;
		
		if(list[i] == 0){
			list[i] += list[i - 1] + check;
		}
	}
	
	cout << cnt << endl;
	
	}
	
	return 0;
}

Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m;
	cin>>n>>m;
	if(n==2||m==2)
	{
		cout<<0<<endl;
		return 0;
	}
	if(n>2&&m>2)
	{
		cout<<(n-2)*(m-2)<<endl;
		return 0;
	}
	if(n>2)
	{
		cout<<n-2<<endl;
		return 0;
	}
	if(m>2)
	{
		cout<<m-2<<endl;
		return 0;
	}
	cout<<1<<endl;
	return 0;
}

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

int main() {

    int n, a, b; cin >> n >> a >> b;
    int l = 0;
    int m = 0;
    int u = 0;
    for (int i = 0; i < n; i++) {
        int p; cin >> p;
        if (p <= a) l++;
        else if (p <= b) m++;
        else u++;
    }
    cout << min({ l,m,u }) << endl;
    return 0;
}

Measured memory_bytes: 3620
import sys
input=sys.stdin.readline

S = input().strip()

ans = 0
s = ""
i = 0
j = 1
while True:
    if s != S[i:j]:
        s = S[i:j]
        i = j
        j = i + 1
        ans += 1
    else:
        j += 1
    if i == len(S)-1:
        if s == S[i]:
            break
    if i > len(S)-1:
        break

print(ans)


Measured memory_bytes: 3500
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define pii pair<int,int>
#include<queue>
using namespace std;
queue<pii> q;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
struct node
{
	int from;
	int to;
	int next;
}edge[500005];
int n,m,head[100005],f[100005][3],tot,s,t;
void add(int u,int v)
{
	edge[tot].from=u;
	edge[tot].to=v;
	edge[tot].next=head[u];
	head[u]=tot++;
}
void bfs(int x)
{
	q.push(pii(x,0));
	while(!q.empty())
	{
		pii temp=q.front();q.pop();
		int x=temp.first,now=f[x][temp.second];
		for(int i=head[x];i!=-1;i=edge[i].next)
		{
			if(now+1<f[edge[i].to][(now+1)%3])
			{
				f[edge[i].to][(now+1)%3]=now+1;
				q.push(pii(edge[i].to,(now+1)%3));
			}
		}
	}
}
int main()
{
	n=read();m=read();
	memset(head,-1,sizeof(head));
	memset(f,0x3f3f3f3f,sizeof(f));
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read();
		add(x,y);
	}
	s=read();t=read();
	f[s][0]=0;
	bfs(s);
	//for(int i=1;i<=n;i++)
	//cout<<f[i][0]<<" "<<f[i][1]<<" "<<f[i][2]<<endl;
	if(f[t][0]>10000000) puts("-1");
	else cout<<f[t][0]/3;
}


Measured memory_bytes: 4736
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
        
        String s = r.readLine();
        int x = Integer.parseInt(s);
        x = x*x*x;
        
        System.out.println(x);
    }
}

Measured memory_bytes: 24240
#include<iostream>

using namespace std;

int main()
{
    for(int i = 1; i < 10; i++)
    {
        for(int j = 1; j < 10; j++)
        {
            cout << i << "x" << j << "=" << i*j << endl;
        }
    }

    return 0;
} 

Measured memory_bytes: 1116
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

int rec[100100];

int main()
{
	long long n;
	int i,a,b,top;
	scanf("%lld",&n);
	while(n)
    {
        top++;
		rec[top]=(n-1)%26;
		n--;
		n/=26;
	}
	for(i=top;i>=1;i--)
        printf("%c",'a'+rec[i]);
	printf("\n");
	return 0;
}



Measured memory_bytes: 1648
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sx = Integer.parseInt(sc.next());
        int sy = Integer.parseInt(sc.next());
        int tx = Integer.parseInt(sc.next());
        int ty = Integer.parseInt(sc.next());
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < Math.abs(ty - sy); i++) {
            ans.append("U");
        }
        for (int i = 0; i < Math.abs(tx - sx); i++) {
            ans.append("R");
        }
        for (int i = 0; i < Math.abs(ty - sy); i++) {
            ans.append("D");
        }
        for (int i = 0; i < Math.abs(tx - sx); i++) {
            ans.append("L");
        }
        ans.append("L");
        for (int i = 0; i < Math.abs(ty - sy) + 1; i++) {
            ans.append("U");
        }
        for (int i = 0; i < Math.abs(tx - sx) + 1; i++) {
            ans.append("R");
        }
        ans.append("D");
        ans.append("R");
        for (int i = 0; i < Math.abs(ty - sy) + 1; i++) {
            ans.append("D");
        }
        for (int i = 0; i < Math.abs(tx - sx) + 1; i++) {
            ans.append("L");
        }
        ans.append("U");
        System.out.println(ans.toString());
    }
}

Measured memory_bytes: 23252
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 1e5+10;

//head

int n;
int l[N], r[N];
ll K;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) cin >> l[i] >> r[i];
  sort(l, l+n+1, greater<int>());
  sort(r, r+n+1);
  rep(i, n) {
    if(l[i] > r[i]) K += (l[i] - r[i]) << 1;
  }
  cout << K << endl;
}

Measured memory_bytes: 4428
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        char c = s.charAt(k - 1);
        String result = s.replaceAll("[^" + c + "]", "*");

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23252
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_094_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(10).
    01 maxlen PIC 9(1)  VALUE 3.
    01 cur    PIC 9(2)  VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 len    PIC 9(2).
    01 ans    PIC -(8)9.
    01 ABX1.
        03 ABX11 OCCURS 3.
            05 ABX PIC S9(8).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO ABX(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    IF ABX(1) <= ABX(3) AND ABX(3) <= ABX(1) + ABX(2) THEN
        DISPLAY "YES";
    ELSE
        DISPLAY "NO";
    END-IF.

    STOP RUN.


Measured memory_bytes: 1016
mod = 998244353

N, *XD = map(int, open(0).read().split())

XD = sorted(zip(*[iter(XD)] * 2), reverse=True)

S = [(1e10, 0)]
dp = [1] + [0] * N
for i, (x, d) in enumerate(XD):
    j = i
    while S[-1][0] < x + d:
        _, j = S.pop()
    S.append((x, j))
    dp[i + 1] = (dp[i] + dp[j]) % mod

print(dp[-1])

Measured memory_bytes: 52200
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
  int n, m;  cin >> n >> m;
  vector<int> cnt(n+5);
  cnt[n] = 1;
  rep(i,m){
    int a; cin >> a;
    cnt[a] = -1;
  }
  const int mod = 1000000007;
  for(int i=n-1; i>=0; i--){
    if(cnt[i] == -1) continue;
    cnt[i] += (max(0,cnt[i+1])%mod+max(0,cnt[i+2])%mod)%mod;
  }
  cout << cnt[0] << endl;
  return 0;
}

Measured memory_bytes: 640
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:23/03/2020
'''


from math import ceil
def main():
    
    
    
    
    
    
    
    
    
    
    
    ans=0
    n=int(input())
    if(n==1):
        print('1')
    elif(n==2 or n==3):
        print('3')
    else:
        ans=0
        c=1
        while(n>3):
            ans+=c
            c*=2
            n//=2
        ans+=(3*c)
        print(ans)
    
    
    
    
    
    
    
    
    
if __name__ =="__main__":
    main()

Measured memory_bytes: 3064
k,n=map(int,input().split())
a=list(map(int,input().split()))
b=[0 for i in range(n)]

b[0]=k-a[n-1]+a[0]
for i in range(1,n):
  b[i]=a[i]-a[i-1]
  
print(k-max(b))

Measured memory_bytes: 26100
#include<bits/stdc++.h>
using namespace std;
int main(){
    int P,Q,R,a,b;
    cin >> P >> Q >> R;
    vector<int> c(3);
    c.at(0)=P;
    c.at(1)=Q;
    c.at(2)=R;
    sort(c.begin(),c.end());
    cout << c.at(0)+c.at(1) << endl;
    
}


Measured memory_bytes: 256
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int X; cin >> X;
    cout << 10 - X / 200 << endl;
}





Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;

int main(){
	int n;
	ll h[100000];

	cin >> n;
	for(int i=0;i<n;i++) cin >> h[i];

	int ans = 0;
	int tmp = 0;
	for(int i=1;i<n;i++){
		if(h[i-1]>=h[i]){
			tmp++;
		}else{
			ans = max(ans,tmp);
			tmp = 0;
		}
	}

	cout << max(ans, tmp) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; ++i) cin >> A[i];
    sort(A.begin(), A.end());
    bool T = true;
    for (int i = 0; i < N - 1; ++i) {
        if (A[i] == A[i + 1]) {
            T = false; break;
        }
    }
    if (T) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  int K;
  cin>>K;
    vector<int>moji(N);
  for(int i=0;i<N;i++){
  cin>>moji.at(i);
  }
  int sum=0;
  sort(moji.begin(),moji.end());
for(int i=0;i<K;i++){
  sum =sum+moji.at(i);
  }
   cout<<sum;
}

Measured memory_bytes: 3604
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1e9 + 7
var inf int = 1000000000000

type lazysegtree struct {
	n    int
	node []int
	lazy []int
}

func newlazySegtree(v []int) *lazysegtree {
	sz := len(v)
	_n := 1
	for _n < sz {
		_n *= 2
	}
	_node := make([]int, 2*_n-1)
	_lazy := make([]int, 2*_n-1)
	for i := 0; i < sz; i++ {
		_node[i+_n-1] = v[i]
	}
	for i := _n - 2; i >= 0; i-- {
		_node[i] = _node[2*i+1] + _node[2*i+2]
	}
	return &lazysegtree{
		n:    _n,
		node: _node,
		lazy: _lazy,
	}
}

// k番目のノードについて遅延評価を行う
func (u lazysegtree) eval(k int, l int, r int) {
	if u.lazy[k] != 0 {
		u.node[k] += u.lazy[k]
		if r-l > 1 {
			u.lazy[2*k+1] += u.lazy[k] / 2
			u.lazy[2*k+2] += u.lazy[k] / 2
		}
		u.lazy[k] = 0
	}
	return
}

func (u lazysegtree) add(a int, b int, x int, k int, l int, r int) {
	if r < 0 {
		r = u.n
	}
	u.eval(k, l, r)
	if b <= l || r <= a {
		return
	}
	if a <= l && r <= b {
		u.lazy[k] += (r - l) * x
		u.eval(k, l, r)
	} else {
		u.add(a, b, x, 2*k+1, l, (l+r)/2)
		u.add(a, b, x, 2*k+2, (l+r)/2, r)
		u.node[k] = u.node[2*k+1] + u.node[2*k+2]
	}
}

//[a,b)内の合計の取得
func (u lazysegtree) getsum(a int, b int, k int, l int, r int) int {
	if r < 0 {
		r = u.n
	}
	if r <= a || b <= l {
		return 0
	}
	u.eval(k, l, r)
	if a <= l && r <= b {
		return u.node[k]
	}
	vl := u.getsum(a, b, 2*k+1, l, (l+r)/2)
	vr := u.getsum(a, b, 2*k+2, (l+r)/2, r)
	return vl + vr
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	n := iScan()
	x := make([]int, n)
	y := make([]int, n)
	d := make([]int, n)
	D := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = iScan()
		y[i] = iScan()
		d[i] = x[i] + y[i]
		D[i] = x[i] - y[i]
	}
	ans1 := max(d) - min(d)
	ans2 := max(D) - min(D)
	if ans1 < ans2 {
		fmt.Println(ans2)
	} else {
		fmt.Println(ans1)
	}
}

Measured memory_bytes: 13516
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  string S; cin>>S;
  ll N=S.size()+1;
  vector<ll> A(N,0);
  rep(i,N)
  {
    if(i==0) {continue;}
    if(S.at(i-1)=='<') {A.at(i)=A.at(i-1)+1;}
  }
  /*
  rep(i,N)
  {
    if(i!=0) {cout<<" ";}
    cout<<A.at(i);
  }
  cout<<endl;
  */
  
  
  reverse(S.begin(),S.end());
  reverse(A.begin(),A.end());
  rep(i,N)
  {
    if(i==0) {continue;}
    if(S.at(i-1)=='>') {A.at(i)=max(A.at(i-1)+1,A.at(i));}
  }
  /*
  reverse(A.begin(),A.end());
  rep(i,N)
  {
    if(i!=0) {cout<<" ";}
    cout<<A.at(i);
  }
  cout<<endl;
  */
  
  ll ans=0;
  rep(i,N)
  {
    ans+=A.at(i);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4740
N, M = [int(v) for v in input().split()]
ans = [0] * (N + 1)
for i in range(M):
    a, b = [int(v) for v in input().split()]
    ans[a] += 1
    ans[b] += 1

for i in range(1, N+1):
    print(ans[i])

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

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

    ll answer;

    if(B <= N)
    {
        answer = (A*(B-1))/B;
    }
    else
    {
        answer = (A*N)/B;
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-
l,r = map(int, input().split())

if r-l+1>=2019 or l==0:
    print(0)
else:
    res = 2019*2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min(res, (i*j)%2019)
    print(res)

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

using namespace std;

using ll = int64_t;
using ull = uint64_t;
using ld = long double;

void gen(const string& s, int pos, string a, string b, vector<pair<string, string> >& res) {
    if (pos == s.size()) {
        res.emplace_back(a, b);
    } else {
        gen(s, pos + 1, a + s[pos], b, res);
        gen(s, pos + 1, a, b + s[pos], res);
    }
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    string a, b;
    for (int i = 0; i < n; i++) {
        a += s[i];
    }
    for (int i = n; i < n + n; i++) {
        b += s[i];
    }

    vector<pair<string, string> > ga, gb;
    gen(a, 0, "", "", ga);
    gen(b, 0, "", "", gb);
    for (auto& x : ga) {
        reverse(x.second.begin(), x.second.end());
    }
    for (auto& x : gb) {
        reverse(x.second.begin(), x.second.end());
    }
    map<pair<string, string>, int> cnt;
    for (const auto& x : ga) {
        cnt[x]++;
    }
    ll res = 0;
    for (const auto& x : gb) {
        res += cnt[make_pair(x.second, x.first)];
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 120556
N = int(input())
A = list(map(int, input().split()))

total_minus_num = 0
B = []
for a in A:
    if a < 0:
        total_minus_num += 1
    B.append(abs(a))

ans = sum(B)
if total_minus_num % 2 == 0:
    print(ans)
else:
    print(ans - 2 * min(B))


Measured memory_bytes: 20036
#include<stdio.h>

int gcd(int p, int q){
    if(p%q==0){
        return q;
    }
    else{
        return gcd(q, p % q);
    }
}


int main(){
    int K;
    scanf("%d",&K);

    int i,j,k;
    int sum=0;
    for(i=1;i<=K;i++){
        for(j=1;j<=K;j++){
            for(k=1;k<=K;k++){
                sum += gcd(gcd(i,j),k);
            }
        }
    }
    printf("%d\n",sum);
    return 0;
}
        





Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll H, W;
ll C[401][401];
vector<ll> adj[160001];
bool visited[401][401];
ll b, w;

void dfs(ll i, ll j){
    if(visited[i][j]) return;
    visited[i][j] = true;
    if(C[i][j] == '#') b++;
    else w++;
    if(i > 0 && C[i - 1][j] != C[i][j]) dfs(i - 1, j);
    if(i < H - 1 && C[i + 1][j] != C[i][j]) dfs(i + 1, j);
    if(j > 0 && C[i][j - 1] != C[i][j]) dfs(i, j - 1);
    if(j < W - 1 && C[i][j + 1] != C[i][j]) dfs(i, j + 1);
}

signed main(){
    cin >> H >> W;
    string S;
    REP(i, H){
        cin >> S;
        REP(j, W) C[i][j] = S[j];
    }
    ll ans = 0;
    REP(i, H){
        REP(j, W){
            b = w = 0;
            dfs(i, j);
            ans += b * w;
        }
    }
    PRINT(ans);
    return 0;
}

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

int main(){
    long long h,n;
    cin >> h >> n;
    long long sum = 0;
    for(int i=0; i<n; i++){
        long long a;
        cin >> a;
        sum += a;
    }
    if(sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    int N,M;cin>>N>>M;
    priority_queue<ll> PQ;
    for(int i=0;i<N;i++){
        ll a;cin>>a;
        PQ.push(a);
    }
    
    ll ans=0;
    
    for(int i=0;i<M;i++){
        ll a=PQ.top();PQ.pop();
        PQ.push(a/2);
    }
    
    while(!PQ.empty()){
        ans+=PQ.top();
        PQ.pop();
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 1400
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

nums = [0]*(n+1)
nums[0]  =1
if 1 not in a: nums[1] = 1

for i in range(2, n+1):
  nums[i] = nums[i-1] + nums[i-2]
  if i in a: nums[i] = 0
print(nums[n]%1000000007)

Measured memory_bytes: 465928
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    ll K;
    cin >> K;
    if(K % 2 == 0) {
        cout << A - B << endl;
    } else {
        cout << B - A << endl;
    }
    return 0;
}

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

int main(){
    int q; cin >> q;
    vector<int> a;
    rep(i ,q){
        int m , n;
        cin >> m;
        if( m == 0 ) {
            cin >> n;
            a.push_back(n);
        }
        else if( m == 1) {
            cin >> n;
            cout << a[n] << endl;
        }
        else {
            a.erase(a.end()-1);
        }
    }
    return 0;
}


Measured memory_bytes: 3932
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<unordered_map>
using namespace std;


int main()
{   
    long long N;
    cin >> N;
    
    vector<long long> A(N, 0);
    long long i;

    for(i=0; i<N; i++){
        cin >> A[i];
    }
    // prepare
    vector<long long> A_pos(N, 0), A_neg(N, 0);
    for(i=0; i<N; i++){
        A_pos[i] = i+1 + A[i];
        A_neg[i] = i+1 - A[i];
    }
    
    // compute
    long long sum = 0;
    
    unordered_map<long, long> hash;
    for(i=0; i<N; i++){
        if(!hash[A_neg[i]]){
            hash[A_neg[i]] = 1;
        }else{   
            hash[A_neg[i]] += 1;
        }
    }
    for(i=0; i<N; i++){
        sum += hash[A_pos[i]];
    }
    
    cout << sum << endl;

}


Measured memory_bytes: 23244
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

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

int main() {
    int a,b;
    double x = 0, y = 0, arg = 0;
    while(1) {
    	scanf("%d,%d",&a,&b);
    	if(a == 0 && b == 0) break;
    	x += a * sin(arg * (M_PI / 180.0));
    	y += a * cos(arg * (M_PI / 180.0));
    	arg += b;
    }
    cout << (int)x << endl;
    cout << (int)y << endl;
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n)cin >> a[i];
  int _min = 10000000,_max = -1, j = 0,k = 0;
  
  rep(i,n){
    if(_min>a[i]){
      _min = a[i];
      j = i;
    }
    if(_max<a[i]){
      _max = a[i];
      k = i;
    }
  }
  int z = 0;
  if(abs(_min) < abs(_max)) z = k;
  else z = j;
  cout<<(n-1)*2<<endl;
  rep(i,n) if(i != z)cout<<z+1<<" "<<i+1<<endl;
  if(z == k){
    rep(i,n-1){
    cout<<i+1<<" "<<i+2<<endl;
    }
  }
  else{
    for(int i = n-1;i>=1;i--){
      cout<<i+1<<" "<<i<<endl;
    }
  }
  return 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll inf = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/


int main(){
    fIO

    int n;
    cin >> n;

    cout << setprecision(10) << fixed << ((n + 1) / 2) / (double)n;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = -n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    ans += tmp;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
cums = [0]
for a in A:
    cums.append(cums[-1] + a)
ans = float('inf')
for i in range(1,N):
    c = cums[i]
    ans = min(ans, abs(cums[-1]-c - c))
print(ans)

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

int N;

int main() {
	cin >> N;

	vector<int> A(N);
	for (auto& Ai : A) cin >> Ai;
	
	long long res = 0;
	
	auto purp = A[N-1];
	for (int i = N-1; 1 <= i; --i) {
		if (A[i] < purp) {
			res = -1;
			break;
		}
		if (purp < A[i]) {
			if (i < purp) {
				res = -1;
				break;
			}
			res += purp;
		}
		purp = max(0, A[i]-1);
		if (A[i]) ++res;
	}
	
	if (A[0] != 0) res = -1;
	
	cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmin(T& a, U b){T bb = b;if(a>bb){a = bb;return 1;}return 0;}
template<class T, class U> inline bool chmax(T& a, U b){T bb = b;if(a<bb){a = bb;return 1;}return 0;}
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
#define double long double
#define PI 3.141592653589793
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e16;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

/*
void dijkstra(){
  priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;pq.push(make_pair(0,0));
  rep(i,110000)d[i] = INF;d[0] = 0;
  while(!pq.empty()){
    pair<int,int> from = pq.top();pq.pop();
    int fromV = from.second, fromC = from.first;
    if(d[fromV] < fromC)continue;
    rep(i,g[fromV].size()){
      int to = g[fromV][i];
      if(d[to] <= fromC+costs[to])continue;
      d[to] = fromC+costs[to];
      pq.push(make_pair(d[to], to));
    }
    //cout << fromV << " " << fromC << endl;
  }
}*/

int n;
signed main(){
  cin>>n;cout << n * n << endl;
}



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

int main(){
  pair<int,int>x;
  rep(i,5){
    cin>>x.first;
    x.second=i;
    if(x.first==0)cout<<i+1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628