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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

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

    int cur = 1;
    for (int i = 0; i < n; ++i) {
        if(a[i] == cur) cur++;
    }
    int res = n - cur + 1;
    if(res == n) res = -1;
    cout << res << endl;
}

Measured memory_bytes: 1024
#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 n,m,cnt;

int vis[maxx];
vector < int > adj[maxx];


void dfs( int u ){
	
	
	vis[u] =1;
	
	for(auto it : adj[u]){
		
		
		if(vis[it]==0){
			dfs(it);
		}
		
		
	}
	cnt++;
	
	
	
}






int Main(){

cin>>n>>m;

memset(vis,0,sizeof(vis));

for(int i = 0 ; i < m;i++){
	
	int a,b;
	cin>>a>>b, a--,b--;
	
	adj[a].pb(b);
	adj[b].pb(a);
	
	
	
}


ll ans = 0;
for(int i =  0 ; i <n;i++){
	
	
	cnt=0 ;
	if(vis[i]==0)
	dfs(i);
	
	ans = max(ans , (ll )cnt);
	
	
	
	
}


cout<<ans<<endl;





return 0;

}






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

 return 0;


}


Measured memory_bytes: 21496
<?php
list($n, $m) = ints();
if ($n >= 2 && $m >= 2) $ans = ($n - 2) * ($m - 2);
elseif ($n === 1 && $m === 1) $ans = 1;
else $ans = max($n - 2, $m - 2);
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,c[100000],cmp,data,m,h,x,y,xcmp=0,ycmp=0;

string s,w;

vector<int> z;

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



pair<int,int> p[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;
       cin >> n >> a;
       long long int b[n-1];
       rep(i,n){
           cin >> b[i] >> c[i];
           p[i] = make_pair(b[i],c[i]);
       }
       sort(p,p+n);
       //cout << p[0].first <<p[0].second << endl;
      // rep(i,n){
        //   cout << b[i] << endl;
       //}
       rep(i,n){
           data+=p[i].second;
           if(data>=a){
               cout << p[i].first << endl;
               return 0;
           }
       }
       
return 0;
}


Measured memory_bytes: 2560
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from math import factorial
    from itertools import combinations_with_replacement
    input = sys.stdin.readline

    N, M, Q = map(int, input().split())
    query = []
    for _ in range(Q):
        query.append(tuple(map(int, input().split())))

    ans = 0
    L = list(range(1, M+1))
    for v in combinations_with_replacement(L, N):
        V = list(v)
        tmp = 0
        for a, b, c, d in query:
            if V[b-1] - V[a-1] == c:
                tmp += d
        ans = max(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()


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

int arr[100004];

void sieve(){
  for(int i = 0; i < 100004; i++)
    arr[i] = 1;
  arr[0] = arr[1] = 0;
  for(int i = 2; i <= sqrt(100004); i++){
    if(arr[i]){
      for(int j = i*i; j <= 100004; j+=i){
        arr[j] = 0;
      }
    }
  }
}
int main(){
  sieve();
  int N;
  cin >> N;
  int temp;
  for(int i = N; i < 100004; i++){
    if(arr[i] == 1){
      temp = i;
      break;
    }
  }
  cout << temp;
}
    


Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint fac(int n){
	mint res=1;
	for(int i=1; i<=n; i++) res*=i;
	return res;
}

int main(void) {
	int n,m; cin >> n >> m;
	if(abs(n-m)>=2){
		cout << 0 << endl;
		return 0;
	}
	mint ans = fac(n)*fac(m);
	if(n==m) ans *= 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, q;
  cin >> n;
  vector<int> a(200001);
  long long total=0, temp;
  for(int i=0; i<n; i++){
    cin >> temp;
    total += temp;
    a[temp]++;
  }
  cin >> q;
  vector<pair<int, int>> b(q);
  int num1, num2, ntemp, diff;
  for(int i=0; i<q; i++){
    cin >> num1 >> num2;
    diff = num2 - num1;
    total += (a[num1] * diff);
    a[num2] += a[num1];
    a[num1] = 0;
    cout << total << endl;
  }
  return 0;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  pp=1e9+7; 
double pi=3.141592653589793238;
  
 int main() {
        ff;
        string s;
        cin>>s;
        int n=s.length();
        if(s[n-1]=='s'){
            cout<<s<<"es"<<endl;
        }else
          cout<<s<<"s"<<endl;
		
    return 0;
}

            
		
        
           
  

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
typedef long long ll;
using namespace std;
const int inf=1e9;
 
int effect[100010];
int edge[100010];
bool visited[100010];
int dfs(int x) {
    if (effect[x]==0) return edge[x] = x;
    if (edge[x]!=-1) return edge[x];
    if (visited[x]) return inf; //roop?
    visited[x]=true;
    return edge[x] = dfs(x + effect[x]);
}
 
int main(){
    int n;
    cin>>n;
    int d[100010];
    REP(i,0,n) {
        cin>>effect[i];
        visited[i]=false;
        edge[i]=-1;
        d[i]=inf;
    }
    REP(i,0,n)  if(edge[i] == -1) dfs(i);
    priority_queue<pair<int,int>> pq;//cost,node
    d[0]=0;
    pq.push({0,0});
    while(!pq.empty()){
        int now = pq.top().second;
        pq.pop();
        REP(i,1,7){
            if(edge[now+i]==inf) continue;
            int next = edge[now+i];
            if(d[next] > d[now] + 1){
                d[next] = d[now] + 1;
                pq.push({-d[next],next});
            }
        }
        if(d[n-1] != inf) break;
    }
    p(d[n-1]);
    return 0;
}

Measured memory_bytes: 5668
sx, sy, tx, ty = map(int, input().split())
print("U"*(ty-sy) + "R"*(tx-sx) + "D"*(ty-sy) + "L"*(tx-sx) + "L" + "U"*(ty-sy+1) + "R"*(tx-sx+1) + "DR" + "D"*(ty-sy+1) + "L"*(tx-sx+1) + "U")

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

using namespace std;
 
#define pb push_back
#define mp make_pair
#define f first
#define s second
 
#define all(s) s.begin(),s.end()
#define spresent(s,v) ((s).find(v)!=s.end())
#define present(s,v) (find(all(s),v)!=s.end())
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL)
 
#define fill_1d(a,val) fill(a,a+sizeof(a)/sizeof(a[0]),val)
#define fill_2d(a,val) fill(&a[0][0],&a[0][0]+sizeof(a)/sizeof(a[0][0]),val)
#define fill_nd(a,p2f,val) fill(p2f,p2f+sizeof(a)/sizeof(*p2f),val)
 
#define deb(x) cout<<#x<<" = "<<x<<endl
#define dout(i,s) cout<<"Case #"<<i<<": "<<s<<"\n"
#define hout(i) cout<<"Case #"<<i<<": "

#define For(a,n) for(int i=a; (a<n?i<n:i>n) ; (a<n?++i:--i))
 
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
typedef struct node{
	ll val,more=0,less=0;
	bool operator <(const node& a){
		return val<a.val;
	}
}node;

struct House{
	int start, end, height;
};
ostream& operator << (ostream &os, const House &s) {
	return (os << "Start: " << s.start << ", End: " << s.end << ", Height: " << s.height);
}

struct Segment{
	int start, end, height;
	ll perimeter;
};
ostream& operator << (ostream &os, const Segment &s) {
	return (os << "Start: " << s.start << ", End: " << s.end << ", Height: " << s.height << ", Perimeter: " << s.perimeter);
}
bool operator <(const Segment& x, const Segment& y) {
    return x.start < y.start;
}



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



void solve(){


}


int main() {

	int n,x,t;
	cin>>n>>x>>t;

	cout<<(n+x-1)/x*t;








	return 0;
}





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

int n;

int get() {
	string S; cin >> S;
	if (S == "Male") return 0;
	if (S == "Female") return 1;
	return 2;
}

int main() {
	cin >> n;
	int L = 0, R = n, M, c;
	cout << "0" << endl;
	c = get();
	if (c == 2) {
		return 0;
	}
	for (int i = 0; i < 19; i++) {
		M = (L + R) / 2;
		cout << M << endl;
		int d = get();
		if (d == 2) { return 0; }
		int e = (d + M) % 2;
		if (e == c) L = M;
		else R = M;
	}
	return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, X;
  cin >> K >> X;
  int start = X - K + 1;
  for(int i = 0;i < 2 * (K-1);i++){
    cout << start + i << " ";
  }
  cout << start + 2 * (K-1) << endl;  
}

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

int main(){

  int a=0;
  int b=0;
  int c=0;
  cin>>a>>b>>c;
  cout<<c<<" "<<a<<" "<<b<<endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func pow(x, n, mod int64) int64 {
	if n == 0 {
		return 1
	}
	xx := x * x % mod
	r := pow(xx, n/2, mod)
	if n%2 == 1 {
		r = x * r % mod
	}
	return r
}

const mod = 1e9 + 7

func main() {
	var n int
	fmt.Scan(&n)
	var a []int
	var m, m2 int
	for i := 0; i < n; i++ {
		var t int
		fmt.Scan(&t)
		if m < t {
			m2 = m
			m = t
		} else if m2 < t {
			m2 = t
		}
		a = append(a, t)
	}
	for i := 0; i < n; i++ {
		if m == a[i] {
			fmt.Println(m2)
		} else {
			fmt.Println(m)
		}
	}
}


Measured memory_bytes: 9984
// Danielxlr
// https://atcoder.jp/contests/abc055/tasks/arc069_a
// math
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    long n,m;
    cin>>n>>m;

    if(m<2*n){
        cout<<min(n,m/2);
    }
    else{
        cout<<(2*n+m)/4;
    }
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <unordered_map>
#include <string>
#include <utility>

using namespace std;

bool comp(pair<string, int> a, pair<string, int> b)
{
    return a.second > b.second;
}

int main(int argc, char const *argv[])
{
    int N, M;
    string in;
    unordered_map<string, int> card;

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> in;
        card[in]++;
    }
    cin >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> in;
        card[in]--;
    }
    
    int max = 0;
    for (const auto& x : card)
    {
        if ((x.second) > max) max = x.second;
    }
    
    cout << max << endl;
    
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(), l.end());

  int ans = 0;
  rep(b,n)rep(a,b){
  	int ab = l[a] + l[b];
  	int left = b + 1;
  	int right = lower_bound(l.begin(), l.end(), ab) - l.begin();
  	ans += right - left;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

bool isgood(vector<string> bd, int x, int y){
    int cnt = 0;

    //lateral direction
    rep(i, 8)if(bd[x][i] == 'Q')cnt++;
    if(cnt != 1)return false;

    //longitudinal direction
    cnt = 0;
    rep(i, 8)if(bd[i][y] == 'Q')cnt++;
    if(cnt != 1)return false;

    // //diagonally upward
    cnt = 0;
    for(int i = 1; x+i < 8 && y+i < 8; ++i){
        if(bd[x+i][y+i] == 'Q')return false;
    }
    for(int i = 1; x-i >= 0 && y-i >= 0; ++i){
        if(bd[x-i][y-i] == 'Q')return false;
    }

    //diagonally downward
    cnt = 0;
    for(int i = 1; x+i < 8 && y-i >= 0; ++i){
        if(bd[x+i][y-i] == 'Q')return false;
    }
    for(int i = 1; x-i >= 0 && y+i < 8; ++i){
        if(bd[x-i][y+i] == 'Q')return false;
    }

    return true;
}

int main(){
    ll k;
    cin >> k;

    vector<int> c(8, -1);
    rep(i, k){
        int r;
        cin >> r;
        cin >> c[r];
    }

    vector<ll> ary(8);
    iota(ALL(ary), 0);

    vector<string> board(8);
    fill(ALL(board), "........");

    do{
        vector<string> board_cp = board;
        vector<int> pos(8);

        rep(i, 8){
            if(c[i] < 0)pos[i] = ary[i];
            else pos[i] = c[i];

            board_cp[i][pos[i]] = 'Q';
        }

        bool isOk = true;

        rep(i, 8){
            isOk &= isgood(board_cp, i, pos[i]);
        }

        
        if(isOk){
            board = board_cp;
            break;
        }

    }while(next_permutation(ALL(ary)));

    rep(i, 8){
        rep(j, 8)cout << board[i][j];
        cout << endl;
    }
}


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

struct Edge {
  int to, id;
  Edge(int to, int id): to(to), id(id) {}
};

vector<Edge> g[55];
bool done[55];

vector<int> es;
bool dfs(int v, int tv) {
    done[v]=true;
  if (v == tv) return true;
  for (Edge e : g[v]) {
    if (done[e.to]) continue;
    if (dfs(e.to, tv)) {
      es.push_back(e.id);
      return true;
    }
  }
  return false;
}

int main() {
  int n, m;
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].emplace_back(b, i);
    g[b].emplace_back(a, i);
  }

  cin >> m;
  vector<ll> eset(m);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    es = vector<int>();
    rep(i,n) done[i]=false;
    dfs(a,b);
    for (int e : es) {
      eset[i] |= 1ll<<e;
    }
  }

  ll ans = 0;
  rep(i,1<<m) {
    ll mask = 0;
    rep(j,m) {
      if (i>>j&1) mask |= eset[j];
    }
    int white = __builtin_popcountll(mask);
    ll now = 1ll<<(n-1-white); // 2^(n-1-white)
    if (__builtin_popcountll(i)%2 == 0) ans += now;
    else ans -= now;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define H_MAX 50
#define W_MAX 50

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

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}

int main() {
	int a,b;
	cin >> a >> b;
	if(a != b)
	cout << 2*max(a,b)-1 << endl;
	else
		cout << 2*max(a,b) << endl;
  return 0;
}
 


Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    X = int(input())

    print('Yes') if X >= 30 else print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10476
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m=MI()
    aa=LI()
    s=sum(aa)
    cnt=0
    for a in aa:
        if a*4*m>=s:cnt+=1
    if cnt>=m:print("Yes")
    else:print("No")

main()

Measured memory_bytes: 3064
H,W = map(int,input().split())
h=0
w=0
if H==1 or W ==1:
    print(int(1))
else:
    h=H 
    w=W

if h!=0 and w!=0 and h%2==1 and w%2==1:
    print(int((w*h+1)/2))
elif h!=0 and w!=0 and h*w%2==0:
    print(int(w*h/2))

Measured memory_bytes: 3060
import java.util.*;
class Main{
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args){
    int X=sc.nextInt(),Y=sc.nextInt();
    boolean f=false;
    for(int y=0;y<=X;y++){
      if(2*(X+y)==Y){
        f=true;
        break;
      }
    }
    System.out.println(f?"Yes":"No");
  }
}

Measured memory_bytes: 35784
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

/*
  AOJ :: 0101
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0101&lang=jp
 */


int main(){
    int n,i;
    string in;

    cin >> n; cin.ignore();
    rep(i,n){
        getline(cin, in);
        while( true ){
            int p = in.find("Hoshino");
            if( p == string::npos ) break;
            in[p+6] = 'a';
        }
        cout << in << endl;
    }

    return 0;
}

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

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

    int X = scanner.nextInt();
    int Y = scanner.nextInt();
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    Apple[] apples = new Apple[A + B + C];
    for (int i = 0; i < A; i++) apples[i] = new Apple(scanner.nextInt(), 'r');
    for (int i = 0; i < B; i++) apples[A + i] = new Apple(scanner.nextInt(), 'g');
    for (int i = 0; i < C; i++) apples[A + B + i] = new Apple(scanner.nextInt(), 'v');
    Arrays.sort(apples, (apple, t1) -> t1.value - apple.value);
    int N = X + Y;
    long res = 0;
    for (int i = 0; i < A + B + C; i++) {
      if (N == 0) break;
      Apple a = apples[i];
      if (a.kind == 'r' && X > 0) {
        X--;
        N--;
        res += a.value;
      }
      if (a.kind == 'g' && Y > 0) {
        Y--;
        N--;
        res += a.value;
      }
      if (a.kind == 'v' && N > 0) {
        N--;
        res += a.value;
      }
    }
    System.out.println(res);
  }

  private static class Apple {
    private final int value;
    private final char kind;

    private Apple(int value, char kind) {
      this.value = value;
      this.kind = kind;
    }
  }
}


Measured memory_bytes: 104624
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m,que=MI()
lis=[[0]*n for i in range(n)]
for i in range(m):
    l,r=MI()
    lis[l-1][r-1]+=1
for i in range(n):
    lis[i]=list(accumulate(lis[i]))
for i in range(n):
    for j in range(n-1):
        lis[j+1][i]+=lis[j][i]
#print(lis)
#print(lis)
for i in range(que):
    p,q=MI()
    if p==1:
        ans=lis[q-1][q-1]
    else:
        ans=lis[q-1][q-1]-lis[p-2][q-1]
    print(ans)

Measured memory_bytes: 80812
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 10000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> gap(m-1);
    for(ll i=0;i<m;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(ll i=0;i<m-1;i++){
        gap[i] = abs(a[i+1]-a[i]);
    }
    ll ans = 0;
    sort(gap.begin(),gap.end());
    for(ll i=0;i<min(m-1,m-1-(n-1));i++){
        ans += gap[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

// int main() {
//     while (true){
//         int H, W;
//         cin >> H >> W;
//         for (int i = 0; i < W; i++){
//             cout << '#';
//         }
//         cout << endl;
//         if (H == 0){
//             break;
//         }
//         for (int i = 0; i < H - 2; i++){
//             cout << '#';
//             for (int i = 0; i < W - 2; i++){
//                 cout << '.';
//             }
//             cout << '#';
//             cout << endl;
//         }
//         for (int i = 0; i < W; i++){
//             cout << '#';
//         }
//         cout << endl << endl;
//     }
// }

int main() {
    while (true){
        int H, W;
        cin >> H >> W;
        if (H == 0){
            break;
        }
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if (i % 2 == 0 ^ j % 2 == 0) {
                    cout << '.';                
                } else {
                    cout << '#';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
long long dp[3001][3001];
long long solve(vector<int>&a,int l,int r)
{
    if(l>r) return dp[l][r]=0;
    if(l==r) return dp[l][r]=a[l];
    if(r==l+1) return dp[l][r]=max(a[l],a[r]);
    if(dp[l][r]!=-1) return dp[l][r];
    return dp[l][r]=max(a[l]+min(solve(a,l+2,r),solve(a,l+1,r-1)),a[r]+min(solve(a,l+1,r-1),solve(a,l,r-2)));
}
int main()
{
    int n,m,k; cin>>n;
    long long total=0;
    vector<int>a(n);
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++) {cin>>a[i]; total+=a[i];}
    long long x=solve(a,0,n-1);
    cout<<2*x-total;
//     int dp[n][n]={0};
//     for(int i=0;i<n;i++)
//     {
//         for(int j=i+1;j<n;j++)
//         {
//             if(j==i+1)  {dp[i][j]=abs(a[i]-a[j]); continue;}
//             if(dp[i-v]==0) dp[i]=1;
//         }
//     }
//   dp[k]==1?cout<<"First":cout<<"Second"; 
}

Measured memory_bytes: 70784
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        int M = fs.nextInt();
        List<Integer> s = new ArrayList<>();
        List<Integer> c = new ArrayList<>();

        for (int i = 0; i < M; ++i) {
            s.add(fs.nextInt());
            c.add(fs.nextInt());
        }

        for (int i = 0; i < 1000; ++i) {
            String str = Integer.toString(i);
            if (str.length() != N) continue;
            boolean flag = true;
            for (int j = 0; j < M; ++j) {
                if (Character.getNumericValue(str.charAt(s.get(j)-1)) != c.get(j)) {
                    flag = false;
                }
            }
            if (flag) {
                System.out.println(i);
                System.exit(0);
            }
        }

        System.out.println(-1);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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




Measured memory_bytes: 32600
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define m 1000001
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int t=__gcd(a[0],a[1]);
  for(int i=2;i<n;i++){
    t=__gcd(a[i],t);
  }
  if(t==1){
  ll p[m]={0};
  for(int i=0;i<n;i++){
    int h=a[i];
    if(h%2==0){
      p[2]+=1;
      while(h%2==0){
        h/=2;
      }
    }
    for(int j=3;(ll)j*j<=h;j+=2){
      if(h%j==0){
        p[j]+=1;
        while(h%j==0){
          h/=j;
        }
      }
    }
    if(h>2)
	p[h]+=1;
  }
  
  bool f=true;
  for(int i=0;i<m;i++){
    if(p[i]>1){
      f=false;
      break;
    }
  }
  if(!f){
    cout<<"setwise coprime";
  }
  else{
    cout<<"pairwise coprime";
  }
  }
  else{
    cout<<"not coprime";
  }
  return 0;
}

Measured memory_bytes: 15284
// -*- coding:utf-8-unix -*-

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: usize = 1000000007;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(unused_macros)]
macro_rules! p {
    ([$($x:expr), *]) => {{
        let mut f = true;
        $(
            print!("{}{}", if f {""} else {" "}, $x);
            f = false;
        )*
78786    print!("\n");
    }};
    ($x:expr) => {{
        let mut f = true;
        for a in $x.iter() {
            print!("{}{}", if f {""} else {" "}, a);
            f = false;
        }
        print!("\n");
    }};
}
#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

fn solve() {
    let mut n: usize = read();
    let mut vv: Vec<Vec<usize>> = vec![vec![0; (4) as usize]; (n + 1) as usize];
    vv[0][0] = 1;
    for i in 0..n {
        for j in 0..4 as usize {
            vv[i + 1][j] += vv[i][j] * 8;
        }
        //1:0 2:9 3:09
        vv[i + 1][1] += vv[i][0];
        vv[i + 1][1] += vv[i][1];
        vv[i + 1][3] += vv[i][2];
        vv[i + 1][3] += vv[i][3];
        vv[i + 1][3] += vv[i][3];

        vv[i + 1][2] += vv[i][0];
        vv[i + 1][2] += vv[i][2];
        vv[i + 1][3] += vv[i][1];
        for j in 0..4 as usize {
            vv[i + 1][j] %= MOD;
        }
    }
    println!("{:?}", vv[n][3]);

    return;
}
fn main() {
    solve()
}


Measured memory_bytes: 72192
#include <stdio.h>

const int mod = (int)1e9 + 7;

#define MaxN 200000
long long fact[MaxN];
int a[MaxN], seen[MaxN], idx[MaxN];

long long power(long long a, long long b) {
  long long ret = 1;
  while (b > 0) {
    if (b % 2) {
      ret = (ret * a) % mod;
    }
    a = (a * a) % mod;
    b /= 2;
  }
  return ret;
}

long long InverseMod(long long n) {
  return power(n, mod-2);
}

long long nChooseK(long long n, long long k) {
  if (k > n) return 0;
  return fact[n] * InverseMod(fact[k]) % mod * InverseMod(fact[n-k]) % mod;
}

int main(void) {
  int n;
  scanf("%i", &n);
  
  fact[0] = 1;
  for (int i = 1; i <= n+1; i++) {
    fact[i] = (fact[i-1] * i) % mod;
  }
  
  int l, r;
  for (int i = 0; i <= n; i++) {
    scanf("%i", &a[i]);
    if (seen[a[i]]) {
      l = idx[a[i]];
      r = i; 
    }
    seen[a[i]] = 1;
    idx[a[i]] = i;
  }
    
  for (int i = 1; i <= n+1; i++) {
    long long tot = nChooseK(n+1, i);
              tot = (tot - nChooseK(n+1-(r-l+1), i-1) + mod) % mod;
    printf("%lld\n", tot);
  }
  
  return 0;
}

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

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    for(int i = 0;i<K/2;i++){
        if(A%2==1){
            A -=1;
        }
        B+=A/2;
        A/=2;

        if(B%2==1){
            B-=1;
        }
        A+=B/2;
        B/=2;
    }
    if(K%2==1){
        if(A%2==1){
              A -=1;
        }
        B+=A/2;
        A/=2;
    }
    cout << A << " " << B << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    int a =0; //出力用
    for(int i = 0; i < N; i++){
        int l, r;
        cin >> l >> r;
        
        a += (r - l + 1);
    }
    
    cout << a <<endl;
}

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

int main(){
    int N,M;
    cin >>N>>M;
    vector<int> k;
    vector<vector<int>> food;
    
    for (int i=0; i<N; i++) {
        int x;
        cin >>x;
        k.push_back(x);
        for (int j=0; j<k[i]; j++) {
            int y;
            cin >> y;
            vector<int> v;
            food.push_back(v);
            food[i].push_back(y);
        }
    }
    
    int b[33]={0};
    for (int i=0; i<N; i++) {
        for (int j=0; j<k[i]; j++) {
            b[food[i][j]]++;
        }
    }
    int count=0;
    for (int i=0; i<34; i++) {
        if (b[i]==N) {
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char b,A,C,T,G;
  cin>>b;
  if(b=='A'){
    cout<<'T'<<endl;
  }
  if(b=='T'){
    cout<<'A'<<endl;
  }
  if(b=='C'){
    cout<<'G'<<endl;
  }
  if(b=='G'){
    cout<<'C'<<endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i64 x, y;
  cin >> x >> y;
  i64 ans = 1e18;
  {
    i64 xx = x, yy = y;
    i64 cnt = 0;
    if (abs(xx) <= abs(yy)) {
      if (xx < 0) { cnt++; xx *= -1; }
      i64 c = abs(yy) - abs(xx);
      cnt += c; xx += c;
      if (xx != yy) cnt++;
      amin(ans, cnt);
    } else {
      if (xx > 0) { cnt++; xx *= -1; }
      i64 c = abs(xx) - abs(yy);
      cnt += c; xx += c;
      if (xx != yy) cnt++;
      amin(ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

fn main() {
    input! {
        n: usize,
        c: i64,
        mut xv: [(i64, i64); n]
    }
    let mut xv_rev = vec![];
    for &(x, v) in xv.iter() {
        xv_rev.push((c - x, v));
    }

    xv_rev.reverse();
    for i in 1..n {
        xv[i].1 += xv[i - 1].1;
        xv_rev[i].1 += xv_rev[i - 1].1;
    }

    let mut ans = 0;
    let mut m = 0;
    for i in 1..n {
        m = max(m, xv_rev[i - 1].1 - xv_rev[i - 1].0);
        ans = max(ans, xv[n - i - 1].1 - xv[n - i - 1].0 * 2 + m);
    }
    m = 0;
    for i in 1..n {
        m = max(m, xv[i - 1].1 - xv[i - 1].0);
        ans = max(ans, xv_rev[n - i - 1].1 - xv_rev[n - i - 1].0 * 2 + m);
    }
    for i in 0..n {
        ans = max(ans, xv[i].1 - xv[i].0);
        ans = max(ans, xv_rev[i].1 - xv_rev[i].0);
    }
    println!("{}", ans);
}


Measured memory_bytes: 7812
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

bool prime(int n){
  bool ret = true;
  if(n==1){
    return false;
  }
  for (int i=2; i*i<=n; i++){
    if(n%i==0){
      ret = false;
      break;
    }
  }
  return ret;
}

int main(){
  int Q;
  scanf("%d", &Q);
  std::vector<int > l(Q), r(Q);
  for (int i=0; i<Q; i++){
    scanf("%d", &l[i]);
    scanf("%d", &r[i]);
  }
  std::vector<int > a(100005);
  a[0]=0;
  for (int i=1; i<100005; i++){
    a[i] = a[i-1];
    if (prime(i)&&i%2==1&&prime((i+1)/2)){
      a[i]++;
    }
  }
  for (int i=0; i<Q; i++){
    printf("%d\n", a[r[i]]-a[l[i]-1]);
  }
  return 0;
}


Measured memory_bytes: 2424
import heapq as hp
n,m=map(int,input().split())
a=[-int(x) for x in input().rstrip().split()]

hp.heapify(a)
for i in range(m):
    
    now=hp.heappop(a)
    now=-now//2
    hp.heappush(a,-now)

print(-sum(a))

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

int main(){
  int N;
  cin >> N;
  for (int i=0; i<15; i++){
    for (int j=0; j<26; j++){
      if (i*7+j*4 == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
 
n, we = map(int, input().split())
 
cf = sorted( [[int(x) for x in sys.stdin.readline().split()] for _ in range(n)] )
 
dp=[0]*(we+1)
cnt=0
 
for w,c in cf:
    cnt=cnt+w
    for j in range(min(cnt, we-w), -1, -1):
        if dp[j+w]<(dp[j] + c): dp[j+w]=dp[j] + c
 
print(max(dp))

Measured memory_bytes: 41708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN=5100;
const ll MAXK=17;
const ll INF=1e18;
const ll MOD=1e9+7;
ll N,T,a,b,c,d,ef;
ll memo[MAXN][MAXN];


int main(){
    char a,b,c;
    cin>>a>>b>>c;
    cout<<a<<b<<c;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main()
{
	long long N=0,sum=0;
	long long a[200001];
	cin>>N;
	for(long long i=0;i<N;i++)
	{
		cin>>a[i];
	}
	for(long long i=0;i<N-1;i++)
	{
		if(a[i+1]<a[i]) 
		{
		    sum+=(a[i]-a[i+1]);
		    a[i+1]=a[i];
	    }
	}
	cout<<sum;
}


Measured memory_bytes: 4680
#include <bits/stdc++.h>
# define lli long long int
# define pb push_back
# define ff first
#define ss second
using namespace std;
lli n,k;
lli dp[100005]={0},a[100005]={0};
lli find(lli n)
{
     for(lli i=1;i<n;i++)
     {
          dp[i]=10000000000ll;
          for(lli m=1;m<=k;m++)
          {
          if((i-m)>=0)
          {
          dp[i]=min(dp[i],abs(a[i]-a[i-m])+dp[i-m]);
          }
          }
     }
     return dp[n-1];
}
int main()
{
     lli n,j;
     cin>>n>>k;
     //memset(dp,10000000000,sizeof(dp));
     for(j=0;j<n;j++)
     {
          cin>>a[j];
     }
     //dp[0]=0;
     //dp[1]=abs(a[0]-a[1]);
     cout<<find(n);
}


Measured memory_bytes: 5084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;

public class Main {
	static HashMap<String, Integer> map = new HashMap<String, Integer>();
	static int n,m;
	static int[] v,t;
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(br.readLine());
		System.out.println(n*(n+1)/2);
	}
}

Measured memory_bytes: 8016
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int32_t; using i64 = int64_t; using f64 = double_t; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define stepup(a, b, s, i) for (i32 i = (a); i <= (b); i+=(s))
#define stepdown(a, b, s, i) for (i32 i = (a); i >= (b); i-=(s))
#define foreach(xs, x) for (auto &x : (xs))
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define maximum(xs) (*max_element(all(xs)))
#define minimum(xs) (*min_element(all(xs)))
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
const i64 MOD = 1000000007;

i32 n, a[100001];
i64 ans[100001];

i32 main()
{
    cin >> n;
    vec<pair<i32, i32>> b(n+1);
    a[0] = 0;
    b[0] = make_pair(0, 0);
    upto(1, n, i) {
        cin >> a[i];
        b[i] = make_pair(a[i], i);
    }
    sortall(b);
    reverseall(b);

    i32 mini = b[0].second;
    upto(1, n, i) {
        mini = min(mini, b[i-1].second);
        ans[mini] += i*i64(b[i-1].first-b[i].first);
    }

    upto(1, n, i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
n =  int(input())


tatemono = [0] * 4 * 3 *10
while ( n > 0 ):
    (b,f,r,v)  =  map(int,input().split())
    tatemono[(b-1)*30 + (f-1)*10 + r-1] += v
    n = n -1


for  i in range (0,4):
    for  i2 in range (0,3):
        for  i3 in range (0,10):
            print (' {}'.format(tatemono[i3 + i*30 + i2*10]),end="")
        else:
            print("")
    if ( i != 3 ):
        print ("####################")




Measured memory_bytes: 5624
#include <algorithm>
    #include <cmath>
    #include <functional>
    #include <iostream>
    #include <map>
    #include <numeric>
    #include <stack>
    #include <string>
    #include <vector>
    typedef long long ll;
    using namespace std;
    const int MOD = (int)1e9 + 7;
    const ll INF = (ll)1e18 + 7;
    #define int long long
    #define vint vector<int>
    #define pint pair<int, int>
    #define pb(a) push_back(a)
    #define all(v) v.begin(), v.end()
    #define dbg(x) cerr << #x << " = " << (x) << endl
    #define yn(b) cout << ((b) ? "Yes" : "No") << endl
    #define YN(b) cout << ((b) ? "YES" : "NO") << endl
     
    int dx[4] = {0, 1, 0, -1};
    int dy[4] = {1, 0, -1, 0};
     
    signed main() {
    	cin.tie(0);
    	ios::sync_with_stdio(false);
     
    	int N;
    	cin >> N;
    	vint a(N);
     
    	for (int i = 0; i < N; i++) {
    		cin >> a[i];
    	}
     
    	int tmp = a[0] ^ a[1];
     
    	for (int i = 2; i < N; i++) {
    		tmp ^= a[i];
    	}
     
    	yn(tmp == 0);
     
    	return 0;
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N; cin >> N;
    int A[100005]; rep(i,N) cin >> A[i];

    vector<pair<int,int>> vec;
    rep(i,N)
    {
        vec.push_back(make_pair(A[i], i + 1));
    }
    sort(vec.begin(), vec.end());

    rep(i,N)
    {
        cout << vec[i].second << " ";
    }
    cout << endl;
}

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

int main()
{
    string S;
    cin >> S;
    REP(i, S.length())
        cout << "x";
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  vector<int>height(N);
  for(int i=0;i<N;i++){
  cin>>height.at(i);
  }
  int count;
  for(int i=0;i<N;i++){
	if(height.at(i)>=K){
    count++;
    }
  }
  cout<<count<<endl;
  }

Measured memory_bytes: 3588
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,K = I()
x = l()
i = bisect.bisect_left(x,0)
x.insert(i,0)
start = max(i-K,0)
stop = min(i+K+1,N+1)
x = x[start:stop]
ans = 10**9
for i in range(len(x)-K):
    a = x[i]
    b = x[i+K]
    ans = min(ans,min(abs(a),abs(b))+abs(a-b))
print(ans)

Measured memory_bytes: 86760