akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define RANGE(i, x, n) for(int i = x; i < n; ++i)
using namespace std;

typedef long long LL;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    int flag =0;
    int ans = 1;
    int sta;
    REP(i, N-1) {
        if(A[i+1] == A[i]) {
            continue;
        }else if(A[i+1] > A[i]) {
            if(flag == 2) {
                ++ans;
                flag = 0;
            }else {
                flag = 1;
            }
        }else {
            if(flag == 1) {
                ++ans;
                flag = 0;
            }else {
                flag = 2;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.setf(ios::fixed);
	cout.precision(20);

	ll a, b, c, n, m, ans = 0, x = 0;
	string s;
	cin >> n;
	vi v(n);
	rep(i, n) {
		cin >> v[i];
	}
	sort(all(v));
	cout << v[v.size() - 1] - v[0] << endl;
	return 0;
}


Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbig=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
ll bs[20];
ll D,calc0[20],calc[20];
ll a[20],an,ans;
void dfs(int x,ll v,ll c)
{
	if(x==an)
	{
		ans+=(v==D)*c;
		return;
	}
	if(abs(v-D)>a[x]*20)return;
	for(int i=0;i<20;i++)
	{
		int cnt;
		if(x==0)cnt=calc0[i];else cnt=calc[i];
		if(a[x]==0)cnt=i<10;
		if(cnt==0)continue;
		dfs(x+1,v+(i-10)*a[x],c*cnt);
	}
}
void solve(int n)
{
	an=0;
	for(int i=0;i<n;i++)
	{
		if(i>n-i-1)break;
		a[an++]=bs[n-i-1]-bs[i];
//		cout<<a[i]<<" ";
	}
//	cout<<endl;
	dfs(0,0,1);
//	cout<<ans<<endl;
}
int main()
{
	for(int i=0;i<=9;i++)
	{
		for(int j=0;j<=9;j++)
		{
			calc[i-j+10]++;
		}
	}
	for(int i=0;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			calc0[i-j+10]++;
		}
	}
	
	bs[0]=1;
	for(int i=1;i<19;i++)bs[i]=bs[i-1]*10;
	cin>>D;
	for(int i=1;i<=19;i++)
	{
		solve(i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#区間[l,r]での最小値は?
#区間[l,l+mid]の最小値+[l+mid+1,r]の最小値+midに依存した計算回数
#(Mi Mj)*(Mj Mk)の計算回数はijk

def kuDP(l,r):
  global dp
  
  if dp[l][r] != -1:
    return dp[l][r]
  
  if l == r:
    dp[l][r] = 0
    return 0
  
  if l+1 == r:
    c = M[l][0]*M[l][1]*M[r][1]
    dp[l][r] = c
    return c
  
  midl = [10**10]*(r-l)
  for mid in range(r-l):
    midl[mid] = kuDP(l,l+mid) + kuDP(l+mid+1,r) + M[l][0]*M[l+mid][1]*M[r][1]
    
  c = min(midl)
  
  dp[l][r] = c
  
  return c

N = int(input())
M = [list(map(int,input().split())) for _ in range(N)]
dp = [[-1]*N for _ in range(N)]
print(kuDP(0,N-1))


Measured memory_bytes: 5920
#include <stdio.h>
int main(void){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?') break;
        if(op=='+') printf("%d\n",a+b);
        if(op=='-') printf("%d\n",a-b);
        if(op=='*') printf("%d\n",a*b);
        if(op=='/') printf("%d\n",a/b);
    }
    return 0;
}



Measured memory_bytes: 2100
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  string S;
  cin >> S;
  if(S[0] != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  int cnt = 0;
  for(int i=2; i<=S.size()-2; i++){
    if(S[i] == 'C'){
      cnt++;
    }
  }
  int x=0;
  for(int i=1; i<S.size(); i++){
    if(isupper(S[i])){
      x++;
    }
  }
  if(cnt==1 && x==1){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		long k = sc.nextLong();
		HashMap<Long, Long> map = new HashMap<>();
		List<Long> list = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			if ( !map.containsKey(a)) {
				list.add(a);			
				map.put(a, b);
			}
			else {
				long num = map.get(a);
				map.put(a, num + b);
			}
		}
		Collections.sort(list);
		
		long sum = 0;
		long ans = 0;
		for(int i = 0; i < list.size(); i++) {
			long num = map.get(list.get(i));
			sum += num;
			if (sum >= k) {
				ans = list.get(i);
				break;
			}			
		}
		out.println(ans);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 36124
from sys import stdin
import numpy as np
from operator import itemgetter

N = int(stdin.readline().rstrip().split()[0])
AB = []
for i in range(N):
    a, b = [int(x) for x in stdin.readline().rstrip().split()]
    AB.append((a,b))

AB = sorted(AB, key=itemgetter(1))
Frag = "Yes"
time=0
for a,b in AB:
    time += a
    if time>b:
        Frag="No"
        break

print(Frag)



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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
bool ischar(char c){
	if('A'<=c&&c<='Z')return true;
	else return false;
}
signed main(){
	int n,k;
	cin>>n>>k;
	int a[200010];
	rep(i,n)cin>>a[i];
	int cnt=0;
	int ans;
	for(int i=0;i<k;i++)cnt+=a[i];
	ans=cnt;
	for(int i=k;i<n;i++){
		cnt-=a[i-k];
		cnt+=a[i];
		chmax(ans,cnt);
	}
	cout<<setprecision(16)<<fixed<<(double)(ans+k)/(double)2<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first

#if MYDEBUG
#define DBG(...) {string dst__=#__VA_ARGS__;dbgsplit(dst__);stringstream dss__; dss__<<dst__; debug(dss__,__VA_ARGS__);}
#else
#define DBG(...)
#endif
void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<'='<<f<<' '; debug(ds,r...);}
void dbgsplit(string &s){int l=s.length(),n=0;for(int i=0; i<l; ++i){if(s[i]=='(')++n;if(s[i]==')')--n;if(s[i]==','&&!n)s[i]=' ';}}
using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;


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

    LL n;
    cin >> n;
    vector<tuple<LL,LL,LL>> a;
    vector<LL> ans(n);
    for(int i=0; i<n; ++i){
        LL tmp;
        cin >>tmp;
        a.emplace_back(tmp,i,0);
    }
    sort(a.begin(),a.end());
    map<LL,LL> cnt,lb;
    LL rb=n,l=n-1;
    for(int i=n-1; i>0;--i){
        if(get<0>(a[i])>get<0>(a[i-1])){
            cnt[get<0>(a[i])]=rb-i;
            rb=i;
            l=min(l,get<1>(a[i]));
            lb[get<0>(a[i])]=l;
        }
    }
    cnt[get<0>(a[0])]=rb;
    lb[get<0>(a[0])]=0;
    LL cntsum=0;
    for(int i=n-1; i>0; --i){
        if(get<0>(a[i-1]) < get<0>(a[i])){
            LL pos,num,sum;
            tie(num,pos,sum)=a[i];
            cntsum+=cnt[num];
    DBG(num,cnt[num],cntsum,lb[num])
            ans[lb[num]]+=cntsum*(num-get<0>(a[i-1]));
        }
    }
    LL pos,num,sum;
    tie(num,pos,sum)=a[0];
    cntsum+=cnt[num];
    DBG(num,cnt[num],cntsum)
    assert(cntsum==n);
    ans[lb[num]]+=cntsum*num;
    for(int i=0; i<n; ++i){
        cout << ans[i]<<"\n";
    }

    return 0;
}



Measured memory_bytes: 16880
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
double a[10002];
int main() {
	int n;
	cin>>n;
	
	for (int i=1; i<=n; i++) 
		cin>>a[i];
	
	sort(a+1,a+n+1);
	
	for (int i=2; i<=n; i++) {
		a[i]=(a[i-1]+a[i])/2.0;
	}
	
	printf("%.7f",a[n]);
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,c,i=0,Count=0;
	
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++){
	if(c%i==0){
		Count++;
	}
	}
	printf("%d\n",Count);
  
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

struct mint {
	typedef long long ll;
	ll x, m;
	mint(ll x=0, ll m=1e9+7): x(x%m), m(m) {}
	mint operator-() const { return mint(m-x, m); }
	mint operator+(const mint o) const { return mint(x+o.x, m); }
	mint operator-(const mint o) const { return mint(x-o.x+m, m); }
	mint operator*(const mint o) const { return mint(x*o.x, m); }
	mint& operator+=(const mint o) { x = (x+o.x)%m; return *this; }
	mint& operator-=(const mint o) { x = (x-o.x+m)%m; return *this; }
	mint& operator*=(const mint o) { x = x*o.x%m; return *this; }
	bool operator==(const mint o) const { return x==o.x; }
	bool operator!=(const mint o) const { return x!=o.x; }
	template<typename T> mint& operator=(const T o) { x = o%m; return *this; }
	template<typename T> mint operator+(const T o) const { return mint(x+o, m); }
	template<typename T> mint operator-(const T o) const { return mint(x-((ll)o)%m+m, m); }
	template<typename T> mint operator*(const T o) const { return mint(x*o, m); }
	template<typename T> mint& operator+=(const T o) { x = (x+(ll)o%m)%m; return *this; }
	template<typename T> mint& operator-=(const T o) { x = (x-((ll)o)%m+m)%m; return *this; }
	template<typename T> mint& operator*=(const T o) { x = x*((ll)o%m)%m; return *this; }
	template<typename T> bool operator==(const T o) const { return x==o%m; }
	template<typename T> bool operator!=(const T o) const { return x!=o%m; }

	mint pow(ll k) const {
		if(k==0) return mint(1, m);
		if(k%2) return pow(k-1)*x;
		mint z = pow(k/2);
		return z*z;
	}

	mint inv() const { return pow(m-2); }
};

int _main(){
	for(auto x: std::vector<int>{3, 5, 7, 11, 13, 17, 19}){
		assert((mint(4, x)*mint(4, x).inv())==1);
	}
	return 0;
}

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

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

	mint ans(0);

	vector<mint> fact(N+1);
	fact[0] = mint(1);
	for(int i=0; i<N; i++) fact[i+1] = fact[i]*(i+1);

	for(int i=K-1; i<N; i++){
		ans += fact[i] * fact[i-K+1].inv() * fact[K-1].inv() * ((ll)(1e9+7) + A[i] - A[N-i-1]);
	}

	cout << ans.x << endl;

	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N =sc.nextInt();
      int R =sc.nextInt();
      
      if(N>=10){
      System.out.println(R);
      }
      else if(N<10){
      System.out.println(R+100*(10-N));
      }
     
    }
}

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

int main()
{
	int H, W;
	cin >> H;
	cin >> W;
	vector<vector<char>> a;
	vector<char> a_frame(W+2,'#');
	a.push_back(a_frame);
	for (int i = 0; i < H; i++)
	{
		vector<char> a_line(W + 2);
		a_line[0] = '#';
		a_line[W + 1] = '#';
		for (int j = 1; j <= W; j++)
		{
			cin >> a_line[j];
		}
		a.push_back(a_line);
	}
	a.push_back(a_frame);

	for (int i = 0; i < H+2; i++)
	{
		for (int j = 0; j < W+2; j++)
		{
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <unordered_map>

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

    std::unordered_map<std::string, std::string> map;
    for (int i = 0; i <= n; ++i) {
        std::string key;
        std::cin >> key;
        if (!key.empty()) {
            map[key] = key;
        }
    }
    
    std::cout << map.size() << std::endl;

    return 0;
}


Measured memory_bytes: 24052
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll n,i,j,sum=0,x,mn=INT_MAX;
  cin>>n;
  ll ar[n+1],cnt=0;
  for(i=0;i<n;i++)
  {
      cin>>ar[i];
      sum=sum+abs(ar[i]);
      if(ar[i]<0)
      {
          cnt++;
          x=abs(ar[i]);
          if(x<mn)
            mn=x;
      }
      else
      {
           if(ar[i]<mn)
            mn=ar[i];
      }
  }
  if(cnt%2==0)
  {
      cout<<sum<<endl;
  }
  else
  {
      sum=sum-(2*mn);
      cout<<sum<<endl;
  }


}


Measured memory_bytes: 4384
#include <stdio.h>
#include <iostream>

using namespace std;

void syuturyoku(int p, int q[]) 
{
	for (int i = 0; i < 5; i++) {
		if (q[i] == p) {
			cout << 1 << endl;
		} else {
			cout << 2 << endl;
		}
	}
	return;
}

int main() {
	int a[5];
	while (1) {
		cin >> a[0];
		if (a[0] == 0) {
			break;
		}
		int b[3] = {0};
		b[a[0]-1] = 1;
		for (int i = 1; i< 5; i++) {
			cin >> a[i];
			b[a[i]-1] = 1;
		}
		if ((b[0] == 1 && b[1] == 1 && b[2] == 1) || (b[0] == 1 && b[1] == 0 && b[2] == 0) || (b[0] == 0 && b[1] == 1 && b[2] == 0) || (b[0] == 0 && b[1] == 0 && b[2] == 1)) {
			for (int i = 0; i < 5; i++) {
				cout << 3 << endl;
			}
		} else {
			if (b[0] == 0) {
				syuturyoku(2,a);
			} else if (b[1] == 0) {
				syuturyoku(3,a);
			} else {
				syuturyoku(1,a);
			}
		}
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    ans=n*(n-1)/2+m*(m-1)/2;
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 256
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    int a,b,s1,s2,p=0;
    cin>>a>>b;
    if(a*4<b)
        cout<<"No"<<endl;
    else
    {
        for(int i=1; i<=a; i++)
        {
            s1=i*2;
            s2=(a-i)*4;
            if(s1+s2==b)
                p=1;
        }
        if(p==0)
        {
            for(int i=1; i<=a; i++)
            {
                s1=i*4;
                s2=(a-i)*2;
                if(s1+s2==b)
                    p=1;
            }
        }
        if(p==1)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

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

signed main(){
    int N;
    cin>>N;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    sort(All(A));
    if(A[0]>=0){
    	int ans=0;
    	rep(i,1,N) ans+=A[i];
    	ans-=A[0];
    	cout<<ans<<endl;
    	rep(i,N-2){
    		cout<<A[i]<<" "<<A[i+1]<<endl;
    		A[i+1]=A[i]-A[i+1];
    	}
    	cout<<A[N-1]<<" "<<A[N-2]<<endl;
    }
    else{
    	int k=lower_bound(All(A),0)-A.begin();
    	if(k<N){
    		int ans=0;
    		rep(i,N) ans+=llabs(A[i]);
    		cout<<ans<<endl;
    	    rep(i,1,k){
    	    	cout<<A[N-1]<<" "<<A[i]<<endl;
    	    	A[N-1]-=A[i]; 
        	}
    	    rep(i,k,N-1){
    	    	cout<<A[0]<<" "<<A[i]<<endl;
    		    A[0]-=A[i];
    	    }
    	    cout<<A[N-1]<<" "<<A[0]<<endl;
    	}	
    	else{
    		int ans=0;
    		rep(i,N-1) ans-=A[i];
    		ans+=A[N-1];
    		cout<<ans<<endl;
    		rep(i,N-2){
    			cout<<A[N-1-i]<<" "<<A[N-2-i]<<endl;
    			A[N-2-i]=A[N-1-i]-A[N-2-i];
    		}
    		cout<<A[1]<<" "<<A[0]<<endl;
    	}
    }
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

Measured memory_bytes: 2688
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string S; cin >> S;
    ll res = 0, cnt = 0;
    rep(i, S.size()){
        if(S[i] == 'W'){
            res += i - cnt;
            cnt++;
        }
    }
    cout << res << ln;
}


Measured memory_bytes: 640
import sys
import math
def input():
    return sys.stdin.readline()[:-1]
mod = 998244353
n,s=map(int,input().split())
a = list(map(int,input().split()))
dp =[[0 for i in range(s+1)]for j in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(s+1):
        if j-a[i-1]>=0:
            dp[i][j] += dp[i-1][j-a[i-1]]
            dp[i][j] %= mod

        dp[i][j] += dp[i-1][j]*2
        dp[i][j] %= mod

print(dp[n][s])


Measured memory_bytes: 147296
#include <iostream>

using namespace std;


#define SIZE 1000001

struct Process
{
	char name[10];
	int time;
};

Process queue[SIZE];
int head = 0;
int tail = 0;

void enqueue(Process p)
{
	queue[tail] = p;
	tail = (tail + 1) % SIZE;
}

Process dequeue()
{
	Process p = queue[head];
	head = (head + 1) % SIZE;
	return p;
}

int main(int argc, char const *argv[])
{
	int n, q;
	int t = 0;
	Process p;
	cin >> n >> q;
	for (int i = 0; i < n; ++i)
	{
		cin >> queue[i].name >> queue[i].time;
	}
	tail = n;
	while(head != tail)
	{
		p = dequeue();
		if (p.time <= q)
		{
			cout << p.name << " " << (t + p.time) << endl;
			t += p.time;
		} else {
			p.time -= q;
			enqueue(p);
			t += q;
		}
	}
}

Measured memory_bytes: 5252
#pragma GCC optimize("O3")
#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>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    ll h; cin>>h;

    ll base = 1, ans = 0;
    while(h != 1){
        ans += base;
        h /= 2;
        base *= 2;
    }

    cout << (ans + base) << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fastio() ios::sync_with_stdio(0);cin.tie(0)
#define MEMS(x,t) memset(x,t,sizeof(x));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*-------------------------------------------------------------------------------------------------------------------------------------*/
//#define MOD 1000000007
#define endl "\n" 
#define int long long
#define inf 1e18
#define ld long double
/*-------------------------------------------------------------------------------------------------------------------------------------*/
 
int32_t main()
{
	fastio();
	int n;
	cin>>n;
	int ar[n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>ar[i];
		sum^=ar[i];
	}
	for(int i=0;i<n;i++)
	{
		cout<<(sum^ar[i])<<" ";
	}
}


Measured memory_bytes: 5220
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

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

    int N;
    cin >> N;

    vector<int>P(N);
    cin >> P;

    int cnt = 0;
    REP(i, N) {
        if (P[i] != i + 1) {
            cnt++;
        }
    }
    YESNO(cnt > 2, "NO", "YES");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;


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

	int N;
	cin >> N;
	VI A(6),B(6);

	REP(a, N) {
		bool F[15] = { false };
		F[7] = true;
		REP(j, 6) {
			cin >> A[j];
			//cout << A[j] << " ";
			F[A[j]] = true;
		}
		//cout << endl;
		SORT(A);
		int k = 0;
		eFOR(j, 1, 13) {
			if (!F[j]) {
				B[k] = j;
				//cout << B[k] << " ";
				k++;
			}
		}

		if (A[0] == 1 && A[5] == 13) {
			cout << "no" << endl;
			continue;
		}
		if (B[0] == 1 && B[5] == 13) {
			cout << "yes" << endl;
			continue;
		}
		bool vis[15] = { false };
		vis[7] = true;
		bool f = true;
		if (A[0] == 1) {
			while (!vis[1]) {
				//eFOR(j, 1, 13)cout << vis[j] << " ";
				//cout << " ";
				int i = 0;
				bool ans = true;
				REP(j, B.size()) {
					if (!vis[B[j]]) {
						ans = false;
						//cout << B[j] << endl;
					}
				}
				if (ans) {
					f = false;
					cout << "no" << endl;
					break;
				}
				while (i<6) {
					if (vis[A[i] + 1]&&!vis[A[i]]) {
						vis[A[i]] = true;
						break;
					}
					if (vis[A[i] - 1] && !vis[A[i]]) {
						vis[A[i]] = true;
						break;
					}
					i++;
				}
				i = 5;
				while (i>=0) {
					if (vis[B[i] - 1] && !vis[B[i]]) {
						vis[B[i]] = true;
						break;
					}
					if (vis[B[i] + 1] && !vis[B[i]]) {
						vis[B[i]] = true;
						break;
					}
					i--;
				}
			}
		}
		else {
			while (!vis[13]) {
				
				int i = 5;
				bool ans = true;
				REP(j, B.size()) {
					if (!vis[B[j]])ans = false;
				}
				if (ans) {
					f = false;
					cout << "no" << endl;
					break;
				}
				while (i>=0) {
					if (vis[A[i] - 1] && !vis[A[i]]) {
						vis[A[i]] = true;
						break;
					}
					if (vis[A[i] + 1] && !vis[A[i]]) {
						vis[A[i]] = true;
						break;
					}
					i--;
				}
				//eFOR(j, 1, 13)cout << vis[j] << " ";
				//cout << " ";
				i = 0;
				while (i<6) {
					if (vis[B[i] + 1]&&!vis[B[i]]) {
						vis[B[i]] = true;
						break;
					}
					if (vis[B[i] - 1] && !vis[B[i]]) {
						vis[B[i]] = true;
						break;
					}
					i++;
				}
			}
		}
		if(f)cout << "yes" << endl;
		//cout << endl;
	}
	
	return 0;
}




Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
int visited[500][500] = {};
int cnter[500][500] = {};
int main() {
#define int long long 
	int h, w;
	cin >> h >> w;
	REP(i, h) {
		string s;
		cin >> s;
		REP(q, s.length()) {
			if (s[q] == '#') {
				cnter[i][q] = 1;
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < h; ++i) {
		for (int q = 0; q < w; ++q) {
			if (visited[i][q] == 0&&cnter[i][q] == 1) {
				visited[i][q] = 1;
				int black = 1;
				int white = 0;
				queue<pair<int, int>> next;
				next.push(make_pair(i, q));
				int xe[4] = { 0,0,1,-1 };
				int ye[4] = { 1,-1,0,0 };
				while (next.empty() == false) {
					pair<int, int> now = next.front();
					next.pop();
					for (int j = 0; j < 4; ++j) {
						int next_x = xe[j] + now.first;
						int next_y = ye[j] + now.second;
						if (next_x >= 0 && next_x < h && next_y >= 0 && next_y < w) {
							if (visited[next_x][next_y] == 0&&cnter[next_x][next_y] + cnter[now.first][now.second] == 1) {
								visited[next_x][next_y] = 1;
								next.push(make_pair(next_x, next_y));
								if (cnter[next_x][next_y] == 1) {
									black++;
								}
								else {
									white++;
								}
							}
						}
					}
				}
				ans += black * white;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2, 7, 61] if n < 1 << 32 else [2, 3, 5, 7, 11, 13,
                                        17] if n < 1 << 48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1:
            continue
        while y != n - 1:
            y = y * y % n
            if y == 1 or t == n - 1:
                return 0
            t <<= 1
    return 1


def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        def f(x): return (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g):
                return g
            elif isPrimeMR(n // g):
                return n // g
            return findFactorRho(g)


def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k:
            ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1:
        ret[n] = 1
    if rhoFlg:
        ret = {x: ret[x] for x in sorted(ret)}
    return ret


def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p] + 1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)


N = int(input())
A_array = list(map(int, input().split()))

A_array.sort()

set_A = set(A_array)


ans = 0

for i in range(N):
    if i != 0:
        if A_array[i] == A_array[i - 1]:
            continue
    if i != N - 1:
        if A_array[i] == A_array[i + 1]:
            continue

    a = A_array[i]
    for p in divisors(a)[:-1]:
        if p in set_A:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 115056
var
  p:array[1..10]of longint;
  n,i,maxIn,ans:longint;
begin
  readln(n);
  for i:=1 to n do
    readln(p[i]);
  maxIn:=1;
  for i:=2 to n do
    if p[i]>p[maxIn] then
      maxIn:=i;
  p[maxIn]:=p[maxIn]div 2;
  for i:=1 to n do
    ans:=ans+p[i];
  write(ans)
end.

Measured memory_bytes: 128
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] XYZ = readln.chomp.split.to!(int[]);
  int X = XYZ[0],
      Y = XYZ[1],
      Z = XYZ[2];
  int n = X - Z;


  writeln(n / (Y + Z));
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
s = abs(A[0]) + abs(A[-1])
for i in range(N-1):
  s += abs(A[i+1] - A[i])
#print(s)
for i in range(N):
  b = A[i]
  if i == 0:
    a = 0
  else:
    a = A[i-1]
  if i == N-1:
    c = 0
  else:
    c = A[i+1]
  print(s-abs(b-a)-abs(c-b)+abs(c-a))


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

int sign(long long int num) {
  if (num<0) {
    return -1;
  }
  else if(num > 0) {
    return 1;
  }
  else {
    return 0;
  }
}

int main() {
  long long int n;
  cin >> n;
  vector<long long int> list(n);
  for (long long int i=0;i<n;i++) {
    cin >> list.at(i);
  }
  long long int count=1;
  long long int len=0;
  long long int judge=0;
  for (long long int i=0;i<n-1;i++) {
    len++;
    //cout << len << endl;
    if (len == 1) {
      judge = 0;
    }
    else {
      //cout << i << endl;
      if(judge==0) {
        judge = sign(list.at(i)-list.at(i-1));
      }
      if ( judge * sign(list.at(i+1)-list.at(i)) < 0 ) {
        count++;
        len=0;
      }
    }
  }
  cout << count << endl;
}

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

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REP1(i,n) for(int i = 1; i <= (n); ++i)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; --i)
#define ALL(a) begin(a), end(a)
#define MP(a,b) make_pair((a), (b))
#define ROUNDUP(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))
#define X first
#define Y second
#define DEBUG(a) cout << #a << ": " << a << "\n"
// #define DEBUG(a) {}

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 4 * 1e18 + 1;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

template<typename T>
T debug(T x) {
	DEBUG(x);
	return x;
}

vector<pii> c[31];

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

	int n, C;
	cin >> n >> C;
	int maxt = 0;
	REP(i, n){
		int s, t, cc;
		cin >> s >> t >> cc;
		c[cc].push_back(MP(s, t));
		maxt = max(maxt, t);
	}

	vi sm(maxt * 2 + 1);

	REP1(i, C){
		auto cc = c[i];
		vi t(maxt * 2 + 1);
		for(const auto &j : cc){
			t[j.X * 2 - 1]++;
			t[j.Y * 2]--;
		}
		REP(j, maxt * 2){
			t[j + 1] += t[j];
		}
		REP(j, maxt * 2 + 1){
			if(t[j] > 0) sm[j]++;
		}
	}

	sort(ALL(sm), greater<int>());

	cout << sm[0] << "\n";

	return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;
 
signed main(){
    int x;cin>>x;
    int ans=x/11;
    ans*=2;
    x%=11;
    if(x>0&&x<=6)ans++;
    if(x>=7)ans+=2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
int n;
auto ab = vector<p>();
auto cd = vector<p>();

int main(){
   cin >> n;
   ab = move(vector<p>(n,p(0,0)));
   cd = move(vector<p>(n,p(0,0)));
   
   for (int i = 0; i < 2*n; i++)
   {
      if(i<n){
         cin >> ab[i].first >> ab[i].second;     
      }else{
         cin >> cd[i-n].first >> cd[i-n].second;
      }
   }

 
   sort(ab.begin(),ab.end());
   sort(cd.begin(),cd.end());

   auto used = vector<int>(n,0);
   auto ans = 0;
   for (int i = 0; i < n; i++)
   {
      auto _miny = INF;
      auto t=-1;
      for (int j = 0; j < n; j++)
      {
         if(!used[j]&&cd[i].first > ab[j].first&&cd[i].second > ab[j].second &&_miny >(cd[i].second-ab[j].second)){
            _miny = cd[i].second-ab[j].second;
            t = j;
            //cout << i << " "<< j << endl;
         }
      }
      if(t>=0){
         used[t]=1;
         ans++;
      }
      
   }

   cout << ans;

}
  
  

Measured memory_bytes: 256
L,R = map(int, input().split())
if R//2019 - (L-1)//2019 > 0:
    print(0)
elif R//673 - (L-1)//673 > 0 and R-L > 2:
    print(0)
else:
    l = L%2019
    r = R%2019
    tmp = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            tmp = min(tmp,(i*j)%2019)
            if tmp == 1:
                break
    print(tmp)

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

int main(){
	int n;
	cin >> n;
	int money = 100000;
	for(int i = 0; i < n; i++){
		money = money * 105 / 100;
		money = ((money + 999) / 1000) * 1000;
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 0
h, w = gets.split.map(&:to_i)
s = Array.new(h + 1).map{Array.new(w + 1, 0)}
1.upto(h) do |i|
  c = 0
  l = 1
  b = gets.chomp.bytes
  1.upto(w) do |j|
    if b[j - 1] == 46
      l = j if c == 0
      c += 1
    elsif c > 0
      l.upto(j - 1) do |k|
        s[i][k] = c
      end
      c = 0
    end
    if j == w && c > 0
      l.upto(j) do |k|
        s[i][k] = c
      end
    end
  end
end
ans = 0
1.upto(w) do |j|
  c = 0
  l = 1
  1.upto(h) do |i|
    if (s[i][j] > 0)
      l = i if c == 0
      c += 1
    elsif c > 0
      l.upto(i - 1) do |k|
        ans = s[k][j] + c if ans < s[k][j] + c
      end
      c = 0
    end
    if i == h && c > 0
      l.upto(i) do |k|
        ans = s[k][j] + c if ans < s[k][j] + c
      end
    end
  end
end
puts ans - 1

Measured memory_bytes: 66728
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 500010

/* Binary Indexed Tree(0-index) */

template<typename Type = int>
struct BIT {
  int bit_size;
  vector<Type> data;

  BIT(int n) {
    bit_size = n;
    data.assign(n + 2, 0);
  }

  //add x to kth value
  void add(int k, Type x) {
    k++;
    while (k <= bit_size) {
      data[k] += x;
      k += k & (-k);
    }
  }

  //sum of [0,k)
  Type query(int k) {
    Type rec = 0;
    while (k > 0) {
      rec += data[k];
      k -= k & (-k);
    }
    return rec;
  }

  //sum of [a, b)
  Type query(int a, int b) {
    return query(b) - query(a);
  }
};

int main() {
  int N, Q;
  char S[SIZE];

  scanf("%d%s%d", &N, S, &Q);

  vector<BIT<ll>> bit(26, BIT<ll>(N));

  for (int i = 0; i < N; i++) {
    bit[S[i] - 'a'].add(i, 1);
  }

  for (int i = 0; i < Q; i++) {
    int q;
    scanf("%d", &q);

    if (q == 1) {
      int p;
      char c;
      scanf("%d %c", &p, &c);
      p--;
      bit[S[p] - 'a'].add(p, -1);
      bit[c - 'a'].add(p, 1);
      S[p] = c;
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      l--;
      int ans = 0;

      for (int i = 0; i < 26; i++) {
        ans += !!bit[i].query(l, r);
      }

      printf("%d\n", ans);
    }
  }

  return 0;
}


Measured memory_bytes: 106240
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
#define s second
unordered_map<char,vector<string>> adj;
vector<ll> vis(100005,0);
vector<ll> p(100005,0);
ll c[100005];
/*void dfs(ll node,ll len)
{
	if(len==n)
	{
		ans++;
		return;
	}
	for(auto str:adj[node])
		dfs(str[0],len+1);
}*/
int main()
{
  string s,t;
  cin>>s>>t;
  ll mn=1e9;
  ll i,j=0,k;
  for(i=0;i<=(s.size()-t.size());i++)
      {
          k=i;
          ll cnt=0;
          for(j=0;j<t.size();j++)
          {
               if(s[k]!=t[j])
                  cnt++;
                k++;
          } 
          mn=min(mn,cnt);
      }
      cout<<mn;
}

Measured memory_bytes: 4648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner	sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		if(a + b <= 2 * c) {
			System.out.println(a * x + b * y);
		} else {
			int maisuABmax = Math.max(x, y) * 2;
			int maisuABmin = Math.min(x, y) * 2;
			int xx = Math.max(0, x - maisuABmax / 2);
			int yy = Math.max(0, y - maisuABmax / 2);
			int xxx = Math.max(0, x - maisuABmin / 2);
			int yyy = Math.max(0, y - maisuABmin / 2);
			if(maisuABmax * c + a * xx + b * yy <= maisuABmin * c + a * xxx + b * yyy) {
				System.out.println(maisuABmax * c + a * xx + b * yy);
			} else {
				System.out.println(maisuABmin * c + a * xxx + b * yyy);
			}
		}
	}
}


Measured memory_bytes: 23764