akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	int R;
	cin >> R;
	cout << R * R << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
from math import sqrt
N, D = map(int,input().split())
points = []
for _ in range(N):
    points.append(np.array(list(map(int,input().split()))))
#print(points)

# def calc_dist(p1,p2):
#     dist = np.linalg.norm(p1-p2)
#     print(dist)
# calc_dist(points[0],points[1])
cnt = 0
for p1 in range(N):
    for p2 in range(p1+1,N):
        dist = np.linalg.norm(points[p1] - points[p2])
        #print(dist)
        if dist.is_integer():
            #print(dist)
            cnt += 1
print(cnt)

Measured memory_bytes: 12504
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e9;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct str { ll a, b, c, d; };
str st[51];
ll ans, n, m, q;
void go(ll pos, vector<ll> vc, ll lst)
{
    if (pos == n + 1)
    {
        ll sum = 0;
        for (ll i = 1; i <= q; i++)
        {
            if (vc[st[i].b - 1] - vc[st[i].a - 1] == st[i].c) sum += st[i].d;
        }
        ans = max(ans, sum);
        return;
    }
    for (ll i = lst; i <= m; i++)
    {
        vc.pb(i);
        go(pos + 1, vc, i);
        vc.pop_back();
    }
}

int main()
{
    fast_io;
    ll i, a, b, c, d;
    cin >> n >> m >> q;
    for (i = 1; i <= q; i++)
    {
        cin >> a >> b >> c >> d;
        st[i] = {a, b, c, d};
    }
    go(1, {}, 1);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3660
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();

    let mut ia = 0;
    for c in s.chars() {
        if c == 'A' {
            break;
        }
        ia += 1;
    }

    let mut iz = 0;
    let mut tmp = 0;
    for c in s.chars() {
        if c == 'Z' {
            iz = tmp;
        }
        tmp += 1;
    }

    println!("{}", iz - ia + 1);
}


Measured memory_bytes: 4352
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n1 = Integer.parseInt(sc.next());
            int n2 = Integer.parseInt(sc.next());
            int counter = 0;
            
            for(int i=n1; i<=n2; i++){
            	if(String.valueOf(i).substring(0,1).equals(String.valueOf(i).substring(4,5)) && String.valueOf(i).substring(1,2).equals(String.valueOf(i).substring(3,4))){
            		counter++;
            	}
            }
            
            //出力
            System.out.println(counter);
            sc.close();
        }
    }

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n = 50;
ll k, a[50];

int main() {
	cin >> k;
	
	// 0,1,2,...,n-1という数列を考え、0,1,2,..,n-1番目という順序で逆操作をするのをk/n周 1周ごとに全体が+1される
	rep(i,n) a[i] = i + k/n;
	// で残りk%n回は普通にシミュレート
	k %= n;
	rep(i,k) {
		a[i] += n+1;
		rep(j,n) a[j]--;
	}
	
	cout << n << ln;
	rep(i,n) cout << a[i] << (i==n-1 ? '\n' : ' ');
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 50
#define MIX 500
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;

typedef pair<string,int> psi;
typedef pair<int,string> pis;

vector<pis> e[MAX];
int n,m,s,g;

bool comp(string a,string b){
  int size=min(a.size(),b.size());
  FOR(i,0,size){
    if(a[i]<b[i])return true;
    if(b[i]<a[i])return false;
  }
  if(a.size()<b.size())return true;
  return false;
}

class compare{
  public:
    bool operator() (psi b,psi a){
      int size=min(a.f.size(),b.f.size());
      FOR(i,0,size){
        if(a.f[i]<b.f[i])return true;
        if(b.f[i]<a.f[i])return false;
     }
      if(a.f.size()<b.f.size())return true;
      return false;
    }
};

string solve(){
  priority_queue<psi,vector<psi>,compare > pq;
  string d[MAX][500];
  FOR(i,0,MAX)fill(d[i],d[i]+500,"~");
  d[s][0]="";
  pq.push(mp("",s));
  while(pq.size()){
    psi u = pq.top();
//    cout<<u.f.size()<<endl;
    pq.pop();
    if(comp(d[u.s][u.f.size()],u.f))continue;
    if(u.s==g && u.f.size()<240){
      FOR(i,0,240)
        if(comp(d[g][240+i],u.f))
          return "NO";
      return u.f;
    }
    FOR(i,0,e[u.s].size()){
      int next=e[u.s][i].f;
      string cost=u.f+e[u.s][i].s;
      int size = cost.size();
      if(500<=size)continue;
      if(comp(cost,d[next][size])){
        d[next][size]=cost;
        pq.push(mp(cost,next));
      }
    }
  }
  return "NO";
}

int main()
{
  while(1){
    cin>>n>>m>>s>>g;
    if(n+m+s+g==0)break;
    FOR(i,0,MAX)e[i].clear();
    FOR(i,0,m){
      int x,y;
      string S;
      cin>>x>>y>>S;
      e[x].pb(mp(y,S));
    }
    cout<<solve()<<endl;
  }
  return 0;
}


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

int main(int argc, const char * argv[]) {
    uint64_t N;
    cin >> N;
    
    uint64_t ans = 0;
    for (uint64_t i = 1; i < N; i++) {
        ans += i;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>

int main(void)
{
  int a,b;
  int ans1,ans2,ans3;
  scanf("%d%d",&a,&b);
  ans1=a+b;
  ans2=a-b;
  ans3=a*b;
  if(ans1>=ans2 && ans1 >= ans3)
    printf("%d",ans1);
  else if(ans2>= ans1 && ans2 >= ans3)
    printf("%d",ans2);
  else
    printf("%d",ans3);

  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] a = new long[N];
		long[] b = new long[N];
		for (int i = 0; i < N; ++i) {
			a[i] = sc.nextLong();
		}
		for (int i = 0; i < N; ++i) {
			b[i] = sc.nextLong();
		}
		long ans = 0;
		for (int k = 0; k <= 28; ++k) {
			long[] a_ = new long[N];
			long[] b_ = new long[N];
			long T = 1 << k;
			for (int i = 0; i < N; ++i) {
				a_[i] = a[i] % (2 * T);
				b_[i] = b[i] % (2 * T);
			}
			Arrays.sort(a_);
			Arrays.sort(b_);
			long c = 0;
			//[s,t)
			int s = 0;
			int t = 0;
			for (int i = N - 1; i >= 0; --i) {
				while (t < N && a_[i] + b_[t] < 2 * T)
					++t;
				while (s < N && a_[i] + b_[s] < T)
					++s;
				c ^= (t - s) % 2;
			}
			s = 0;
			t = 0;
			for (int i = N - 1; i >= 0; --i) {
				while (t < N && a_[i] + b_[t] < 4 * T)
					++t;
				while (s < N && a_[i] + b_[s] < 3 * T)
					++s;
				c ^= (t - s) % 2;
			}
			ans |= T * c;
		}
		System.out.println(ans);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;

void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	int n;
	cin >> n;
	vector<ll> a(n), b(n), f(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	if (a[n - 1] != b[0]) {
		cout << 0 << endl;
		return;
	}
	ll ans = 1;
	
	f[0] = f[n - 1] = 1;
	FOR (i, 1, n - 1) {
		if (b[n - i - 1] > b[n - i]) {
			f[n - i - 1] = b[n - i - 1];
			if (f[n - i - 1] > a[n - i - 1]) {
				cout << 0 << endl;
				return;
			}
		}
		if (a[i - 1] < a[i]) {
			f[i] = a[i];
			if (f[i] > b[i]) {
				cout << 0 << endl;
				return;
			}
		}
	}
	bool flag = false;
	rep(i, n) {
		if (f[i]) {
			continue;
		}
		flag = true;
		ans *= min(a[i], b[i]);
		ans %= 1000000007ll;
	}
	cout << ans << endl;
}




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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

class Main {

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

        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int i = 0;

        if (b > a) {
            i = b - (a + w);
        } else if (a > b) {
            i = a - (b + w);
        } else {
            i = 0;
        }
        if (i <= 0) {
            i = 0;
        }
        System.out.println(i);
    }
}


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

int sort(int *a,int n){
  int count=0;
  bool j=true;
  while(j){
    j=false;
    for(int i=1;i<n;i++){
    if(*(a+i-1)>*(a+i)){j=true; swap(*(a+i-1),*(a+i)); count++;}
  }}
  return count;
}


int main(){
  int n;
  cin>>n;
  int a[100000];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int c=sort(a,n);
  for(int i=0;i<n;i++){
    cout<<a[i];
    if(i!=n-1){cout<<" ";}
  }
  cout<<endl<<c<<endl;
  
  return 0;
}



Measured memory_bytes: 3088
x,k,d=map(int,input().split())

if x<0:
    x*=(-1)

dx=x//d
if dx<k:
    x-=d*dx
    k-=dx
else:
    x-=d*k
    k=0

if k%2==0:
    if x>=0:
        print(x)
    else:
        print((-1)*x)
else:
    print((x-d)*(-1))


Measured memory_bytes: 61812
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut a:usize = read!();
    let mut b:usize = read!();
    let mut d:usize = 1;
    for i in 0..a-1 {
        let mut c:usize = read!();
        if b>=c {
            b=c;
            d+=1;
        }
    }
    println!("{}",d);
}

Measured memory_bytes: 2064
import java.util.Scanner;

class Main {

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

        int x=stdIn.nextInt();
        long sum=0;
        for(int i=1; i<=x; i++){
            if(i%5!=0&&i%3!=0){
                sum+=i;
            }
        }
        System.out.println(sum);
        
        
    }

}

Measured memory_bytes: 35720
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    N, W = map(int, input().split())
    V = [[0] for _ in range(4)]
    for i in range(N):
        w, v = map(int, input().split())
        if i == 0:
            init = w
        V[w - init].append(v)

    for i in range(4):
        V[i].sort(reverse=True)

    res = 0
    for i in range(len(V[0]) + 1):
        a = sum(V[0][:i])
        for j in range(len(V[1]) + 1):
            b = sum(V[1][:j])
            for k in range(len(V[2]) + 1):
                c = sum(V[2][:k])
                for l in range(len(V[3]) + 1):
                    d = sum(V[3][:l])
                    total_w = init * i + (init + 1) * j + (init + 2) * k + (init + 3) * l
                    if total_w <= W:
                        res = max(res, a + b + c + d)
    print(res)


if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9164
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
ll h[111];

ll rec(ll l, ll r) {
    if(l>=r) return 0;
    
    ll res=0;
    ll i;
    ll min=INF;
    for(i=l; i<r; i++) chmin(min, h[i]);
    res+=min;
    
    vector<ll> ze;
    ze.pb(-1);
    for(i=l; i<r; i++) {
        h[i]-=min;
        if(h[i]==0) ze.pb(i);
    }
    ze.pb(r);
    
    for(i=0; i<ze.size()-1; i++)
        res+=rec(ze[i]+1, ze[i+1]);
    
    return res;
}

int main(void) {
    cin >> N;
    ll i;
    
    for(i=0; i<N; i++) cin >> h[i];
    
    pt(rec(0, N));
}




Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#include <numeric>
#include <map>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 1000000000000

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

vector< vector<int> > G(100005);
bool visited[100005];

void dfs(int root) {
	stack<int> s;
	visited[root] = true;
	s.push(root);
	while(!s.empty()) {
		int cur = s.top();
		s.pop();
		for (const int child : G[cur]) {
			if (visited[child])
				continue;
			s.push(child);
			visited[child] = true;
		}
	}
}

int main () {
	int N, M;
    cin >> N >> M;
	int x, y, z;
	rep(i,M) {
		cin >> x >> y >> z;
		--x;
		--y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (visited[i])
			continue;
		dfs(i);
		++ans;
	} 
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6648
#include <bits/stdc++.h>
#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++)
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<bool>a(101,true);
  
  a.at(0)==false;
  a.at(1)==false;
  
  
  rep2(i,2,n+1){
    if(a.at(i)){
      for(int j=i*2;j<n+1;j+=i){
        a.at(j)=false;
      }
    }
  }
  vector<int>b(101);
  rep2(i,2,n+1){
    if(a.at(i)){
      int ch=n/i;
      while(ch>0){
        b.at(i)+=ch;
        ch/=i;
      }
    }
  }
  int c=0;
  int d=0;
  int e=0;
  int f=0;
  int g=0;
  rep(i,n+1){
    if(b.at(i)>=74){
      c++;
    }
    if(b.at(i)>=24){
      d++;
    }
    if(b.at(i)>=14){
      e++;
    }
    if(b.at(i)>=4){
      f++;
    }
    if(b.at(i)>=2){
      g++;
    }
  }
  int h=0;
  if(g>1){
    h=d*(g-1);
  }
  int m=0;
  if(f>1){
    m=e*(f-1);
  }
  int l=0;
  if(f>1&&g>2){
    l=f*(f-1)/2*(g-2);
  }
  
  int ans=c+h+m+l;
  cout<<ans<<endl;

  
}
  




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
int n,m; ll ans;
struct cmp {
	bool operator() (int x,int y) { return x<y; }
};
priority_queue<int,vector<int>,cmp> q;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m); int x;
	while (n--) read(x),q.push(x);
	while (m--) {
		x=q.top(); q.pop();
		q.push(x/2);
	}
	while (!q.empty()) ans+=q.top(),q.pop();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 892
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,ll> > v;
	rep(i,0,n){
		ll a,b;
		cin>>a>>b;
		v.pb(mp(a,b));
	}
	sort(all(v));
	ll ans = 0;
	rep(i,0,n){
		ll a = min(m,v[i].se);
		ans += a*v[i].fi;
		m-=a;
	}
	cout << ans << endl;
	return 0;	
}

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

int main(){
//srandom((unsigned long)time(NULL));
long long n;
cin>>n;
if(n==1){
    cout<<"Yes"<<endl;
    return 0;
}
vector<long long> h;
for(long long i=0;i<n;i++){
    long long x;
    cin>>x;
    h.emplace_back(x);
}
long long mn=0;
for(long long i=0;i<n-1;i++){
    if(h[i+1]<mn){
        cout<<"No"<<endl;
        return 0;
    }
    if(h[i+1]<h[i]){
        h[i]--;
        mn=h[i];
    }
    if(h[i+1]<h[i]){
        cout<<"No"<<endl;
        return 0;
    }
}
cout<<"Yes"<<endl;

return 0;
}

Measured memory_bytes: 1400
import math

n=int(input())
h=list(map(int,input().split()))
now=-1;maxnum=0;
for i in range(n):
    if i==0:
        now+=1;
    elif h[n-i-1]>=h[n-i]:
        now+=1
    else:
        maxnum=max(maxnum,now)
        now=0
print(max(maxnum,now))


Measured memory_bytes: 63856
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];int mn=INT_MAX;
	for(int i=0;i<n;i++)
	{cin>>a[i];mn=min(mn, a[i]);}
	
	bool winning[k+1];
	memset(winning, 0, sizeof winning);
	for(int i=0;i<=k;i++)
	{
		for(auto c : a)
		{
			if(i-c>=0 and !winning[i-c]){winning[i]=1;}
		}
		
	}
	if(winning[k])cout<<"First\n";
	else cout<<"Second\n";
	
	
	
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long long K = 0;

long long f(long long x) { return llabs(x - K); }

int main()
{
  char in[1000];
  fgets(in, 1000, stdin);
  
  long long x = atoll(strtok(in," "));
  K = atoll(strtok(NULL, " "));
  
  if(x == 0) { printf("0"); return 0; }
  if(x == K) { printf("0"); return 0; }
  
  x %= K;
  long long old = x;
  long long next = f(x);
  for(; old > next && old != next; next = f(next)) { /*printf("%ld %ld\n", old, next);*/ old = next; }
  
  //printf("%ld\n", sizeof(long long));
  printf("%lld", old);
  return 0;
}

Measured memory_bytes: 128
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
void get_divisors(vl& d, ll n) {
    for(ll i= 1; i*i <= n; i++) {
        if (n%i == 0){
            ll m = n / i;
            if (i==m) d.push_back(m);
            else {
                d.push_back(i);
                d.push_back(m);
            }
        }
    }
}
#endif 


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

    int N, M; cin >> N >> M;

    vl divs;
    get_divisors(divs, M);

    ll ans = 1;
    for(ll d : divs) {
        if (d <= M / N) ans = max(ans, d);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from fractions import gcd
def solve(N: int, X: int, x: "List[int]"):
    ans = abs(X-x[0])
    for i in range(N):
        ans = gcd(ans, abs(X-x[i]))
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17620
#include <stdio.h>
#include <stdlib.h>

int top,a[1000];
int pop(void);
void push(int);

int main()
{
  int x,y;
  char str[100];
  top = 0;

  while(scanf("%s", str) !=EOF )
    {
      if(str[0]=='+')
	{
	  x = pop();
	  y = pop();
	  push(x+y);
	}
      else if(str[0]=='-')
	{
	  x = pop();
	  y = pop();
	  push(y-x);
	}
      else if(str[0]=='*')
	{
	  x = pop();
	  y = pop();
	  push(x*y);
	}
      else
	{
	  x = atoi(str);
	  push(x);
	}
    }
  printf("%d\n",pop());
  return 0;
}
void push(int n)
{
  top = top+1;
  a[top]=n;
}
int pop()
{
  top = top-1;
  return a[top+1];
}

  



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

using namespace std;
#define int long long
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define X first
#define Y second
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define all(o) o.begin(), o.end()
const int maxn = 1e6 + 10;
int dp[maxn];
vi adj[maxn];
void dfs(int v){
	if(adj[v].size() == 0) return;
	vi p;
	for(int u : adj[v]){
		dfs(u);
		p.push_back(dp[u]);
	}
	sort(all(p), greater<int>());
	int mx = 0;
	for(int i=0; i<p.size(); i++)
		mx = max(mx, p[i] + i);
	dp[v] = mx + 1;
}
main(){
	int n;
	cin >> n;
	for(int i=1; i<n; i++){
		int p;
		cin >> p;
		adj[p - 1].push_back(i);
	}
	dfs(0);
	cout << dp[0] << endl;

}

Measured memory_bytes: 35328
#include<bits/stdc++.h>
using namespace std;
#define d double
d dp[3001][3001];
d a[3001];
d f(int i, int k)
{
    d &ans = dp[i][k];
    if (ans != -1)
        return ans;
    if (i == 0)
    {
        if (k == 1)
            return (ans = a[0]);
        else if (k == 0)
            return (ans = (1 - a[0]));
        else
            return (ans = 0);
    }
    ans = 0;
    if (k != 0)
        ans += a[i] * f(i - 1, k - 1);
    ans += (1 - a[i]) * f(i - 1, k);
    return ans;
}
int main()
{
    for (int i = 0; i < 3001; ++i)
    {
        for (int j = 0; j < 3001; ++j)
        {
            dp[i][j] = -1;
        }
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    d ans = 0;
    for (int i = (n / 2) + 1; i <= n; ++i)
    {
        ans += f(n - 1, i);
    }
    cout << fixed << setprecision(10) << ans;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
  string in;
  cin >> in;
  int ans = 0;
  int tmp = 0;
  for( int i=0;i<in.size();i++)
    {
      if( in[i]=='A'
	  || in[i]=='T'
	  || in[i]=='C'
	  || in[i]=='G' )
	tmp++;
      else
	tmp = 0;
      ans = max(ans, tmp);
    }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

long long n, x_cnt, y_cnt, ans;
vector<int> x_edge[110000];
vector<int> y_edge[110000];
bool x_visited[110000];
bool y_visited[110000];

void dfs(int i)
{
  if (x_visited[i]) return;
  x_visited[i] = true;
  x_cnt++;
  for (int y: x_edge[i]) {
    if (y_visited[y]) {
      continue;
    }
    y_visited[y] = true;
    y_cnt++;
    for (int x: y_edge[y]) {
      dfs(x);
    }
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x_edge[x].push_back(y);
    y_edge[y].push_back(x);
  }
  
  for (int i = 1; i <= 100000; i++) {
    x_cnt = y_cnt = 0;
    dfs(i);
    ans += x_cnt * y_cnt;
  }
  
  ans -= n;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10240
import math
n = int(input())
mod = 10**9+7

def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

p = []
for i in range(1,n+1):
	if is_prime(i):
		p.append(i)
ans = 1
for i in p:
	s = 0
	x = i
	while x <= n:
		s += n//x
		x *= i
	ans *= (s+1)
	ans %= mod
print (ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

#define INF 1e+9
#define MAX_V 100005

struct edge {
    int to;
    int cost;
};

int V;
vector<edge> G[MAX_V];
int d[MAX_V];
vector<int> ans(MAX_V, -1);

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                ans[e.to]=v;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin >> V;
    int E;
    cin >> E;
    for (int i=0; i<E; ++i) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        edge e = {b, 1};
        edge e2 = {a, 1};
        G[a].push_back(e);
        G[b].push_back(e2);
    }
    dijkstra(0);
    ans[0]=0;
    rep(i, V){
      if(ans[i]==-1){
        cout << "No" <<endl;
        return 0;
      }
    }
    cout << "Yes" <<endl;
    repo(i, V-1){
      cout << ans[i]+1 << endl;
    }
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 998244353, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

int main()
{
    string s ;
    cin >> s ;

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '?')    s[i] = 'D' ;
    }
    cout << s ;


    return 0 ;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

void solve(long long N, long long K, std::vector<long long> a) {
    vector<long long> S;
    for (int i = 0; i < N; i++) {
        long long sum = 0;
        for (int j = i; j < N; j++) {
            sum += a[j];
            S.push_back(sum);
        }
    }

    sort(S.rbegin(), S.rend());
    long long ans = 0;
    for (int j = 42; j >= 0; j--) {
        int cnt = 0;
        int lst = 0;
        for (int k = 0; k < S.size(); k++) {
            if (S[k] >> j & 1) {
                cnt++;
                lst = k;
            }
        }
        if (cnt >= K) {
            ans += (1ll<<j);
            S.resize(lst + 1);
        } else {
            for (int k = 0; k < S.size(); k++) {
                S[k] &= ~(1ll << j);
            }
        }
        sort(S.rbegin(), S.rend());
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, K, std::move(a));
    return 0;
}


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

using namespace std;

typedef long long int lli;

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

    int n, a[20], b, c, bonus[20] = { 0 }, ans = 0;

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        if (i != 0 && a[i]-1 == a[i-1]) bonus[a[i-1]-1] = 1;
    }
    for (int i=0; i<n; i++) {
        cin >> b;
        ans += b;
    }
    for (int i=0; i<n-1; i++) {
        cin >> c;
        if (bonus[i]) ans += c;
    }

    cout << ans << endl;

    return 0;
}


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	string s = "CODEFESTIVAL2016";
	string wrong;
	cin >> wrong;
	int count = 0;
	rep(i,s.length()){
		if(s[i] != wrong[i])count++;
	}
	P(count);
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

long long int result[1001][128] = {};

long long int solve(int n, int d)
{
	if(result[n][d] > 0) return result[n][d];
	if(n == 1) return result[n][d] = d;
	for(int i = 0; i < 128; i++){
		result[n][d] = max(result[n][d], max(solve(n - 1, i) + (d ^ i), solve(n - 1, (d ^ i)) + i));
	}
	return result[n][d];
}

int main()
{
	int t;
	cin >> t;
	for(int i = 0; i < t; i++){
		int n, d;
		cin >> n >> d;
		cout << solve(n, d) << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n-1); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

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

int main(){
    int n, q; cin >> n >> q;
    string s; cin >> s;
    int left = 0, right = n-1;
    vector<char> t(q), d(q); rep(i,q) cin >> t[i] >> d[i];
    rrep(i,q){
        if(s[left] == t[i] && d[i] == 'L') left++;
        else if(left > 0 && s[left-1] == t[i] && d[i] == 'R') left--;
        if(s[right] == t[i] &&  d[i] == 'R') right--;
        else if(right < n-1 && s[right+1] == t[i] && d[i] == 'L') right++;
        if(right <= left){ cout << 0 << endl; return 0; }
    }
    cout << right - left + 1 << endl;
    return 0;
}


Measured memory_bytes: 3928
n = int(input())
a=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append([x,y])
ans=0
a=a[::-1]
for i,j in a:
  ans+=j- (i+ans)%j if (i+ans)%j else 0
print(ans)


Measured memory_bytes: 20392
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define f first
#define s second 
using namespace std;
const LL INF = (LL) 1e9 + 5;
const LL MOD = (LL) 1e9 + 7;
const int MAXN = 300005;

struct DSU {
	int pa[MAXN], sz[MAXN];
	void init(int n) {
		for (int i = 0; i <= n; i++) {
			pa[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		return x == pa[x] ? x : x = find(pa[x]);
	}
	int merge(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return 0;
		if (sz[x] < sz[y]) swap(x, y);
		sz[x] += sz[y];
		pa[y] = x;
		return 1;
	}
} ds;

struct Edge {
	int to, id;
};

int n, m, d[MAXN], w[MAXN], col[MAXN], dep[MAXN];
Edge pa[MAXN];
vector<Edge> G[MAXN];
vector<int> ch[MAXN];

void dfs(int v, int d) {
	dep[v] = d;
//	cout << "DFS " << v << " " << d << '\n';
	for (int to : ch[v]) {
		dfs(to, d + 1);
	}
}

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

	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> d[i];
	}
	for (int i = 1; i <= m; i++) {
		int u, v;
		cin >> u >> v;
		G[u].push_back({v, i});
		G[v].push_back({u, i});
		w[i] = (int) 1e9;
	}
	
	ds.init(n);
	for (int i = 1; i <= n; i++) {
		int ok = 0;
		for (Edge e : G[i]) {
			if (d[e.to] <= d[i]) {
				ok = 1;
				if (ds.merge(i, e.to)) {
					pa[i] = e;
					ch[e.to].push_back(i);
					w[e.id] = d[i];
				}
				break;
			}
		}
		if (!ok) {
			cout << "-1\n";
			return 0;
		}
	}
	
	for (int i = 1; i <= n; i++) {
//		cout << "At " << i << " " << pa[i].to << '\n';
		if (pa[i].to == 0) {
			dfs(i, 1);
		}
	}
	
	for (int i = 1; i <= n; i++) {
		assert(dep[i] != 0);
		cout << (dep[i] % 2 ? "B" : "W");
	}
	cout << '\n';
	for (int i = 1; i <= m; i++) {
		cout << w[i] << '\n';
	}

	return 0;
}

Measured memory_bytes: 32512
n=int(input())
a=[int(input()) for _ in range(n)]
b=sorted(a)
if b[-1]==b[-2]:f=1
else:f=0
for i in a:
  if f:print(b[-1])
  else:
    if i==b[-1]:print(b[-2])
    else:print(b[-1])

Measured memory_bytes: 19028
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  int ma = max({a1, a2, a3});
  int mi = min({a1, a2, a3});

  cout << ma - mi << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int w, h, n;
  cin >> w >> h >> n;
  int l = 0, r = w, u = h, d = 0;
  rep(i, n){
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1) l = max(x, l);
    if(a == 2) r = min(x, r);
    if(a == 3) d = max(y, d);
    if(a == 4) u = min(y, u);
  }
  if(r < l || u < d) cout << 0 << endl;
  else cout << (r-l)*(u-d) << endl;
  return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1010;

int n, l;
vector<string> a;

int main()
{
    cin >> n >> l;
    for(int i = 0; i < n; i++)
    {
        string t;
        cin >> t;
        a.push_back(t);
    }
    sort(a.begin(), a.end());

    for(int i = 0; i < a.size(); i++) cout << a[i];
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;


int main(void) {
	int N, K;
	scanf("%d %d", &N, &K);
	printf("%d\n", N - K + 1);
}

Measured memory_bytes: 256
x=input()
x0=x.split()
a=int(x0[0])
b=int(x0[1])
c=int(x0[2])
k=int(input())
q=0
while a>=b:
    q+=1
    b*=2
while b>=c:
    q+=1
    c*=2
if q<=k:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61860
s= input()

# 0 start
ans1 = 0
for i,c in enumerate(s):
    if i %2==1:
        if c != '1':
            ans1+=1
    else:
        if c !='0':
            ans1+=1

# 1 start
ans2=0
for i,c in enumerate(s):
    if i%2 ==1:
        if c!='0':
            ans2+=1
    else:
        if c!='1':
            ans2+=1

print(min(ans1,ans2))


Measured memory_bytes: 9228
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def gcd(a, b):
    if a < b:
        d, (p, q) = gcd(b, a)
        return d, (q, p)
    if b == 0:
        return a, (1, 0)
    d, (q, p) = gcd(b, a % b)
    q -= a // b * p
    return d, (p, q)


def ch(x, y):
    a1, m1 = x
    a2, m2 = y
    d, (p, q) = gcd(m1, m2)
    if (a2 - a1) % d != 0:
        return (0, -1)

    m = m1 * m2 // d
    r = (a1 + m1 * (a2 - a1) // d * p) % m
    return (r, m)


def main():
    N = int(input())
    D = len(str(N))

    res = 0
    for n in range(1, N + 1):
        p, q = int(str(n)[0]), int(str(n)[-1])
        if q == 0:
            continue
        for k in range(1, D + 1):
            if k == 1:
                res += 1 if p == q else 0
                continue

            if k == D:
                t = int(str(N)[0])
                if t < q:
                    continue
                elif t == q:
                    res += ((N - t * 10 ** (D - 1)) - p) // 10 + 1
                    continue

            res += 10 ** (k - 2)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;

void call(int n) {
    foreach(i;1..n+1) {
        if(i%3==0)
            writef(" %d",i);
        else {
            int x = i;
            while(x>0)
            {
                if( x%10==3 )
                {
                    writef(" %d",i);
                    break;
                }
                x = x/10;
            }
        }
    }
    writeln();
}

void main()
{
  auto n = readln;
  call(n.strip.to!int);
}

Measured memory_bytes: 2476
#include<bits/stdc++.h>
using namespace  std;
const int sz=1e5+100;
int main()
{
 
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    cin>>n>>m;
 
    cin>>str;
    
    int dist[n+5];
    ++n;

    dist[n-1]=0;
    
    bl=true;
    l=n-1;
    while(l>0)
    {
        int next=max(0,l-m);
        while(next<=l){
            if(str[next]=='0'){
                dist[next]=l-next;
                break;
            }
            else ++next;
        }

        if(l==next) {
            bl=false;
            break;
        }
      
        l=next;
    }
    

    if(!bl){
        cout<<"-1"<<endl;
        return 0;
    }
    
    l=0;
    cout<<dist[l];
    
    l=dist[l];
    while(l<n-1)
    {
        cout<<" "<<dist[l];
        l=dist[l]+l;
    }


    cout<<endl;
    
 
 
}

Measured memory_bytes: 1024
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
/*
	Problem: Sports Festival
	Source: AtCoder Grand Contest 018
	Author: fts2001 (the_silliest)
 */
using namespace std;
int n,m,a[305][305],cnt[305];
bool av[305];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
            a[i][j]--;
        }
    }
    for(int i=0;i<m;i++){
        av[i]=true;
    }
    int ans=n;
    for(int k=0;k<m;k++){
        for(int j=0;j<m;j++){
            cnt[j]=0;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(av[a[i][j]]){
                    cnt[a[i][j]]++;
                    break;
                }
            }
        }
        int mx=0;
        for(int j=1;j<m;j++){
            if(cnt[j]>cnt[mx])mx=j;
        }
        ans=min(ans,cnt[mx]);
        av[mx]=false;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int N;
int main() {
    while (cin >> N) {
        long long res = 1;
        long long sub = 1;
        for (int i = 0; i < N; ++i) {
            int a; cin >> a;
            res *= 3;
            if (a & 1) sub *= 1;
            else sub *= 2;
        }
        cout << res - sub << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
cnt = 0

for i in range(N-2):
    if P[i+1] < P[i] and P[i+1] > P[i+2]:
        cnt += 1
    elif  P[i+1] > P[i] and P[i+1] < P[i+2]:
        cnt += 1
print(cnt)

Measured memory_bytes: 38256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int pop();
void push();
int A[1000],top=0;
  
int main(){
  int a,b;
  char s[100];
    
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else
      push(atoi(s));
  }
  
  printf("%d\n",pop());
   
  return 0;
}
 
int pop(){
  top--;
  return A[top+1];
}
 
void push(int x){
  A[++top]=x;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=2e6+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,ch[N][3],tt,id[N],len,pos[N];
bool rev[N];
char s[N];

void reverse(int x) {
	rev[x]^=1;swap(ch[x][1],ch[x][2]);
}

void down(int x) {
	if(rev[x]) {
		for(int i=0;i<3;i++) reverse(ch[x][i]);
		rev[x]=0;
	}
}

int main() {
	cin>>m;n=powl(3,m)+0.5;scanf("%s",s+1);len=strlen(s+1);
	for(int i=0;i<n;i++) {
		int x=i,u=0;
		for(int j=0;j<m;j++) {
			if(!ch[u][x%3]) ch[u][x%3]=++tt;
			u=ch[u][x%3];x/=3;
		}
		id[u]=i;
	}
	for(int now=1;now<=len;now++)
		if(s[now]=='S') reverse(0);
		else {
			int u=0;
			for(int j=0;j<m;j++) {
				down(u);
				int tmp=ch[u][2];ch[u][2]=ch[u][1];ch[u][1]=ch[u][0];ch[u][0]=tmp;
				u=ch[u][0];
			}
		}
	for(int i=0;i<n;i++) {
		int x=i,u=0;
		for(int j=0;j<m;j++) {
			down(u);
			u=ch[u][x%3];x/=3;
		}
		pos[id[u]]=i;
	}
	for(int i=0;i<n;i++) cout<<pos[i]<<' ';
	return 0;
}


Measured memory_bytes: 19560
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int K = sc.nextInt();
        int S = sc.nextInt();

        System.out.println(solve(K, S));

        sc.close();
    }

    static int solve(int K, int S) {
        return IntStream.rangeClosed(0, K)
                .map(x -> (int) IntStream.rangeClosed(0, K).filter(y -> S - x - y >= 0 && S - x - y <= K).count())
                .sum();
    }
}

Measured memory_bytes: 28500