akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;

public class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt();
        int idCount = 0;
        int[][] ids = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i < j) {
                    ids[i][j] = idCount;
                    idCount++;
                }
            }
        }

        final int[][] expected = new int[n][n - 1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n - 1; j++) {
                expected[i][j] = in.nextInt() - 1;
            }
        }

        final BiFunction<Integer, Integer, Integer> toId = (from, to) -> {
            if (from < to) {
                return ids[from][to];
            }
            return ids[to][from];
        };

        final Map<Integer, List<Integer>> routes = new HashMap<>();
        for (int i = 0; i < n; i++) {
            for (int j = 1; j < n - 1; j++) {
                final int id = toId.apply(i, expected[i][j]);
                final int prevId = toId.apply(i, expected[i][j - 1]);
                routes.compute(id, (key, value) -> {
                    if (value == null) {
                        value = new ArrayList<>();
                    }
                    value.add(prevId);
                    return value;
                });
            }
        }
        final int[] dp = new int[(n * n - 1) / 2];
        final boolean[] visited = new boolean[(n * n - 1) / 2];
        final boolean[] computed = new boolean[(n * n - 1) / 2];

        final Function<Integer, Integer> dfs = new Function<Integer, Integer>() {
            @Override
            public Integer apply(Integer node) {
                if (dp[node] != 0) {
                    return dp[node];
                }

                if (visited[node] && !computed[node]) {
                    return -1;
                }
                visited[node] = true;

                if (routes.get(node) == null) {
                    dp[node] = 1;
                } else {
                    int result = 1;
                    for (Integer id : routes.get(node)) {
                        Integer subResult = apply(id);
                        if (subResult == -1) {
                            return -1;
                        }
                        result = Math.max(result, subResult + 1);
                    }
                    dp[node] = result;
                }
                computed[node] = true;
                return dp[node];
            }
        };

        int result = Integer.MIN_VALUE;
        for (int i = 0; i < (n * n - 1) / 2; i++) {
            final int r = dfs.apply(i);
            if (r == -1) {
                System.out.println(-1);
                return;
            }
            result = Math.max(result, r);
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 306896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(b,a*n)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>
#include <set>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  int X, Y, A, B, C;

  cin >> X >> Y >> A >> B >> C;
  
  vector<int> P, Q, R;

  P.reserve(A);
  Q.reserve(B);
  R.reserve(C+X+Y);
  
  for (int a=0; a<A; ++a) {
    int p;
    cin >> p;
    P.push_back(p);
  }

  std::sort(P.begin(), P.end(), greater<int>());

  for (int b=0; b<B; ++b) {
    int q;
    cin >> q;
    Q.push_back(q);
  }

  std::sort(Q.begin(), Q.end(), greater<int>());
  
  for (int c=0; c<C; ++c) {
    int r;
    cin >> r;
    R.push_back(r);
  }

  R.insert(R.end(), P.begin(), P.begin()+X);
  R.insert(R.end(), Q.begin(), Q.begin()+Y);
  
  std::sort(R.begin(), R.end(), greater<int>());

  uint64_t ans = 0;
  for (int xy=0; xy<X+Y && xy<R.size(); xy++) {
    ans += R[xy];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

void Trace(vector<pair<char, char> > card)
{
    for(int i = 0; i < card.size(); i++) {
        if (i) {
            cout << " ";
        }
        cout << card[i].first << card[i].second;
    }
    cout << endl;
}

void BubbleSort(vector<pair<char, char> >& card)
{
    bool flag = true;
    for (int i = 0; flag; i++) {
        flag = false;
        for (int j = card.size() - 1; j >= i + 1; j--) {
            if (card[j].second < card[j - 1].second) {
                swap(card[j], card[j - 1]);
                flag = true;
            }
        }
    }
}

void SelectionSort(vector<pair<char, char> >& card)
{
    for (int i = 0; i < card.size(); i++) {
        int minj = i;
        for (int j = i; j < card.size(); j++) {
            if (card[j].second < card[minj].second) {
                minj = j;
            }
        }
        if(minj != i) {
            swap(card[i], card[minj]);
        }
    }
}

string IsStable(vector<pair<char, char> > v1, vector<pair<char, char> > v2)
{
    for (int i = 0; i < v1.size(); i++) {
        vector<pair<char, char> > vi1, vi2;
        for (int j = 0; j < v1.size(); j++) {
            char ref = v1[i].second;
            if (v1[j].second == ref) {
                vi1.push_back(v1[j]);
            }
            if (v2[j].second == ref) {
                vi2.push_back(v2[j]);
            }
        }
        if (vi1 != vi2) {
            return "Not stable";
        }
    }

    return "Stable";
}

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

    vector<pair<char, char> > card1, card2, card3;

    for (int i = 0; i < n; i++) {
        char c1, c2;
        cin >> c1 >> c2;
        card1.push_back(make_pair(c1, c2));
        card2.push_back(make_pair(c1, c2));
        card3.push_back(make_pair(c1, c2));
    }

    BubbleSort(card2);
    Trace(card2);
    cout << IsStable(card1, card2) << endl;

    SelectionSort(card3);
    Trace(card3);
    cout << IsStable(card1, card3) << endl;

    return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define mp make_pair
#define pii pair<int,int>

using namespace std;

const int nax = 2e5 + 5;

int cnt[nax];

int a[nax];
int b[nax];
int n;

void ans()
{
    for(int i=1;i<=n;i++) cout<<b[i]<<" ";
    cout<<endl;
    exit(0);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    for(int i=1;i<=n;i++) cnt[a[i]]++;
    for(int i=1;i<=n;i++) cnt[b[i]]++;

    for(int i=1;i<=n;i++)
    {
        if(cnt[i] > n)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    reverse(b + 1,b + n + 1);
    int col = 0;
    int wa = -1;
    for(int i=1;i<=n;i++)
    {
        if(a[i] == b[i])
        {
            wa = a[i];
            col++;
        }
    }
    if(!col) ans();

    int lo1,hi1,lo2,hi2;
    for(int i=1;i<=n;i++)
    {
        if(a[i] == wa) hi1 = i;
        if(b[i] == wa) hi2 = i;
    }
    for(int i=n;i>=1;i--)
    {
        if(a[i] == wa) lo1 = i;
        if(b[i] == wa) lo2 = i;
    }

    int lo = max(lo1,lo2);
    int hi = min(hi1,hi2);
    int wa_lo = min(lo1,lo2);
    int wa_hi = max(hi1,hi2);
    int pos = 0;
    int done = 0;
    while(col)
    {
        pos++;
        while(pos >= wa_lo && pos <= wa_hi) pos++;

        swap(b[pos],b[lo + done]);

        col--;
        done++;
    }

    ans();
    return 0;

}



Measured memory_bytes: 5900
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int p[110];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	int ret=0;
	while(1){
		bool ok=true;
		for(int i=0;i<a;i++){
			if(p[i]){
				ok=false;
				for(int j=i;j<a;j++){
					if(p[j]==0)break;
					p[j]--;
				}
				break;
			}
		}
		if(ok)break;
		ret++;
	}
	printf("%d\n",ret);
}

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

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl

int main() {
  string s;
  cin >> s;

  // c-'0'
  int rep = 1000;
  FOR(i, 0, s.length() - 2) {
    int tmp = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
    CHMIN(rep, abs(753 - tmp));
  }

  cout << rep << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define ll long long
#define gc getchar()
using namespace std;
#define mem(a,b) memset(a,b,sizeof a)
#define upf(i,a,b) for(int i=a,i##e=b;i<=i##e;++i)
#define fup(i,a,b) for(int i=a,i##e=b;i<i##e;++i)
#define hh putchar(10)


class FIO
{
public:
	template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }
	template<typename T>FIO& operator <<(T x){ _W(x);return *this; }
private:
	char f,c,a[26],i;
	template<typename T>inline void _R(T& x)
	{
		for(f=0;(c=getchar())<48;c==45&&(f=1));
		for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));
		if(f)x=-x;
	}
	template<typename T>inline void _W(T x)
	{
		if(sizeof(x)==1){ putchar(x);return; }
		if(x<0)putchar(45),x=-x;
		if(x>99) {
			for(i=0;x;x/=10)a[i++]=x%10;
			while(i--)putchar(a[i]+48);
		} else if(x>9)putchar(x/10+48),putchar(x%10+48);
		else putchar(x+48);
	}
}io;

char ch,fh;
template<class T>inline void zin(T& x) {
	for(fh=0;(ch=getchar())<48;ch==45&&(fh=1));
	for(x=ch^48;(ch=getchar())>47;)x=(x<<3)+(x<<1)+(ch^48);
	if(fh)x=-x;
} void qin(){}
template<class T,class...U>
void qin(T& head,U&...tail){zin(head);qin(tail...);}



char mp[106][106],bookh[106],bookw[106];

int main()
{
	int h,w;
	io>>h>>w;
	fup(i,0,h)scanf("%s",mp[i]);
	for(int i=0,j;i<h;++i)
	{
		j=0;
		while(mp[i][j]=='.'&&j<w)++j;
		if(j==w)bookh[i]=1;
	}
	for(int i=0,j;i<w;++i)
	{
		j=0;
		while(mp[j][i]=='.'&&j<h)++j;
		if(j==h)bookw[i]=1;
	}
	/*
	for(int i=0;i<h;++i)printf("%d",bookh[i]);hh;
	for(int i=0;i<w;++i)printf("%d",bookw[i]);hh;
	*/
	fup(i,0,h) {
		if(bookh[i])continue;
		fup(j,0,w) {
			if(bookw[j])continue;
			putchar(mp[i][j]);
		}hh;
	}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int h,w;
	char a[10][10];
	cin>>h>>w;
	int ma=0;
	rep(i,h){
		rep(j,w){
			cin>>a[j][i];
			if(a[j][i]=='#'&&j<ma){
				cout<<"Impossible"<<endl;
				return 0;
			}
			if(a[j][i]=='#')ma=j;
		}
	}
	cout<<"Possible"<<endl;
	return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2")
#pragma GCC optimize ("trapv")


#include <bits/stdc++.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);
//#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rep(i, a, b) for(lli i = a; i < (b); ++i)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define what_is(x) cerr << #x << " is " << x << endl;
#define wis cout<<endl<<"I already speak english, bitch"<<endl<<endl;

typedef long long int lli;
typedef vector<lli> vi;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef pair<ii,lli> iii;

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


int main(){
    fastio;
    lli n,k; cin>>n>>k;
    vi v(n); rep(i,0,n) cin>>v[i];
    lli wyn=1e17;
    rep(i,0,n-k+1){
        if(v[i]<=0 and v[i+k-1]>=0){
            //cuando es un mix de una parte negativa y una parte positiva
            wyn=min({wyn,2*abs(v[i])+v[i+k-1],2*v[i+k-1]+abs(v[i])});
        }else if(v[i]<0 and v[i+k-1]<0){
            //cuando todo está en el lado negativo
            wyn=min(wyn,abs(v[i]));
        }else{
            //cuando todo está en el lado positivo
            wyn=min(wyn,v[i+k-1]);
        }
    }
    cout<<wyn<<endl;

    return 0;
}


Measured memory_bytes: 3992
# coding: UTF-8
# sample code

v = list(map(int, input().split()))
n, k = v[0], v[1]

result = 0
for i in range(n):
	p = 1/n
	need = 0
	num = i+1
	while True:
		if num >= k :
			break
		else :
			num *= 2
			need += 1
	p *= pow(1/2, need)
	result += p

print(result)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>

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

using namespace std;

int map[51][51];
int w,h;

void dfs(int x,int y) {
	map[x][y]=0;
	for(int i=-1;i<=1;i++) {
		for(int j=-1;j<=1;j++) {
			int nx = x+i;
			int ny = y+j;
			if(0<=nx&&nx<w && 0<=ny&&ny<h && map[nx][ny]==1)
				dfs(nx,ny);
		}
	}


}

void solve() {
	rep(i,51) rep(j,51) map[i][j]=0;

	rep(i,w) rep(j,h) cin>>map[i][j];

	int ans=0;
	rep(i,w) rep(j,h) {
		if(map[i][j]==1) {
			dfs(i,j);
			ans++;
		}
	}
	cout<<ans<<endl;
}

int main() {

	while (cin>>h>>w)
	{
		if(h+w==0) return 0;
		solve();

	}

	return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
   ll n,c=1;
   cin>>n;
   string s[n];
   for(int i=0;i<n;i++)
      cin>>s[i];
   sort(s,s+n);
   for(int i=0;i<n-1;i++)
     {
         if(s[i]!=s[i+1])
          c++;
     }
     cout<<c;
}

Measured memory_bytes: 9880
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    n--;
    ll odd = n/2+n%2,even = n/2,s = abs(a-b),k = abs(c-d);
    bool ok = 0;
    rep(i,n+1){
        if (n%2 == 0 && i == 0){
            if (k*even >= s) ok = 1;
        }
        else if (n%2 == 0 && i%2 == 0){
            if (c*i-k*(even-i/2) <= s && s <= d*i+k*(even-i/2)) ok = 1;
        }
        else if (n%2 == 1 && i%2 == 1){
            if (c*i-k*(odd-i/2-1) <= s && s <= d*i+k*(odd-i/2-1)) ok = 1;
        }
    }
    if (ok) PRINT("YES");
    else PRINT("NO");
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
#define ll long long int  
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
 
 
using namespace std;

int cnt[1000005],a[1000005];
int gcd(int a,int b)
{
    if(a%b==0) return b;
    return gcd(b,a%b);
}

int main() {
    int n,f1=1;
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<=n;i++){
        int t=a[i];
        for(int j=2;j*j<=t;j++)
        {
            if(t%j==0)
            {
                while(t%j==0) t/=j;
                cnt[j]++;
                if(cnt[i]>1)
                {
                    f1=0;
                    break;
                }
            }
        }
        if(t>1){
            cnt[t]++;
            if(cnt[t]>1)
            {
                f1=0;
                break;
            }
        }
        if(f1==0) break;
    }
    if(f1){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    int now=a[1];
    for(int i=2;i<=n;i++) 
        now=gcd(now,a[i]);
    if(now==1) 
        cout<<"setwise coprime"<<endl;
    else 
        cout<<"not coprime"<<endl;
    return 0;
}

Measured memory_bytes: 7876
#include<iostream>
using namespace std;
int main()
{
    long long int n,c=0;
    cin>>n;
    if(n<10)

    {
        cout<<n<<endl;
        return 0;
    }
    if(n>=10)
    {
        c+=9;
    }
    if(n>=100&&n<1000)
    {
        c+=(n-99);
    }
    if(n>=1000)
    {
        c+=900;
    }

    if(n>=10000&&n<100000)
    {
       c+=(n-9999);
    }
    if(n>=100000)
    {
        c+=90000;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 256
k = int(input())
lunlun = list(range(1, 10))

for i in range(k-1):
    a = lunlun[i]
    b = a * 10 +  a % 10 
    if a % 10 != 0:
        lunlun.append(b - 1)
    lunlun.append(b)
    if a % 10 != 9:
        lunlun.append(b + 1)

print(lunlun[k-1])

Measured memory_bytes: 15768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
const ll inf = 1e9+10;
 
 
char s[maxN];
int main() {
	unordered_map<char,int> mp[2];
	mp[1]['R'] = 1;
	mp[1]['U'] = 1;
	mp[1]['D'] = 1;
	
	mp[0]['L'] = 1;
	mp[0]['U'] = 1;
	mp[0]['D'] = 1;
	
	scanf("%s",s+1);
	int n = strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		if(mp[i%2][s[i]] == 1)continue;
		else
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli a, b;
    cin2(a,b);
    if (a >= 10 || b >= 10)
        cout << -1 << endl;
    else
        cout << a*b << endl;

}


Measured memory_bytes: 256
import Control.Monad.Primitive (PrimState)
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as MV
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
 
main :: IO ()
main = do
    _ <- B.getLine
    vs <- V.fromList . map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let vmin = V.minimum vs
        vmax = V.maximum vs
    mv <- MV.replicate (vmax - vmin + 3) 0 :: IO (MV.MVector (PrimState IO) Int)
    V.forM_ vs $ \i -> MV.unsafeModify mv succ (i + 1 - vmin)
    v <- V.unsafeFreeze mv
    let v1 = v
        v2 = V.tail v1
        v3 = V.tail v2
    print $ V.maximum $ V.zipWith3 (\x y z -> x + y + z) v1 v2 v3

Measured memory_bytes: 4988
#include <bits/stdc++.h>
//#pragma GCC diagnostic warning "-std=c++11"
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e18+100))
#define MX ((ll)(1e6+90))
#define ARRS ((ll)(2e5+100))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 21






ll a[5];
int main(){
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	//cout<<(a[2]+a[2]&1);
	if((a[0]+a[1]+a[2])&1){
		cout<<((a[2]+(1^(a[2]&1)))*3-a[0]-a[1]-a[2])/2;
	}
	else
	cout<<((a[2]+(a[2]&1))*3-a[0]-a[1]-a[2])/2;
}






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

ll a[300005];

int main(){
  ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
  int a, b, c; cin >> a >> b >> c;
  if(a==b&&b==c&&a%2==0) cout << -1;
  else{
    int cnt = 0;
    while(a%2==0&&b%2==0&&c%2==0){
      int aa = (b+c)/2;
      int bb = (a+c)/2;
      int cc = (a+b)/2;
      a = aa, b = bb, c = cc;
      cnt++;
    }
    cout << cnt;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	vector<pair<ll, bool>> visited(n);
	for (int i = 0; i < n; i++)
		visited[i].second = false;
	ll i = 0;
	ll count = 1;
	while (!visited[i].second) {
		visited[i].first = count;
		visited[i].second = true;
		if (count == k)
			break;
		i = a[i];
		count++;
	}
	int ans = 0;
	if (count == k) {
		cout << a[i] + 1 << endl;
		return 0;
	}
	ll roop = count - visited[i].first;
	ll other = visited[i].first;
	k -= other;
	k %= roop;
	for (int i = 0; i < other + k; i++)
		ans = a[ans];
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 8012
h,w=map(int,input().split())

s=[]
for i in range(h):
    s.append(list(input()))

l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]

for i in range(h):
    f=0
    for j in range(w):
        if s[i][j]=='#':
            f=0
            l[i][j]=0
        else:
            f+=1
            l[i][j]=f
            
for i in range(h):
    f=0
    for j in range(w-1,-1,-1):
        if s[i][j]=='#':
            f=0
            r[i][j]=0
        else:
            f+=1
            r[i][j]=f
            
for j in range(w):
    f=0
    for i in range(h):
        if s[i][j]=='#':
            f=0
            u[i][j]=0
        else:
            f+=1
            u[i][j]=f
    
for j in range(w):
    f=0
    for i in range(h-1,-1,-1):
        if s[i][j]=='#':
            f=0
            d[i][j]=0
        else:
            f+=1
            d[i][j]=f

ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)
print(ans)

Measured memory_bytes: 309512
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;
 
void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}
 
const int N=2e6+3,M=5e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;
 
int n,m,k,tc,ans,a[N];
 
char s[N];

int main(){
    scanf("%d",&n);
    if (n>=30)
        printf("Yes\n");
    else
        printf("No\n"); 
}


Measured memory_bytes: 3660
n,m=map(int,input().split())
from collections import Counter as co
d=co(list(map(int,input().split())))
for i in range(m):
    b,c=map(int,input().split())
    if c in d:d[c]+=b
    else:d[c]=b
f=sorted(d.items(),reverse=1)

now =0
s=0
for k,v in f:
    if now+v<=n:
        now+=v
        s+=k*v
    else:
        
        print(s+(n-now)*k);exit()


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

int main(){
  int n;
  cin>>n;
  int data[n][2];
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> data[i][j];
    }
  }
  for(int i=0;i<n;i++){
    if(data[i][0]!=data[i][1]){
      continue;}
    if(data[i][0]==data[i][1]){
       if(data[i+1][0]==data[i+1][1]){
         if(data[i+2][0]==data[i+2][1]){
          cout<<"Yes"<<endl;
         return 0;}}}
    }
      if(data[n-1][0]!=data[n-1][1]){
    cout<<"No"<<endl;}
  else if(data[n-2][0]!=data[n-2][1]){
    cout<<"No"<<endl;}
  else if(data[n-3][0]!=data[n-3][1]){
    cout<<"No"<<endl;}
}

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

int main() {
  string s;
  cin >> s;
  rep(i,s.size()){
    cout << 'x';
  }
  cout << endl;

  return 0;
}


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

#define is_uruu main
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
    
int is_uruu() {
	int A,B,count=0;
    cin >> A >> B;
    FOR(i,A,B+1){
    	if(i/10000 == i%10 && (i/1000)%10 == (i%100)/10)count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = 10 ** 9
MOD = 10 ** 9 + 7

def main(): 
    n,k = map(int,input().split())
    v = list(map(int,input().split()))
    
    
    ans = 0
    for l in range(n+1):
        for r in range(n-l,-1,-1):
            take = k - r - l
            if take < 0:
                continue
            tot = sum(v[:l])
            if r != 0:
                tot += sum(v[-r:])
            
            if take == 0:
                ans = max(ans,tot)
            else:
                minus = []
                for i in range(l):
                    if v[i] < 0:
                        minus.append(v[i])
                for i in range(n-1,n-r-1,-1):
                    if v[i] < 0:
                        minus.append(v[i])
                minus.sort()
                tot -= sum(minus[:take])
                ans = max(ans,tot)
    
    print(ans)
   
if __name__=='__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> a;

  FOR(i, 1, 10) {
    if(a % i == 0 && a / i < 10) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int N, X, L[N], cnt = 0, tmp = 0, ans = 1;
  cin >> N >> X;
  for(int i = 0; i < N; i++) {
    cin >> L[i]; 
  }
  while((tmp += L[cnt]) <= X) {
    ans++;
    cnt++;
    if(N <= cnt) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new AOJ1148().doIt();
	}

	class AOJ1148{
		void doIt(){
			while(true){
				int n = in.nextInt();
				int m = in.nextInt();
				if(n+m==0)break;
				Student student[] = new Student[m];
				for(int i=0;i<m;i++)student[i] = new Student();
				int l = in.nextInt();
				Log[] log = new Log[l];
				for(int i=0;i<l;i++)log[i] = new Log(in.nextInt(), in.nextInt(), in.nextInt(),in.nextInt());
				for(int i=0;i<l;i++){
					if(log[i].sw==1)student[log[i].student-1].get_start(log[i].time);
					else if(log[i].sw==0)student[log[i].student-1].reload(log[i].time);
				}
				int q = in.nextInt();
				for(int i=0;i<q;i++){
					int start = in.nextInt();
					int end = in.nextInt();
					int s = in.nextInt();
					System.out.println(student[s-1].question(start, end));
				}
			}
		}

		class Student{
			boolean[]  memo;
			LinkedList<Integer> start;
			public Student() {
				memo = new boolean[720];
				start = new LinkedList<Integer>();
			}

			int question(int start,int end){
				int result = 0;
				for(int i=start;i<end;i++)if(memo[i-540])result++;
				return result;
			}

			void get_start(int start){
				this.start.add(start);
			}

			void reload(int end){
				int st = start.remove();
				for(int i=st;i<end;i++)memo[i-540] = true;
			}
		}

		class Log{
			int time,pc,student,sw;
			public Log(int t,int pc,int s,int sw) {
				this.time = t;
				this.pc = pc;
				this.student = s;
				this.sw =sw;
			}
		}
	}

}

Measured memory_bytes: 69184
#include <iostream>
using namespace std;
 
int
main(int argc, char *argv[])
{
        int a,b,sum=0;
        cin >> a;
        cin >> b;
		int i=0;
		while(i<2){
			if(a>b){
				sum = sum + a;
				a--;
			}else{
				sum = sum + b;
				b--;
			}
			i++;
		}
        cout << sum << endl;

        return 0;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MAX = 2000000;
const ll MOD = 1000000007;
ll x, y;

ll fac[MAX], finv[MAX], inv[MAX];

void comInit() {
    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;
    }
}

ll com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    comInit();
    cin >> x >> y;
    ll ways = 0;
    bool cond1 = ((x+y)%3==0);
    bool cond2 = (x <= 2 * y);
    bool cond3 = (2 * x >= y);
    bool cond = cond1&&cond2&&cond3;
    if(cond){
        ll nthis = (x+y)/3;
        ll kthis = x-nthis;
        ways = com(nthis, kthis);
    }
    cout << ways << endl;
}

Measured memory_bytes: 47104
#include <cstdio>
#include <vector>
using namespace std;

int main() {
	char i_mark, o_mark;
	int i_rank, n,ma['S'+1],mb[4];
	ma['S'] = 0, ma['H'] = 1, ma['C'] = 2, ma['D'] = 3;
	mb[0] = 'S', mb[1] = 'H', mb[2] = 'C', mb[3] = 'D';
	(void)scanf("%d", &n);
	vector<vector<bool> > v(4, vector<bool>(13, 0));
	for (int i = 0; i < n; i++) {
		(void)scanf("%*c%c %d", &i_mark, &i_rank);
	     v[ma[i_mark]][i_rank - 1] = 1;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (!v[i][j]) printf("%c %d\n", mb[i], j + 1);
		}
	}
	return 0;
}


Measured memory_bytes: 2620
n, t = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[0] * t for _ in range(n)]
ans = 0
a.sort()
for i in range(n-1):
    for j in range(t):
        if j - a[i][0] < 0:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - a[i][0]] + a[i][1])
    ans = max(ans, dp[i + 1][-1] + a[i+1][1])
print(ans)

Measured memory_bytes: 144616
import java.util.*;
class Main{
  public static void main(String []args){
    Scanner x=new Scanner(System.in);
    String table="abcdefghijklmnopqrstuvwxyz";
    loop:while(x.hasNext()){
      String s=x.nextLine();
      int c=0;
      for(;c<table.length();c++){
        char []p=s.toCharArray();
        int i=0;
        for(;i<s.length();i++)
          if(table.indexOf(p[i])!=-1)p[i]=table.charAt( (table.indexOf(p[i])+c)%table.length() );
        String r=new String(p);
        if(r.indexOf("the")!=-1||r.indexOf("this")!=-1||r.indexOf("that")!=-1){
          System.out.println(r);
          continue loop;
        }
      }
    }
  }
}

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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long n; cin >> n;
    if(n>= 30){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int t[100000];

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    t[A]++;
    t[B+1]--;
    t[C]++;
    t[D+1]--;
    for (int i=1; i<=1000; ++i) {
        t[i] += t[i-1];
        if (t[i] > 2) t[i] = 2;
    }
    int ans = 0;
    for (int i=0; i<=1000; ++i) {
        if (t[i] >= 2) ans++;
    }
    cout << max(0, ans-1) << endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(b, d) - max(a, c);
    if(ans < 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j,n,tmp;
  int fact[1000]={0};
  long result=1,divider=1000000007;
  
  scanf("%d",&n);
  
  for(i=2;i<=n;i++){
    tmp=i;
    j=2;
    while(tmp>1){
      if(tmp%j==0){
        fact[j-1]++;
        tmp=tmp/j;
        j=2;
      } else {
        j++;
      }
    }
  }
  
  for(i=0;i<1000;i++){
    result=(result*(fact[i]+1))%divider;
  }
  
  printf("%ld",result);
}

Measured memory_bytes: 1740
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int k;
	string s;
	cin>>k>>s;
	if(s.length()>k)
	{
		for(int i=0;i<k;i++)
		cout<<s[i];
		cout<<"...";
	}
	else
	cout<<s;
} 

Measured memory_bytes: 3568
import math
n,d = map(int,input().split())
#左から純に配置．d+1,3*d+2,,(2i-1)*d+i
#iばんめの人...(2i)*d+iまで見れる．これがn以上
for i in range(1,n+1):
    if 2*i*d+i >= n:
        print(i)
        break

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("ip1.txt", "r", stdin);
  freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
  return (a.second < b.second);
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int prime(int n) {
  int flag = 1;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {flag = 0; break;}
  }
  return flag;
}
int power(int x, int y)
{
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
  else
    return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}

int32_t main()
{
  k_007();
  int p, n;
  cin >> p >> n;
  int a[n];
  f(i, n) cin >> a[i];

  int pre[n];
  int suff[n];
  pre[0] = a[0] - 0;
  suff[n - 1] = p - a[n - 1];
  for (int i = 1; i < n; i++)
  {
    pre[i] = pre[i - 1] + abs(a[i] - a[i - 1]);
  }

  for (int i = n - 2; i >= 0; i--)
  {
    suff[i] = suff[i + 1] + abs(a[i] - a[i + 1]);
  }
  int ans = inf;
  for (int i = 0; i < n - 1; i++)
  {
    ans = min(ans, pre[i] + suff[i + 1]);
  }

  ans = min(ans, pre[n - 1] - pre[0]);
  ans = min(ans, suff[0] - (suff[n - 1]));

  cout << ans << endl;
}


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

main()
{
    int n; cin>>n;
    long long ans=0;
    for(int i=1;i<=n;++i)
    {
        if(i%3 and i%5)
        {
            ans+=i;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3616
fun main(args: Array<String>) {
    abc124d()
}

fun abc124d() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!.map { it == '1' }.toBooleanArray()

    val list = mutableListOf(s[0] to 1)

    for (i in 1 until n) {
        if (s[i] == s[i - 1]) {
            list[list.lastIndex] = list[list.lastIndex].first to list[list.lastIndex].second + 1
        } else {
            list.add(s[i] to 1)
        }
    }

    val cSum = IntArray(list.size + 1)
    for (i in 0 until list.size) cSum[i + 1] = cSum[i] + list[i].second

    val answer = list.mapIndexed { index, pair ->
        val take = 2 * k + if (pair.first) 1 else 0
        val takeIndex = Math.min(cSum.lastIndex, index + take)
        cSum[takeIndex] - cSum[index]
    }.max()!!

    println(answer)
}


Measured memory_bytes: 41780
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort()
c = Counter(a)
m = max(a) + 1
dp = [False]*m
ans = 0
for ai in a:
    if dp[ai]:
        continue
    if c[ai] == 1:
        ans += 1
    for i in range(ai, m, ai):
        dp[i] = True
print(ans)


Measured memory_bytes: 38264
#include <iostream>
using namespace std;
int selectionSort(int A[], int N){
    int i, j, s=0, tmp, minj;
    for(i=0; i<N-1; i++){
        minj = i;
        for(j=i; j<N; j++){
            if(A[j]<A[minj]) minj = j;
        }
        tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
        
        if(i != minj) s++;
    }
    return s;
}

int main(void){
    int N, s;
    int A[101];
    
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    
    s = selectionSort(A, N);
    
    for(int i=0; i<N; i++){
        if(i>0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << s << endl;
    
    return 0;
}



Measured memory_bytes: 3112
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeSet;

public class Main{
       
	public static void main(String[] args) {
		Scanner sdf = new Scanner(System.in);
		
                int t=1;
                while(t-->0){
                    int n=sdf.nextInt();
                    int r=sdf.nextInt();
                    if(n>=10){
                        System.out.println(r);
                        return;
                    }
                    r=r+100*(10-n);
                    System.out.println(r);
                        
                
                }                
        }
   


}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    //Fast Reader
        private static class FastReader {
            BufferedReader br;
            StringTokenizer st;

            public FastReader() {
                br = new BufferedReader(new InputStreamReader(System.in));
            }

            public String next() {
                while (st == null || !st.hasMoreElements()) {
                    try {
                        st = new StringTokenizer(br.readLine());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            public void resetST() {
                st = null;
            }

            public int nextInt() {
                return Integer.parseInt(next());
            }

            public long nextLong() {
                return Long.parseLong(next());
            }

            public double nextDouble() {
                return Double.parseDouble(next());
            }

            public float nextFloat() {
                return Float.parseFloat(next());
            }

            public String nextLine() {
                String str = "";
                try {
                    str = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                st = null;
                return str;
            }

            public int[] nextIntArray(int size) {
                int[] arr = new int[size];
                for (int i = 0; i < size; i++) {
                    arr[i] = nextInt();
                }
                return arr;
            }

            public long[] nextLongArray(int size) {
                long[] arr = new long[size];
                for (int i = 0; i < size; i++) {
                    arr[i] = nextLong();
                }
                return arr;
            }

            public double[] nextDoubleArray(int size) {
                double[] arr = new double[size];
                for (int i = 0; i < size; i++) {
                    arr[i] = nextDouble();
                }
                return arr;
            }
        }
    public static void main(String[] args)
    {
        FastReader sc = new FastReader();
        PrintWriter pr = new PrintWriter(System.out);
        long n =sc.nextInt();
        long k=n%1000;
        if(k==0)
        {
            pr.println("0");
        }
        else
        {
            pr.println(1000-k);
        }
        pr.close();
	// write your code here
    }
}


Measured memory_bytes: 32900
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main () {
   int n;
   int t[123456],x[123456],y[123456];
   cin>>n;
   for(int i=0;i<n;i++)
   {
    cin>>t[i]>>x[i]>>y[i];
   }
   int flag=0;
   int cx=0,cy=0,ct=0;
   for(int i=0;i<n;i++)
   {
      int d=abs(x[i]-cx)+abs(y[i]-cy);
      int dt=t[i]-ct;
      if(dt<d)
      {
        flag=1;
        break;
      }
       if((dt-d)%2)
      {
        flag=1;
        break;
      }
      cx=x[i],cy=y[i],ct=t[i];
   }
   if(flag)
   {
    cout<<"No"<<endl;
   }
   else
    cout<<"Yes"<<endl;
   return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <fstream>

using namespace std;

int const NMAX = 1e6;
bool freq[1 + NMAX];

int main() {

  int n, m = 0, ans = 0;
  cin >> n >> m >> ans;
  if(n > ans || n + m < ans){
    cout << "NO";
  }else{
    cout << "YES";
  }
  return 0;
}


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

int main(void)
{
	int N,L;

	cin >> N >> L;

	int ans = N * ( L + ( N + L - 1 ) ) / 2;
	
	if (!(0 > L && 0 < (N + L - 1)))
	{
		if (0 < L)
		{
			ans -= L;
		}
		else if ((N + L - 1) < 0)
		{
			ans -= (N + L - 1);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define deb(var) "[" << (#var) << " : " << var <<"]" << " "
#define debv(v) "[" << (#v) << " : {";for(int i = 0; i < v.size() - 1; ++i)\
					cout << v[i] <<", ";cout << v.back() << "}] "
#define deba(a,n) "[" << (#a) << " : {";for(int i = 0; i < n - 1; ++i)\
					cout << a[i] << ", ";cout << a[n - 1] << "}] "
#define debp(p) "[" << (#p) << " : {" << p.first << ", " << p.second << "}] "
#define debs(s) "[" << (#s) << " : {";auto _itr = s.begin();\
					for(int k = s.size(); k > 1; --k) {cout << *_itr << ", "; ++_itr;} cout << *_itr << "}] "

typedef long long ll;

/*LETS BEGIN WITH THE NAME OF LORD MAHADEV*/
const int mxN = 2e5;
int ar[mxN];
bool dp[1000001];

int main(){
	int n, mx = -2e9; 
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> ar[i];
		mx = max(mx, ar[i]);
	}
	memset(dp, true, sizeof(dp));
	sort(ar, ar + n);
	
	for(int i = 0; i < n; ++i){
		if(dp[ar[i]]){
			if(i != n-1 && ar[i] == ar[i + 1]){
				dp[ar[i]] = false;
			}
			for(int j = 2 * ar[i]; j <= mx; j += ar[i]){
				dp[j] = false;
			}
		}
	}

	int ans = 0;
	for(int i = 0; i < n; ++i){
		if(dp[ar[i]]){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5348