akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};


int main(){
    int n,b;
    cin >> n >> b;
    FOR(i,1,4){
        if (i!= n&& i!= b){
            cout << i;
        }
    }
}


Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))

w = []
for i in range(0, len(p)):
  if i+1 != p[i]:
    w.append(i)

if len(w) == 0:
  print("YES")
  exit()

if (len(w) == 2):
  p[w[0]], p[w[1]] = p[w[1]], p[w[0]]
  if (list(range(1, N+1)) == p):
    print("YES")
    exit()

print("NO")

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

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

	ans = n;

	for (int i = 0; i <= n; i++) {
		int x = 0;
		int k = i;

		while (k > 0) {
			x += k % 6;
			k /= 6;
		}
		k = n - i;
		while (k > 0) {
			x += k % 9;
			k /= 9;
		}
		if (ans > x) {
			ans = x;
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
pair=[list(map(lambda x:int(x)-1,input().split())) for _ in range(m)]
graph=[[n]*n for i in range(n)]

def dfs(v):
    if visited[v]:
        return
    visited[v]=True
    for j in [j for j,v2 in enumerate(graph[v]) if v2 == 1]:
        dfs(j)

ans = 0

for p in pair:
    graph[p[0]][p[1]] = graph[p[1]][p[0]] = 1
    
for i in range(m):
    visited=[False]*n
    x,y = pair[i]
    graph[x][y] = graph[y][x] = 0    
    dfs(0)
    
    if not all(visited):
        ans += 1
        
    graph[x][y] = graph[y][x] = 1     
    
print(ans)

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

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> tn(n);
    rep(i,n) cin >> tn.at(i);
    
    int ans = 0;
    int end = 0;
    rep(i,n) {
        if(tn.at(i) < end) {
            ans += tn.at(i) + t - end;
        }
        else ans += t;
        end = tn.at(i) + t;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
char s[200005];
int dp[200005][2];
int main(){
	int l;
	while(~getI(l)){
		scanf("%s",s);
		if(s[0]=='#'){
			dp[0][0]=0;
			dp[0][1]=1;
		}else{
			dp[0][0]=1;
			dp[0][1]=0;
		}
		F(i,1,l){
			if(s[i]=='#') dp[i][0]=min(dp[i-1][0],dp[i-1][1]);
			else dp[i][0]=min(dp[i-1][0],dp[i-1][1])+1;
			if(s[i]=='.') dp[i][1]=dp[i-1][1];
			else dp[i][1]=dp[i-1][1]+1;
		}
		printf("%d\n",min(dp[l-1][0],dp[l-1][1]));
	}
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, maxx;
	string s;
	cin >> n;
	map<string, int> ct;
	maxx = 0;
	while (n--) {
		cin >> s;
		ct[s]++;
		maxx = max(maxx, ct[s]);
	}
	for (auto p : ct) {
		if (p.second == maxx) cout << p.first << "\n";
	}

	return 0;
}


Measured memory_bytes: 17664
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;


int main() {
	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	ans += min(n, m / 2);
	m -= 2 * (ans);
	
	ans += (m / 4);

	cout << ans << endl;


}


Measured memory_bytes: 256
fun main(args: Array<String>) = yorukatsu18b()

fun yorukatsu18b() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val grid = (1..h).map { readLine()!!.toCharArray() }

    val removeHorizon = grid.filter { it.any { it == '#' } }

    val removeVertical = (0 until w).mapNotNull { i ->
        val column = removeHorizon.map { it[i] }
        if (column.any { it == '#' }) column else null
    }

    val answer = removeHorizon.indices.joinToString(System.lineSeparator()) { y ->
        removeVertical.indices.map { x -> removeVertical[x][y] }.joinToString("")
    }

    println(answer)
}


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

int main() {
	int N, K;

	cin >> N >> K;

	double ans = 0;
	for( int i = 1; i <= N; i++ ) {
		double d = 1.0 / N;
		for( int j = i; j < K; j *= 2 ) {
			d /= 2;
		}
		ans += d;
	}

	cout << fixed << setprecision(12) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	string s; cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
void main()
{
    long n = readln.chomp.to!long;

    long[] op = [1];
    foreach (i; 0 .. n)
    {
        if (6 ^^ (i + 1) <= n)
        {
            op ~= 6 ^^ (i + 1);
        }
        if (9 ^^ (i + 1) <= n)
        {
            op ~= 9 ^^ (i + 1);
        }

        if (6 ^^ (i + 1) > n)
        {
            break;
        }
    }
    op.sort!"a < b";
    long m = op.length;

    long[] dp = new long[n+1];
    dp[] = long.max;
    dp[0] = 0;
    foreach (x; op)
    {
        foreach (i; x .. n+1)
        {
            dp[i] = min(dp[i], dp[i-x]+1);
        }
    }

    dp[n].writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a, b;
    cin >> a >> b;
    long double temp_b = b / 2.0;
    long long places_in_b = (long long)ceil(temp_b);
    long long not_places_in_b = b - places_in_b;
    long double temp_a = a / 2.0;
    long long places_in_hr = (long long)ceil(temp_a);
    long long not_places_in_hr = a - places_in_hr;
    long long ans = (places_in_b * places_in_hr) + (not_places_in_b * not_places_in_hr);
    if(a == 1 || b == 1){
        cout<<1;
    }
    else
        cout<<ans<<endl;;
    //cout << places_in_b <<" "<<not_places_in_b<<endl; 
    //cout<<places_in_hr<<" "<<not_places_in_hr;
    
    return 0;
}

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

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

	long long f[n][10], p[n][11];
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < 10; j++)
		{
			cin >> f[i][j];
		}		
	}

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < 11; j++)
		{
			cin >> p[i][j];
		}
		
	}
	
	long long ans = -70000000000;

	for(int bit = 1; bit < (1<<10); bit++)
	{
		long long num = 0;
		for(int i = 0; i < n; i++)
		{
			int c=0;
			for(int j = 0; j < 10; j++)
			{
				if(bit & (1<<j) && f[i][j] == 1){
					c++;
				}
			}
			num += p[i][c];	
		}
		ans = max(ans, num);
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

///Code starts from here
int main()
{

        ll n,i,flag=0;
        cin>>n;
        ll a[n];
        ll prod=1;

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

        }
        for(i=0;i<n;i++)
        {
            if(a[i]==0)
            {
                cout<<"0"<<endl;
                return 0;
            }


        }

            for(i=0;i<n;i++)
            {
               if(a[i]<=1000000000000000000/prod)
               {
                   prod*=a[i];
               }
               else
               {
                   cout<<"-1"<<endl;
                   return 0;
               }

            }

            cout<<prod<<endl;
    return 0;
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define vl vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：
// 問題文URL：
// ------------------

// ----ここから本問のソースコード----


// グローバル変数（入力）
ll A,B;

void solve() { cout << A * B << endl; }

int main() {
  cin >> A >> B;
  solve();
  return 0;
}


Measured memory_bytes: 3636
local n=io.read("*n")
local verte={}
local flag=true
for i=1,n do
    local x=io.read("*n")
    if (i==1 and x>0) or (i>1 and x==0) then
        flag=false
    end
    verte[x]=(verte[x] or 0)+1
end

if not flag then
    print(0)
else
    local tree=1
    local mod=998244353
    for x,_ in pairs(verte) do
        if x+1<=#verte then
            if not verte[x] or not verte[x+1] then
                print(0)
                return
            end
            for i=1,verte[x+1] do
                tree=tree*verte[x]%mod
            end
        end
    end
    print(tree)
end

Measured memory_bytes: 2228
import itertools

N,M=map(int,input().split())
g=[[0]*N for _ in range(N)]
#print(g)
for _ in range(M):
    a,b=map(int,input().split())
    g[a-1][b-1]=1
    g[b-1][a-1]=1
    #print(g)

num=0
for a in itertools.permutations(range(N)):
    #print(a)
    connect=1
    if a[0]==0:
        for i in range(N-1):
            connect=connect*g[a[i]][a[i+1]]
            #print(connect)
        num=num+connect
        #print(num)
print(num)

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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	ll A, B;
	in A >> B;
	ll x = A * B;
	if (A < B)
	{
		ll n = A;
		A = B;
		B = n;
	}
	ll r = A % B;
	while (r != 0)
	{
		A = B;
		B = r;
		r = A % B;
	}
	out x / B en;
}


Measured memory_bytes: 256
#include<iostream>
int main(void){
  char c;
  std::cin>>c;
  if(c=='a'){
    std::cout<<"vowel"<<std::endl;
  }else if(c=='e'){
    std::cout<<"vowel"<<std::endl;
  }else if(c=='i'){
    std::cout<<"vowel"<<std::endl;
  }else if(c=='o'){
    std::cout<<"vowel"<<std::endl;
  }else if(c=='u'){
    std::cout<<"vowel"<<std::endl;
  }else{
    std::cout<<"consonant"<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
long P=0,m=1e9+7;
main()
{
    cin>>N;
    long s=0;
    for(int i=0;i<N;++i){
        long a;
        cin>>a;
        P=(P+a*s)%m;
        s=(s+a)%m;
    }
    cout<<P<<endl;
}

Measured memory_bytes: 3532
#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>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, m, k;
bool f = 0;

int main() {
	cin >> n >> m >> k;
	rep(i, n + 1) {
		rep(j, m + 1) {
			//cout << i*m + j*n - 2 * j*i << endl;
			if (i*m + j*n - 2 * j*i == k)f = 1;
		}
	}
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;

typedef struct node {
    int s, e, val, pos;
    bool operator < (const node& n) const {
        if (e != n.e) return e < n.e;
        return val > n.val;
    }
    node() {};
    node(int ss, int ee, int v, int p) {
        s = ss, e = ee, val = v, pos = p;
    }
} node;

int occs[(int)1e6 + 5], tree[500005], n, ans[500005];

void update(int x, int val) {
    while (x <= n) {
        tree[x] += val;
        x += x & -x;
    }
}

int query(int x) {
    int ret = 0;
    while (x > 0) {
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}

int main() {
    int q, s, e;
    vector<node> v;
    scanf("%d %d", &n, &q);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    for (int i = 0; i < q; i++) {
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
        if (v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        } else {
            if (occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }
    for (int i = 0; i < q; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}



Measured memory_bytes: 25340
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string s[9]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		string ss;
		cin >> ss;
		int cnt=0,now;
		for(int j=0;j<ss.size();j++){
			if(ss[j]-'0'==0){
				if(cnt==0) continue;
				printf("%c",s[now-1][(cnt-1)%s[now-1].size()]);
				cnt=0;
				continue;
			}
			cnt++;
			now=ss[j]-'0';
		}
		printf("\n"); 
	}
}

Measured memory_bytes: 1200
#include<algorithm>
#include<string>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

struct Data{
    llong w;
    llong p;
    double ka;
};

bool Cmp(struct Data &prev,struct Data &next){
    return prev.ka>next.ka;
}
 
 
int main(){
    int n;
    cin >> n;
    vi na(4);
    na[0]=n/1000;
    n=n%1000;
    na[1]=n/100;
    n=n%100;
    na[2]=n/10;
    n=n%10;
    na[3]=n;

    int count=0;
    REP(i,4){
        if(na[i]==2){
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll n; cin >> n;
  vll a(n+1);
  ll s = 0;
  REP(i, n) {
    cin >> a[i];
    s += a[i];
  }
  a[n] = a[0];
  vll b(n);
  REP(i, n) {
    b[i] = a[i+1] - a[i];
  }

  // printv(b);


  ll su = n * (n + 1) / 2ll;
  // cout << s << ":" << su << endl;
  if(s % su == 0) {
    ll cnt = 0;
    REP(i, n) {
      b[i] -= s / su;
      if(abs(b[i]) % n != 0) {
        cout << "NO" << endl;
        return 0;
      }
      cnt += abs(b[i]) / n;
    }
    if(cnt == s / su) cout << "YES" << endl;
    else cout << "NO" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,k; cin >> n >> k;
    vi ans(n,1);
    rep(i,k){
        int x; cin >> x;
        rep(i,x){
            int y; cin >> y;
            y--;
            ans[y] = 0;
        }
    }
    cout << accumulate(all(ans),0) << endl;
    return 0;
}


Measured memory_bytes: 3636
let N = Int(readLine()!)!
let atoz = Array("abcdefghijklmnopqrstuvwxyz")
var n = N
var result = ""
while n > 0 {
    result += String(atoz[(n-1)%26])
    n = Int((n-1) / 26)
}
print(String(result.reversed()))


Measured memory_bytes: 7868
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,j=0;
	cin>>n;
	int a[100000];
	if(n>2){
		while(n>0){
			for( i=1;;i++){
				int k = (i*(i+1))/2;
				if(k>=n){
					break;
				}
			}
			n = n-i;
			a[j++] = i;
		}
		for(int k=j-1;k>=0;k--){
			cout<<a[k]<<endl;
		}
	}else{
		cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,sum;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    if(K-x>x){
      sum+=x*2;
    }
    else{
      sum+=(K-x)*2;
    }
  }
  cout<<sum<<endl;
}
  

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        System.out.println(IntStream.range(0, n).map(e -> sc.nextInt()).filter(h -> h >= k).count());

        sc.close();
    }
}

Measured memory_bytes: 48836
def main():
    length = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    count_operation = 0
    for i in range(length):
        if a[i] < b[i]:
            count_operation -= (b[i] - a[i]) // 2
        else:
            count_operation += a[i] - b[i]
    print("Yes" if count_operation <= 0 else "No")


if __name__ == '__main__':
    main()



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

using namespace std;

int main()
{
    int m,d;
    cin>>m>>d;
  
    int sol = 0;

    for(int i = 22 ; i <= d ; i++)
    {
      int d0 = i%10;
      int d1 = i/10;

      if(d0 >=2 && d1 >=2 && d1*d0 <= m)
      sol++;
    }

    cout<<sol<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,cnt,A,B;
int main()
{
    cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>A>>B;
       
       cnt=cnt+B-A+1;
   }
   cout<< cnt;
   
    
  
   
    
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int a[] = new int[200005];
        int xorSum = 0;
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextInt();
            xorSum ^= a[i];
        }
        for (int i = 0; i < N; i++) {
            if (i > 0) {
                System.out.print(" ");
            }
            System.out.print(xorSum ^ a[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 60664
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
A = [a, b, c, d, e]
B = []
for x in A:
  if x%10 == 0:
    B.append(x)
    A.remove(x)
A.sort(key = lambda y:y%10, reverse = True)
B.extend(A)
time = 0
for i in range(4):
  if (B[i]) % 10 == 0:
    time += B[i]
  else:
    time += 10*((B[i] // 10) + 1)
print(time+B[4])

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1);
  int l, r;
  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    v[l - 1]++;
    v[r]--;
  }

  // 累積和
  int s = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    s += v[i];
    v[i] = s;
    if (s == m) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#define M 1046527
#define L 14

char H[M][L];

int getChar(char ch)
{
	if(ch == 'A')
		return 1;
	else if(ch == 'C')
		return 2;
	else if(ch == 'G')
		return 3;
	else if(ch == 'T')
		return 4;
	else
		return 0;
}

long long getKey(char str[])
{
	long long sum = 0;
	long long p = 1;
	int i;

	for(i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key)
{
	return key % M;
}

int h2(int key)
{
	return 1 + (key % (M - 1));
}

int find(char str[])
{
	long long key, h;
	int i;
	key = getKey(str);

	for(i = 0;; ++i) {
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h], str) == 0)
			return 1;
		else if(strlen(H[h]) == 0)
			return 0;
	}
	return 0;
}

int insert(char str[])
{
	long long key, h;
	int i;
	key = getKey(str);

	for(i = 0;; ++i) {
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h], str) == 0) {
			return 1;
		}
		else if(strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main()
{	
	int i, n, h;
	char str[L], com[9];
	for(i = 0; i < M; ++i)
		H[i][0] = '\0';
	scanf("%d", &n);
	for(i = 0; i < n; ++i) {
		scanf("%s %s", com, str);

		if(com[0] == 'i') {
			insert(str);
		}else {
			if(find(str))
				printf("yes\n");
			else
				printf("no\n");
		}
	}
    return 0;
}

Measured memory_bytes: 14916
#include <bits/stdc++.h>
#define mod 1000000007
#define ull unsigned ll
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi acos(-1)
#define nui 100
#define INF 100000000000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define F(i,a,n) for(ll i=a;i<n;i++)
#define B(i,a,n) for(ll i=n-1;i>=a;i--)
#define tc int t;cin>>t;while(t--)
#define tcf int t;cin>>t;for(int w=1;w<=t;w++)
#define pfn cout<<"-1\n"
#define pfp cout<<"1\n";



using namespace std;


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}

ll fermat_inv(ll y) {return binpow(y, mod - 2);}



int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);



    /*ll n, x;
    cin >> n >> x;
    ll a[n];
    F(i, 0, n)
    {
        cin >> a[i];
    }
    ll ans = 0;
    F(i, 0, n)
    {
        if (i - 1 >= 0)
        {
            if (a[i] + a[i - 1] > x)
            {
                if (a[i] >= a[i - 1])
                {
                    ans += a[i] + a[i - 1] - x;
                    a[i] -= a[i] + a[i - 1] - x;

                }
                else
                {
                    ans += a[i] + a[i - 1] - x;
                    a[i] -= a[i] + a[i - 1] - x;

                }
            }
        }
        if (i + 1 < n)
        {
            if (a[i] + a[i + 1] > x)
            {
                if (a[i] > a[i + 1])
                {
                    ans += a[i] + a[i + 1] - x;
                    a[i+1] -= a[i] + a[i + 1] - x;

                }
                else if (a[i] == a[i + 1])
                {
                    ans += a[i] + a[i + 1] - x;
                    a[i + 1] -= a[i] + a[i + 1] - x;
                }
                else
                {
                    ans += a[i + 1] + a[i] - x;
                    a[i + 1] -= a[i] + a[i + 1] - x;

                }
            }
        }
    }
    cout << ans << "\n";*/
    ll n;
    cin >> n;
    ll a[n];
    ll l = 1000;
    ll r = 0;
    F(i, 0, n)
    {
        cin >> a[i];
        l = min(l, a[i]);
        r = max(r, a[i]);
    }
    ll cost = INF;
    F(i, l, r+1)
    {
        ll k = 0;
        F(j, 0, n)
        {
            k += (a[j] - i) * (a[j] - i);
        }
        cost = min(cost, k);
    }
    cout << cost << "\n";
    return 0;

}

Measured memory_bytes: 3608
import math
john=[]
while True:
    try:
        john.append(input())
    except EOFError:
        break
for i in john:
    k=list(map(int,i.split()))
    print(int(math.gcd(k[0],k[1])),int(k[0]*k[1]/math.gcd(k[0],k[1])))
    
    


Measured memory_bytes: 5668
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define INF (1 << 31) - 1

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A.at(i);
  }
  ll ans = 1;
  ll num = 1000000000000000000;
 
  rep(i,N){
    if(ans>(num/A.at(i))){
      ans = -1;
      break;
    }
    ans *= A.at(i);
  }
   rep(i,N){
    if(A.at(i) == 0){
      ans = 0;
    }
   }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 4052
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int[][] map;
	String rp = ".OPYBGR";
	int w = 6, h = 12;

	void run() {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(;t>0;t--) {
			map = new int[h+2][w+2];
			for(int i=1;i<=12;i++) {
				String s = sc.next();
				for(int j=0;j<rp.length();j++) s = s.replace(rp.charAt(j), (char)('0' + j));
				for(int j=1;j<=6;j++) map[i][j] = s.charAt(j-1) - '0';
			}
			boolean ch = true;
			int c = 0;
//			for(int[] a: map) debug(a);
			for(;;c++) {
				ch = false;
				for(int i=1;i<=w;i++) for(int j=1;j<=h;j++) if(map[j][i] > 1) {
					int cnt = dfs(i, j, map[j][i]);
					if(cnt >= 4) { del(i, j, map[j][i]); ch = true; }
//					for(int[] a: map) debug(a);
				}
				if(!ch) break;
				down();
//				for(int[] a: map) debug(a);

			}
			System.out.println(c);
		}
	}

	int dx[] = {-1,0,1,0}, dy[] = {0,-1,0,1};
	int dfs(int x, int y, int c) {
//		debug(x, y);
		map[y][x] = 0;
		int cnt = 1;
		for(int i=0;i<4;i++) if(map[y+dy[i]][x+dx[i]] == c) cnt += dfs(x+dx[i], y+dy[i], c);
		map[y][x] = c;
		return cnt;
	}

	void del(int x, int y, int c) {
		map[y][x] = 0;
		for(int i=0;i<4;i++) {
			if(map[y+dy[i]][x+dx[i]] == c) del(x+dx[i], y+dy[i], c);
			if(map[y+dy[i]][x+dx[i]] == 1) map[y+dy[i]][x+dx[i]] = 0;
		}
	}

	void down() {
		for(int j=1;j<=w;j++){
			for(int k=0;k<=h+2;k++) for(int i=0;i<=h-1;i++)
				if(map[i+1][j] == 0) { map[i+1][j] = map[i][j]; map[i][j] = 0;}
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

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

Measured memory_bytes: 21216
#include<bits/stdc++.h>
#define LL long long 
#define pb push_back
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=a;i<=b;i++)
#define DF(i,a,b) for (int i=a;i>=b;i--)
#define SZ(x) (int)x.size()-1
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for (;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=333;
int dp[M][M][M];
char s[M];
int n,k;
int solve(int x,int y,int l){
	if (dp[x][y][l]) return dp[x][y][l];
	if (l<0) return -1e9;
	if (x>y) return 0;
	if (x==y) return dp[x][y][l]=1;
	dp[x][y][l]=max(solve(x+1,y-1,l-(s[x]!=s[y]))+2,max(solve(x+1,y,l),solve(x,y-1,l)));
	return dp[x][y][l];
} 
int main(){
	scanf("%s%d",s+1,&k);
	n=strlen(s+1);
	cout<<solve(1,n,k)<<"\n";
	return 0;
} 

Measured memory_bytes: 130944
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


int main() {
	int n;
	cin >> n;
	vector<int64_t> H(n);
	rep(i, n) cin >> H.at(i);

	rep(i, n-1) {
		if (i==0 || H.at(i-1) < H.at(i)) H.at(i)--;
	}
	rep(i, n-1) {
		if (H.at(i) > H.at(i+1)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >>d;
    int tm = min(b, d) - max(a, c);
    if (tm < 0) {
        cout << 0 << endl;
    } else {
        cout << tm << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;


int main(){
    int N;
    scanf("%d", &N);
    int ODD = 0;
    vector<long long> A(N);
    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
        if(A[i] % 2 == 1)ODD++;
    }
    
    bool judge;
    if(ODD == 0)judge = true;
    else{
        if(ODD % 2 == 0){
            judge = true;
        }else{
            judge = false;
        }
    }
    
    cout << ((judge) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
typedef pair<string, ll> sl;
typedef pair<l_l, sl> llsl;
map<sl, vector<llsl>> paths;
map<sl, l_l> dist;
string A, B;
ll N, T;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> T >> A >> B;
    for(int j = 1; j <= N; j++) {
        ll a;
        cin >> a;
        vector<string> S(a);
        vector<ll> t(a - 1);
        for(int i = 0; i < a; i++) {
            cin >> S[i];
            paths[{S[i], 0}].push_back({{0, 0}, {S[i], j + 1e9 * i}});
            paths[{S[i], j + 1e9 * i}].push_back({{T, 1}, {S[i], 0}});
        }
        for(int i = 0; i < a - 1; i++) cin >> t[i];
        for(int i = 0; i < a - 1; i++) {
            paths[{S[i], j + 1e9 * i}].push_back({{t[i], 0}, {S[i+1], j + 1e9 * (i+1)}});
            paths[{S[i+1], j + 1e9 * (i+1)}].push_back({{t[i], 0}, {S[i], j+1e9*i}});
        }
    }
    priority_queue<llsl, vector<llsl>, greater<llsl>> que;
    dist[{A, 0}] = {0, 0};
    que.push({{0, 0}, {A, 0}});
    while(!que.empty()) {
        auto tmp = que.top();
        que.pop();
        sl now = tmp.second;
        l_l nowcost = tmp.first;
        for(auto tmp : paths[now]) {
            sl to = tmp.second;
            l_l newcost = tmp.first;
            newcost.first += nowcost.first;
            newcost.second += nowcost.second;
            if(dist.count(to) == 0 or chmin(dist[to], newcost)) {
                dist[to] = newcost;
                que.push({newcost, to});
            }
        }
    }
    if(dist.count({B, 0}) == 0) {
        cout << -1 << endl;
        return 0;
    }
    l_l ans = dist[{B, 0}];
    cout << ans.first - T << " " << ans.second - 1 << endl;
    return 0;
}


Measured memory_bytes: 57196
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define endl "\n"
#define what_is(x) cout<<#x<<" is "<<x<<endl;
#define F(i,a,b) for(int i = a; i < b; i++)
#define MAX(a,b,c) max(a,max(b,c))
#define MIN(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define inf 1e18
const double pi = 3.141592653589793238460;
#define debug false
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define mod 1000000007 


void solve()
{
    string s1;
	cin>>s1;
	int len = s1.length();
	
	bool ans = true;
	for(int i=0;i<len;i++)
	{
		if(s1[i]!=s1[s1.length()-i-1])
			ans = false;
	}

	int n1 = (len-1)/2;
	int n2 = (len+3)/2;
 
	string a="",b="";
	for(int i=0;i<n1;i++)
		a += s1[i];
	for(int i=n2-1;i<len;i++)
		b += s1[i];

	for(int i=0;i<a.length();i++)
	{
		if(a[i]!=a[a.length()-i-1])
			ans = false;
	}
	for(int i=0;i<b.length();i++)
	{
		if(b[i]!=b[b.length()-i-1])
			ans = false;
	}
	
	if(ans)
		cout<<"Yes"<<"\n";
	else cout<<"No"<<"\n";
	
}

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("Test.txt","r",stdin);
        // freopen("Output.txt","w",stdout);
    #endif
    
     // if(debug){watch_is();}
    solve();   
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    sort(a.begin(), a.end());

    cout << a[n-1] - a[0] << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  ll s; cin >> s;
  ll a = sqrt(s);
  while (a*a < s) a++;
  ll d = a;
  ll c = 1;
  ll b = a*a - s;
  cout << 0 << ' ' << 0 << ' ' << a << ' ' << b << ' ' << c << ' ' << d << endl;
}

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

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int num[] = new int[n];
		for(int i = 0; i < n; i++) {
			num[i] = sc.nextInt();
		}
		double ave = Arrays.stream(num).average().getAsDouble();
		long a = Math.round(ave);
		long ans = 0L;
		for(int i : num) {
			ans += Math.pow(a-i, 2);
		}
		System.out.println(ans);
	}
}


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

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 1000000007
#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;
typedef pair<ll, string> PLS;

string s;

int main(){
	cin >> s;
	REP(i, s.size()){
		if (i == 3)cout << s[i] << " ";
		else cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc076/tasks/abc076_d
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int t[201],v[201];
	int ruit[201]={};
	double speed[44000];
	int kukan[44000];
	double ans=0;
	scan(N);
	int now=0;
	rep(i,N){
		scan(t[i]);
		for(int jikan=now;jikan<now+t[i]*2;jikan++){
			kukan[jikan]=i;
		}
		ruit[i+1]=ruit[i]+t[i]*2;
		now+=t[i]*2;
	}
	rep(i,N){
		scan(v[i]);
	}
	rep(i,now){
		speed[i]=min(0.5*i,-0.5*i+now/2);
		rep(j,N){
			if(kukan[i]<j){
				speed[i]=min(speed[i],-0.5*i+ruit[j]/2+v[j]);
			}
			else if(kukan[i]>j){
				speed[i]=min(speed[i],0.5*i-ruit[j+1]/2+v[j]);
			}
			if(kukan[i]==j||(i>0&&kukan[i-1]==j)){
				speed[i]=min(speed[i],(double)v[j]);
			}
		}
	}
	speed[now]=0;
	rep(i,now){
		//printf("now:%d i:%d kukan:%d v[kukan]:%d speed:%f\n",now,i,kukan[i],v[kukan[i]],speed[i]);
		ans+=(speed[i]+speed[i+1])*0.25;
	}
	prin(setprecision(10)<<ans);
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define MAX_K 222222
#define fi first
#define sc second
#define pb push_back
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,int> Pi;
typedef pair<ll,int> Pl;
int M,N,K;
int X[MAX_K];int Y[MAX_K];
vector<P>G[2*MAX_K];
ll S[2*MAX_K];
int main()
{
	scanf("%d%d%d",&M,&N,&K);
	for(int i=0;i<K;i++){
		scanf("%d%d",&X[i],&Y[i]);X[i]--;Y[i]--;
	}
	vector<Pi>sX;
	for(int i=0;i<K;i++){
		sX.pb(Pi(P(X[i],Y[i]),i));
	}
	sX.pb(Pi(P(0,0),K));
	sX.pb(Pi(P(M-1,N-1),K+1));
	sort(sX.begin(),sX.end());
	/*
	for(int i=0;i<K+2;i++){
		printf("%d %d %d\n",sX[i].fi.fi,sX[i].fi.sc,sX[i].sc);
	}
	*/
	for(int i=0;i<K+1;i++){
		if(sX[i].fi.fi==sX[i+1].fi.fi){
			G[2*sX[i].sc+1].pb(P(2*sX[i+1].sc+1,sX[i+1].fi.sc-sX[i].fi.sc));
			G[2*sX[i+1].sc+1].pb(P(2*sX[i].sc+1,sX[i+1].fi.sc-sX[i].fi.sc));
		}
	}
	vector<Pi>sY;
	for(int i=0;i<K;i++){
		sY.pb(Pi(P(Y[i],X[i]),i));
	}
	sY.pb(Pi(P(0,0),K));
	sY.pb(Pi(P(N-1,M-1),K+1));
	sort(sY.begin(),sY.end());
	for(int i=0;i<K+1;i++){
		if(sY[i].fi.fi==sY[i+1].fi.fi){
			G[2*sY[i].sc].pb(P(2*sY[i+1].sc,sY[i+1].fi.sc-sY[i].fi.sc));
			G[2*sY[i+1].sc].pb(P(2*sY[i].sc,sY[i+1].fi.sc-sY[i].fi.sc));
		}
	}
	for(int i=0;i<K;i++){
		G[2*i].pb(P(2*i+1,1));
		G[2*i+1].pb(P(2*i,1));
	}
	for(int i=0;i<2*K+4;i++){
		S[i]=111111111111111;
		/*
		for(int j=0;j<(int)G[i].size();j++){
			printf("%d-%d:%d\n",i,G[i][j].fi,G[i][j].sc);
		}
		*/
	}
	priority_queue<Pl,vector<Pl>,greater<Pl> >que;
	/*
	for(int i=0;i<K;i++){
		if(X[i]==0){
			que.push(P((ll)Y[i],2*i+1));
		}
		if(Y[i]==0){
			que.push(P((ll)X[i]+1,2*i));
		}
	}*/
	que.push(P(0,2*K+1));
	while(!que.empty()){
		Pl p=que.top();que.pop();
		if(S[p.sc]<=p.fi){continue;}
		//printf("S[%d]=%lld\n",p.fi,p.sc);
		S[p.sc]=p.fi;
		for(int i=0;i<(int)G[p.sc].size();i++){
			if(S[G[p.sc][i].fi]>p.fi+(ll)G[p.sc][i].sc){
				que.push(Pl(p.fi+(ll)G[p.sc][i].sc,G[p.sc][i].fi));
			}
		}
	}
	//printf("%lld %lld\n",S[2*K],S[2*K+1]);
	if(min(S[2*K+2],S[2*K+3])==(ll)(111111111111111)){
		printf("-1\n");
	}
	else{
		printf("%lld\n",min(S[2*K+2],S[2*K+3]));
	}
	return 0;
}

Measured memory_bytes: 44992
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long int N, F[101][6][3] = {}, P[101][11] = {}, ans = -1000000000;
vector<long long int> store(101);

void solve(long long int num, bool open, bool close, vector<long long int>shop) {
	if (open) {
		for (int i = 1; i <= N; i++) {
			if (F[i][(num + 1) / 2][num % 2 + 1] == 1)shop[i]++;
		}
	}
	if (num == 10) {
		if (open || !close) {
			long long int sum = 0;
			for (int i = 1; i <= N; i++)sum += P[i][shop[i]];
			ans = max(ans, sum);
		}
	}
	else {
		if (open)close = false;
		solve(num + 1, true, close, shop);
		solve(num + 1, true, close, shop);
		solve(num + 1, false, close, shop);
		solve(num + 1, false, close, shop);
	}
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= 5; j++) {
			cin >> F[i][j][1];
			cin >> F[i][j][2];
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 10; j++)cin >> P[i][j];
	}
	solve(1, true, true, store);
	solve(1, false, true, store);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
s = input()

c01010c = 0
c10101c = 0
i = 0

for ss in s:
    if ss == '0' and i % 2 == 0:
        c10101c += 1
    elif ss == '0' and i % 2 == 1:
        c01010c += 1
    elif ss == '1' and i % 2 == 0:
        c01010c += 1
    elif ss == '1' and i % 2 == 1:
        c10101c += 1
    i += 1

print(min(c01010c, c10101c))


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

signed main(){

	int n;
	cin >> n;

	vector<int> a(n);

	rep(i, n) {
		cin >> a[i];
	}

	rep(i, n) {
		a[i] -= (i + 1);
	}

	int low = -1e9;
	int high = 1e9;

	auto calc = [&](int t){
		int cost = 0;
		rep(i, n) {
			cost += abs(a[i] - t);
		}
		return cost;
	};

	while(low + 3 < high) {
		int m1 = (low * 2 + high) / 3;
		int m2 = (low + 2 * high) / 3;
		if(calc(m1) < calc(m2)) {
			high = m2;
		} else {
			low = m1;
		}
	}

	int ans = 1e17;
	REP(i, low-10, low+10) {
		ans = min(ans, calc(i));
	}

	cout << ans << endl;


}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    ll n, h;
    cin >> n >> h;
    vector<P> a(n), b(n), c(n);
    rep(i, n) {
        cin >> a[i].fi >> b[i].fi;
        a[i].se = b[i].se = i;
        c[i] = P(a[i].fi, b[i].fi);
    }
    sort(all(a)); sort(all(b));
    reverse(all(a)); reverse(all(b));
    ll cnt = 0;
    if (c[a[0].se].se >= h) {
        cout << 1 << endl;
    } else {
        int i = 0;
        while(h > 0 && i < n && b[i].fi >= a[0].fi) {
            h -= b[i].fi;
            i++;
            cnt++;
        }
        if (h > 0) {
            cnt = cnt + h / a[0].fi + (h % a[0].fi != 0);
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    int MAX(int a,int b){
      if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
      }
      int r = a%b;
      while(!r){
        a = b;
        b = r;
        r = a%b;
      }
      return r;
    }

    int main(){
      auto v = vvec(3,3);
      auto a = vec(int,3);
      auto b = vec(int,3);
      rep(i,3){
        rep(j,3){
          cin>>v[i][j];
          if(i == 0)a[j] = v[0][j];
          if(j == 0)b[i] = v[i][0]-v[0][0];
        }
      }
      rep(i,3)rep(j,3){
        if(v[i][j] != a[j]+b[i]){
          cout<<"No";;
          return 0;
        }
      }
      cout<<"Yes";
    }


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

using namespace std;

int a[100000];
int b[100000];
int c[100000];
int dp[100001][3];

int main() {
    int n, i, j;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d %d %d", &a[i], &b[i], &c[i]);
    
    for (i = 0; i < n; i++) {
        dp[i + 1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
        dp[i + 1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
        dp[i + 1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
    }
    
    printf("%d\n", max(dp[n][0], max(dp[n][1], dp[n][2])));
    
    return 0;
}


Measured memory_bytes: 2560