akhauriyash/Code-Regression huggingface dataset:
n=int(input())
pts=[list(map(int,input().split())) for _ in range(n)]

if n==1:
    print(1)
    exit(0)

ans=100

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return -1

for i in range(n):
    for j in range(i+1,n):
        x1,y1=pts[i]
        x2,y2=pts[j]

        p=x1-x2
        q=y1-y2

        visit=[0]*n
        
        cur=0
        for k in range(n):
            if visit[k]==1:
                continue
            cur+=1
            x3,y3=pts[k]
            cx=x3
            cy=y3
            while my_index(pts,[cx,cy])>=0:
                visit[my_index(pts,[cx,cy])]=1
                cx+=p
                cy+=q
            cx=x3
            cy=y3
            while my_index(pts,[cx,cy])>=0:
                visit[my_index(pts,[cx,cy])]=1
                cx-=p
                cy-=q
        
        ans=min(ans,cur)
    
print(ans)

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

int cnt[1010][1010][3] = {0};

void count(int a, int b, char c) {
	if(c == 'J') {
		cnt[a][b][0]++;
	} else if(c == 'O') {
		cnt[a][b][1]++;
	} else {
		cnt[a][b][2]++;
	}
	return;
}

void printans(int a, int b, int c, int d) {

	int ans[3] = {0};

	for(int i = a-1; i < c; i++) {
		ans[0] += cnt[i][d-1][0] - cnt[i][b-2][0];
		ans[1] += cnt[i][d-1][1] - cnt[i][b-2][1];
		ans[2] += cnt[i][d-1][2] - cnt[i][b-2][2];
	}
	
	cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;

	return;
}

int main() {

	//ifstream cin("in/01.in");
	//ofstream cout("OUTPUT.txt");

	int M, N, K;
	int a, b, c, d;
	char map[1010][1010];
	
	cin >> M >> N >> K;
	
	for(int i = 0; i < M; i++) {
		cin >> map[i];
	}
	
	for(int i = 0; i < M; i++) {
		for(int j = 0; j < N; j++) {
			if(j != 0) {
				for(int k = 0; k < 3; k++) {
					cnt[i][j][k] = cnt[i][j-1][k];
				}
			}
			count(i, j, map[i][j]);
		}
	}
	
	for(int i = 0; i < K; i++) {
		cin >> a >> b >> c >> d;
		printans(a, b, c, d);
	}
	
	/* for(int i = 0; i < K; i++) {
		int cnt[3] = {0};
		cin >> a >> b >> c >> d;
		for(int j = a-1; j < c; j++) {
			for(int k = b-1; k < d; k++) {
				if(map[j][k] == 'J') {
					cnt[0]++;
				} else if(map[j][k] == 'O') {
					cnt[1]++;
				} else {
					cnt[2]++;
				}
			}
		}
		cout << cnt[0] << " " << cnt[1] << " " << cnt[2] << endl;
	} */

	return 0;

}

Measured memory_bytes: 13860
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {
	int n, T[100]; cin >> n;
	double V[100];
	for (int i = 0; i < n; i++)cin >> T[i];
	for (int i = 0; i < n; i++)cin >> V[i];

	int t = 0; double vl[40005], vr[40005];
	vl[0] = 0;
	for (int i = 0; i < n; i++)for (int j = 0; j < 2 * T[i]; j++) {
		vl[t + 1] = min(vl[t] + 0.5, V[i]); t++;
	}

	vr[t] = 0;
	for (int i = n - 1; i >= 0; i--)for (int j = 0; j < 2 * T[i]; j++) {
		vr[t - 1] = min(vr[t] + 0.5, V[i]); t--;
	}

	double ans = 0; t = 0;
	for (int i = 0; i < n; i++)for (int j = 0; j < 2 * T[i]; j++) {
		ans += (min(vl[t], vr[t]) + min(vl[t + 1], vr[t + 1])) / 4; t++;
	}
	cout << fixed << setprecision(14) << ans << endl;

	return 0;
}

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

#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

struct Prefix {
    int64_t i_s = 0;
    int64_t len = 0;
};

struct EqualPrefix {
    bool operator()(const Prefix& lhs, const Prefix& rhs) const {
        return string_view(s[lhs.i_s]).substr(0, lhs.len) ==
               string_view(s[rhs.i_s]).substr(0, rhs.len);
    }

    const vector<string>& s;
};

struct HashPrefix {
    size_t operator()(const Prefix& p) const {
        static vector<vector<boost::optional<size_t>>> memo(s.size());

        if (memo[p.i_s].empty()) {
            memo[p.i_s].resize(s[p.i_s].size() + 1, boost::none);
            memo[p.i_s][0] = 0;
        }

        if (memo[p.i_s][p.len] == boost::none) {
            memo[p.i_s][p.len] = (*this)(Prefix{p.i_s, p.len - 1}) * 29 +
                                 s[p.i_s][p.len - 1];
        }

        return *memo[p.i_s][p.len];
    }

    const vector<string>& s;
};

int main() {
    int64_t n;
    cin >> n;

    vector<string> s(n);
    for (auto&& ss : s) {
        cin >> ss;
        reverse(ss.begin(), ss.end());

        for (auto&& c : ss) {
            c -= 'a';
        }
    }

    sort(s.begin(), s.end(),
         [](const string& l, const string& r) { return l.size() < r.size(); });

    int64_t ans = 0;
    unordered_map<Prefix, array<int64_t, 26>, HashPrefix, EqualPrefix> m(
            0, HashPrefix{s}, EqualPrefix{s});
    for (auto i_s : irange(0L, n)) {
        const auto& ss = s[i_s];
        if (ss.size() >= 2) {
            array<int64_t, 26> v{};
            for (auto c : ss) {
                ++v[c];
            }

            for (auto i : irange(0uL, ss.size() - 1)) {
                Prefix p{i_s, i};

                if (m.count(p) > 0) {
                    const auto& ar = m[p];
                    for (auto c : irange(0L, 26L)) {
                        if (v[c] > 0) {
                            ans += ar[c];
                        }
                    }
                }

                --v[ss[i]];
            }
        }

        ++m[Prefix{i_s, ss.size() - 1}][ss.back()];
    }

    cout << ans << endl;
}

Measured memory_bytes: 72184
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pl;
#define pi pair<int,int>
#define MM 1000000000
#define MOD MM+7
#define initial_value -1
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[8] = {-1,0,1,0,1,-1,1,-1};
int dy[8] = {0,-1,0,1,1,1,-1,-1};
struct edge{ll to,cost;};

int main() {
	int N, M; cin >> N >> M;
 
	vector<vector<int>> vec(M);
 
	for (int i = 0; i < M; ++i) {
		int k; cin >> k;
		vec[i].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> vec[i][j];
			--vec[i][j];
		}
	}
 
	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];
 
	int ans = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id : vec[j]) {
				if ((i >> id) & 1) {
					++c;
				}
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			++ans;
		}
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[10000];
int main(){
	int a;
	while(~scanf("%d",&a)){
		for(int i=0;i<a;i++)scanf("%d",b+i);
		std::sort(b,b+a);
		long long ret=0;
		for(int i=0;i<a;i++)ret+=b[i]*(a-i);
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 1044
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		long A = 0;
		long B = 0;
		long[] map = new long[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextLong();
			A += map[i];
		}
		
		long ans = Long.MAX_VALUE;
		for (int i = N - 1; i > 0; i--) {
			B += map[i];
			A -= map[i];
			long abs = Math.abs(A - B);
			ans = Math.min(abs, ans);
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 64132
#include <iostream>
using namespace std;
typedef long long ll;
#include <unordered_map>
#include <algorithm>
#include <unordered_set>
int main()
{
	int n;
	ll a,b = 1,c;
	cin >> n;
	for(int i = 0;i<n;i++)
	{
		cin >> a;
		c= __gcd(b,a);
	//	cout <<"c = "<<c<<endl;
		b =a/c*b; 
	}
	cout<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())

v = [0] * n
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    v[a] += 1
    v[b] += 1
    g[a].append(b)
    g[b].append(a)

for i in range(n):
    if v[i] % 2 == 1:
        print("No")
        exit()

v4 = 0
for i in range(n):
    if v[i] >= 6:
        print("Yes")
        exit()
    if v[i] == 4:
        v4 += 1

if v4 == 0:
    print("No")
    exit()
if v4 == 1:
    print("No")
    exit()
if v4 >= 3:
    print("Yes")
    exit()


memo = [0] * n
ord = [0] * n
lowlink = [0] * n
articulation = [0] * n

def dfs(v, p, k):
    memo[v] = 1
    ord[v] = k
    lowlink[v] = ord[v]
    isArticulation = False
    count = 0
    for nv in g[v]:
        if memo[nv] == 0:
            count += 1
            dfs(nv, v, k+1)
            lowlink[v] = min(lowlink[v], lowlink[nv])
            if p != -1 and ord[v] <= lowlink[nv]:
                isArticulation = True
        elif nv != p:
            lowlink[v] = min(lowlink[v], ord[nv])

    if p == -1 and count > 1:
        isArticulation = True
    if isArticulation:
        articulation[v] = 1

dfs(0, -1, 0)

count = 0
for i in range(n):
    if v[i] == 4 and articulation[i] == 1:
        count += 1

if count >= 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 86064
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;


int main(){    
  int N,now = 0;
  int next,time;
  cin >> N ;
  int t[N+1],x[N+1],y[N+1];
  for (int i = 1; i < N+1; i++){
    cin >> t[i] >> x[i] >> y[i]; 
  }
  t[0] = 0;

  for(int i=1;i<N+1;i++){
    time = t[i]-t[i-1];
    next = x[i]+y[i];
    if(time - (next-now) >= 0 && (time - (next-now)) % 2 == 0){
      now = x[i]+y[i];
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

vector<int> pre_kmp(const string& pat) {
	int k;
	vector<int> table((int)pat.size() + 1);
	table[0] = -1;

	for (int i = 1; i <= pat.size(); ++i) {
		k = table[i-1];

		while (k >= 0) {
			if (pat[k] == pat[i-1]) break;
			else k = table[k];
		}

		table[i] = k + 1;
	}

	return table;
}

vector<ll> len;
vector<vector<ll>> num;

vector<ll> calc(ll t, string &S) {
	vector<ll> cnt(26);
	if (t == 0) return cnt;
	for (int i = (int)len.size()-1; i >= 0; --i) {
		if (len[i] <= t) {
			rep(c, 26) cnt[c] += num[i][c];
			t -= len[i];
		}
	}
	if (t > 0) rep(i, t) cnt[S[i] - 'a']++;
	return cnt;
}

int main() {
	string S; ll L, R;
	cin >> S >> L >> R;

	int N = S.size() / 2;

	vi vec = pre_kmp(S);
	int cyc = N - vec[N];

	len.pb(N);
	vector<ll> c0(26);
	rep(i, N) ++c0[S[i] - 'a'];

	num.pb(c0);

	len.pb(N + cyc);
	rep(i, cyc) ++c0[S[i]-'a'];
	num.pb(c0);

	for (int i = 2; ; ++i) {
		ll nl = len[i-2] + len[i-1];
		if (nl > R) break;
		len.pb(nl);
		vector<ll> nx(26);
		rep(c, 26) nx[c] = num[i-1][c] + num[i-2][c];
		num.pb(nx);
	}

	auto vl = calc(L-1, S), vr = calc(R, S);
	rep(i, 26) printf("%lld%c", vr[i] - vl[i], i == 25 ? '\n' : ' ');

	return 0;
}

Measured memory_bytes: 1412
#include "bits/stdc++.h"
using namespace std;

int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    cout<<min(min(a*x+b*y,(x-min(x,y))*a+(y-min(x,y))*b+min(x,y)*2*c),max(x,y)*2*c)<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n;
    cin >> n;
    map<int ,int> mp;
    rep(i,n-1){
        int a;
        cin >> a;
        mp[a]++;
    } 
    rep1(i,n+1){
        cout << mp[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 13036
class Dice():

    def __init__(self, dice_list):
        self.state = [0 for _ in range(6)]
        self.state[0] = dice_list[0]
        self.state[1] = dice_list[1]
        self.state[2] = dice_list[2]
        self.state[3] = dice_list[3]
        self.state[4] = dice_list[4]
        self.state[5] = dice_list[5]

    def north(self):
        tmp = self.state[0]
        self.state[0] = self.state[1]
        self.state[1] = self.state[5]
        self.state[5] = self.state[4]
        self.state[4] = tmp

    def west(self):
        tmp = self.state[0]
        self.state[0] = self.state[2]
        self.state[2] = self.state[5]
        self.state[5] = self.state[3]
        self.state[3] = tmp

    def south(self):
        tmp = self.state[0]
        self.state[0] = self.state[4]
        self.state[4] = self.state[5]
        self.state[5] = self.state[1]
        self.state[1] = tmp


    def east(self):
        tmp = self.state[0]
        self.state[0] = self.state[3]
        self.state[3] = self.state[5]
        self.state[5] = self.state[2]
        self.state[2] = tmp

    
if __name__ == '__main__':
    duce_num1 = list(map(int, input().split()))
    duce_num2 = list(map(int, input().split()))

    dice1 = Dice(duce_num1)
    ans = 'No'
    flag = False

    dice2 = Dice(duce_num2)
    for i in range(4):
        for j in range(4):
            if dice1.state[1] == dice2.state[1]:
                flag = True
                break
            dice2.east()

        if dice1.state[1] == dice2.state[1]:
            flag = True
            break

        dice2.north()

    if flag == False:
        dice2 = Dice(duce_num2)
        dice2.west()
        dice2.south()
        for i in range(4):
            if dice1.state[1] == dice2.state[1]:
                flag = True
                break
            dice2.west()

    if flag == False:
        dice2 = Dice(duce_num2)
        dice2.east()
        dice2.south()
        for i in range(4):
            if dice1.state[1] == dice2.state[1]:
                break
            dice2.west()

    for i in range(4):
        if dice1.state == dice2.state:
            ans = 'Yes'
            break
        dice2.west()
        
    print(ans)


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

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	double t[110] = {};
	double v[110] = {};
	for(int i = 1; i <= n; i++){
		cin >> t[i];
		t[i] += t[i - 1];
	}
	t[n + 1] = t[n];
	for(int i = 1; i <= n; i++){
		cin >> v[i];
	}

	double ans = 0.0;
	double beforev = 0.0;
	for(double i = 0.5; i <= t[n]; i += 0.5)
	{
		double nowv = 200000.0;
		for(int j = 0; j <= n + 1; j++){
			double tmpv = 0.0;
			if(j == 0) tmpv = v[j] + i;
			else if(i < t[j - 1]) tmpv = v[j] + t[j - 1] - i;
			else if(i <= t[j]) tmpv = v[j];
			else tmpv = v[j] + i - t[j];
			nowv = min(nowv, tmpv);
		}
		ans += (beforev + nowv) * 0.5 / 2.0;
		beforev = nowv;
	}
	printf("%.10f\n", ans);
}

Measured memory_bytes: 256
use std::io;
fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let input = input.trim().split(" ").collect::<Vec<_>>();

    let input = input.iter().map(|i| i.parse::<i32>().unwrap()).collect::<Vec<_>>();
    println!("{}",
             if input[1] - input[0] == input[2] - input[1] {
                 "YES"
             } else {
                 "NO"
             });
}


Measured memory_bytes: 4352
n, m = map(int, raw_input().split())
a = map(int,raw_input().split())

cntodd = 0
for x in a:cntodd += x % 2

if cntodd > 2:
    print "Impossible"
    exit()
evens = [x for x in a if x % 2 == 0]
odds = [x for x in a if x % 2 == 1]

if len(a) == 1:
    if a[0] == 1:
        print 1
        print 1
        print 1
        exit()
    print a[0]
    print 2
    print a[0]-1,1
    exit()
    
if cntodd == 2:
    a = [odds[0]] + evens + [odds[1]]
    b = a[::]
    b[0] += 1
    b[-1] -= 1

if cntodd == 1:
    a = [odds[0]] + evens
    b = a[::]
    b[0] += 1
    b[-1] -= 1

if cntodd == 0:
    a = evens
    b = a[::]
    b[0] += 1
    b[-1] -= 1

if b[-1] == 0:
    b = b[:-1]
    
print " ".join(map(str, a))
print len(b)
print " ".join(map(str, b))


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector <int>
#define vl vector <long long>
#define pb push_back
#define mk make_pair
#define pi pair <int,int>
#define pl pair <ll,ll>
#define rep(a,b) for(int i=a;i<=b;i++)
#define rep_(a,b) for(int i=a;i>=b;i--)
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    rep(0,n-1)
    	cin>>a[i];
    int ans=0;
    for(int i=n-1;i>=0;i--)
    {
    	if(a[i]==0)
    		continue;
    	else
    	{
    		vi v;
    		for(int j=2;j<=sqrt(i+1);j++)
    		{
    			if((i+1)%j==0)
    			{
    				v.pb(j);
    				if((i+1)/j!=j)
    					v.pb((i+1)/j);
    			}
			}
			for(int j=0;j<v.size();j++)
				a[v[j]-1]=1-a[v[j]-1];
			if(i!=0)
				a[0]=1-a[0];
			ans++;
		}
	}
	cout<<ans<<endl;
	for(int i=0;i<n;i++)
	{
		if(a[i]==1)
			cout<<i+1<<" ";
	}
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main (){
  int a=0,b=0;
  cin>>a;
  cin>>b;
  if(a-b*2>=0){
  cout<<a-b*2<<endl;
  }
  else if(a-b*2<=0){
    cout<<0<<endl;
  }
return 0;
}
  

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define Pb push_back
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 7;

inline int R()
{
    int rt = 0; char ch = getchar(); bool isn = false;
    for ( ; ch < '0' || ch > '9'; ch = getchar() ) isn = ch == '-' ? true : isn;
    for ( ; ch >= '0' && ch <= '9'; ch = getchar() ) rt = rt * 10 + ch - '0';
    return isn ? -rt : rt;
}

int n, a[MAXN];
ll lm;
int s[MAXN], t[MAXN << 1];

inline int Lowbit ( int x ) { return x & -x; }

void Add ( int pos, int val )
{
	pos += n + 1;
	for ( ; pos <= n + n + 1; pos += Lowbit ( pos ) )
		t[pos] += val;
}

int Query ( int pos )
{
	pos += n + 1;
	int rt = 0;
	for ( ; pos; pos -= Lowbit ( pos ) )
		rt += t[pos];
	return rt;
}

bool Chk ( int na )
{
	memset ( t, 0, sizeof t );
	for ( int i = 1; i <= n; ++i )
		s[i] = ( a[i] < na ? -1 : 1 );
	ll rt = 0;
	Add ( 0, 1 );
	int nv = 0;
	for ( int i = 1; i <= n; ++i )
	{
		nv += s[i];
		rt += Query ( nv );
		Add ( nv, 1 );
	}
	return rt >= lm;
}

int main()
{
	n = R(), lm = 1ll * n * ( n + 1 ) / 2 / 2 + 1;
	lm = 1ll * n * ( n + 1 ) / 2 - lm + 1;
	for ( int i = 1; i <= n; ++i )
		a[i] = R();
	int nl = 1, nr = 1e9, ans;
	while ( nl <= nr )
	{
		int mid = nl + nr >> 1;
		if ( Chk ( mid ) )
			ans = mid, nl = mid + 1;
		else
			nr = mid - 1;
	}
	printf ( "%d\n", ans );
	return 0;
}

Measured memory_bytes: 1792
package main

import (
	"fmt"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	return -min(-a, -b)
}

func main() {
	var k, x int
	fmt.Scan(&k, &x)
	mi := max(-1000000, x-k+1)
	ma := min(1000000, x+k-1)
	for i := mi; i < ma; i++ {
		fmt.Print(i, " ")
	}
	fmt.Println(ma)
}


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

public class Main {
    private static final long MOD = 998_244_353;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int s = scanner.nextInt();

        final int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        final long[][] dpTable = new long[n][s];
        for (final long[] array : dpTable) {
            Arrays.fill(array, -1);
        }
        long count = 0;
        if (a[0] < s) {
            dpTable[0][a[0]] = 1;
        } else if (a[0] == s) {
            count = n;
        }

        for (int i = 1; i < n; i++) {
            // a[i]を選ばない場合
            System.arraycopy(dpTable[i - 1], 0, dpTable[i], 0, s);

            // a[i] が s を超過した場合何もしない
            if (a[i] > s) {
                continue;
            }
            // a[i] が s だと，a[i] を含む全ての区間の組み合わせを足す
            else if (a[i] == s) {
                count = (count + (i + 1) * (n - i)) % MOD;
                continue;
            }

            // a[i] を足して s になる場合，始点の距離の総数 * 終点の距離の総数を足せる
            if (dpTable[i - 1][s - a[i]] != -1) {
                count = (count + dpTable[i - 1][s - a[i]] * (n - i)) % MOD;
            }

            // a[i] を選ぶ場合
            for (int j = 1; j < s - a[i]; j++) {
                if (dpTable[i - 1][j] == -1) {
                    continue;
                }
                //
                if (dpTable[i][j + a[i]] == -1) {
                    dpTable[i][j + a[i]] = 0;
                }
                dpTable[i][j + a[i]] += dpTable[i - 1][j];
                dpTable[i][j + a[i]] %= MOD;
            }

            // 新たに始点を始める場合
            if (dpTable[i][a[i]] == -1) {
                dpTable[i][a[i]] = 0;
            }
            dpTable[i][a[i]] += i + 1;
            dpTable[i][a[i]] %= MOD;
        }

        System.out.println(count);
    }
}


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

int main(){
	int H,A;
	cin>>H>>A;
	int count=0;
	while(H>0){
		count++;
		H-=A;
	}
	cout<<count<<endl;
	return 0;

}

Measured memory_bytes: 256
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)

N = int(input())
P = [int(x) for x in input().split()]
# L = [[int(x) for x in input().split()] for _ in range(N)]
# N, M = map(int, input().split())
# S = input()

ans = 0
for i in range(N - 2):
    p = P[i : i + 3]
    p.sort()

    if p[1] == P[i + 1]:
        ans += 1

print(ans)


Measured memory_bytes: 38496
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, k, x, y;
    cin >> n >> k >> x >> y;
    ll ret = 0;
    if (n >= k) {
        ret += k * x;
        n -= k;
        ret += n * y;
    } else {
        ret = n * x;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <stdlib.h>
#include <time.h>
#include <random>
#include <string>
#include<algorithm>


using namespace std;


int main(){
	int n,t,k=1;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> t;
		if(t%2){
			k*=1;
		}
		else{
			k*=2;
		}
	}
	int tt=1;
	for(int i=0; i<n; i++){
		tt*=3;
	}
	cout << tt-k << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int main()
{
	int h,w,n;
	int a[10004];
	int color[101][101];
	memset(a,0,sizeof(a));
	scanf("%d %d\n%d",&h,&w,&n);
	for(int i = 1;i <= n;i ++)
	scanf("%d",&a[i]);
	
	int tot = 0;
	
	while(tot < h*w)
	{
		int flag = 1,j,k = 1;
		for(int i = 0;i < h && tot < h*w;i ++)
		{
			if(flag == 1)
			{
				for(int j = 0;j < w && tot < h*w;j ++)
				{
					if(a[k] == 0)
					k ++;
					color[i][j] = k;
					a[k] --;
					tot ++;
				}
			}
			else 
			for(int j = w-1;j >= 0&& tot < h*w;j --)
			{
				if(a[k] == 0)
					k ++;
					color[i][j] = k;
					a[k] --;
					tot ++;
			}
		
			flag *= (-1);
		}
	}
	for(int i = 0;i < h;i ++)
	{
		for(int j = 0;j < w;j ++)
		printf("%d ",color[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long LL;

void set_bit(LL &n, int position)
{
    n |= (1LL << position);
}

LL no_of_set_bits(LL n, int position)
{
    LL set_bits = 0; 

    LL weight = (1LL << position);
    
    LL no_of_blocks = (n)/weight; 

    set_bits += (no_of_blocks/2)*weight;

    LL total_reached = no_of_blocks*weight; 

    if(no_of_blocks%2 == 1)
      set_bits += n - total_reached + 1;
  
    return set_bits;
}

int main()
{
    LL left, right;
    cin >> left >> right;

    LL xor_answer = 0;

    const int MAX_BITS = 63;
    for(int i = 0; i < MAX_BITS; i++)
    {
        LL no_of_set_bits_here = no_of_set_bits(right, i);

      	if(left != 0) 
          no_of_set_bits_here -= no_of_set_bits(left - 1, i);
      
        if(no_of_set_bits_here%2 == 1)
            set_bit(xor_answer, i);
    }

    cout << xor_answer;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
int n,a[300001];
bool cmp(int x,int y) {
	return x>y;
}
int main() {
    scanf("%d",&n);
    for (int i=1;i<=n*3;i++) scanf("%d",&a[i]);
    sort(a+1,a+n*3+1,cmp);
    LL sum=0;
    for (int i=1;i<=n;i++) sum+=a[i*2];
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define IN freopen("in.txt","r",stdin);
#define OUT freopen("out.txt","w",stdout);
#define sc scanf
#define itn int
#define STR clock_t startTime = clock();
#define END clock_t endTime = clock();cout << double(endTime - startTime) / CLOCKS_PER_SEC *1000<< "ms" << endl;
using namespace std;
const int N=1e6+5;
const long long mod=1e9+7;
const long long mod2=998244353;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
inline ll mul_64(ll x,ll y,ll c){return (x*y-(ll)((long double)x/c*y)*c+c)%c;}
inline ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=a*a%c)if(b&1)ans=ans*a%c;return ans;}
inline void exgcd(ll a,ll b,ll &x,ll &y){if(!b)x=1,y=0;else exgcd(b,a%b,y,x),y-=x*(a/b);}
int n,l[N];
int pos(int x,int y){
    int ans=0,L=y,R=n;
    int num=l[x]+l[y];
    while(R>=L){
        itn mid=L+R>>1;
        if(l[mid]>=num)R=mid-1;
        else ans=mid,L=mid+1;
    }
    return ans;
}
int main(){
    
    cin>>n;
    for(int i=1;i<=n;i++)sc("%d",&l[i]);
    sort(l+1,l+1+n);
    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            ans+=pos(i,j)-j;
        }
    }
    o(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

int V, Q;

struct HeapNode {
	int d, u;
	bool operator < (const HeapNode& rhs) const {
		return d > rhs.d;
	}
};

struct Edge {
	int from, to, dist;
	Edge(int u, int v, int d) :from(u), to(v), dist(d) {}
};

struct Dijkstra {
	int n, m;
	vector<Edge> edges;
	vector<int> G[NUM];

	int dep[NUM], p[20][NUM];

	void init(int n) {
		this->n = n;
		dfs(0, -1, 0);
		for (int k = 0; k + 1 < 20; k++) {
			for (int v = 0; v < V; v++) {
				if (p[k][v] < 0)
					p[k + 1][v] = -1;
				else
					p[k + 1][v] = p[k][p[k][v]];
			}
		}
	}

	void AddEdge(int from, int to, int dist) {
		edges.push_back(Edge(from, to, dist));
		m = edges.size();
		G[from].push_back(m - 1);
	}

	void dfs(int u, int fa, int depth) {
		dep[u] = depth;
		p[0][u] = fa;
		for (int i = 0; i < G[u].size(); i++) {
			Edge& e = edges[G[u][i]];
			int v = e.to;
			if (v == fa)
				continue;
			dfs(v, u, depth + 1);
		}
	}

	int lca(int u, int v) {
		if (dep[u] > dep[v])
			swap(u, v);
		for (int k = 0; k < 20; k++) {
			if ((dep[v] - dep[u]) >> k & 1) {
				v = p[k][v];
			}
		}
		if (u == v)
			return u;
		for (int k = 19; k >= 0; k--) {
			if (p[k][u] != p[k][v]) {
				u = p[k][u];
				v = p[k][v];
			}
		}
		return p[0][u];
	}
};

Dijkstra solve;

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int k, c, u, v;
	cin >> V;
	for (int i = 0; i < V; i++) {
		scanf("%d", &k);
		for (int j = 0; j < k; j++) {
			scanf("%d", &c);
			solve.AddEdge(i, c, 1);
			solve.AddEdge(c, i, 1);
		}
	}
	solve.init(V);
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		scanf("%d%d", &u, &v);
		printf("%d\n", solve.lca(u, v));
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 21948
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;
int n,a,b,i,j,str[100005];
int main()
{

    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a);
        str[a]=i;
    }
    printf("%d",str[1]);
    for(i=2;i<=n;i++)
    {
        printf(" %d",str[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);

int main() {
  ll n;
  cin >> n;
  ll res = INF;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ll j = n / i - 1;
      res = min(res, i + j - 1);
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    string S,T;
    cin>>S>>T;
    if(S==T)
        cout<<"Yes";
    else
    {
        string S1;
        for(int i=S.length()-1;i>=0;--i)
        {
            S1.clear();
            S1+=S.substr(i,S.length()-i);
            S1+=S.substr(0,i);
            if(S1==T)
            {
                cout<<"Yes";
                return 0;
            }
        }
        cout<<"No";
    }
    return 0;
}


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

int H[100010];

int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> H[i];
	H[N]=1+1e9;
	int ans=0, now=0;
	for(int i=1; i<=N; ++i){
		if(H[i-1]<H[i]){
			ans=max(ans, i-now-1);
			now=i;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int A, B, H, M;
    std::cin >> A >> B >> H >> M;

    const double h = 30.0 * H + M / 2.0; 
    const double m = 6.0 * M;

    const double rad = (h - m) / 180.0 * M_PI;

    std::printf("%.10lf\n", std::sqrt(A * A + B * B - 2 * A * B * std::cos(rad)));

    return 0;
}


Measured memory_bytes: 4156
import java.math.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int num = 0;
        for(int i = 0; i < N; ++i) {
            String s;
            s = scan.next();
            if(new BigInteger(s).isProbablePrime(5)) ++num;
        }
        System.out.println(num);
    }
}


Measured memory_bytes: 51144
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

vi C(26), Last(26, -1), T(365);
vector<vi> S(365, vi(26));
vector<vi> table(365, vi(26));
ll ans = 0;
int D, M;

void Query(int d, int q) {
  int prev;
  prev = T.at(d);
  T.at(d) = q;
  ll sabun = 0;
  sabun += (S.at(d).at(q) - S.at(d).at(prev));

  sabun += table.at(d).at(q);
  table.at(d).at(q) = 0;
  for (int i = d + 1; i < D && table.at(i).at(q) != 0; i++) {
    sabun += table.at(i).at(q);
    table.at(i).at(q) = table.at(i - 1).at(q) + C.at(q);
    sabun -= table.at(i).at(q);
  }
  /*
  cout << "table " << q << ": ";
  REP(i, D) cout << table.at(i).at(q) << " ";
  cout << "\n";
  */

  table.at(d).at(prev) =
      (d == 0) ? C.at(prev) : table.at(d - 1).at(prev) + C.at(prev);
  sabun -= table.at(d).at(prev);
  for (int j = d + 1; j < D && table.at(j).at(prev) != 0; j++) {
    sabun += table.at(j).at(prev);
    table.at(j).at(prev) = table.at(j - 1).at(prev) + C.at(prev);
    sabun -= table.at(j).at(prev);
  }
  /*
  cout << "table " << prev << ": ";
  REP(i, D) cout << table.at(i).at(prev) << " ";
  cout << "\n";
  cout << "sabun = " << sabun << endl;
*/
  ans += sabun;
  // cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"

  cin >> D;
  REP(i, 26) cin >> C.at(i);
  REP(i, D) REP(j, 26) cin >> S.at(i).at(j);

  REP(i, D) { T.at(i) = i % 26; }

  for (int i = 0; i < D; i++) {
    REP(j, 26) {
      if (j == T.at(i)) {
        Last.at(j) = i;
        table.at(i).at(j) = 0;
      } else {
        table.at(i).at(j) = C.at(j) * (i - Last.at(j));
      }
    }
    // cout << count << endl;

    // cout << "T = " << T.at(i) << " S = " << S.at(i).at(T.at(i)) << endl;
    ans += S.at(i).at(T.at(i));
  }

  REP(i, D) {
    REP(j, 26) { ans -= table.at(i).at(j); }
  }
  /*
    REP(i, 26) {
      cout << "table " << i << ": ";
      REP(j, D) cout << table.at(j).at(i) << " ";
      cout << "\n";
    }
    cout << ans << endl;
  */

  random_device rnd;
  mt19937 mt((int)time(0));
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  // Query
  REP(i, 10000) {
    ll pans = ans;
    vector<vi> oldtable = table;
    int d = rand365(mt), q = rand26(mt);
    // cout << d << " " << q << endl;
    int oq = T.at(d);
    Query(d, q);
    if (ans < pans) {
      ans = pans;
      T.at(d) = oq;
      table = oldtable;
    }
  }

  REP(i, D) cout << T.at(i) + 1 << endl;
  /*
std::random_device rnd;  // 非決定的な乱数生成器を生成
std::mt19937 mt(
    rnd());  //  メルセンヌ・ツイスタの32ビット版、引数は初期シード値
std::uniform_int_distribution<> rand100(0, 99);  // [0, 99] 範囲の一様乱数
for (int i = 0; i < 20; ++i) {
  std::cout << rand100(mt) << "\n";
}*/
}


Measured memory_bytes: 3808
#include <cstdio>
#include <utility>
#include <vector>
#include <string>
#include <queue>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

struct point {int x, y;};
typedef vector<string> map;

struct node {int d; point p;};

int walk(point s, point e, map m) {
	queue<node> q;
	static point d[4] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

	q.push({0, s});

	while (!q.empty()) {
		node n = q.front();
		q.pop();
		if (n.p.x == e.x && n.p.y == e.y)
			return n.d;
		for (auto p: d) {
			p.x += n.p.x;
			p.y += n.p.y;
			if (p.x >= 0 && p.x < (int) m[0].size()
				&& p.y >= 0 && p.y < (int) m.size()) {
				char &c = m[p.y][p.x];
				if (c == '.') {
					c = 'X';
					q.push({n.d + 1, p});
				}
			}
		}
	}
	return 0;
}

int main() {
	int h = in(), w = in(), d = 0;
	map m(h);
	vector<point> p(in());
	point s;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char c = gcu();
			if (isdigit(c)) {
				p[c - '0' - 1] = {j, i};
				c = '.';
			} else if (c == 'S') {
				s = {j, i};
				c = '.';
			}
			m[i].push_back(c);
		}
		gcu();
	}
	for (auto t: p) {
		d += walk(s, t, m);
		s = t;
	}
	out(d, '\n');
}


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

         
                    
using namespace std;
                     
#define rep(i,a,b); for(long int i=a;i<b;i++)
#define mk make_pair        
#define LIMIT 100007
#define MOD 1000000007
#define ll long long int
#define endl '\n'
#define min(a,b) (a>b?b:a)
#define max(a,b) (a<b?b:a)
#define pb push_back
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll power(ll t,ll x)
{

	ll ans=1;
	while(t>0)
	{
		if(t%2==1)
			ans=(ans*x)%MOD;

		t=t/2;
		x=(x*x)%MOD;
	}

	return ans;
}


int main() 
{ 
    FAST
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	int h[n];
	rep(i,0,n) cin>>h[i];

	ll dp[n];
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	rep(i,2,n)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}

	cout<<dp[n-1];


    return 0; 
}  


Measured memory_bytes: 4704
// kartikay26
#include <bits/stdc++.h>
using namespace std;
#define debug(x...) 
#ifdef LOCAL
#include "prettyprint.hpp"
#endif
void print(){cout << endl;} void prints(){}
template<typename T=int> T get(){T x; cin >> x; return x;}
template<typename T> void get(T* x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T> void get(T& x, int n){for (int i = 0; i < n; ++i) { cin >> x[i]; }}
template<typename T, typename... A> void print(T x,A... r){cout << x << " ";print(r...);}
template<typename T, typename... A> void prints(T x,A... r){cout << x << " ";prints(r...);}
typedef long long int ll; typedef double db; typedef vector<ll> vi; typedef pair<ll, ll> pii;
#define int ll
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define clear(x) memset(x, 0, sizeof(x))
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int mod = 1e9+7;
const int N = 1e6+1;

int dp[101][100001];
// dp[i][k] ~ num ways to dist k candies among first i children
int pp[101][100001];
// pp ~ prefix sum of dp along dimension K

int32_t main(){
	fast_io();

	int n, K; cin >> n >> K;
	vi a(n); get(a,n);

	dp[0][0] = 1;
	for (int i = 0; i <= K; ++i) {
		pp[0][i] = 1;
	}

	for (int i = 1; i <= n; ++i) {
		int ai = a[i-1];
		for (int k = 0; k <= K; ++k) {
			pp[i][k] = k>0 ? pp[i][k-1] : 0;
			// dp[i][k] = dp[i-1][k-0] + dp[i-1][k-1] + ... + dp[i-1][k-ai]
			//          = pp[i-1][k] - pp[i-1][k-ai-1]
			dp[i][k] =  pp[i-1][k] - ((k-ai-1>=0) ? pp[i-1][k-ai-1] : 0);
			pp[i][k] += pp[i-1][k] - ((k-ai-1>=0) ? pp[i-1][k-ai-1] : 0);
			dp[i][k] += mod; dp[i][k] %= mod; pp[i][k] += mod; pp[i][k] %= mod;
			// for (int c = 0; c <= min(k,ai); ++c) {
			// 	dp[i][k] += dp[i-1][k-c];
			// 	pp[i][k] += dp[i-1][k-c];
			// }
		}
		debug(i, arr(dp[i], K+1));
		debug(i, arr(pp[i], K+1));
	}


	print(dp[n][K]);
	
	return 0;
}

Measured memory_bytes: 158080
import numpy as np
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
b = np.array(b)
count = 0
for i in range(n):
  a = list(map(int,input().split()))
  a = np.array(a)
  if np.sum(np.multiply(a,b))+c>0:
    count += 1
print(count)
  

Measured memory_bytes: 12396
while True:
    s=input()
    if s=="-":
        break
    m=int(input())
    i=0
    l=len(s)
    while i<m:
        h=int(input())
        temp1=s[0:h]
        temp2=s[h:l]
        s=temp2+temp1
        i+=1
    print(s)



Measured memory_bytes: 5592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

ll expmod(ll x, ll n, ll mod){
	if(n == 0) return 1;
	else if(n % 2 == 0){
		ll temp = expmod(x, n / 2, mod);
		return (temp * temp) % mod;
	}
	else{
		return (expmod(x, n - 1, mod) * x) % mod;
	}
}

ll modinv(ll x, ll mod){
	return expmod(x, mod - 2, mod);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n, m;
	cin >> n >> m;
	cout << ((m >= n) ? "Yes" : "No") << endl;
}		


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

//by using 2d array

ll knapsack(ll n,ll w,vll wei, vll val){
    vector<vll> dp(n+1,vll(w+1));

    repA(i,0,n){
        repA(j,0,w){
            if(i==0 or j==0)dp[i][j]=0;
            else if(wei[i-1]<=j) dp[i][j] = max(dp[i-1][j],dp[i-1][j-wei[i-1]]+val[i-1]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    return dp[n][w];
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n,w; cin >> n >> w;
        vll wei(n),val(n);
        repA(i,0,n-1) cin >> wei[i] >> val[i];

        cout << knapsack(n,w,wei,val) << endl;
    }
}


Measured memory_bytes: 83112
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define LL long long

using namespace std;

const int N = 2e5 + 7;
const LL mod = 1e9 + 7;
const int B = sqrt(1e5);

string t;
map < string , string > s;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    s["Rainy"] = "Sunny";
    s["Sunny"] = "Cloudy";
    s["Cloudy"] = "Rainy";
    cin >> t;
    cout << s[t];
}


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

int main() {
    int H, W;
    while(true) {
        cin >> H >> W;
        if(H * W == 0) break;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;
typedef long long ll;


int main(){

    string s;
    cin >> s;

    string t = "keyence";

    bool flag = 0;    
    //l 文字目からr文字目を取り除く
    for(int l = 0; l < s.size(); l++){
        for(int r = l; r < s.size(); r++){
            string s2 = s.substr(0, l) + s.substr(r) ; 
            if(s2 == t) flag = true;
        }
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
using namespace std;


int main(){
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  k--;

  if(islower(s[k])){

  } else {
    s[k] = s[k] - 'A' + 'a';
  }

  cout << s << endl;
}


Measured memory_bytes: 256