akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;
int a[100100];
string s, t;

int main(){
	cin >> n >> s >> t;
	string ans = "";
	int pos = -1;
	REP(i, s.size()){
		string buf = s.substr(i);
		if (t.find(buf) != -1){
			pos = i;
			break;
		}
	}
	REP(i, s.size()){
		if (pos == i){
			ans += t;
			break;
		}
		else{
			ans += s[i];
		}
	}
	if (pos == -1)ans += t;
	cout << ans.size() << endl;
}

Measured memory_bytes: 256
// the best deleted dialogue for this code was 'you make my atheism difficult, god'.  the worst was 'colonel bluegrass, i want my pliers back'
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, 0, n)cin >> v[i];
    ll res = 0;
    stack<pair<ll, ll>> s;
    s.push({0, 0});
    ll cur = 0;
    
    rep(i, 0, n) {
        pair<ll, ll> add = {v[i], 1};
        while (s.top().first > add.first) {
            add.second += s.top().second;
            cur -= s.top().first * s.top().second;
            s.pop();
        }
        s.push(add);
        cur += add.first * add.second;
        res += cur;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 5120
# adj = {
#     1: [2, 3, 4, 8, 9],
#     2: [1, 3, 5],
#     3: [1, 2, 6],
#     4: [1, 6],
#     5: [2, 6, 7],
#     6: [5, 3, 4],
#     7: [5],
#     8: [1],
#     9: [1]
# }

from collections import deque

H, W = map(int, input().split())
d = []
for i in range(H):
    d.append(input())

adj = {(i, j): [] for i in range(H) for j in range(W)}
for i in range(H):
    for j in range(W):
        for m in [(i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)]:
            row, col = m[0], m[1]
            if 0 <= row <= H - 1 and 0 <= col <= W - 1 and d[row][col] != '#':
                adj[i, j].append(m)


def bfs(g, s):
    if d[s[0]][s[1]] == "#":
        return 0
    visited = {}
    distance = {}
    q = deque()
    q.append(s)
    visited[s] = True
    distance[s] = 0
    while q:
        u = q.popleft()
        for i in g[u]:
            if i not in visited:
                q.append(i)
                visited[i] = True
                distance[i] = distance[u] + 1

    return max(distance.values())


ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, bfs(adj, (i, j)))

print(ans)


Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int n;
set<int> st;

int main()
{
	cin >> n;
	rep(i, n) {
		int a;
		cin >> a;
		st.insert(a);
	}
	int k = st.size();
	if (k % 2) {
		cout << k << endl;
	}
	else {
		cout << k - 1 << endl;
	}
	return 0;
}

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

#define ll long long int
ll mod=1e9+7;

// vector<ll> g[200005];
// ll vis[200005];
// queue<ll> q;
// ll level[200005];

// void dfs(ll i)
// {
//     vis[i] = 1;
//     for(ll j=0;j<g[i].size();j++)
//     {
//         ll child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(ll i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         ll top = q.front();
//         ll len_adj = g[top].size();
//         ll j;
//         for(j=0;j<len_adj;j++)
//         {
//             ll v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

vector<ll> DecToBinary(ll num,ll trailing_zero, ll nbits)
{
    vector<ll> bits;
    while(num > 0)
    {
        bits.push_back(num%2);
        num /= 2;
    }

    if(trailing_zero == 1)
    {
        while(bits.size() < nbits)
        {
            bits.push_back(0);
        }
    }

    return bits;
}

long long int BinaryToDec(vector<ll> bits)
{
    ll number = 0;
    ll i;
    for(i=bits.size()-1;i>=0;i--)
    {
        number += (bits[i] * (long long)pow((ll)2 , i));
    }
    return number;
}

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

string solve(long long int A)
{
    string ans = ""; 
    while(A > 0)
    {
        int add = A%26;
        if(add == 0)
        {
            add = 26;
            A--;
        }
        char to_add = 'a' + add - 1;
        ans += to_add;
        A/=26;
    }
    
    string anss = "";
    
    for(int i=ans.size()-1;i>=0;i--)
    {
        anss += ans[i];
    }
    return anss;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        cin >> n;
        cout << solve(n) << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 3720
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            if (map.containsKey(a)) {
                map.remove(a);
            } else {
                map.put(a, 1);
            }
        }
        int ans = 0;
        for (Map.Entry<Integer, Integer> temp : map.entrySet()) {
            ans += temp.getValue();
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 47280
N, M = map(int,input().split())
XYZ = list(list(map(int,input().split()))for i in range(N))
ans = 0
for i in range(-1,2,2):
    for j in range(-1,2,2):
        for k in range(-1,2,2):
            score = []
            for x,y,z in XYZ:
                score.append(x*i + y*j + z*k)
            score.sort(reverse = True)
            ans = max(sum(score[:M]),ans)
print(ans)

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

#define repl(i,a,b) for(i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define max(x,y) x>y?x:y
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)

typedef int bool;

#define true 1
#define false 0

int dd[]={-1,0,1,0,-1};

int h,w,c;
int p[11][11];

bool visc[11][11];
int cnt;

void cntc(int i,int j,int cc){
	visc[i][j]=true;
	cnt++;
	int d;
	rep(d,4){
		int ni=i+dd[d],nj=j+dd[d+1];
		if(ni>=0&&ni<h&&nj>=0&&nj<w&&p[ni][nj]==cc&&!visc[ni][nj])cntc(ni,nj,cc);
	}
}

void change(int i,int j,int mc,int cc){
	p[i][j]=cc;
	visc[i][j]=true;
	int d;
	rep(d,4){
		int ni=i+dd[d],nj=j+dd[d+1];
		if(ni>=0&&ni<h&&nj>=0&&nj<w&&p[ni][nj]==mc&&!visc[ni][nj])change(ni,nj,mc,cc);
	}
}

int dfs(int d){
	if(d==5){
		cnt=0;
		memset(visc,0,sizeof(visc));
		cntc(0,0,c);
		return cnt;
	}else{
		int res=0;
		int sav[11][11];
		memcpy(sav,p,sizeof(p));
		if(d==4){
			memset(visc,0,sizeof(visc));
			change(0,0,p[0][0],c);
			maxch(res,dfs(d+1));
		}else{
			int i;
			repl(i,1,6+1){
				memset(visc,0,sizeof(visc));
				change(0,0,p[0][0],i);
				maxch(res,dfs(d+1));
				memcpy(p,sav,sizeof(sav));
			}
		}
		return res;
	}
}

int main(){
	//cin.sync_with_stdio(false);
	while(1){
		scanf("%d%d%d",&h,&w,&c);
		if(h==0)break;
		int i,j;
		rep(i,h)rep(j,w)scanf("%d",&p[i][j]);
		printf("%d\n", dfs(0));
	}
	return 0;
}

Measured memory_bytes: 604
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>

double round(double r) {
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}

using namespace std;




int main() {
	
	string a,b,c;
	cin>>a>>b>>c;
	char t='a';
	string h=a;
	while(1){
		if(t=='a')h=a;
		else if(t=='b')h=b;
		else h=c;
		if(h.size()==0){
			if(t=='a')cout<<'A'<<endl;
			else if(t=='b')cout<<'B'<<endl;
			else cout<<'C'<<endl;
			return 0;
		}
		if(t=='a')a.erase(0,1);
		else if(t=='b')b.erase(0,1);
		else c.erase(0,1);
		t=h[0];
		
		

	}
	
    return 0;
}

	
	


	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)



int main(){
	ll n,k,b,m;
	cin >> n;
	bitset<64> bs,cnt;
	bitset<64> mask[n+1];
	bool ans;

	FOR(i,0,n){
		cin >> k;
		FOR(j,0,k){
			cin >> b;
			mask[i][b] = 1;
		}
	}
	
	cin >> n;
	FOR(i,0,n){
		cin >> k >> m;
		if(k==0){
			cout << bs[m] << endl;
		}else if(k==1){
			bs |= mask[m];
		}else if(k==2){
			bs |= mask[m];
			bs ^= mask[m];
		}else if(k==3){
			bs ^= mask[m];
		}else if(k==4){
			ans = ( (bs&mask[m]) == mask[m]);
			cout << ans << endl;
		}else if(k==5){//any
			ans = (bs&mask[m]).any();
			cout<< ans << endl;
		}else if(k==6){//none
			ans = (bs&mask[m]).none();
			cout << ans << endl;
		}else if(k==7){
			cnt = bs&mask[m];
			cout << cnt.count() << endl;
		}else if(k==8){
			cnt = bs&mask[m];
			cout << cnt.to_ullong() << endl;
		}
	}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
   ll N, M;
   cin>>N>>M;
   vector<ll> A(N);
   ll Sum=0;
   rep(i, N){
       cin>>A[i];
       Sum+=A[i];
   }
   //ll B=4*M;
   //ll Bo=Sum/B;
   ll Cou=0;
   rep(i, N){
       if(Sum<=A[i]*4*M){
           Cou++;
       }
   }
   Yes(Cou>=M);
   return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  vector<int>a(n);
  for(int i; i<n; i++) cin >> a[i];
  int rsl=0;
  for(int i; i<n; i++){
    rsl += a[i];
  }
  rsl -= n;
  cout << rsl << endl;
}



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

int main() {
  long double a, b, c;
  cin >> a >> b >> c;
  long double k=c-b-a;
  if(k/2>sqrt(a*b))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

prev = [0] * N
se = set([0])
q = deque([0])
while q:
    x = q.popleft()
    for y in graph[x]:
        if y in se:
            continue
        prev[y] = x
        q.append(y)
        se.add(y)
if len(se) == N:
    print('Yes')
    for x in prev[1:]:
        print(x + 1)
else:
    print('No')

Measured memory_bytes: 39968
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

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

	// 何を優先するか
	// もしaでbのマックス以上の値があればずっとそれをやる
	// a <= bだった
	// bとaの攻撃順番は実質変わらない
	// 大きい順にソートする

	sort(allof(a), greater<int>());
	sort(allof(b), greater<int>());

	// aは一番大きいものだけで充分
	int amax = a[0];
	// bを上から見てってamax以下となったらその後amax使う
	int i = 0;
	while (h > 0) {
		if (amax >= b[i]) break;
		h -= b[i];
		i++;
		if (i == n) break;
	}

	int ans = i;

	if (h > 0) {
		ans += h / amax;
		if (h % amax != 0) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	int count[n+1]={};
	rep(i,n){
		cin>>a[i];
		count[a[i]]++;
	}
	ll ans[n+1]={};
	ll sum = 0;
	for(int i=1;i<n+1;i++){
		ll coun = count[i];
		ans[i] = coun*(coun-1)/2;
		sum+=ans[i];
	}
	for(int i=1;i<n+1;i++){
		ll coun = count[a[i-1]]-1;
		ll each = coun*(coun-1)/2;
		cout << sum - ans[a[i-1]] + each << endl;
	}
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  int n,m;
  cin>>n>>m;
  string s;
  cin>>s;
  int now = n;
  bool outp = true;
  vector<int> process;
  while(now > 0){
    int start = min(m, now);
    bool flag = false;
    for(int i = start; i>=1; i--){
      if(s[now-i] == '1')continue;
      flag = true;
      now = now - i;
      process.push_back(i);
      break;
    }
    if(!flag){
      outp = false;
      break;
    }
  }
  if(!outp){
    cout<<-1<<endl;
    return 0;
  }
  reverse(ALL(process));
  
  int k = process.size();
  REP(i,k){
    cout<<process[i]<<' ';
  }
  cout<<endl;
      
  return 0; 
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
 
using namespace std;
/**************************************************************************/
int main()
{
	fastIO;
	ll t,n,i,j,k;
	cin>>n;
	vector < ll > ans;
	if(n==0){cout<<0;return(0);}
	while(n!=0)
	{
		if(n<0)
		{
			ans.push_back((-1ll*n)%2ll);
			if(n%2ll!=0)n = (-1ll*n)/2 + 1;
			else n = (-1ll*n)/2;
		}
		else
		{
			ans.push_back((n)%2ll);
			n = -1ll*(n/2ll);
		}
	}
	reverse(ans.begin(),ans.end());
	for(auto x:ans)cout<<x;
}
/*************************************************************************/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> cnt1(100);
    int maxbit = 0;
    rep(i, N) {
        ll tmp = A[i];
        int cnt = 0;
        while (tmp > 0) {
            if (tmp & 1) cnt1[cnt]++;
            cnt++;
            tmp >>= 1;
        }
        chmax(maxbit, cnt);
    }

    ll ans = 0;
    ll ct = 1;
    rep(i, maxbit) {
        ll t = cnt1[i] * (N - cnt1[i]);
        t %= MOD;
        ans += (t * ct) % MOD;
        ans %= MOD;
        ct *= 2;
        ct %= MOD;
    }

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

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

typedef long long ll;
const int N = 55;

ll n, A, a[N], mm[N][N][N * N];

ll dp(int i, int cnt, int sum) {
	if (i == n) {
		if (cnt == 0)return 0;
		if ((sum / cnt) == A && (sum % cnt == 0))return 1;
		return 0;
	}

	ll& ret = mm[i][cnt][sum];
	if (ret != -1)return ret;
	return ret = dp(i + 1, cnt, sum) + dp(i + 1, cnt + 1, sum + a[i]);
}

int main() {
	cin >> n >> A;
	for (int i = 0; i < n; i++)cin >> a[i];
	memset(mm, -1, sizeof mm);
	cout << dp(0, 0, 0) << endl;

	return 0;
}

Measured memory_bytes: 71680
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion

template <class T>
T mod_pow(T x, int n, int mod) {
    if (n == 0) return 1;
    ll res = mod_pow(x * x % mod, n >> 1, mod);
    if (n & 1) res = res * x % mod;
    return res;
}

int main() {
    int n;
    cin >> n;
    string x;
    cin >> x;
    reverse(x.begin(), x.end());
    int popc = 0;
    rep(i, n) if (x[i] == '1') popc++;
    
    ll mod_p_p1 = 0, mod_p_m1 = 0;

    rep(i, n) {
        if (x[i] == '0') continue;
        
        mod_p_p1 += mod_pow(2ll, i, popc + 1);
        mod_p_p1 %= popc + 1;

        if (popc == 1) continue;

        mod_p_m1 += mod_pow(2ll, i, popc - 1);
        mod_p_m1 %= popc - 1;
    }

    const int M = 200000;
    vector<int> f(M + 1);
    repr(i, 1, M + 1) {
        f[i] = f[i % popcnt(i)] + 1;
    }
    //cout << "f[m]" << f[M] << endl;
    //rep(i, 10) cout << f[i] << " ";
    //cout << endl;
    
    vector<int> ans(n);
    rep(i, n) {
        if (x[i] == '1') {
            if (popc == 1) {
                ans[i] = 0;
                continue;
            }

            ll fst = mod_p_m1 - mod_pow(2ll, i, popc - 1);
            if (fst < 0) fst += popc - 1;
            ans[i] = f[fst] + 1;
        }
        else {
            ll fst = (mod_p_p1 + mod_pow(2ll, i, popc + 1)) % (popc + 1);
            ans[i] = f[fst] + 1;
        }
    }

    reverse(ans.begin(), ans.end());
    print(ans, "\n");
}

Measured memory_bytes: 5240
#include <iostream>
#include <queue>
#include <array>

int main() {
  static int const MaxElement = 100;
  std::array<std::array<bool, MaxElement>, MaxElement> map = {};

  int n = 0;
  std::cin >> n;
  for( int i=0; i<n; ++i ) {
	int r = 0, k = 0;
	std::cin >> r >> k;
	for( int j=0; j<k; ++j ) {
	  int idx = 0;
	  std::cin >> idx;
	  map[r-1][idx-1] = true;
	}
  }

  int m = 0;
  std::cin >> m;
  for( int i=0; i<m; ++i ) {
	int src = 0, dst = 0, ttl = 0;
	std::cin >> src >> dst >> ttl;

	std::array<int, MaxElement> distance;
	distance.fill( -1 );

	std::queue<int> q;
	q.push( src - 1 );
	distance[src-1] = 0;
	while( !q.empty() ) {
	  int const u = q.front();
	  q.pop();
	  for( int v=0; v<n; ++v ) {
		if ( map[u][v] && distance[v] == -1 ) {
		  distance[v] = distance[u] + 1;
		  q.push( v );
		}
	  }
	}

	if ( distance[dst-1] == -1 || ttl - distance[dst-1] <= 0 ) {
	  std::cout << "NA" << std::endl;
	} else {
	  std::cout <<  distance[dst-1] + 1 << std::endl;
	}
  }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e6 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
ll fac[N], inv[N];
ll powmod(ll a, ll b)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%mod;
		a = a*a%mod;
		b >>= 1;
	}
	return ans;
}
void init(int n)
{
	fac[0] = 1;
	for(int i=1;i<=n;i++) fac[i] = fac[i-1]*i%mod;
	inv[n] = powmod(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i] = inv[i+1]*(i+1)%mod;
}
ll comp(ll a,ll b)
{
	if(a<b||b<0||a<0) return 0;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
ll cal(ll x, ll y)
{
	return comp(x+y+2, x+1);
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int r1, c1, r2, c2;
 	cin >> r1 >> c1 >> r2 >> c2;
 	init(r2+c2+2);
 	ll ans = (cal(r2, c2) - cal(r1-1, c2) - cal(r2, c1-1) + cal(r1-1, c1-1))%mod;
 	ans = (ans + mod)%mod;
 	cout << ans;
	return 0;
}


Measured memory_bytes: 31488
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int64 val, n;
pii a[2002];
int64 f[2002][2002];
bool cmp(const pii &a, const pii &b){
    return a.fr > b.fr;
}

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> val;
        a[i] = pii({val, i});
    }
    sort(a + 1, a + 1 + n, cmp);
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= i; j++){
            f[i][j] = -1e18;
            if (j > 0)
                f[i][j] = max(f[i][j], f[i - 1][j - 1] + a[i].fr * abs(a[i].sc - j));
            if (j < i)
                f[i][j] = max(f[i][j], f[i - 1][j] + a[i].fr * abs(a[i].sc - (n + 1 - (i - j))));
        }
    }
    int64 res = 0;
    for (int i = 0; i <= n; i++) res = max(res, f[n][i]);
    cout << res;
    return 0;
}


Measured memory_bytes: 26300
#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>;

int main(){
    int n,r;
    cin >> n >> r;
    if (n>=10){
        cout << r << endl;
    }
    else{
        cout << r+100*(10-n) << endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
/*...Part - 01...*/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/

const int max_n = 110 ;
const int max_v = 100100 ;

ll dp[max_n][max_v] ;
int val[max_n], cap[max_n] ;

int main(){
    int test = 1 , tc = 0 ;
    while(test--){
        int n = Int, w = Int ;
        for(int i = 1 ; i <= n ; ++i)cap[i] = Int, val[i] = Int ;
        for(int i = 0 ; i < max_n ; ++i){
        	for(int j = 0 ; j < max_v ; ++j)
        		dp[i][j] = Inf ;
        }
        dp[1][0] = dp[0][0] = 0 ;
        for(int i = 1 ; i <= n ; ++i){
        	for(int j = 0 ; j < max_v ; ++j){
        		if(j >= val[i])dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - val[i]] + cap[i]) ;
        		else dp[i][j] = dp[i - 1][j] ;
        	}
        }
        int res = 0 ;
        for(int i = 0 ; i < max_v ; ++i){
        	if(dp[n][i] <= w){
        		res = i ;
        	}
        }
        cout << res << '\n' ;
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/




Measured memory_bytes: 86272
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <queue>

#define MAXN 100050
#define MAXK 11
#define MAXM 100005

using namespace std;



int n, k, a[MAXN];

int main()
{

    //freopen("c.txt", "r", stdin);
    while (cin >> n >> k) {
        int p1 = 0;
        for (int i = 1; i <= n; i++) {
            scanf("%d", a + i);
            if (a[i] == 1) {
                p1 = i;
            }
        }

        int ans = 0;
        int pos = 1;
        while (pos < p1) {
            ans++;
            pos += k - 1;
        }
        while (pos < n) {
            ans++;
            pos += k - 1;
        }
        printf("%d\n", ans);
    }
    return 0;

}


Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
  int n;
  
  scanf( "%d", &n );
  
  for( int i=1 ; i<=9 ; i++ )
  {
    if( ( (n%i)==0 ) && ( (n/i)<=9 ) )
    {
      puts( "Yes" );
      return 0;
    }
  }
  
  puts( "No" );
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;

#define ll long long

int main(void){

    int k,s;
    cin>>k>>s;

    int ans = 0;

    for(int i=0;i<=k;i++){
        for(int j = 0;j<=k && i+j<=s;j++){
            if(s-(i+j)<=k)ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;


long long lcm(long long a, long long b ) {
  long long x = a*b;

  if (a < b) {
    long long t = a;
    a = b;
    b = t;
  }

  long long r = a % b;
  while (r > 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}//lcm

void solve(long long N, long long M, string S, string T){
  long long ret = lcm(N, M);
  for (int i = 0; i < N; i++) {
    if ((i*(ret/N) % (ret/M) != 0) || (i*(ret/N) / (ret/M) > M-1)) {
      continue;
    }
    if (S[i] != T[i*(ret/N) / (ret/M)]) {
        std::cout << -1 << std::endl;
        return;
    }
  }
  std::cout << ret << std::endl;
  return;
}

int main(){
  string T;
  string S;
  long long N;
  long long M;
  scanf("%lld",&N);
  scanf("%lld",&M);
  cin >> S;
  cin >> T;
  solve(N, M, S, T);
  return 0;
}


Measured memory_bytes: 888
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(l, r, d);
    ll s = 0;
    reps(i, l, r+1) {
        if (i % d == 0) s++;
    }
    cout << s << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>
#include <algorithm>

using namespace std;
//--------------------
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

//------------
bool check(int num) {
    const int right = int(sqrt(double(num)));
    set<int> s;
    for (int j = 1; j <= right; ++j) {
        if(num % j == 0) {
            s.insert(j);
            s.insert(num / j);
        }
    }
    return s.size() == 8;
}
//-------
void func() {
    int N;
    cin >> N;
    int count = 0;
    for (int i = 1; i <= N; i += 2) {
        if(check(i)) {
            count += 1;
        }
    }
    cout << count << endl;
}

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

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char s[11];
  scanf("%s",s);
  char t[]="YAKI";
  int i;
  for(i=0;i<4;i++) if(s[i]!=t[i]) break;
  printf("%s\n",i==4?"Yes":"No");
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>


int main(){

  int H, W, i, j;

  while(1){

  scanf("%d %d", &H, &W);

  if(H == 0 && W == 0)

    break;

  else

  for(i = 0;i < H;i++){

    for(j = 0;j < W;j++){

      printf("#");

    }

    printf("\n");

  }

  printf("\n");

  
  }

    
  return 0;
  
}

Measured memory_bytes: 572
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n, s;
    cin >> n >> s;
    vector<ll> a(n + 1);
    // rep(i, n) cin >> a[i];
    for (ll i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    vector<vector<ll>> dp(s + 1, vector<ll>(n + 1));
    // 0 <= i <= n
    // 0 <= j <= s
    ll mod = 998244353;
    dp[0][0] = 1;
    for (ll i = 1; i <= n; ++i)
    {
        for (ll j = 0; j <= s; ++j)
        {
            if (i >= 1)
                dp[j][i] = (dp[j][i] + dp[j][i - 1] * 2) % mod;
            if (i >= 1 && j >= a[i])
                dp[j][i] = (dp[j][i] + dp[j - a[i]][i - 1]) % mod;
        }
    }
    cout << dp[s][n] << endl;
}

Measured memory_bytes: 73544
#include<iostream>
#include<cstdio>
#define N 100100
using namespace std;
int od[N];
int n,p[N],pri[N],prin;
void shai(){
	int i,j,m,a;
	for(i=2;i<N;++i){
		if(!p[i])
			pri[++prin]=i;
		for(j=1;j<=prin;++j){
			if(i*pri[j]>N) break;
			p[i*pri[j]]=1;
			if(i%pri[j]==0) break;
		}
	}
}
int main()
{
	shai();
	for(int i=3;i<N;++i)
	{
		if(!p[i] && !p[(i+1)/2])
			od[i]=1;
	}
	for(int i=4;i<N;++i)
		od[i]+=od[i-1];
	scanf("%d",&n);
	while(n--)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		printf("%d\n",od[r]-od[l-1]);
	}
	return 0;
}


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

const int N = 15;

int n, d;
int x[N][N];
int ans;

int main()
{
	scanf("%d%d", &n, &d);
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= d; j ++)
			scanf("%d", &x[i][j]);
	for (int i = 1; i < n; i ++)
		for (int j = i + 1; j <= n; j ++)
		{
			int sum = 0;
			for (int k = 1; k <= d; k ++)
				sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			if (((int)sqrt(sum) * (int)sqrt(sum)) == sum)
				ans ++;
		}
	printf("%d", ans); 
	return 0;
}

Measured memory_bytes: 256
if __name__=='__main__':
    s = input()
    locate = len(s)-1

    # +を入れる箇所をbit探索で探す
    sum_all = 0
    for bit in range(1 << locate):
        binary = str(format(bit, 'b'))
        binary = binary.zfill(len(s)-1)
        head = 0
        for i in range(len(binary)):
            if binary[i] == '1':
                sum_all += int(s[head:i+1])
                head = i+1
        sum_all += int(s[head:])

    print(sum_all)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
typedef long long ll;

ll l_max(ll a, ll b){
    return a < b ? b : a;
}

bool is_prime(int x){
    for(int i = 2; i*i < x; i++){
        if(x % i == 0) return false;
    }
    return true;
}

int main() {
    int x;
    cin >> x;
    while(1){
        if(is_prime(x)){
            cout << x << el;
            return 0;
        }
        x++;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(), v.end()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


ll n, ruiseki;
ll a[100005];

int main() {

	cin >> n;

	rrep(i, n) {
		cin >> a[i];
		ruiseki += abs(a[i] - a[i - 1]);
	}

	ruiseki += abs(a[n] - 0);

	rrep(i, n) {
		ruiseki -= abs(a[i] - a[i - 1]);
		ruiseki -= abs(a[i] - a[i + 1]);
		ruiseki += abs(a[i - 1] - a[i + 1]);
		cout << ruiseki << endl;
		ruiseki += abs(a[i] - a[i - 1]);
		ruiseki += abs(a[i] - a[i + 1]);
		ruiseki -= abs(a[i - 1] - a[i + 1]);
	}

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);

const int N = 2e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
int tc;
ll x, k, d;
int main()
{
    FIO
    cin>>x>>k>>d;
    ll tmpx = abs(x);
    ll y = tmpx / d;
    // cout<<y<<endl;
    if(y < k)
    {
        if((k - y) %2 == 0)
        {
            cout<<tmpx - y*d<<endl;
        }
        else
        {
            cout<<min(abs(tmpx - (y-1)*d), abs(tmpx - (y+1)*d))<<endl;
        }
    }
    else
    {
        if(x < 0)
           cout<<abs(x + k*d) <<endl;
        else
            cout<<x - k*d<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
from operator import itemgetter
s = input()
l = len(s)
ans = []
flag = False 
for i in range(l):
    if flag:
        if s[i] in "AGCT":
            continue
        else:
            ans.append([i-start,start,i])
            flag = False
    if s[i] in "AGCT":
        flag = True
        start = i 
else:
    if flag:
        ans.append([l-start,start,l])
ans.sort(key=itemgetter(0),reverse=True)
#print(s[ans[0][1]:ans[0][2]])
if ans:
    print(ans[0][0])
else:
    print(0)

Measured memory_bytes: 3064
//
//  main.cpp
//  dp
//
//  Created by 贾皓翔 on 2019/11/26.
//  Copyright © 2019 贾皓翔. All rights reserved.
//
#include <iostream>
#include <cmath>
using namespace std;

bool isPrime(int N){
    for(int i=2;i<=sqrt(N);i++){
        if(N%i==0){
            return false;
        }
    }
    return true;
}
int main(){
    int N;
    cin>>N;
    for(;!isPrime(N);N++){
        
    }
    cout<<N<<endl;
    

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N,M;
    cin >> N >>M;
    int a[N];
    int max=0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        max+=a[i];
    }
    int count =0;
    for(int i=0;i<N;i++){
        if(4*M*a[i]>=max){
            count++;
        }
    }
    if(count>=M){
        cout << "Yes\n";
    }else{

        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    w = input()
    lst = [0] * 26

    for c in w:
        lst[ord(c) - ord("a")] += 1

    for num in lst:
        if num % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61136
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int h,w;
    vector<pair<int, pair<int, int>>> rec;
    for (int i=1; i<=150; i++){
        for (int j=i+1; j<=150; j++){
            rec.push_back(make_pair(i*i+j*j, make_pair(i,j)));
        }
    }
    sort(rec.begin(), rec.end());
    for (int i=0; i<rec.size(); i++){
        // cout << rec[i].first << " " << rec[i].second.first << " " << rec[i].second.second << endl;
    }
    
    while(cin >> h >> w, h){
        int s = h * h * w * w;

        for (int i=0; i<rec.size(); i++){
            if (rec[i].second.first == h && rec[i].second.second == w){
                cout << rec[i+1].second.first << " " << rec[i+1].second.second << endl;
                break;
            }
        }
        
        
    }
    return 0;
}



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

using namespace std;

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

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

ll N, A, B;
ll ans = 0;
ll X[101010];

void solve() {
    cin >> N >> A >> B;
    cin >> X[0];
    REP(i,1,N) {
        cin >> X[i];
        ans += min(A*(X[i]-X[i-1]), B);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, a;
	cin >> n >> a;
	cout << n * n - a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
    ll n, weight;
    cin >> n >> weight;
    ll we[n], val[n];
    for (int i = 0; i < n; i++)
    {
        cin >> we[i] >> val[i];
    }
    ll dp[n + 1][weight + 1];
    for (int i = 0; i <= n; i++)
    {
        for (int w = 0; w <= weight; w++)
        {
            if (i == 0 || w == 0)
            {
                dp[i][w] = 0;
            }
            else if (we[i - 1] <= w)
            {
                dp[i][w] = max(val[i - 1] + dp[i - 1][w - we[i - 1]], dp[i - 1][w]);
            }
            else
            {
                dp[i][w] = dp[i - 1][w];
            }
        }
    }
    cout << dp[n][weight] << "\n";
}
int main()
{

    int t;
    //cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long ans=0;
	for (int i = 1; i <= n; ++i)
	{
		if (i%3==0||i%5==0)
		{
			continue;
		}
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
/*
 * atcode153-d
 */

#include <stdio.h>
#include <stdlib.h>
typedef unsigned long long ull;

ull 
f(ull n)
{
  if (n == 1)
    return (1);

  return (2 * f(n/2) + 1);
}

int
main(int argc, char *argv[])
{
  ull h;
  ull cnt;

  scanf("%llu", &h);

  cnt = f((ull) h);

  printf("%llu\n", cnt);
  return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

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

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

  int n;
  cin >> n;
  ll a[n], b[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];

  ll sum_a = 0, sum_b = 0;
  for(int i = 0; i < n; i++){
    sum_a += a[i];
    sum_b += b[i];
  }

  if(sum_b > sum_a){
    cout << -1 << endl;
    return 0;
  }

  ll c[n];
  for(int i = 0; i < n; i++){
    c[i] = a[i] - b[i];
  }
  sort(c, c + n);

  int count = 0;
  ll d = 0;
  int i = 0;
  while(i < n && c[i] < 0){
    d += c[i];
    ++count;
    ++i;
  }

  i = n - 1;
  while(i >= 0 && c[i] >= 0 && d < 0){
    d += c[i];
    ++count;
    --i;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 13;
int n, mx, num, a[maxN], mn = 1e9 + 13, val;;
int main () {
    cin >> n;
    for (int i = 0; i < n; i++) {
	cin >> a[i];
	if (a[i] > mx) {
	    mx = a[i];
	    val = i;
	}
    }
    for (int i = 0; i < n; i++) {
	if (i != val) {
	if (abs(a[i] - mx / 2) < mn) {
	    mn = abs(a[i] - mx / 2);
	    num = a[i];
	}
	}
    }
    cout << mx << " " << num << endl;
}


Measured memory_bytes: 640