akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size();
    int l = -1, r = -1;
    REP(i,N-1) if(S[i] == S[i+1]) l = i+1, r = i+2;
    REP(i,N-2) if(S[i] == S[i+2]) l = i+1, r = i+3;
    cout << l << " " << r << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

int good[1000];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		int x;
		cin >> x;
		while (x--) {
			int t;
			cin >> t;
			good[t] = 1;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (!good[i]) {
			ans++;
		}
	}
	cout << ans;
}


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

public class Main {

    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long[] a=new long[n];
        long[] sum=new long[n];
        for(int i=0;i<n;i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);
        sum[0]=a[0];
        for(int i=0;i<n;i++){
            if(i>0)sum[i]=sum[i-1]+a[i];
        }

        int t=0;
        for(int i=0;i<n-1;i++){
            if(sum[i]*2<a[i+1]) {
                t = i+1;
            }
        }
        System.out.println(n-t);
    }
}

Measured memory_bytes: 58260
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int N;
  cin>>N;
  vector <int> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  cout<< a[N-1]-a[0] <<endl;
}


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

int n, m;
bool g[50][50];
int es[50][2];
bool b[50];

void dfs(int v, int e) {
	for (int i = 0; i < n; i++) {
		if (!b[i] && g[v][i]) {
			if (es[e][0] == min(v, i) && es[e][1] == max(v, i))
				continue;
			b[i] = 1;
			dfs(i, e);
		}
	}
}

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

	for (int i = 0, a, b; i < m; i++) {
		cin >> a >> b;
		a--, b--;
		es[i][0] = a, es[i][1] = b;
		g[a][b] = 1, g[b][a] = 1;
	}

	int rv = 0;
	for (int i = 0; i < m; i++) {
		fill(b, b + n, 0), b[0] = 1;
		dfs(0, i);
		bool flag = 0;
		for (int j = 0; j < n; j++)
			if (!b[j])
				flag = 1;
		if (flag)
			rv++;
	}
	cout << rv << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

ll f(vi a, ll b) {
    ll res = 0;
    rep(i, sz(a)) {
        res += abs(a[i] - b);
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    vi a(n);
    rep(i,n) {
        cin >> a[i];
        a[i] = a[i] - i - 1;
    }
    sort(all(a));
    ll b;
    if (n & 1) {
        b = a[(n - 1) / 2];
    }
    else {
        b = (a[(n - 1) / 2] + a[n / 2]) / 2;
    }
    print(f(a, b));
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  
  int s, t, u, v;
  int r = 0;
  
  cin >> A >> B;
  
  for (int i = A; i <= B; i++) {
    s = i / 10000;
    t = i % 10;
    
    u = i / 1000 % 10;
    v = i / 10 % 10;
    
    if (s == t && u == v)
      r++;
  }
  
  cout << r << endl;
}

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

using namespace std;

void print_vec(vector<vector<int> > g,int N){
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cout << g.at(i).at(j);
    }
  cout << endl;
  }
}
int N,M;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
int ans= 0;
vector<vector<int> > G(N+1, vector<int>(N+1));

void dfs1(int i,vector<int> visited){
  bool all_visited = true;
  //cout << "visited: " << i << endl;
  for(int s = 0; s < N;s++){
    //cout << visited.at(s) << " ";
    if(visited.at(s) == 0)
      all_visited = false;
  }
  //cout << endl;
  if(all_visited){
    //cout << "ans++"<<endl;
    ans+=1;
    return;
  }
  for(int n = 0; n < N; n++){
    if(G.at(i).at(n) == 0)continue;
    if(visited.at(n) == 1)continue;
    visited.at(n) = 1;
    dfs1(n,visited);
    visited.at(n) = 0;
  }
  return ;
}
int dfs(int v, int N,vector<int> visited){
  bool all_visited = true;
  for(int i = 0; i < N; i++){
    if(visited.at(i) == 0){
      all_visited = false;
    }
  }
  if(all_visited){
    return 1;
  }
  int ret = 0;
  for(int i= 0;i < N; ++i){
    if(G[v][i] == 0)continue;
    if(visited[i])continue;

    visited.at(i) = 1;
    ret += dfs(i,N,visited);
    visited.at(i) = 0;
  }
  return ret;
}

int main(int argc, char *argv[])
{
  int  a, b,res;
  vector<int > visited(N);
  cin >> N >> M;
  G.assign(N, vector<int>(N,0));
  visited.assign(N,0);
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    a--;b--;
    G.at(a).at(b) = 1;
    G.at(b).at(a) = 1;
  }
  //print_vec(G,N);
  visited.at(0) = 1;
  //res = dfs(0,N,visited);
  dfs1(0,visited);
  cout << ans << endl;
  //cout << res << endl;
  return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef long long lint;
template< typename T > using Vec = vector< T >;

lint encode(lint v, lint c) { return (v << 32) | c; }

struct Edge {
	lint to;
	int dst;
};

int N, M;
unordered_map< lint, Vec< Edge > > edges;
unordered_map< lint, int > dst;

void solve() {
	deque< lint > que;
	que.push_back(0);
	dst[0] = 0;
	
	while (!que.empty()) {
		lint cur = que.front(); que.pop_front();
				
		for (const Edge& e : edges[cur]) {
			if (dst.count(e.to) == 0 || dst[e.to] > dst[cur] + e.dst) {
				dst[e.to] = dst[cur] + e.dst;
				if (e.dst == 0) que.push_front(e.to);
				else que.push_back(e.to);
			}
		}
	}
	
	if (dst.count(encode(N-1, 0)) == 0) puts("-1");
	else cout << dst[encode(N-1, 0)] << endl;
}

int main() {
	cin >> N >> M;
	
	for_(i,0,M) {
		int u, v, c;
		cin >> u >> v >> c;
		--u; --v;
		
		edges[encode(u, c)].push_back(Edge{encode(v, c), 0});
		edges[encode(v, c)].push_back(Edge{encode(u, c), 0});
		
		edges[encode(u, 0)].push_back(Edge{encode(u, c), 1});
		edges[encode(v, 0)].push_back(Edge{encode(v, c), 1});
		
		edges[encode(u, c)].push_back(Edge{encode(u, 0), 0});
		edges[encode(v, c)].push_back(Edge{encode(v, 0), 0});
	}
	
	solve();
}

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

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

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

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

i64 solve(i64 n, vector<i64> p, vector<i64> q){
    i64 ans = 0, s = 0;
    rep(i, n) s += p[i];
    sort(q.begin(), q.end(), greater<i64>());
    rep(i, n - 1){
        ans = max(ans, s * (n - i));
        s += q[i];
    }
    cout << max(ans, s) << endl;
}

int main(){
    while(true){
        i64 n;
        cin >> n;
        if(n == 0) break;
        vector<i64> p(n), j(n - 1);
        rep(i, n) cin >> p[i];
        rep(i, n - 1) cin >> j[i];
        solve(n, p, j);
    }
}


Measured memory_bytes: 4848
#include <algorithm>
#include <cmath>
#include <vector>

/*
 * Closest pair.
 */
class ClosestPair {
private:
  std::vector<double> x, y;
  struct x_cmp {
    const ClosestPair &cp;
    x_cmp(const ClosestPair &cp) : cp(cp) {} 
    bool operator() (int i, int j) {
      return cp.x[i] < cp.x[j];
    }
  };
  struct y_cmp {
    const ClosestPair &cp;
    y_cmp(const ClosestPair &cp) : cp(cp) {} 
    bool operator() (int i, int j) {
      return cp.y[i] < cp.y[j];
    }
  };
  x_cmp xc;
  y_cmp yc;
  double gl_mi; // global minimum;
  double dist2(int i, int j) const {
    return pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2);
  }

  void min_brute_force(const std::vector<int> & v) {
    int n = v.size();
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
	if (i == j) {
	  continue;
	}
	gl_mi = std::min(gl_mi, dist2(v[i], v[j]));
      }
    }
  }


  void min_strip(const std::vector<int> &v) {
    int n = v.size();
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n && pow(y[v[j]] - y[v[i]], 2) < gl_mi; ++j) {
	gl_mi = std::min(gl_mi, dist2(v[i], v[j]));
      }
    }
  }

  /*
   */
  void min_pair_util(const std::vector<int> &vx) {
    int n = vx.size();
    if (n <= 4) {
      min_brute_force(vx);
      return;
    }
    // divide at middle
    int mid = n / 2;
    double mid_x = x[vx[mid]];
    min_pair_util(std::vector<int>(vx.begin(), vx.begin() + mid));
    min_pair_util(std::vector<int>(vx.begin() + mid, vx.end()));
    std::vector<int> strip;
    for(int i = 0; i < n; ++i) {
      if (pow(x[vx[i]] - mid_x, 2) < gl_mi) {
	strip.push_back(vx[i]);
      }
    }
    std::sort(strip.begin(), strip.end(), yc);
    min_strip(strip);
  }
  ClosestPair(const std::vector<double> &xs, const std::vector<double> &ys) : x(xs), y(ys), xc(*this), yc(*this), gl_mi(1.0 / 0.0) {
  }
  double internal_solve(void) {
    int n = x.size();
    std::vector<int> v(n);
    for (int i = 0; i < n; ++i) {
      v[i] = i;
    }
    std::sort(v.begin(), v.end(), xc);
    min_pair_util(v);
    return std::sqrt(gl_mi);
  }
public:
  static double solve(const std::vector<double> &xs, const std::vector<double> &ys) {
    return ClosestPair(xs, ys).internal_solve();    
  }
};
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

#include <cstdio>
#include <iostream>

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

int main(void){
  int n;
  cin >> n;
  vector<double> x(n), y(n);
  REP(i, 0, n) {
    cin >> x[i] >> y[i];
  }
  printf("%.9f\n", ClosestPair::solve(x, y));
}

Measured memory_bytes: 5132
N,M,K = list(map(int, input().split()))
mod = 998244353

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

p = 998244353
N1 = 2 * 10 ** 5 + 10  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N1 + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0
mem = 1
mem = pow(M-1,N-K-1,p)
for i in range(K,-1,-1):
  wk = M * mem
  wk %= p
  wk *= cmb(N-1,i,p)
  #print(wk,mem,i)
  mem *= (M-1)
  mem %= p
  ans += wk
  ans %= p
  
print(ans)

Measured memory_bytes: 33304
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  char a[H][W];
  vector<bool> isW(W, false);
  vector<bool> isH(H, false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
      if (a[i][j] == '#') isH[i] = true;
      if (a[i][j] == '#') isW[j] = true;
    }
  }
  for (int i = 0; i < H; i++) {
    if (isH[i] == true) {
      for (int j = 0; j < W; j++) {
        if (isW[j] == true) cout << a[i][j] << flush;
      }
      cout << endl;
    }
  }
}

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

int main() {
  ll N;
  cin >> N;
  stack<int> ans;

  while(N!=0){
      N--;
      ans.push(N%26);
      N=N/26;
  }

  while (!ans.empty()) {
    char s = ans.top()+97;
    cout << s; 
    ans.pop();  
  }
  
}

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

int main(){
  ull n,m;
  cin >> n >> m;
  vector<pair<int,int>> ab(n);
  rep(i,n) cin >> ab.at(i).first >> ab.at(i).second;
  sort(ab.begin(),ab.end());
  ull ans=0;
  rep(i,n){
    while( m > 0 && ab.at(i).second > 0 ){
      m--;
      ans += ab.at(i).first;
      ab.at(i).second--;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

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

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

//Watchin' TVA
class Program{
public:
	int time;
	string name;
	Program(int _time, string _name) : time(_time), name(_name) {}

	bool operator < (const Program& p) const{
		return time < p.time;
	}
};

int main(){
	int N,P;
	

	while(~scanf("%d",&N)){
		if(N==0) break;
		map<int,vector<Program> > PRO;
		map<string,bool> FAV;

		for(int i=0;i<N;i++){
			string name;
			int day;
			int time;
			cin >> name >> day >> time;
			int m = time % 100;
			int h = time / 100;
			int total = h * 60 + m;
			PRO[day].push_back(Program(total,name));
		}
		scanf("%d",&P);
		for(int i=0;i<P;i++){
			string name;
			cin >> name;
			FAV[name] = true;
		}

		bool failed = false;
		int res = 0;
		for(map<int,vector<Program> >::iterator it = PRO.begin(); it != PRO.end(); it++){
			bool reserve[100000];
			memset(reserve,0,sizeof(reserve));

			sort(it->second.begin(),it->second.end());

			for(int i=0;i< it->second.size(); i++){
				if(FAV.find(it->second[i].name) != FAV.end()){
					for(int j=it->second[i].time; j<it->second[i].time+30;j++){
						if(reserve[j]){
							failed = true;
							goto next;
						}
						reserve[j]=true;
					}
					res++;
				}
			}

			for(int i=0;i< it->second.size(); i++){
				if(FAV.find(it->second[i].name) == FAV.end()){
					bool tmp[100000];
					memcpy(tmp,reserve,sizeof(reserve));

					for(int j=it->second[i].time; j<it->second[i].time+30;j++){
						if(tmp[j]){
							goto cancel;
						}
						tmp[j]=true;
					}
					memcpy(reserve,tmp,sizeof(tmp));
					res++;
				}		
cancel:;
			}
		}
next:;

		if(failed){
			printf("%d\n",-1);
		}
		else{
			printf("%d\n",res);
		}
	}
}

Measured memory_bytes: 1540
#include<bits/stdc++.h>
using namespace std;
int ufd[101010];
int Find(int a)
{
	if(a==ufd[a]) return a;
	return ufd[a] = Find(ufd[a]);
}
void Union(int a, int b)
{
	ufd[Find(a)] = Find(b);
}
int main()
{
	int N, M; scanf("%d%d", &N, &M);
	for(int i=1; i<=N; ++i) ufd[i] = i;
	for(int i=0; i<M; ++i)
	{
		int x, y;
		scanf("%d%d%*d", &x, &y);
		Union(x, y);
	}
	int ans = 0;
	for(int i=1; i<=N; ++i)
		if(i==Find(i)) ++ans;
	printf("%d\n", ans);
}

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

int main() {
  int N;
  cin >> N;
  if (N % 2 == 0) {
    cout << 0.5 << endl;
  }
  if (N % 2 == 1) {
    double ans = ((N + 1.0) / 2.0) / N;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using Int = int64_t;
Int solve() {
    Int N, sumA = 0, sumB = 0;
    cin >> N;
    vector<Int> A(N), B(N);
    for (auto& i : A) {
        cin >> i;
        sumA += i;
    }
    for (auto& i : B) {
        cin >> i;
        sumB += i;
    }
    if (sumA < sumB) return -1;
    vector<Int> g;
    Int l = 0, cnt = 0;
    for (Int i = 0; i < N; i++) {
        auto t = A[i] - B[i];
        if (t > 0) g.push_back(t);
        else if (t < 0) {
            l += -t;
            cnt++;
        }
    }
    if (l == 0) return 0;
    sort(g.begin(), g.end(), greater<Int>());
    for (size_t i = 0; i < g.size(); i++) {
        if ((l -= g[i]) <= 0) return cnt + i + 1;
    }
    return -1;
}
int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 2428
n = int(input())
L = [list(map(int,input().split())), list(map(int,input().split()))]
ans = 0

for i in range(n):
  cnt = 0
  for j in range(n):
    if j < i: 
      cnt += L[0][j]
    elif j == i:
      cnt += L[0][j] + L[1][j]
    else:
      cnt += L[1][j]
  ans = max(ans,cnt)

print(ans)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc155() {
	ll n;

	cin >> n;

	vector<string> s(n);
	rep(i, n) {
		cin >> s[i];
	}

	map<string, ll> map;
	ll val;
	rep(i, n) {
		auto itr = map.find(s[i]);
		if (itr != map.end()) {
			val = map.at(s[i]);
			map.erase(itr);
			map.insert(make_pair(s[i], val + 1));
		}
		else {
			map.insert(make_pair(s[i], 1));
		}
	}

	vector<pair<ll, string>> ls;
	for (auto it = map.begin(); it != map.end(); it++) {
		ls.push_back(make_pair(it->second, it->first));
	}

	sort(ALL(ls));

	ll num = ls[ls.size() - 1].first;
	vector<string> ans;
	rep(i, ls.size()) {
		if (ls[ls.size() - 1 - i].first == num) {
			ans.push_back(ls[ls.size() - 1 - i].second);
		}
		else {
			break;
		}
	}

	sort(ALL(ans));
	rep(i, ans.size()) {
		cout << ans[i] << "\n";
	}
}

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

	solve_abc155();

	return 0;
}

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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 2e5 + 10;
using namespace std;
int sum[N] = {};
vector<vector<int>> adj;

void dfs(int u, int p) {
    for (auto child:adj[u]) {
        if (child != p) {
            sum[child] += sum[u];
            dfs(child, u);
        }
    }
}

int main() {
    IO;
    int n, t;
    cin >> n >> t;
    adj.resize(n + 1);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    while (t--) {
        int u, x;
        cin >> u >> x;
        sum[u] += x;
    }
    dfs(1, -1);
    for (int i = 1; i <= n; ++i) {
        cout << sum[i] << " ";
    }


}


Measured memory_bytes: 27408
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>


#define DEBUG 0
#define OUT


#if DEBUG
    #define LOG(...) {printf(__VA_ARGS__); printf("\n");}
    #define print_int_array(arr, n) {\
                for (int k = 0; k < n; ++k) {\
                    std::cout << std::setw(2) << arr[k] << " ";\
                }\
                    std::cout << "\n";\
                }
#else
    #define LOG(...) {}
    #define print_int_array(arr, n) {}
#endif

const size_t n_max = (size_t)1e5;



int main(int argc, char** argv)
{
    int n;
    std::cin >> n;

    int a[n], b[n], c[n];
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i] >> b[i] >> c[i];
    }

    int dp[3][n_max];

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    LOG("a: %d, b: %d, c: %d", dp[0][0], dp[1][0], dp[2][0]);


    for (int i = 1; i < n; ++i) {
        dp[0][i] = a[i] + std::max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = b[i] + std::max(dp[2][i-1], dp[0][i-1]);
        dp[2][i] = c[i] + std::max(dp[0][i-1], dp[1][i-1]);

        LOG("a: %d, b: %d, c: %d", dp[0][i], dp[1][i], dp[2][i]);
    }

    std::cout << std::max(std::max(dp[0][n-1], dp[1][n-1]), 
                          dp[2][n-1]);


    return 0;
}

Measured memory_bytes: 2560
N, u, v = map(int, input().split())
L = [[] for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    L[a - 1].append(b - 1)
    L[b - 1].append(a - 1)

Leaf = []  # 葉かどうかを記録する
for i in range(N):
    c = 0
    for j in L[i]:
        c = c + 1
    if c == 1:
        Leaf.append(True)
    else:
        Leaf.append(False)

UD = [0 for i in range(N)]  # 各頂点のuからの距離
UD[u - 1] = -1  # 0でないなら訪問済みとする
M = L[u - 1]  # 次に訪れるノードのリスト
d = 1  # uからの距離
while True:
    new_M = []
    for i in M:
        if UD[i] == 0:  # 0 ならiに隣接するノードをnew_Mに追加
            UD[i] = d
            for j in L[i]:
                new_M.append(j)
        else:
            pass
    M = new_M
    if len(M) == 0:
        break
    d = d + 1
UD[u-1] = 0

VD = [0 for i in range(N)]
VD[v-1] = -1
M = L[v-1]
d = 1

while True:
    new_M = []
    for i in M:
        if VD[i] == 0:  # 0 ならiに隣接するノードをnew_Mに追加
            VD[i] = d
            for j in L[i]:
                new_M.append(j)
        else:
            pass
    M = new_M
    if len(M) == 0:
        break
    d = d + 1
VD[v-1] = 0




d = -1
index = u-1
# vよりもuの方が近く,最もvから離れている葉を見つける
for i in range(N):
    if Leaf[i]:
        if UD[i] < VD[i]:
            if d < VD[i]:
                d = VD[i]

print(d-1)








Measured memory_bytes: 28268
import java.io.IOException;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int n = in.nextInt();
        int[] arr = new int[n];
        int[] ans = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        for (int i = 1; i < n; i++) {
            ans[i] = arr[i] - arr[i - 1];
        }
        ans[0] = k - arr[n - 1] + arr[0];

        int temp = 0;
        for (int i = 1; i < n; i++) {
            if (Math.max(ans[temp], ans[i]) == ans[i]) {
                temp = i;
            }
        }
        System.out.println(k - ans[temp]);
    }
}

Measured memory_bytes: 79276
import sys
from collections import defaultdict
input = sys.stdin.readline


dic = defaultdict(list)
n, m = map(int, input().split())
for i in range(m):
    pref, year = map(int, input().split())
    dic[pref].append([year, i])

cities = [0]*m


for i in range(1, n+1):
    dic[i].sort(reverse=True)
    count = 0
    while dic[i]:
        year, no = dic[i].pop()
        count += 1
        cities[no] = str(i).zfill(6) + str(count).zfill(6)

for city in cities:
    print(city)

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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int[] a = new int[4];
        for(int i=0;i<4;i++) a[i]=sc.nextInt();
        Arrays.sort(a);
        String ans = a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9?"YES":"NO";
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
priority_queue<long long >q;
long long n,m,a[100010],ans;;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(register int i=1;i<=n;i++){
		cin>>a[i],q.push(a[i]); 
	}
	while(m--){
		int x=q.top() ;q.pop() ;
		q.push(x>>1);  
	}
	while(!q.empty() ){
		ans+=q.top() ;q.pop() ;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }
//答え0~12しかないから決め打てないかやってみる

int n;
vector<int> d;
int main(){
    cin>>n;
    d.resize(n);
    rep(i,n){
        cin>>d[i];
    }
    sort(ALL(d));
    int cnt[30]={};
    cnt[0]++;
    for(auto x:d){
        cnt[x]++;
    }
    for(auto x:cnt){
        if(x>2){
            cout<<0<<endl;return 0;
        }
    }
    for(int ans=12;ans>0;ans--){
        multiset<int> tim;
        tim.insert(0);
        tim.insert(24);
        for(int i=0;i<n;i++){
            auto ite=tim.lower_bound(d[i]+1);
            if(ite==tim.begin()){
                cout<<0<<endl;return 0;
            }
            ite--;
            if(d[i]-*ite<ans){
                tim.insert(24-d[i]);
            }
            else{
                tim.insert(d[i]);
            }
        }
        bool f=true;
        for(auto it=tim.begin();it!=tim.end();it++){
            auto x=*it;
            auto nit=it;nit++;
            if(nit==tim.end()) break;
            auto y=*nit;
            if(abs(x-y)<ans){
                f=false;break;
            }
        }
        if(f){
            cout<<ans<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int s,h,m,S,a,b,c;
	scanf("%d",&S);
	a=S/3600;
	b=S%3600/60;
	c=S%3600%60;
	printf("%d:%d:%d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 592
/*<<head>> {{{*/
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
//INF = 1 061 109 567 ; INF + INF = 2 122 219 134 ;
//LINF = 4 557 430 888 798 830 399 ; LINF + LINF = 9 114 861 777 597 660 798 ;
const int INF = 0x3f3f3f3f;     // -INF: 0xc0   abs(-INF) = INF + 1
const ll LINF = 0x3f3f3f3f3f3f3f3f;
/*}}}*/                         // zr, zm
const int MOD = (int)1e9+7;     // when MOD = 1e9+7, inv2 = 500000004
const int N = (int)1e6+7;

// ------- 变量 ------- //

struct node {
    int x1, x2, y, ty;
    node () {} node (int x1, int x2, int y, int ty) : x1(x1), x2(x2), y(y), ty(ty) {}
    bool operator < (const node &rhs) const {
        return y != rhs.y ? y < rhs.y : ty > rhs.ty;
    }
};

int n;
vector <node> endp;
vi dis;

// ------- 函数 ------- //

int rk(int x) { return lower_bound(all(dis), x) - dis.begin() + 1; }

int t[N];
int sum(int x) { int res = 0; for (; x > 0; x -= x&-x) res += t[x]; return res; }
void upd(int x, int d) { for (; x <= N; x += x&-x) t[x] += d; }

void Init() {
    endp.clear(); dis.clear();
    rep(i, 0, n) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        if (x1 == x2) {
            if (y1 > y2) swap(y1, y2);
            endp.pb(node(x1, 0, y1, 1));
            endp.pb(node(x1, 0, y2, -1));
        } else {
            if (x1 > x2) swap(x1, x2);
            endp.pb(node(x1, x2, y1, 0));
        }
        dis.pb(x1); dis.pb(x2);
    }
    sort(all(dis));
    dis.erase(unique(all(dis)), dis.end());
    sort(all(endp));
}

int Solve() {
    int ans = 0;
    for (auto o : endp) {
        if (o.ty == 0) {
            ans += sum(rk(o.x2)) - sum(rk(o.x1)-1);
        } else {
            upd(rk(o.x1), o.ty);
        }
    }
    printf("%d\n", ans);
    return 0;
}

// ------- main ------- //

int main ()
{
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    //Pre();
    //int t; scanf("%d", &t); while (t--) {
    while (~scanf("%d", &n)) {
    //while(fgets(s, N, stdin)) {   // 注意 fgets 会读入换行符
        //if (n == 0) break;
        //static int kase = 0; printf("Case %d: ", ++kase);
        Init();
        Solve();
        //if (t) puts("");
    }
    return 0;
}


Measured memory_bytes: 8548
N = int(input())
XL = [list(map(int,input().split())) for i in range(N)]
XL.sort(key=lambda x: x[0]+x[1])
M = XL[0][0]+XL[0][1]-1
ans = 0
for i in range(1,N):
    if M >= XL[i][0]-XL[i][1]:
        ans += 1
    else:
        M = XL[i][0]+XL[i][1]-1
print(N-ans)


Measured memory_bytes: 32296
console.log((args=>{
  const [[N,M],...tmp] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  const p = Array.from({length:N},_=>[]);
  for ( let i = 0; i < M; i++ ) {
    const [P,Y] = tmp[i];
    p[P-1].push([i,Y]);
  }
  p.forEach(r=>r.sort((a,b)=>a[1]-b[1]));
  const a = Array.from(tmp,([p])=>`${p}`.padStart(6,0));
  p.forEach(r=>r.forEach(([i],j)=>a[i] += `${j+1}`.padStart(6,0)))
  return a.join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 115044
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    vector<int> a(110);
    cin >> N;
    for (int i=0;i<N;i++) cin >> a[i];

    vector<int> gray, brown, green, cyan, blue, yellow, orange, red, any;
    for (int i=0;i<N;i++) {
        if (a[i] < 400) gray.push_back(i);
        else if (a[i] < 800) brown.push_back(i);
        else if (a[i] < 1200) green.push_back(i);
        else if (a[i] < 1600) cyan.push_back(i);
        else if (a[i] < 2000) blue.push_back(i);
        else if (a[i] < 2400) yellow.push_back(i);
        else if (a[i] < 2800) orange.push_back(i);
        else if (a[i] < 3200) red.push_back(i);
        else any.push_back(i);
    }
    int X = 0, Y = 0;
    if (gray.size()>0) X++;
    else Y++;
    if (brown.size()>0) X++;
    else Y++;
    if (green.size()>0) X++;
    else Y++;
    if (cyan.size()>0) X++;
    else Y++;
    if (blue.size()>0) X++;
    else Y++;
    if (yellow.size()>0) X++;
    else Y++;
    if (orange.size()>0) X++;
    else Y++;
    if (red.size()>0) X++;
    else Y++;
    if (X == 0) cout << 1 << " " << any.size() << endl;
    else cout << X << " " << X+any.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#gets??§??¨??£????????????????????°????????????????°????????????????????????????????????¨????????????puts
#????¨???????????????????????????§????¶?????????????
#????????????n?????¨??£????????????????????????gets????????????????????????????????????sort??????
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
#sales a
#sales.sort
sum = 0
a.each do |i|
    sum += i
end
puts "#{a.min} #{a.max} #{sum}"
#puts " #{n} #{a}"

Measured memory_bytes: 6496
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x is not None: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result is None

def delete(target):
    def remove_node(p, c, a):
        if p.left == c: p.left = a
        else: p.right = a
    p, c = None, root
    while c.key != target: p, c = c, c.left if target < c.key else c.right
    if c.left is None:
        remove_node(p, c, c.right)
    elif c.right is None:
        remove_node(p, c, c.left)
    elif c.right.left is None:
        c.right.left = c.left
        remove_node(p, c, c.right)
    else:
        g = c.right
        while g.left.left is not None: g = g.left
        c.key = g.left.key
        g.left = g.left.right

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'd': delete(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 56180
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int lis[5];
    for(int i=0;i<5;i++){
        cin>>lis[i];
        if(lis[i]==0)cout<<i+1<<endl;
    }
    return 0;
}


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

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

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

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, w;
    cin >> n >> w;
    vector<vector<ll> > wv(n, vector<ll> (2));
    rep(i, n)rep(j, 2) cin >> wv[i][j];

    vector<vector<ll> > dp(n + 1, vector<ll> (100001, INF));
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, 100001) {
            if (j >= wv[i][1]) chmin(dp[i + 1][j], dp[i][j - wv[i][1]] + wv[i][0]);
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }

    ll ans = 0;
    rep(i, 100001) {
        if (dp[n][i] <= w) ans = max(ans, (ll)i);
    }
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 83260
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
set<int>s;
int n;
int main() {
	read(n);
	for(int i=1,x;i<=n;i++) {
		read(x);
		s.insert(x);
	}
	cout<<s.size();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    if (n % 1000 == 0){
        cout << 0 << endl;
    }else{
        cout << 1000-n % 1000 << endl;
    }
    return 0;
}


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

using namespace std;

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

    while (true)
    {
        int n, m;
        cin >> n >> m;
        if (n == 0)
            break;
        int h[1024 * 1500] = {0}, w[1024 * 1500] = {0};
        int tmp_h[n + 1], tmp_w[m + 1];
        int sum1 = 0, sum2 = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> tmp_h[i];
            sum1 += tmp_h[i];
            //cout<<tmp_h[i]<<endl;
        }
        for (int i = 0; i < m; i++)
        {
            cin >> tmp_w[i];
            sum2 += tmp_w[i];
            // cout<<tmp_w[i]<<endl;
        }
        for (int i = 0; i < n; i++)
        {
            int tmp = 0;
            for (int j = i; j < n; j++)
            {
                tmp += tmp_h[j];
                h[tmp]++;
            }
        }
        for (int i = 0; i < m; i++)
        {
            int tmp = 0;
            for (int j = i; j < m; j++)
            {
                tmp += tmp_w[j];
                w[tmp]++;
            }
        }
        long long res = 0;
        for (int i = 1; i <= min(sum1, sum2); i++)
        {
            res += h[i] * w[i];
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 15028
n = int(input())
a = list(map(int, input().split()))

d = {}
for i in a:
  if i in d: d[i] += 1
  else: d[i] = 1

ans = 0
for i in d.values(): ans += i*(i-1)//2
  
for i in a:
  print(ans - (d[i]-1))

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

static const ll INF = 1e15;


int main(void)	
{
	list<char> lc;
	string s;
	cin >> s;
	for (auto c : s) {
		lc.push_back(c);
	}
	ll q;
	cin >> q;
	bool r= false;
	rep(i, q) {
		ll e;
		cin >> e;
		if (e == 1) {
			r = !r;
		}
		else {
			ll f; char c;
			cin >> f >> c;
			bool front = f == 1;
			if (r ^ front) {
				lc.push_front(c);
			}
			else {
				lc.push_back(c);
			}
		}
	}
	if (r) {
		for (auto it = lc.rbegin(); it != lc.rend(); it++) {
			cout << *it;
		}
		cout << endl;
	}
	else{
		for (auto it = lc.begin(); it != lc.end(); it++) {
			cout << *it;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 9984
#include <bits/stdc++.h>
#include <math.h>
#include <regex>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

ll f(ll x){
    string s = to_string(x);
    ll n = s.size();
    vector<vector<pair<ll,ll>>> dp(10,vector<pair<ll,ll>>(n+1,make_pair(0,0)));
    ll first = s.at(0) - '0';
    for(int i=1;i<=first;i++){
        if(i!=first)dp.at(i).at(1).first = 1;
        else dp.at(i).at(1).second = 1;
    }


    for(int i=1;i<=9;i++){
        for(int j=2;j<=n;j++){
            dp.at(i).at(j).first += 1;
        }
    }

    for(int i=1;i<=n-1;i++){
        ll next = s.at(i) - '0';
        for(int j=0;j<=9;j++){
            if(j-1>=0){
                dp[j-1][i+1].first += dp[j][i].first;
                if(j-1<next){
                    dp[j-1][i+1].first += dp[j][i].second;
                }else if(j-1==next){
                    dp[j-1][i+1].second += dp[j][i].second;
                }
            }
            dp[j][i+1].first += dp[j][i].first;
            if(j<next){
                dp[j][i+1].first += dp[j][i].second;
            }else if(j==next){
                dp[j][i+1].second += dp[j][i].second;
            }
            if(j+1<=9){
                dp[j+1][i+1].first += dp[j][i].first;
                if(j+1<next){
                    dp[j+1][i+1].first += dp[j][i].second;
                }else if(j+1==next){
                    dp[j+1][i+1].second = dp[j][i].second;
                }
            }
        }
    }

    /*
    rep(i,10){
        rep(j,n+1){
            cout << dp.at(i).at(j).first << " ";
        }
        cout << endl;
    }
    */
    

    ll ret = 0;
    for(int i=0;i<=9;i++){
        ret += dp.at(i).at(n).first;
        ret += dp.at(i).at(n).second;
    }
    return ret;
}

int main(){
    ll k ; cin >> k; 
    ll left = 0, right = 3234566668ll;
    ll center = (left+right)/2;
    
    
    while(right-left>1){
        if(f(center)<k){
            left = center;
        }else if(f(center)>k){
            right = center;
        }else{
            right = center;
        }
        center = (left+right)/2;
        //cout << left << " " << center << " " << right << endl;
    }

    cout << right << endl;
    
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    C = list(input().strip("\n"))

    count = 0
    rightBound = N - 1
    for i in range(N):
        if C[i] == "W":
            while rightBound > i:
                if C[rightBound] == "R":
                    C[i] = "R"
                    C[rightBound] = "W"
                    count += 1
                    break
                else:
                    rightBound -= 1
            else: break
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10644
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define int long long
#define mod 1000000007

void solve() {
        int n; cin >> n;
        string a, b; cin >> a>> b;
        lp(i, n) cout << a[i]<< b[i];
        return;
}

int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    arc061_c();
}

fn arc061_c() {
    input! {
        s: u64
    }
    let n = (s as f64).log10().floor() as u32;
    let mut sum = 0 as u64;
    for i in 0..(2 as u32).pow(n) {
        sum += arc061_c_helper(i, s)
    }
    println!("{}", sum);
}

fn arc061_c_helper(bits: u32, n: u64) -> u64 {
    let mut bits = bits;
    if bits == 0 {
        return n;
    } else {
        let mut i = 0 as u32;
        while bits % 2 == 0 {
            i += 1;
            bits /= 2
        }
        bits = bits / 2;
        let shift = (10 as u32).pow(i+1) as u64;
        return n % shift + arc061_c_helper(bits, n / shift);
    }
}


Measured memory_bytes: 4352