akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int a[N],b[N],c[N],d[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> c[i] >> d[i];
  }
  vector<int> Can[N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (a[i] < c[j] && b[i] < d[j]) {
        Can[i].push_back(j);
      }
    }
  }
  bool Pair[N];
  for (int i = 0; i < N; i++) Pair[i] = false;
  int K[N];
  for (int i = 0; i < N; i++) K[i] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < (int)Can[i].size(); j++) {
      K[Can[i][j]]++;
    }
  }
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j < N; j++) {
      if ((int)Can[j].size() == i) {
        int min_K = 999999;
        int where = -1;
        for (int k = 0; k < (int)Can[j].size(); k++) {
          K[Can[j][k]]--;
          if (!Pair[Can[j][k]]) {
            if (min_K > K[Can[j][k]]) {
              min_K = K[Can[j][k]];
              where = Can[j][k];
            }
          }
        }
        if (where == -1) {
          continue;
        }
        Pair[where] = true;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (Pair[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

const ll L = 1e1+5;

ll f[L][L];

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

    ll N;
    cin >> N;

    for(ll i=1; i <= N; i++)
    {
        ll temp = i;

        while(temp >= 10)
        {
            temp /= 10;
        }

        f[temp][i%10]++;
    }

    ll ans = 0;

    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            ans += (f[i][j] * f[j][i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
#define FOR(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0};

int bs_lower_bound(int a[], int n, int x) {
    int l = 0;
    int h = n; // Not n - 1
    while (l < h) {
        int mid = (l + h) / 2;
        if (x <= a[mid]) {
            h = mid;
        } else {
            l = mid + 1;
        }
    }
    return l;
}
void solve(){
	int n;
	cin>>n;
	int arr[n];
	FOR(i, 0, n)cin>>arr[i];
	sort(arr, arr+n);
	int cnt=0;
	FOR(i, 0, n) {
		FOR(j, i+1, n){
			int sum = arr[i]+arr[j];
			int index = bs_lower_bound(arr, n, sum);
			cnt+=index-j-1;	
		}
	}
	cout<<cnt;
}
signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> h(n);
  for (int i = 0; i < n; i++)
    cin >> h[i];
  sort(h.begin(), h.end());
  long long ans = 10000000000LL;
  for (int i = 0; i + k - 1 < n; i++) {
    ans = min(ans, h[i + k - 1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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 ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int m, d;
    cin >> m >> d;
    int ans = 0;
    rep(i, 1, m + 1)
    {
        rep(j, 1, d + 1)
        {
            int a, b;
            a = j / 10;
            b = j % 10;
            if (a >= 2 && b >= 2 && a * b == i)
            {
              //  cerr << i << " " << j << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 1e5 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;

void solve() {
	int n;
	cin >> n;
	vector <double> p(n);
	for (int i = 0; i < n; ++i)
		cin >> p[i];
	double dp[n + 1][n + 1];
	memset(dp, 0, sizeof dp);
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		dp[i + 1][0] = dp[i][0] * (1 - p[i]);
		for (int j = 1; j <= i + 1; ++j) {
			dp[i + 1][j] = dp[i][j]*(1 - p[i]) + dp[i][j - 1]*p[i];
		}
	}
	double ans = 0;
	for (int i = n/2 + 1; i <= n; ++i)
		ans += dp[n][i];
	cout << setprecision(12) << ans;
}
int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

Measured memory_bytes: 70656
#include <iostream>
#include <string>
#define s(w,x,y,z) swap(d[w],d[x]);swap(d[x],d[y]);swap(d[y],d[z]);break;
using namespace std;
int main(){
      string str;int tmp,i;
      while(cin>>tmp&&tmp){
            int d[]={1,5,3,2,4,6},ctn=1;
            for(i=0;i<tmp;i++){
                  cin>>str;
                  switch(str[0]){
                        case 'N':s(0,3,5,1);
                        case 'E':s(0,4,5,2);
                        case 'W':s(2,5,4,0);
                        case 'S':s(0,1,5,3);
                        case 'R':s(2,1,4,3);
                        case 'L':s(3,4,1,2);
                  }
                  ctn+=d[0];
            }
            cout<<ctn<<endl;
      }
}

Measured memory_bytes: 1204
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner str = new Scanner(System.in);
		String s = str.nextLine();
		int tcnt = 0, scnt = 0;
		for (int i = 0; i < s.length(); i++) {
			if (String.valueOf(s.charAt(i)).equals("S")) {
				scnt += 1;
			} else {
				if (scnt == 0) {
					tcnt += 1;
				} else {
					scnt -= 1;
				}
			}
		}
		System.out.println(tcnt + scnt);
		str.close();
	}
}


Measured memory_bytes: 24388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


//#define int ll

vector <int> x[200009];
int n,a,b;
int dist1[200009],dist2[200009];
int cnt1=0,cnt2=0;

void dfs1(int pos,int depth){
    if(dist1[pos]!=-1)return;
    dist1[pos]=depth;
    rep(i,0,x[pos].size()){
        dfs1(x[pos][i],depth+1);
    }
}

void dfs2(int pos,int depth){
    if(dist2[pos]!=-1)return;
    dist2[pos]=depth;
    rep(i,0,x[pos].size()){
        dfs2(x[pos][i],depth+1);
    }
}

signed main(){
    cin>>n;
    rep(i,0,200009)dist1[i]=dist2[i]=-1;
    rep(i,0,n){
        cin>>a>>b;
        x[a].pb(b);
        x[b].pb(a);
    }
    
    dfs1(1,0);dfs2(n,0);
    rep(i,1,n+1){
        if(dist1[i]<=dist2[i])cnt1++;
        else cnt2++;
    }
    
    if(cnt1>cnt2)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()
 
typedef long long ll;
typedef long double ld;
 
const int INF = 1e9;
const ld EPS = 1e-8;
 
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
 
int main(){
  int N, K, L;
  cin >> N >> K >> L;
  vector<int> p(K), q(K), r(L), s(L);
  REP(i,K) {
    cin >> p[i] >> q[i]; --p[i]; --q[i];
  }
  REP(i,L) {
    cin >> r[i] >> s[i]; --r[i]; --s[i];
  }
 
  UnionFind ufroad(N), ufline(N);
  REP(i,K) ufroad.unionSet(p[i], q[i]);
  REP(i,L) ufline.unionSet(r[i], s[i]);
  map<pair<int,int>,int> mp;
  REP(i,N) mp[make_pair(ufroad.root(i), ufline.root(i))] += 1;
  REP(i,N) {
    if(i) cout << " ";
    cout << mp[make_pair(ufroad.root(i), ufline.root(i))];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 15232
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] H = new long[N];
        for (int i = 0; i < N; i++) {
            H[i] = scan.nextLong();
        }
        H[0] -= 1;
        boolean solve = true;
        for (int i = 1; i < N; i++) {
            if (H[i-1] < H[i]) {
                H[i] -= 1;
            }
            if (H[i]<H[i-1]) {
                solve = false;
                break;
            }
        }
        System.out.println(solve ? "Yes" : "No");
    }
}


Measured memory_bytes: 52412
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int cost = 1e9;
  int N, T; cin >> N >> T;
  for (int i = 0; i < N; ++i) {
    int c, t; cin >> c >> t;
    if (t <= T) cost = min(cost, c);
  }
  if (cost == 1e9) cout << "TLE" << endl;
  else cout << cost << endl;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    for(i = 0;i < n;++i){
        cin >> v.at(i);
    }
    sort(all(v), greater<ll>());
    ll tmp = 0;
    for(i = 0;i < a;++i){
        tmp += v.at(i);
    }
    if(v.at(0) == v.at(a-1)){
        j = 0;
        while(j < n){
            if(v.at(j) != v.at(0)) break;
            else ++j;
        }
        vector<ll> nCk(j+1,1);
        for(i = 1;i <= j;++i){
            nCk.at(i) = nCk.at(i-1)*(j-i+1)/i;
        }
        
        ll num = 0;
        for(i = a;i <= min(j,b);++i){
            num += nCk.at(i);
        }
        cout << fixed << setprecision(10) << v.at(0) << endl;
        cout << num << endl;
    }else{
        ll left = 0, right = a-1;
        while(true){
            if(v.at(left) == v.at(a-1)) break;
            else ++left;
        }
        while(right < n){
            if(v.at(right) != v.at(a-1)) break;
            else ++right;
        }
        ll mn = right - left;
        vector<ll> nCk(mn+1,1);
        for(i = 1;i <= a - left;++i){
            nCk.at(i) = nCk.at(i-1)*(mn-i+1)/i;
        }
        double ans = (double)tmp/(double)a;
        cout << fixed << setprecision(10) << ans << endl;
        cout << nCk.at(a-left) << endl;
    }


    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i+=2){
        int yakusu = 0;
        for(int j = 1; j <= i; j++){
            if(i % j == 0){
                yakusu++;
            }
        }
        if(yakusu == 8){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  int a[10001];
  cin >> n ;
  for (int i=1; i<=n; i++){
      cin >> a[i] ;
  }
  int Max=-1000000;
  int min=1000000;
  long long sum=0;

  for(int i=1; i<=n; i++) {
    if(a[i] > Max) Max = a[i];
    if(a[i] < min) min = a[i];
    sum = sum + a[i];
  }

  //Max=a[n];
  //min=a[1];
  //sum=a
  
  cout << min << " " << Max << " " << sum << endl;
  
}



Measured memory_bytes: 3144
#pragma GCC optimize("Ofast", "unroll-loops")

#pragma GCC target("popcnt,abm,mmx,tune=native")

#include <bits/stdc++.h>

#define ll int64_t

#define fi first

#define se second

#define pb push_back

#define sqr(x) (ll)(x)*(x)

#define inf LLONG_MAX

#define mod 1000000007

using namespace std;

ll i;

string s;

main()
{
    [=]()
    {
        ios_base :: sync_with_stdio(false);

        cin.tie(nullptr);
    }();

    cin >> s;

    for (i=1; i<=s.size(); i++)
    {
        if (i&1) if (s[i-1]=='R' || s[i-1]=='U' || s[i-1]=='D') continue; else return cout << "No", 0;

        if (i%2==0) if (s[i-1]=='L' || s[i-1]=='U' || s[i-1]=='D') continue; else return cout << "No", 0;
    }

    cout << "Yes";
}


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

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	unordered_map<int, vector<int> > g;
	for (int i = 0; i < m; i++) {
		int b, e;
		cin >> b >> e;
		g[b].push_back(e);
	}
	int s, t;
	cin >> s >> t;
	if (s == t) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> v1(n + 1, 0), v2(n + 1, 0), v3(n + 1, 0);
	unordered_set<int> pos;
	pos.insert(s);
	v3[s] = 1;
	int res = 0;
	while (pos.size() > 0) {
		unordered_set<int> pos_temp;
		for (auto ppos : pos) {
			if (ppos == t) {
				cout << res << endl;
				return 0;
			}
			unordered_set<int> next1_pos, next2_pos;
			for (auto p : g[ppos]) {
				if (v1[p] == 0)
					next1_pos.insert(p);
				v1[p] = 1;
			}
			for (auto p : next1_pos)
				for (auto pp : g[p]) {
					if (v2[pp] == 0)
						next2_pos.insert(pp);
					v2[pp] = 1;
				}
			for (auto p : next2_pos)
				for (auto pp : g[p])
					if (v3[pp] == 0) {
						pos_temp.insert(pp);
						v3[pp] = 1;
					}
		}
		res++;
		pos = pos_temp;
	}
	cout << -1 << endl;
}














Measured memory_bytes: 10276
//Skip

#include<iostream>
using namespace std;
int N,X,D;

int euclid(int a,int b){
    if ( a % b ==0) return b;
    else return euclid(b,a % b);
}

int main(){
    cin >> N >> X;
    int x[N];
    for(int i=0;i<N;++i){
        cin >> x[i];
    }
    if(N==1) D = x[0]-X;
    else D = euclid(x[0]-X,x[1]-X);
    for(int city=2;city<N;++city){
        D = euclid(D,x[city]-X);
    }
    cout << abs(D) << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

void solv(int n, int y) {
  int m, g, s;


  for (m = n; m >= 0; m--) {
    for (g = n - m; g >= 0; g--) {
      s = n - m - g;
      if (s < 0) break;

      if (m * 10000 + g * 5000 + s * 1000 == y) {
        printf("%d %d %d\n", m, g, s);
        return;
      }
    }
  }

  printf("-1 -1 -1\n");
}

int main(int argc, char **argv) {
  int n, y;

  while (scanf("%d %d", &n, &y) != EOF) {
    solv(n, y);
  }

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> P;
const int MAX_N=1e5+1;
const int INF=1e9+2;

vector<P> G[MAX_N];
vector<bool> visited(MAX_N,false);
vector<int> dist(MAX_N,INF);

bool dfs(int i,int d){
    if(visited[i]&&dist[i]!=d) return false;
    if(visited[i]&&dist[i]==d) return true;
    visited[i]=true;
    dist[i]=d;
    for(auto& it:G[i]){
        if(!(dfs(it.first,d+it.second))) return false;
    }
    return true;
}

int main(){
    int N,M;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int l,r,d;
        cin >> l >> r >> d;
        l--;r--;
        G[l].push_back(P(r,d));
        G[r].push_back(P(l,-d));
    }
    for(int i=0;i<N;i++){
        if(!visited[i]){
            if(!dfs(i,0)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  string s;cin >> s;
  std::vector<int> v;
  int cnt_l=0;
  int cnt_r=1;
  for(int i=0; i< s.size()-1;++i){
    string sub = s.substr(i,2);
    if(sub == "RL")v.push_back(i);
  }
  vector<pair<int, int>> p;
  for(int i=0; i< v.size();++i){
    int cnt_r =0;
    int cnt_l =0;
    for(int j=v[i];j>=0;--j){
      string sub = s.substr(j,1);
      if(sub=="R"){
        ++cnt_r;
      } else {
        break;
      }
    }
    for(int j=v[i]+1;j<s.size();++j){
      string sub = s.substr(j,1);
      if(sub=="L"){
        ++cnt_l;
      } else {
        break;
      }
    }
    p.push_back(make_pair(cnt_r, cnt_l));
  }
  std::vector<int> vout(s.size(),0);
  for(int i=0; i<v.size();++i){
    vout[v[i]] = p[i].second/2 + 1 + (p[i].first - p[i].first/2 - 1);
    vout[v[i]+1] = p[i].first/2 + 1 + (p[i].second - p[i].second/2 - 1);
  }
  for(int i=0; i<vout.size();++i){
    cout << vout[i] << " ";
  }
  return 0;
}


Measured memory_bytes: 1720
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = parseInt(sc.next());
		int[] a = new int[n+1];
		int[] b = new int[n];
		for(i=0;i<n+1;i++) {
			a[i] = parseInt(sc.next());
		}
		for(i=0;i<n;i++) {
			b[i] = parseInt(sc.next());
		}
		sc.close();
		long sum = 0;
		int m=0;
		for(i=0;i<n;i++) {
			m = Math.min(a[i]+a[i+1],b[i]);
			sum += (long)m;
			a[i+1] = Math.min(a[i]+a[i+1]-m,a[i+1]);
		}
		out.println(sum);
	}
}


Measured memory_bytes: 50284
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e5;

int n, c, ct[N];
string s[N];
bool any[N];

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int ans = IINF;
  FOR(i, 0, n) cin >> s[i];
  FOR(i, 0, n){
    bool all = true;
    FOR(j, 0, n){
      if(s[j][i] == '.'){
        all = false;
        ct[j]++;
      }else{
        any[i] = true;
      }
    }
    if(!all) c++;
  }
  FOR(i, 0, n) mins(ans, ct[i] + !any[i] + c);
  cout << (ans==(n*2+1) ? -1 : ans) << endl;
}

Measured memory_bytes: 2176
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const int INF = 2e9;
int N;
ll k, A[100005];

int main() {
  INCANT;
  cin >> N >> k;
  rep(i, N) cin >> A[i];

  ll ans=0ll;
  ll Cnt[40];
  rep(i, 40) {
    ll mask = 1ll << i;
    ll cnt = 0;
    rep(j, N) if (mask & A[j]) cnt++;
    Cnt[i] = cnt;
  }
  for (int i = 39; i>=-1; i--) { // XとKが初めて違うbitのところ。-1はX=K用
    if (i>=0 && !(k & (1ll<<i))) continue;
    ll tmp = 0ll;
    for (int bit=39; bit>=0; bit--) {
      ll mask = 1ll << bit;
      ll keisu = 0ll;
      if (i<bit) {
        if (k & mask) keisu = N-Cnt[bit];
        else keisu = Cnt[bit];
      }
      else if (i==bit) keisu=Cnt[bit];
      else keisu = max(Cnt[bit], N-Cnt[bit]);
      
      tmp+=keisu*mask; 
    }
    ans  = max(ans,tmp);
  }
  
  cout << ans <<  endl;
  return 0;
}

Measured memory_bytes: 1024
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: usize,
        a: [usize; n], // v_1 v_2 ... v_n
        b: [usize; m], // v_1 v_2 ... v_n
    }

    let sum_a = {
        let mut sum_a: Vec<usize> = Vec::new();
        if a[0] > k {
            sum_a
        } else {
            sum_a.push(a[0]);
            for i in 1..n {
                let xx = sum_a[i-1]+a[i];
                if xx > k {
                    break;
                }
                sum_a.push(xx);
            }
            sum_a.reverse();
            sum_a
        }
    };

    let sum_b = {
        let mut sum_b: Vec<usize> = Vec::new();
        if b[0] > k {
            sum_b
        } else {
            sum_b.push(b[0]);
            for i in 1..m {
                let xx = sum_b[i-1]+b[i];
                if xx > k {
                    break;
                }
                sum_b.push(xx);
            }
            sum_b
        }
    };

    let len_a = sum_a.len();
    let len_b = sum_b.len();
    let mut ans = len_a.max(len_b);
    if len_b > 0 {
        let mut j = 0;
        for i in 0..len_a {
            if j == len_b {
                break;
            }
            let mut yy = sum_a[i]+sum_b[j];
            while yy <= k {
                j += 1;
                if j == m {
                    break;
                }
                yy += b[j];
            }
            if ans < (len_a-i)+j {
                ans = (len_a-i)+j
            }
        }
    }

    println!("{}",ans)

}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

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

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

  int N, M;
  cin >> N >> M;
  vector<int> solved(N);
  vector<int> WA(N);

  for(int i = 0; i < N; i++){
    solved[i] = 0;
    WA[i] = 0;
  }

  int p;
  string S;
  for(int i = 0; i < M; i++){
    cin >> p >> S;
    p--;
    if(S == "AC"){
      solved[p] = 1;
    }else{
      if(solved[p] == 0){
        WA[p]++;
      }
    }
  }

  ll ans_s = 0;
  for(int i = 0; i < N; i++){
    if(solved[i] == 1){
      ans_s++;
    }
  }

  ll ans_w = 0;
  for(int i = 0; i < N; i++){
    if(solved[i] == 1){
      ans_w += WA[i];
    }    
  }

  cout << ans_s << " " << ans_w << endl;

  return 0;
}


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

int main() {
	int n,x,t;
	cin>>n>>x>>t;
	int co=0;
	while(n>0)
	{
	    n-=x;
	    co++;
	}
	cout<<t*co;
	return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; 4 * i <= n; ++i) {
    for (int j = 0; 4 * i + 7 * j <= n; ++j) {
      if (4 * i + 7 * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np
import collections as col

a,b,c,d = int_map()

x1 = a*c
x2 = a*d
x3 = b*c
x4 = b*d

print(max(x1,x2,x3,x4))

Measured memory_bytes: 27172
N,M=map(int,input().split())

def factorization(n):#次数だけ
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr
     
p=factorization(M)#素因数分解して次数を調べる

    
def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return (fact[n] * factinv[r] * factinv[n-r])%mod

mod=10**9 + 7
fact=[1,1]
factinv=[1,1]
inv=[0,1]
 
N2=N+max(p)    

for i in range(2, N2 + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)
    

        
ans=1
for i in range(len(p)):
    ans*=cmb(p[i]+N-1,p[i],mod)
    ans%=mod
if M==1:
    ans=1
print(ans)




Measured memory_bytes: 57968
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const ll mod = 1e9+7;

int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll mx=-(ll)(1e18+19);
	mx = max(mx, a*c);
	mx = max({mx, a*d, b*c, b*d});
	cout<<mx;
	return 0;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

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

    int hp = 0;

    while (x >= 500)
    {
        x -= 500;
        hp += 1000;
    }
    while (x >= 5)
    {
        x -= 5;
        hp += 5;
    }

    cout << hp << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll sum = 0L;
  int remain;
  rep(i,n) {
    if (a[i] > b[i]) {
      sum += b[i];
    } else {
      sum += a[i];
      b[i] = b[i]-a[i];
      if (a[i+1] > b[i]) {
        sum += b[i];
        a[i+1] = a[i+1] - b[i];
      } else {
        sum += a[i+1];
        a[i+1] = 0;
      }
    }
  }
  cout << sum << endl;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int s, w;
    cin >> s >> w;
    if (w >= s)
        print("unsafe");
    else
        print("safe");

    return 0;
}


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

int main()
{   int n,k;
    int a[55];
    while(cin>>n>>k)
    {   int sum=0;
       for(int i=0;i<n;i++)
        cin>>a[i];
       sort(a,a+n);
       for(int i=n-1;i>=n-k;i--) sum+=a[i];
       cout<<sum<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn comb2(n: usize) -> Vec<(usize, usize)> {
    let mut v = Vec::new();
    for i in 0..(n - 1) {
        for j in (i + 1)..n {
            v.push((i, j));
        }
    }
    v
}

trait Sortable {
    fn is_sorted(&self) -> bool;
}

impl Sortable for Vec<u32> {
    fn is_sorted(&self) -> bool {
        (*self).windows(2).all(|w| w[0] <= w[1])
    }
}

fn main() {
    read_line();
    let nums: Vec<u32> = read_line().split_whitespace().map(|x| x.parse().unwrap()).collect();
    
    if nums.is_sorted() {
        println!("YES");
        return;
    }

    let sortable = comb2(nums.len())
        .into_iter()
        .any(|(i, j)| {
            let mut v = nums.clone();
            v.swap(i, j);
            v.is_sorted()
        });

    println!("{}", if sortable { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
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(){
    ll N,M; cin >> N >> M;
    ll ans=(1900*M+100*(N-M))*pow(2,M);
    cout << ans << endl;
    return 0;
}

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

int main() {
    int r, g;
    cin >> r >> g;
    cout << g * 2 - r << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (1 << 30);
const ll inf = (1LL << 60LL);
const int maxn = 3e5 + 5;
int n;
string s;
int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> n >> s;
    
    ll ret = 0;
    map<string, int> cnt;
    
    for (int mask = 0; mask < (1 << n); mask ++){
        string red = "", blue = "";
        for (int i = 0; i < n; i ++){
            if (mask & (1 << i)) {
                red += s[i];
            }
            else {
                blue += s[i];
            }
        }
        string curr = red + "." +  string(blue.rbegin(), blue.rend());
        cnt[curr] ++;
    }
    
    for (int mask = 0; mask < (1 << n); mask ++) {
        string red = "", blue = "";
        for (int i = 0; i < n; i ++){
            if(mask & (1 << i)){
                red += s[i + n];
            }
            else{
                blue += s[i + n];
            }
        }
        string curr = string(red.rbegin(), red.rend()) + "." +  blue;
        ret += cnt[curr];
    }
    cout << ret << endl;
    return 0;
}



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

using namespace std;

int main() {
    int n;
    cin>>n;
    long long int ans = n-1;
    for(int i=2; i<n; i++) {
        ans += (int)((n-1)/i);
    }
    // ans = ans-(n-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;

import static java.lang.Math.min;

public class Main {

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

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);
    StringTokenizer st;

    int readInt() throws IOException {
        if (canRead()) {
            return Integer.parseInt(st.nextToken());
        }
        throw new NoSuchElementException();
    }
    long readLong() throws IOException {
        if (canRead()) {
            return Long.parseLong(st.nextToken());
        }
        throw new NoSuchElementException();
    }

    char readChar() throws IOException {
        if (canRead()) {
            return st.nextToken().charAt(0);
        }
        throw new NoSuchElementException();
    }

    boolean canRead() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String s = in.readLine();
            if (s != null) {
                st = new StringTokenizer(s, " ");
            } else {
                return false;
            }
        }
        return true;
    }

    int MAXN = 20;
    int INF = 1000000007;
    int N;
    int[] A = new int[MAXN], B = new int[MAXN];
    private void solve() throws IOException {
        N = readInt();
        for (int i = 0; i < N; i++) {
            A[i] = readInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = readInt();
        }
        dosolve();
        int ans = INF;
        for (int i = 0; i < N; i++) {
            ans = min(ans, dp[(1<<N)-1][i]);
        }
        out.println(ans == INF ? -1 : ans);
        out.flush();
    }

    int[][] dp = new int[1<<MAXN][MAXN];
    private void dosolve() {
        for (int S = 0; S < (1 << N); S++) {
            Arrays.fill(dp[S], INF);
        }
        for (int i = 0; i < N; i++) {
            dp[1<<i][i] = 0;
        }
        for (int S = 0; S < (1 << N); S++) {
            for (int i = 0; i < N; i++) {
                if ((S>>i&1) == 1) {
                    int c = Integer.bitCount(S);
                    int vi = (c-1&1) == (i&1) ? A[i] : B[i];
                    int cost = c;
                    for (int j = 0; j < N; j++) {
                        if ((S>>j&1) == 1) {
                            cost--;
                            continue;
                        }
                        int vj = (c&1) == (j&1)? A[j] : B[j];
                        if (vj >= vi) {
                            dp[S|1<<j][j] = min(dp[S|1<<j][j], dp[S][i] + cost);
                        }
                    }
                }
            }
        }
    }


}

Measured memory_bytes: 164948
#include <iostream>
#include <algorithm>
 
inline void fastin(int &number) {
    bool negative = false;
    int c;
    number = 0;
    c = getchar_unlocked();
    if (c == '-') {
        negative = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) number = number * 10 + c - 48;
    if (negative) number *= -1;
}
 
inline void fastout(int64_t n) {
    int64_t N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { count++; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar('0');
}
     
int main(){
        
    int N; fastin(N);
    int A[N];
    for (int i = 0; i < N; ++i) fastin(A[i]);
    sort(A, A + N, std::greater<int>());
     
    int point1 = -1; int point2 = -1;
    int len1, len2;
    for (int i = 0; i < N - 1; ++i) {
    if (A[i] == A[i + 1]){
           point1 = i; len1 = A[i]; break;
        }
    }
    if (point1 < 0){
        fastout(0); return 0;
    }
    for (int i = point1 + 2; i < N - 1; ++i) {
        if (A[i] == A[i + 1]){
            point2 = i; len2 = A[i]; break;
        }
    }
    if (point2 < 0){
        fastout(0); return 0;
    }    
    int64_t ans = 1LL * len1 * len2;
    fastout(ans);
     
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/02/27  Problem: ABC 111 B / Link: http://abc111.contest.atcoder.jp/tasks/abc111_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N; 
	cin >> N;
	ans = ((N+110) / 111) * 111;
	
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)3e5 + 5

int a[MAX];

int main() {
	ll i, j, k, l;
	int N, L;
	cin >> N >> L;
	rep(i, N) cin >> a[i];
	bool possible = false;
	int first;
	rep(i, N - 1) {
		if (a[i] + a[i + 1] >= L) {
			possible = true;
			first = i;
			break;
		}
	}
	if (!possible) {
		puts("Impossible");
		return 0;
	}
	puts("Possible");
	vector<int> v;
	for (i = first; i < N-1; ++i) {
		v.push_back(i);
	}
	for (i = first-1; i >= 0; --i) {
		v.push_back(i);
	}
	reverse(ALL(v));
	auto itr = v.begin();
	for (; itr != v.end(); itr++) {
		cout << *itr + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1784
A, B, C, D, E, F = map(int, input().split())

W = set()
for a in range(0, F + 1, 100 * A):
    for b in range(0, F + 1 - a, 100 * B):
        W.add(a + b)
        
S = set()
for c in range(0, F + 1, C):
    for d in range(0, F + 1 - c, D):
        S.add(c + d)
        
rate = -1
for w in W:
    for s in S:
        if 0 < w + s <= F and s / (w + s) <= E / (E + 100):
            if s / (w + s) > rate:
                rate = s / (w + s)
                ans = w + s, s
                
print(ans[0], ans[1])

Measured memory_bytes: 3188
N = gets.to_i
A = gets.split.map(&:to_i)

num = 1
ans = 0
A.each{|x|
  if x == num 
    num = num + 1
  else 
    ans = ans + 1
  end

  if ans == A.length
    ans = -1
  end
}

puts ans

Measured memory_bytes: 15364
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,y,z=0;
    cin>>x>>y;
    rep(i,x+1){
        if(i*2+(x-i)*4==y) z=1;
    }
    if(z) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// 0 <= unsigned int <= 4.2e9

int main()
{
    llong a, b, c;
    cin >> a >> b >> c;
    llong sub = c - a - b;
    if (sub < 0) {
        cout << "No" << endl;
        return 0;
    }
    llong left = 4 * a * b;
    llong right = sub * sub;
    if (left < right) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto N = readln.split[0].to!int;
	alias Point = Tuple!(int, "x", int, "y", int, "h");
	Point[101] points;
	Point point_;
	foreach (i; 0 .. N) {
		auto data = readln.split;
		Point p = Point(data[0].to!int, data[1].to!int, data[2].to!int);
		points[i] = p;
		if (p.h > 0) point_ = p;
	}
	
	if (N == 1) { auto p = points[0]; writeln(p.x, " ", p.y, " ", p.h); return; }
	

	foreach (x; 0 .. 101) foreach (y; 0 .. 101) {
		auto H = point_.h + (point_.x - x).abs + (point_.y - y).abs;
		bool flag = true;
		foreach (i; 0 .. N) {
			auto p = points[i];
			if ( max(H - abs(p.x - x) - abs(p.y - y), 0) != p.h ) { flag = false; break; }
		}
		if (flag) { writeln( x, " ", y, " ", H ); return; }
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
typedef pair<long long, long long> P;
int main(){
    long long a,b;
    cin>>a>>b;
    if(a*b%2==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

using namespace std;
int main (){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int s=*max_element(a.begin(),a.end());
    int t=*min_element(a.begin(),a.end());
    cout << s-t <<"\n";

    
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    auto x = vector<int>(n);
    for (auto &x_i : x)
        cin >> x_i;

    int lowest = 1'000'000'000;
    for (int pos = 1; pos <= 100; pos++) {
        int test = accumulate(x.begin(), x.end(), 0, [pos](auto sum, auto x_i) { return sum + (x_i - pos) * (x_i - pos); });
        if (test < lowest) {
            lowest = test;
        }
    }

    cout << lowest;
    return 0;
}


Measured memory_bytes: 256