akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int[] a=new int[n];
    int p=0;
    for(int i=0;i<m;i++){
      int k=sc.nextInt();
      for(int j=0;j<k;j++){
        a[sc.nextInt()-1]+=pow(2,i);
      }
    }
    for(int i=0;i<m;i++){
      p+=sc.nextInt()*pow(2,i);
    }
    BAS bas=new BAS(n);
    int ans=0;
    boolean[] b=bas.a();
    do{
//      System.out.println(Arrays.toString(b));
      int sum=0;
      for(int i=0;i<n;i++){
        if(b[i]){
          sum=(sum^a[i]);
        }
      }
//      System.out.println(sum+":"+p);
      if(sum==p){
        ans++;
      }
    }while(bas.next());
    System.out.println(ans);
  }
  static int pow(int b,int p){
    int res=1;
    for(int i=0;i<p;i++){
      res*=b;
    }
    return res;
  }
  static class BAS{
    int n;
    boolean[] a;
    BAS(int n){
      this.n=n;
      a=new boolean[n];
    }
    boolean next(){
      for(int i=0;i<n;i++){
        if(a[i]){
          a[i]=false;
        }else{
          a[i]=true;
          return true;
        }
      }
      return false;
    }
    boolean[] a(){
      return a;
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>

using int64 = long long;

int64 gcd(int64 a, int64 b)
{
    if (b == 0)
        return a;

    return gcd(b, a % b);
}

int64 lcm(int64 a, int64 b)
{
    return a / gcd(a, b) * b;
}

int main()
{
    int N;
    std::cin >> N;
    int64 res = 1;
    for (int i = 0; i < N; i++) {
        int64 T;
        std::cin >> T;
        res = lcm(res, T);
    }

    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(void)
{
  int A, B;
  scanf("%d %d", &A, &B);
  int n = 0;
  int c = 1;
  while(c < B){
    n++;
    c = c - 1 + A;
  }
  printf("%d\n", n);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

using namespace std;
ll a[100100];
ll b[100100];
int main()  {
    ll n;
    cin>>n;
    for(int i=0 ;i <n ; i++)scanf("%lld",&a[i]);
    for(int i=0 ;i <n ; i++)scanf("%lld",&b[i]);

    ll r = 0;
    for(int i=0 ;i <n ;i++){
        if(a[i] > b[i]){
            r += a[i]-b[i];
        }
        else{
            r -= (b[i]-a[i])/2;
        }
    }
    if(r<=0)
    cout<<"Yes\n";
    else
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

ll binominalCoeff(ll n, ll k) {
    ll res = 1;
    if (k > n - k) k = n - k;
    for (ll i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

int main() {
    int N; cin >> N;
    map<string, int> s;

    for (int i = 0; i < N; ++i) {
        string st; cin >> st;
        sort(st.begin(), st.end());
        s[st]++;
    }

    ll rtn = 0;
    for (auto & it : s) {
//        cout << it.first << " " << it.second << endl;
        if (it.second >=2) {
            rtn += (ll)binominalCoeff(it.second, 2);
        }
    }
    cout << rtn << endl;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

    int happiness = X / 500;
    happiness *= 1000;
    X %= 500;
    happiness += (X / 5) * 5;
    cout << happiness << endl;

    return 0;
}


Measured memory_bytes: 3628
import sys
input = sys.stdin.readline

h, w, m = map(int,input().split())

row = [0]*h
col = [0]*w
enemy = []

for i in range(m):
    hh, ww = map(lambda x:int(x)-1,input().split())
    row[hh] += 1
    col[ww] += 1
    enemy.append((hh,ww))

enemy = set(enemy)
rmax = max(row)
cmax = max(col)

on_r = row.count(rmax)
on_c = col.count(cmax)

on = 0
for hh, ww in enemy:
    if row[hh] == rmax and col[ww] == cmax:
        on += 1
if on == on_r*on_c:
    print(rmax+cmax-1)
else:
    print(rmax+cmax)

Measured memory_bytes: 153060
#include <iostream>
using namespace std;
long long n, a[100000];

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n;
    long long sum = 0;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n - 1; ++i)
    {
        sum += a[i] / 2;
        a[i] %= 2;
        if (a[i] && a[i + 1])
            ++sum, --a[i + 1];
    }
    cout << sum + (a[n - 1] / 2) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
ll fact[N], invFact[N];

ll nCr(int n, int r){
	return fact[n] * invFact[r] % mod * invFact[n - r] % mod;
}
void solve()
{	
	int res = 0;
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i = 2; i < sz(s); ++i){
		if(s[i] == 'C' && s[i - 1] == 'B' && s[i - 2] == 'A') ++res;
	}
	cout << res;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int i = pp; i < nn; ++i)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define endl "\n"

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

vector<int64_t> INVERSE(int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
	vector<int64_t> mul(nn + 1);
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
	return mul;
}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	IOS;
	int n;
	cin >> n;
	string s;
	cin >> s;
//8
//WRWWRWRR
//RRR  WWW
	int l = 0;
	int r = n - 1;
	int cnt = 0;
	while (l < r) {
		while (l < r && s[r] != 'R') {
			r--;
		}
		while (l < r && s[l] != 'W') {
			l++;
		}
		swap(s[l],s[r]);
		cnt++;
	}
	debug(s);
	cout << cnt  - 1<< endl;
	//int l = 0;
	//int r = n - 1;
	//while (l < r) {
		//int mid = (l + r) / 2;
		//for (int i = 0; i < mid; ++i) {
			
		//}
		
		//if (ans) {
			//r = mid;
		//}else {
			//l = mid + 1;
		//}
	//}
	//cout << l;
}















Measured memory_bytes: 3700
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;
import std.typecons;
import std.array;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

alias City = Tuple!(string, "s", int, "p", int, "i");

void main(){
  auto n = readNum!int;
  City[] c;

  foreach(i; 0 .. n){
    string[] s = readln.chomp.split;
    c ~= City(s[0], s[1].to!int, i+1);
  }

  c.multiSort!("a.s < b.s", "a.p > b.p");
  foreach(e; c){
    writeln(e.i);
  }
}


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

int main(void){
	int H, W, K;
	cin >> H >> W >>K;
	int c[H][W];
	char tmp;
	rep(i,H){
		rep(j,W){
			cin >> tmp;
			if (tmp=='.') c[i][j] = 0;
			else  c[i][j] = 1;
		}
	}
	int ans = 0;
	rep(i,pow(2,H))rep(j,pow(2,W)){
			int tmp = 0;
			rep(k,H)rep(l,W){
					if (i>>k & 1 ) continue;
					if (j>>l & 1 ) continue;
					tmp += c[k][l];
			}

			if (tmp == K) ans ++;
	}
	cout << ans << endl;

return 0;
}


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

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

int main()
{
    vector<char> C1(3);
    vector<char> C2(3);
    cin >> C1.at(0) >> C1.at(1) >> C1.at(2) >> C2.at(0) >> C2.at(1) >> C2.at(2);
    cout << (C1.at(0) == C2.at(2) && C1.at(1) == C2.at(1) && C1.at(2) == C2.at(0) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
# 160 B

s = input()
pd = False

if s[::-1] == s:
    n1 = (len(s) - 1) // 2
    s1 = s[:n1]
    if s1 == s1[::-1]:
        n2 = (len(s) + 3) // 2
        s2 = s[n2-1:]
        if s2 == s2[::-1]:
            pd = True

if pd:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9020
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

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

vector<ll> ans;
vector<ll> memo;
vector<vector<int>> G;

void dfs(int v, int p){
  if(v==0){
    ans[v]=memo[v];
  }
  else{
    ans[v]=memo[v]+ans[p];
  }
  for(auto nv:G[v]){
    if(nv==p) continue;
    dfs(nv,v);
  }
}

int main() {
  int n,q;
  cin>>n>>q;
  G.assign(n,vector<int> {});
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  memo.assign(n,0);
  for(int i=0;i<q;i++){
    int p,x;
    cin>>p>>x;
    p--;
    memo[p]+=x;
  }
  ans.assign(n,0);
  dfs(0,-1);
  for(int i=0;i<n;i++){
    cout<<ans[i];
    if(i!=n-1) cout<<' ';
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 26724
import sys
sx, sy, tx, ty = [int(i) for i in sys.stdin.readline().split()]
diff_y = abs(ty - sy)
diff_x = abs(tx - sx)
res = "L"
res += (diff_y + 1) * "U"
res += (diff_x + 1) * "R"
res += "D"
res += (diff_x) * "L"
res += (diff_y + 1) * "D"
res += (diff_x + 1) * "R"
res += (diff_y + 1) * "U"
res += "L"
res += (diff_y) * "D"
res += diff_x * "L"
print(res)

Measured memory_bytes: 3064
// UTPC2010 E. ツトツーツマツスツ・ツδ可イツトツづ個憂ツ鬱

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

int main(){
	int n;
	int a[10000], b[10000];
	int p[10000];
	while(cin >> n, n){
		for(int i=0;i<n;i++) cin >> a[i];
		for(int i=0;i<n;i++) cin >> b[i];
		sort(a, a+n);
		sort(b, b+n);
		memset(p, 0, sizeof(p));
		for(int i=0;i<n;i++){
			if(a[i]==0) continue;
			p[n-a[i]]++;
		}
		bool ok = true;
		int sum = 0;
		for(int i=0;i<n;i++){
			sum += p[i];
			if(sum != b[i]) ok = false;
		}
		cout << (ok ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define sci(x) scanf("%d",&x)
#define scs(s) scanf("%s",s)
#define scc(c) scanf("%c",c)
#define scd(d) scanf("%lf",&d)
#define scld(ld) scanf("%Lf",&ld)
#define int long long
using namespace std;

//********************************************
//Error tracking
#define show(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

vector<string> split(const string& s, char c) {
    vector<string> v;
    stringstream ss(s);
    string x;
    while (getline(ss, x, c))
        v.emplace_back(x);
    return move(v);
}

void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
    err(++it, args...);
}
//********************************************

const int NMAX = 100005;

int n, L, T, a[NMAX], w[NMAX];
int b[NMAX];

int32_t main()
{
  //  freopen("input","r",stdin);
   // freopen("output","w",stdout);
    cin.sync_with_stdio(false);
    
    int i, nr = 0;
    cin >> n >> L >> T;
    for (i = 1; i <= n; i++) 
    {
    	cin >> a[i] >> w[i];
    	if (w[i] == 1) 
    		{
    			b[i] = (a[i] + T) % L;
    			nr += T / L;
    			if ((a[i] + T - (T / L)*L)%L < a[i]) nr++;
    		}
    	else
    	{
    		b[i] = a[i] - T%L;
    		if (b[i] < 0) b[i] += L;
    		nr -= T / L;
    		int val = a[i] - (T - (T / L)*L );
    		if (val < 0) val += L;
    		if (a[i] < val) nr--;
    	}
    	//cout << nr << "\n";
    }

    //cout << nr << "\n";
    sort(b + 1, b + n + 1);

    nr %= n;
    if (nr < 0) nr += n;

    for (i = nr + 1; i <= n; i++) cout << b[i] << "\n";
    for (i = 1; i <= nr; i++) cout << b[i] << "\n";
    return 0;   
}

Measured memory_bytes: 3584
import sys
import heapq
import bisect
import itertools

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def LI_(): return([int(x)-1 for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def Eratosthenes(N):
    r = [True]*(N+1)
    r[0] = False
    r[1] = False
    i = 2
    while i*i<=N:
        if r[i]: 
            j = i
            while i*j<=N:
                prime[i*j]=False
                j+=1
        i+=1
    return(r)

def factorization(N):
    arr = []
    temp = N
    for i in range(2, int(-(-N**0.5//1))+1):
        if temp%i == 0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //=i
            arr.append([i,cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([N,1])

    return arr

def main():
    A,B = LI()
    GCD_AB = GCD(A,B)
    if GCD_AB == 1:
        return 1
    arr = factorization(GCD(A,B))
    return(len(arr)+1)

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 38612
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		double di1 = 0, di2 = 0, di3 = 0, diinf = 0;
		for(int i = 0; i < n; ++i)
			x[i] = sc.nextInt();
		for(int i = 0; i < n; ++i){
			x[i] = Math.abs(x[i] - sc.nextInt());
			di1 += x[i];
			di2 += x[i]*x[i];
			di3 += x[i]*x[i]*x[i];
			diinf = Math.max(diinf, x[i]);
		}
		System.out.printf("%.6f\n", di1);
		System.out.printf("%.6f\n", Math.sqrt(di2));
		System.out.printf("%.6f\n", Math.cbrt(di3));
		System.out.printf("%.6f\n", diinf);
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main()
{
    #ifdef LOCAL_FILE
    freopen("in.txt","r",stdin);
    #endif // LOCAL_FILE
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    char s1[105],s2[105];
    int n,last,i=0;
    long long ans = 1;
    cin>>n;
    cin>>s1;
    cin>>s2;
    while(i<n)
    {
        if(i == 0)
        {
            if(s1[i] == s2[i])
            {
                ans = ans*3;
                last = 1;
                i++;
            }
            else
            {
                ans = ans*6;
                last = 2;
                i+=2;
            }
        }
        else
        {
            if(s1[i] == s2[i])
            {
                if(last == 1) ans = (ans*2)%mod; //X->X
                else if(last == 2) ans = (ans*1)%mod; //Y->X
                last = 1;
                i++;
            }
            else
            {
                if(last == 1) ans = (ans*2)%mod;//X->Y
                else if(last == 2) ans = (ans*3)%mod; //Y->Y
                last = 2;
                i+=2;
            }
        }
    }
    cout<<ans<<endl;

}

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

A = []
B = []
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

A.sort(reverse=True)
B.sort(reverse=True)
ans = 0
tmp = 0
cnt = 0
while(1):
    if tmp>=H:
        print(ans)
        exit()
    if cnt==len(B):
        break
    if A[0]>=B[cnt]:
        break
    tmp += B[cnt]
    ans += 1
    cnt += 1

res = H - tmp
if res%A[0]==0:
    ans += res//A[0]
else:
    ans += res//A[0]
    ans += 1
print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cout << 'x';
    }










    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ll long long
#define INF 1000000007
#define EPS 0.000001
#define f first
#define s second
#define in(n) scanf("%lld", &n)
#define ina(arr,n) for(ll x = 0; x < n; x++) in(arr[x]);
#define loop(i,n) for(ll i=0;i<n;i++)
#define leep(i,n) for(ll i=1;i<=n;i++)

int main()
{

 string s;
 cin>>s;

 int low=0,high=s.length()-1;
    int cnt=0;
    while(low<high)
    {
        if(s[low]!=s[high])
        cnt++;
           low++,high--;
    }
cout<<cnt;
}


Measured memory_bytes: 256
#include <iostream>

int main(){
  int n,i,near0=1000000000;
  bool isOdd=0,notExist0=1;
  long ans=0;
  std::cin>>n;
  int a[n];
  for (i=0;i<n;i++)std::cin>>a[i];
  for (i = 0; i < n; i++) {
    if (a[i]<0){
      a[i]=-a[i];
      isOdd=!isOdd;
  }
  ans+=a[i];
}
  if (isOdd){
    for(i=0;i<n;i++){
      if (near0>a[i])near0=a[i];
      if (near0==0)break;
    }
    ans-=near0*2;
  }
  std::cout<<ans<<'\n';
}


Measured memory_bytes: 640
import sys
readline = sys.stdin.readline
NIL = None
class Tree:
    __slots__ = ['key', 'p', 'left', 'right']
    def __init__(self, key = None):
        self.key = key
        self.p = NIL
        self.left = NIL
        self.right = NIL
n = int(input())
tree = {"root":NIL}
def insert(T, z):
    y = NIL
    x = T["root"]
    while x != NIL:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.p = y
    if y == NIL:
        T["root"] = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
def preorder_tree_walk(T):
    print(f" {T.key}", end="")
    if T.left != NIL:
        preorder_tree_walk(T.left)
    if T.right != NIL:
        preorder_tree_walk(T.right)
def inorder_tree_walk(T):
    if T.left != NIL:
        inorder_tree_walk(T.left)
    print(f" {T.key}", end="")
    if T.right != NIL:
        inorder_tree_walk(T.right)
for _ in range(n):
    ss = readline()
    if ss[0] == "i":
        s, v = ss.split()
        insert(tree, Tree(int(v)))
    else:
        inorder_tree_walk(tree["root"])
        print()
        preorder_tree_walk(tree["root"])
        print()



Measured memory_bytes: 57536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll MAX = 1e5;
const ll INF = 1e17;

int main(){
  ll n, W;
  cin >> n >> W; 
  vector<vector<ll>> dp(n+1,vector<ll>(MAX,INF));
  ll v[n], w[n];
  rep(i,n) cin >> v[i] >> w[i];
  dp[0][0] = 0;
  rep(i,n) {
    rep(j,MAX) {
      dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
      if(j+v[i] < MAX) dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
    }
  }
  ll ans = 0;
  rep(i,MAX) {
    if(dp[n][i] <= W) ans = i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 82880
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

const int MAX_D = 60;
const int MAX_N = 200005;
// to[i][j]: dist 2^i from j
int to[MAX_D][MAX_N];

int main() {
    int n;
    lint k;
    cin >> n >> k;
    rep(i, n) {
        cin >> to[0][i];
        to[0][i]--;
    }

    rep(i, MAX_D-1) rep(j, n) to[i+1][j] = to[i][to[i][j]];

    int v = 0;
    int now = 0;

    while (k) {
        if (k & 1) v = to[now][v];

        k >>= 1;
        now++;
    }

    v++;
    cout << v << endl;
    return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e6 + 1;

int cnt[MAX_N];

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

  CIN(N, K);
  vector< int > a(N);
  REP(i, N) {
    cin >> a[i];
    cnt[a[i]]++;
  }

  sort(cnt, cnt + MAX_N, [](int x, int y) {
      return x > y;
    });

  int ans = 0;
  FOR(i, K, N)
    ans += cnt[i];

  cout << ans << endl;
  

  return 0;
}



Measured memory_bytes: 4992
R=range
def F(a,b):A=len(a);r=[all([len(set([a[i+j],b[j],'?']))<3for j in R(min(A-i,len(b)))])for i in R(A)];return r+[1]
def Z(X):
 i,j,k=X;U,V,W=M[i][j],M[j][k],M[i][k];A,B,C=map(len,[S[i]for i in X]);q=A+B+C
 for l in R(A+1):
  if U[l]:
   for r in R(l,A+B+1):
    if(B<r-l or V[r-l])*W[min(A,r)]:q=min(q,max(A,l+B,r+C))
 return q
S=[input()for i in'abc']
T=R(3)
M=[[F(S[i],S[j])for j in T]for i in T]
from itertools import *;print(min([Z(i)for i in permutations(T)]))

Measured memory_bytes: 55940
#include<iostream>
#include<string>
#include<set>
#include <iterator>
using namespace std;
template<typename T>
void print(T value)
{
	cout << value << endl;
}

void init() 
{
	
}
int n, m;
int result;
char symbol[] = {'+', '*', 'x'};
int main() 
{
	cin >> n >> m;
	if(n*m == 15)
	{
		result = 1;
	}
	else if(n+m == 15)
	{
		result = 0;
	}
	else 
	{
		result = 2;
	}
	print(symbol[result]);
	return 0;
}

Measured memory_bytes: 256
import numpy as np
w,h,n = map(int,input().split())
cl = np.zeros((w, h) , dtype = int)
for i in range(n):
    x, y, a, = map(int,input().split())
    if a ==1: 
        cl[:x, :] = 1
    if a ==2: 
        cl[x:, :] = 1
    if a ==3:
        cl[:, :y] = 1
    if a ==4:
        cl[:, y:] = 1
print(w * h - np.sum(cl))

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

typedef int Coins[4];

int coins[] = {10, 50, 100, 500};

int S;
int sum;
int ans;
Coins nums;
vector<int> anscs;

void GetChange(int v, int *cp) {
  for (int i=3; i>=0; i--) {
    cp[i] = v/coins[i];
    v %= coins[i];
  }
}

void Rec(int idx, int total, vector<int> &cs) {
  if (idx == 4) {
    if (total < S) return;

    Coins res;
    GetChange(total-S, res);

    int df = 0;
    for (int i=0; i<4; i++) {
      if (cs[i] && res[i]) return;
      df += res[i]-cs[i];
    }

    if (ans > sum+df) {
      ans = sum+df;
      anscs = cs;
    }

    return;
  }

  for (int i=0; i<=nums[idx]; i++) {
    cs.push_back(i);
    Rec(idx+1, total+coins[idx]*i, cs);
    cs.pop_back();
  }
}

int main() {
  bool is_first = true;

  while (1) {
    scanf("%d", &S);
    if (S == 0) return 0;
    if (!is_first) puts("");
    is_first = false;

    sum = 0;
    for (int i=0; i<4; i++) {
      scanf("%d", &nums[i]);
      sum += nums[i];
    }

    ans = 1145141919;
    vector<int> _;
    Rec(0, 0, _);

    for (int i=0; i<4; i++) {
      if (anscs[i]) {
        printf("%d %d\n", coins[i], anscs[i]);
      }
    }
  }
}

Measured memory_bytes: 3168
n,k,q = map(int, input().split())
pdic = {}
for i in range(q):
    p = int(input())
    if p in pdic:
        pdic[p] += 1
    else:
        pdic[p] = 1
for i in range(1,n+1):
    if i in pdic:
        if k + pdic[i] - q <= 0:
            print('No')
        else:
            print('Yes')
    else:
        if k - q <= 0:
            print('No')
        else:
            print('Yes')

Measured memory_bytes: 53720
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,x,a;
    cin>>n>>m>>x;
    int ls=0,rs=0;
    for (int i=0;i<m;i++) {
        cin>>a;
        if (a<x) {
            ls++;
        } else {
            rs++;
        }
    }
    if (ls<rs) {
        cout<<ls<<endl;
    } else {
        cout<<rs<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
int T;
int n;
struct data{
    int to,nxt;
};
struct Graph{
    int ma[55][55];
    int d[55];
    int ed[55][2];
    int oe[55];
    data mp[110];
    int head[55],cnt;
    void clear()
    {
        memset(ma,0,sizeof(ma));
        memset(d,0,sizeof(d));
        memset(ed,0,sizeof(ed));
        memset(oe,0,sizeof(oe));
        memset(head,0,sizeof(head));cnt=0;
    }
    void ins()
    {
        int xx,yy;
        for(int i=1;i<n;++i)
        {
            scanf("%d%d",&xx,&yy);
            ed[i][0]=xx;ed[i][1]=yy;
            d[xx]++;d[yy]++;
            oe[xx]=oe[yy]=i;
            ma[xx][yy]=ma[yy][xx]=1;
        }
    }
    void link(int x,int y)
    {
        mp[++cnt].to=y;
        mp[cnt].nxt=head[x];
        head[x]=cnt;
    }
    int fa[55];
    void dfs(int x,int f)
    {
        fa[x]=f;
        for(int i=head[x];i;i=mp[i].nxt)
            if(mp[i].to!=f)
                dfs(mp[i].to,x);
    }
}A,B;
void build_B()
{
    for(int i=1;i<n;++i)
    {
        B.link(B.ed[i][0],B.ed[i][1]);
        B.link(B.ed[i][1],B.ed[i][0]);
    }
}
int ch[55];
data mp[110];
int head[55],cnt;
int d[55];
bool in[55];
void link(int x,int y)
{
    mp[++cnt].to=y;
    mp[cnt].nxt=head[x];
    head[x]=cnt;
    in[x]=in[y]=1;
}
bool ot[55];
bool Topsort()
{
    queue<int>q;
    memset(ot,0,sizeof(ot));
    for(int i=1;i<=n;++i)
        if(in[i]&&!d[i])
            ot[i]=1,q.push(i);
    int u,v;
    while(!q.empty())
    {
        u=q.front();q.pop();
        for(int i=head[u];i;i=mp[i].nxt)
        {
            v=mp[i].to;
            d[v]--;
            if(!d[v])ot[v]=1,q.push(v);
        }
    }
    for(int i=1;i<=n;++i)
        if(in[i]&&!ot[i])return 0;
    return 1;
}
int solve(int rt,int ano,int id)
{
    memset(A.head,0,sizeof(A.head));
    A.cnt=0;
    for(int i=1;i<n;++i)
    {
        if(i==id)continue;
        A.link(A.ed[i][0],A.ed[i][1]);
        A.link(A.ed[i][1],A.ed[i][0]);
    }
    A.link(rt,ano);A.link(ano,rt);
    A.dfs(rt,0);B.dfs(rt,0);
    int res=0;
    for(int i=1;i<=n;++i) ch[i]=(A.fa[i]!=B.fa[i]),res+=ch[i];
    memset(head,0,sizeof(head));cnt=0;
    memset(d,0,sizeof(d));
    memset(in,0,sizeof(in));
    for(int i=1;i<=n;++i)
    {
        if(i==rt)continue;
        if(!ch[i]&&ch[A.fa[i]])return inf;
        if(ch[i]&&ch[A.fa[i]]) link(i,A.fa[i]),d[A.fa[i]]++;
        if(ch[i]&&ch[B.fa[i]]) link(B.fa[i],i),d[i]++;
    }
    if(Topsort())return res;
    else return inf;
}
int main()
{
    scanf("%d",&T);
while(T--)
{
    scanf("%d",&n);
    A.clear();B.clear();
    A.ins();  B.ins();
    build_B();
    int ans=inf;
    for(int rt=1;rt<=n;++rt)
    {
        if(A.d[rt]!=1)continue;
        for(int f=1;f<=n;++f)
        {
            if(f==rt)continue;
            ans=min(ans,(A.ma[rt][f]^1)+solve(rt,f,A.oe[rt]));
        }
    }
    if(ans>n)puts("-1");
    else printf("%d\n",ans);
}
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef int_fast64_t ll;

const int buff_size = 1 << 21;
char buff[buff_size], *ci, ct;
int A;

inline int readint() {
    A = 0;
    while ((ct = *ci++) >= '0') A = (A << 3) + (A << 1) + ct - '0';
    return A;
}

inline ll solve() {
    fread_unlocked(buff, 1, buff_size, stdin);
    ci = buff;
    int N = readint();
    int M = 2, cnt;
    ll ans = readint() - 1;
    while(--N) {
        int A = readint();
        if(A == M) M++;
        else {
            cnt = A / M;
            ans += cnt;
            if(A - cnt * M == 0) ans--;
        }
    }
    return ans;
}

int main() {
    printf("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstdio>
#include <algorithm>
#include <math.h>

using namespace std;


int main() {

    string str;
    cin >> str;
    bool isOk = false;
    
    for (int i = 0; i < 9; i++) {
	int count = 0;
	for (int j = 0; j < 2; j++) {
	    if (str[j] != str[j + 1]) {
		break;
	    }
	    count++;
	}
	if (count == 2) {
	    isOk = true;
	}
    }
    for (int i = 0; i < 9; i++) {
	int count = 0;
	for (int j = 0; j < 2; j++) {
	    if (str[j+1] != str[j+2]) {
		break;
	    }
	    count++;
	}
	if (count == 2) {
	    isOk = true;
	}
    }
    
    if (isOk) {
	printf("Yes\n");
    }
    else {
	printf("No\n");
    }

}



Measured memory_bytes: 256
{$mode objfpc}
program D;
uses
  fgl, math;

type
  TIntLIst = specialize TFPGList<Int64>;

var
  N: Integer;
  C: Int64;
  xi, li, ri, vi: TIntLIst;

procedure ReadData;
var
  i: Integer;
  x, v: Int64;

begin
  ReadLn(N, C);

  li := TIntLIst.Create;
  ri := TIntLIst.Create;
  ri.Count := N;
  xi := TIntLIst.Create;
  vi := TIntLIst.Create;

  for i := 1 to N do
  begin
    ReadLn(x, v);
    xi.Add(x);
    li.Add(x);
    vi.Add(v);
  end;

  ri.Count := N;
  for i := N - 1 downto 0 do
    ri[i] := c - xi[i];
end;

var
  L1, L2, R1, R2: TIntList;
  L1M, L2M, R1M, R2M: TIntList;

function Solve: Int64;
var
  i: Integer;
  l, r: Integer;
  Current: Int64;
  CurSum: Int64;

begin
  L1 := TIntLIst.Create;
  L2 := TIntLIst.Create;
  R1 := TIntLIst.Create;
  R2 := TIntLIst.Create;
  L1M := TIntLIst.Create;
  L2M := TIntLIst.Create;
  R1M := TIntLIst.Create;
  R2M := TIntLIst.Create;
  L1.Count := N + 1;
  L2.Count := N + 1;
  R1.Count := N + 1;
  R2.Count := N + 1;
  L1M.Count := N + 1;
  L2M.Count := N + 1;
  R1M.Count := N + 1;
  R2M.Count := N + 1;

{
l1(l) := v0+...+vl-(xl)
l2(l) := v0+...+vr-2(xl)
r2(r) := vr+...+vN-1-(C - xr)
r2(r) := vr+...+vN-1-2(C - xr)
}
  l := 0;
  L1[l] := vi[l] - xi[l];
  L2[l] := vi[l] - 2 * xi[l];
  L1M[l] := L1[l];
  L2M[l] := L2[l];
  CurSum := vi[l];
  for l := 1 to N - 1 do
  begin
    Inc(CurSum, vi[l]);
    L1[l] := CurSum - xi[l];
    L2[l] := CurSum - 2 * li[l];
    L1M[l] := Max(L1[l], L1M[l - 1]);
    L2M[l] := Max(L2[l], L2M[l - 1]);
  end;

  r := N - 1;
  CurSum := vi[r];
  R1[r] := CurSum - (C - xi[r]);
  R2[r] := CurSum - 2 * (C - xi[r]);
  R1M[r] := R1[r];
  R2M[r] := R2[r];
  for r := N - 2 downto 0 do
  begin
    Inc(CurSum, vi[r]);
    R1[r] := CurSum - ri[r];
    R2[r] := CurSum - 2 * ri[r];
    R1M[r] := Max(R1[r], R1M[r + 1]);
    R2M[r] := Max(R2[r], R2M[r + 1]);
  end;

  Result := 0;

  for i := 0 to N - 2 do
  begin
    if Result < L1[i] then
      Result := L1[i];
    if Result < R1[i] then
      Result := R1[i];

    l := i;
    r := (i + 1);
  {
    WriteLn('L1:', L1[l], ' L2:', L2[l]); 
    WriteLn('R1:', R1[r], ' R2:', R2[r]); 
    WriteLn('LM:', L1M[l], ' L2M:', L2M[l]); 
    WriteLn('RM:', R1M[r], ' R2M:', R2M[r]); 
  }

    if Result < L2[l] + R1M[r] then
      Result := L2[l] + R1M[r];

    if Result < L1M[l] + R2[r] then
      Result := L1M[l] + R2[r];
  end;
  i := N - 1;
  if Result < L1[i] then
    Result := L1[i];
  if Result < R1[i] then
    Result := R1[i];
end;

begin
  ReadData;

  WriteLn(Solve);
end.

Measured memory_bytes: 10568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int n,k;cin>>n>>k;
  ll ans=0;
  for(int b=k+1;b<=n;b++){
    int p=n/b,r=n-p*b;
    ans+=(ll)(p*(b-k)+max(0,r-k+1));
    if(k==0) ans--;
  }
  cout<<ans;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 405;
const ll mod = 1000000007;

ll f[N][N], g[N][N], pw[N][N];
int n, C, A[N], B[N];

void calc(){
	for(int i = 1; i < N; i++){
		pw[i][0] = 1;
		for(int j = 1; j < N; j++){
			pw[i][j] = (pw[i][j - 1]*i)%mod;
		}
	}
	for(int i = 1; i <= n; i++){
		for(int a = 0; a <= C; a++){
			f[i][a] = 0;
			for(int x = A[i]; x <= B[i]; x++){
				f[i][a] += pw[x][a];
				if(f[i][a] >= mod)f[i][a] -= mod;
			}
		}
	}
}

ll gfunc(int ind, int cc){
	if(ind == 0)return cc == 0;
	if(g[ind][cc] != -1)return g[ind][cc];
	ll ret = 0;
	for(int a = 0; a <= cc; a++){
		ret += f[ind][a]*gfunc(ind - 1, cc - a)%mod;
		if(ret >= mod)ret -= mod;
	}
	return g[ind][cc] = ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	cin>>n>>C;
	for(int i = 1; i <= n; i++){
		cin>>A[i];
	}
	for(int i = 1; i <= n; i++){
		cin>>B[i];
	}
	calc();
	memset(g, -1, sizeof(g));
	cout<<gfunc(n, C)<<endl;

	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;
int main()
{
	int N;
	vector<int>V;
	cin >> N;
	fore(i,0,N){
		int t;
		cin >> t;
		V.push_back(t);
	}
	sort(V.begin(),V.end());
	cout << *(V.end()-1)-*(V.begin()) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;
 
int main(){
	int n,q;
	cin >> n >> q;
	string s;
	cin >> s;
	int ac[n] = {};
	int j = 0,k = 0;
	for(int i = 0; i < n; i++){
		ac[i] = k;
		if(s[i] == 'A'){
			if(s[i + 1] == 'C'){
				ac[i] = k;
				k++;
				ac[i + 1] = k;
				i++;
			}
		}
	}
	for(int i = 0; i < q; i++){
		int l,r;
		cin >> l >> r;
		cout << ac[r - 1] - ac[l - 1] << endl;
	}
}

Measured memory_bytes: 1408
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 200010
ll n, q, c, x[N];
set<P> dp[2];

int main(){
	cin>>n>>q>>x[0]>>c;
	rep(i, q) cin>>x[i+1];
	dp[0].insert(P(c, 0));
	for(int i = 1; i <= q; i++){
		int t = i%2;
		dp[t].clear();
		for(auto p: dp[!t]){
			dp[t].insert(P(x[i-1], p.snd+abs(x[i]-p.fst)));
			dp[t].insert(P(p.fst, p.snd+abs(x[i]-x[i-1])));
		}
		{
			auto it = dp[t].begin(), it2 = it; ++it2;
			while(it2!=dp[t].end()){
				while(it2!=dp[t].end() && it->snd+abs(it->fst-it2->fst)<=it2->snd){
					dp[t].erase(it2);
					it2 = it;
					++it2;
				}
				++it;
				if(it2!=dp[t].end()) ++it2;
			}
		}
		{
			auto it = dp[t].end();
			if(it!=dp[t].begin()) --it;
			auto it2 = it;
			if(it!=dp[t].begin()) --it2;
			while(it!=dp[t].begin()){
				while(it!=dp[t].begin() && it->snd+abs(it->fst-it2->fst)<=it2->snd){
					dp[t].erase(it2);
					it2 = it;
					if(it2!=dp[t].begin()) --it2;
				}
				if(it!=dp[t].begin()){
					--it;
					if(it2!=dp[t].begin()) --it2;
				}
			}
		}
	}
	ll res = 1e17;
	for(auto p: dp[q%2]) res = min(res, p.snd);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
n,c,k=map(int,input().split())
a=[int(input())for _ in range(n)]
a.sort()
t=a[0]
ans=0
cc=1
for i in range(1,n):
  tt=a[i]
  if t+k<tt or cc==c:ans+=1;t=tt;cc=1
  else:cc+=1
print(ans+1)

Measured memory_bytes: 7384
import sys
input=sys.stdin.readline
x,y,a,b,c=map(int,input().split())

a_list=list(map(int,input().split()))
a_list=sorted(a_list)
b_list=list(map(int,input().split()))
b_list=sorted(b_list)
a_list=a_list[-x:]
b_list=b_list[-y:]
c_list=list(map(int,input().split()))
for i in range(c):
    c_list[i]=-c_list[i]
import heapq
heapq.heapify(a_list)
heapq.heapify(b_list)
heapq.heapify(c_list)

flag=True
while flag and c_list:
    x=heapq.heappop(c_list)
    x=x*(-1)
    #ｃ_listの中でのもっとも大きい値
    min_a=heapq.heappop(a_list)
    min_b=heapq.heappop(b_list)
    if min(min_a,min_b)>=x:
        flag=False
        heapq.heappush(a_list,min_a)
        heapq.heappush(b_list,min_b)
    else:
        if min_a>=min_b:
            heapq.heappush(a_list,min_a)
            heapq.heappush(b_list,x)
            
        elif min_a<min_b:
            heapq.heappush(b_list,min_b)
            heapq.heappush(a_list,x)

sum_a=sum(list(a_list))
sum_b=sum(list(b_list))

print(sum_a+sum_b)
            

    


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> sorted = a;
    sort(sorted.begin(), sorted.end());
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            bool f = true;
            for(int k = 0; k < n; k++){
                if(k == i){
                    if(sorted[k] != a[j]) f = false;
                }else if(k == j){
                    if(sorted[k] != a[i]) f = false;
                }else{
                    if(sorted[k] != a[k]) f = false;
                }
            }
            if(f){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	/*入力部分*/
	int A,B,C,D;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	//条件、出力
	if(A*B>=C*D){
		printf("%d\n",A*B);}
	if(A*B<C*D){
		printf("%d\n",C*D);}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int dp[11][1<<10][331];

int main()
{
//	cut here before submit 
//	freopen ("testcase.CNS", "r", stdin );
	memset (dp, 0, sizeof (dp ) );
	dp[0][0][0] = 1;	// dp[現在の位置][使った数字][総和]
	rep (i, 10 ){
		for (int j = 0; j < (1<<10); j++ ){
			rep (k, 10 ){
				if (j&(1<<k)) continue;
				for (int sum = 330; sum >= 0; sum-- ){
					if (sum + (i+1)*k <= 330 ){
						dp[i+1][j | (1<<k)][sum + (i+1)*k] += dp[i][j][sum];
					} // end if
				} // end for
			} // end rep
		} // end for
	} // end rep			

	int n,s;
	while (scanf ("%d %d", &n, &s ) != EOF ){
		if (n >= 11 || s > 330 ){
			cout << 0 << endl;
			continue;
		} // end if

		int total = 0;
		for (int j = 0; j < (1<<10); j++ ){
			total += dp[n][j][s];
		} // end for
		cout << total << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 15780
#include<stdio.h>
int a[2000001];
int h;
void maxHeapify(int i){
    int largest, r, l, tmp;
    r=2*i+1;
    l=2*i;
    if(l<=h&&a[l]>a[i])largest=l;
    else largest=i;
    if(r<=h&&a[r]>a[largest])largest=r;
    if(largest!=i){
        tmp=a[i];
        a[i]=a[largest];
        a[largest]=tmp;
        maxHeapify(largest);
    }
}
int main(){
    int i;
    scanf("%d", &h);
    for(i=1; i<=h; i++)scanf("%d", &a[i]);
    for(i=h/2; i>0; i--)maxHeapify(i);
    for(i=1; i<=h; i++)printf(" %d", a[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 2552
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string a, b; cin >> a >> b;
    int X = atoi((a+b).c_str());
    int Y = 1;
    while(Y*Y<=X) {
        if(Y*Y == X) {
            cout << "Yes" << endl;
            return 0;
        }
        Y++;
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int N;
  cin >> N;
  bool flag = true;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 2 == 0) {
      if (a % 3 != 0 && a % 5 != 0) {
        flag = false;
      }
    }
  }
  if (flag) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    for(int i = 0;i < n;i++){
        cin >> p[i];
    }
    for(int i = 0;i < n;i++){
        cin >> q[i];
    }
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        a[i] = i + 1;
    }
    
    map<vector<int>,int> m;
    
    do{
        m[a] = m.size();
    }while(next_permutation(a.begin(),a.end()));
    
    int ans = abs(m[p] - m[q]);
    cout << ans << endl;
    
    return 0;
}


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


#define ll long long
#define IM INT_MAX
#define LM LLONG_MAX
#define m_p make_pair
#define MOD 1000000007
#define dbg(x) cerr << #x << " = " << x << "\n"


/*
ID: vlad.io1
TASK: 
LANG: C++
*/


bool comp(int a, int b) {
	return a > b;
}


template<typename T>
T gcd(T a, T b) {
	while (a != 0 && b != 0) {
		if (a > b) {
			a %= b;
		} else {
			b %= a;
		}
	}
	return (a > b ? a : b);
}


void solve() {
	int l, r, d;
	cin >> l >> r >> d;
	int cnt=0;
	for(int i = l; i <= r; i++) {
		if(i % d == 0) cnt++;
	}
	cout << cnt << ' ';
}


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

	//freopen("output.txt", "w", stdout);
	//freopen("input.txt", "r", stdin);

	int t=1;
	//cin >> t;

	while(t--)
		solve();
}


























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

int main(){
  
  int a, b, c, NUM;
  scanf("%d/%d/%d", &a, &b, &c);
  
  if(b > 4){
    cout << "TBD" << endl;
    return 0;
  }
  cout << "Heisei" << endl;
  return 0;
}

Measured memory_bytes: 3772