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

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

public class Main {
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] ls = new int[2*n];
    for (int i = 0; i < 2*n; i++) {
      ls[i] = reader.nextInt();
    }
    Arrays.sort(ls);
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += ls[2*i];
    }
    out.println(sum);
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
vector<int>edge[105];
int dist[105][105];
void dfs(int v,int u,int b){
	if(u == -1) dist[b][v] = 0;
	else dist[b][v] = dist[b][u]+1;
	rep(i,edge[v].size()){
		int to = edge[v][i];
		if(to == u) continue;
		dfs(to,v,b);
	}
}
int mx[105];
int col[105];
void dfss(int v,int u,int d){
	col[v] = d;
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i] == u) continue;
		dfss(edge[v][i],v,d+1);
	}
}
ll get(bool D){
	ll mxx[105]={};
	for(int i=1;i<=n;i++){
		int C = 0;
		for(int j=0;j<edge[i].size();j++){
			int to = edge[i][j];
			if(col[i]+1 == col[to]) C++;
		}
		mxx[col[i]] = max(mxx[col[i]],1LL*C);
	}
	ll ans = 1;
	for(int i=1;i<=n;i++){
		if(mxx[i]) ans = ans*mxx[i];
	}
	if(D){
		ans *= 2LL;
	}
	return ans;
}
int main(){
	cin>>n;
	rep(i,n-1){
		int a,b; cin>>a>>b;
		edge[a].pb(b);
		edge[b].pb(a);
	}
	repn(i,n) dfs(i,-1,i);
	P1 p = mp(-1,mp(-1,-1));
	repn(i,n) repn(j,n) p = max(p,mp(dist[i][j],mp(i,j)));
	int u = p.sc.fi, v = p.sc.sc;
	vector<int>dm;
	int cur = u;
	while(1){
		dm.pb(cur);
		if(cur == v) break;
		for(int i=0;i<edge[cur].size();i++){
			int to = edge[cur][i];
			if(dist[v][cur] == dist[v][to]+1){
				cur = to; break;
			}
		}
	}
	ll ans;
	if(dm.size()%2 == 1){
		int x = dm[dm.size()/2];
		dfss(x,-1,1);
		ans = get(false);
		for(int e=0;e<edge[x].size();e++){
			int to = edge[x][e];
			dfss(x,to,1);
			dfss(to,x,1);
			ans = min(ans,get(true));
		}
	}
	else{
		int x = dm[dm.size()/2-1];
		int y = dm[dm.size()/2];
		dfss(x,y,1);
		dfss(y,x,1);
		ans = get(true);
	}
	int ans2;
	if(dm.size()%2 == 0){
		ans2 = dm.size()/2;
	}
	else{
		ans2 = dm.size()/2+1;
	}
	cout<<ans2<<" "<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

int N;
int D[200010];
int M;
int T[200010];


signed main()
{
	cin >> N;
	REP(i, N) cin >> D[i];
	cin >> M;
	REP(i, M) cin >> T[i];
	ARY_SORT(D, N);
	ARY_SORT(T, M);

	int a = 0;
	for (int t = 0; t < M; t++)
	{
		bool is_found = false;
		for (int d = a; d < N; d++)
		{
			if (D[d] == T[t])
			{
				a = d + 1;
				is_found = true;
				break;
			}
		}
		if (!is_found)
		{
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}



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

long long cmb(int n, int r){
  if(n-r<r)r=n-r;
  if(r==0)return 1;
  if(r==1)return n;

  vector<int> num(r);
  vector<int> den(r);
  for(int i=0; i<r; i++){
    num[i]=n-r+i+1;
    den[i]=i+1;
  }

  for(int p=2; p<=r; p++){
    int piv=den[p-1];
    int sld=(n-r)%p;
    for(int i=p-1; i<r; i+=p){
      num[i-sld]/=piv;
      den[i]/=piv;
    }
  }

  long long res=1;
  for(int i=0; i<r; i++)res*=num[i];

  return res;  
}

int main(){
  int n,p,o=0,e=0;
  cin>>n>>p;
  for(int i=0; i<n; i++){
    int a;
    cin>>a;
    if(a%2==0)e++;
    else o++;
  }

  long long odd=0;
  if(p==0){
    for(int i=0; i<=o; i+=2)odd+=cmb(o,i);
  }else{
    for(int i=1; i<=o; i+=2)odd+=cmb(o,i);
  }

  for(int i=0; i<e; i++)odd*=2;

  cout<<odd<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, M, S;
int U[100], V[100], A[100]; ll B[100];
int C[50]; ll D[50];

vector<pair<int, pair<int, ll>>> e[50];
ll cost[50][2501];

signed main(){
	cin >> N >> M >> S;
	rep(i, M){
		cin >> U[i] >> V[i] >> A[i] >> B[i];
		U[i]--; V[i]--;
		e[U[i]].pb({ V[i],{ A[i],B[i]} });
		e[V[i]].pb({ U[i],{ A[i],B[i]} });
	}
	rep(i, N) cin >> C[i] >> D[i];

	rep(i, N){
		rep(j, 2501) cost[i][j] = LLONG_MAX;
	}

	priority_queue<pair<ll, pair<int, int>>> pq;
	cost[0][min(S, 2500)] = 0;
	pq.push({ 0, {0, min(S, 2500)} });
	while(!pq.empty()){
		int n = pq.top().second.first;
		int s = pq.top().second.second;
		pq.pop();
		if(cost[n][min(s+C[n], 2500)] > cost[n][s] + D[n]){
			cost[n][min(s+C[n], 2500)] = cost[n][s] + D[n];
			pq.push({ -cost[n][min(s+C[n], 2500)] , {n, min(s+C[n], 2500)} });
		}
		rep(i, e[n].size()){
			if(e[n][i].second.first > s) continue;
			int m = e[n][i].first;
			int a = e[n][i].second.first;
			ll b = e[n][i].second.second;
			if(cost[m][s-a] > cost[n][s] + b){
				cost[m][s-a] = cost[n][s] + b;
				pq.push({ -cost[m][s-a] , {m, s-a} });
			}
		}
	}

	rep(i, N){
		if(i == 0) continue;
		ll ans = LLONG_MAX;
		rep(j, 2501){
			ans = min(ans, cost[i][j]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 6316
#include<stdio.h>


#define LIMIT 101

int time=1;
int g[LIMIT][LIMIT];
int d[LIMIT] ;
int f[LIMIT] ;
int n;

void search(int p){
  int i;

  if(d[p]>0)return ;
	d[p]=time;
	time++;

	for(i=1;i<=n;i++){
		if(g[p][i]==1&&d[i]==0){
 			search(i);
		}
	}

	f[p]=time;
	time++;
}

int main(){
	int u,k,v;
  int i;
	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
 		while(k--){
			scanf("%d",&v);
			g[u][v]=1;
		}
	}
	for(i=1;i<=n;i++){
		search(i);
	}
	for(i=1;i<=n;i++)printf("%d %d %d\n",i,d[i],f[i]);

  return 0;
}



Measured memory_bytes: 2048
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        v = R * r + G * g
        if v > N:
            break
        if (N - v) % B == 0:
            ans +=1 
        
print(ans)


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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    vector<int> d(n+1);
    d[0] = 0;
    int cnt = 1 ;
    for(int i = 1; i <= n; ++i) {
        d[i] = d[i-1] + l[i-1];
        if(d[i]<=x) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX_N = 13;
const int MAX_M = 1e3 + 10;
int N, M;
int a[MAX_M], b[MAX_M];
int c[MAX_M][MAX_N];
LL dp[MAX_M][1 << MAX_N];

int main(void) {
    cin >> N >> M;
    REP(i, M) {
        cin >> a[i] >> b[i];
        REP(j, b[i]) {
            cin >> c[i][j];
            c[i][j]--;
        }
    }

    REP(i, MAX_M) FOR(j, 1, (1 << MAX_N)) dp[i][j] = LLINF;

    REP(i, M) {
        int bit = 0;
        REP(j, b[i]) bit |= (1 << c[i][j]);

        REP(j, (1 << N)) {
            if (dp[i][j] == LLINF) continue;
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][j | bit], dp[i][j] + a[i]);
        }
    }

    if (dp[M][(1 << N) - 1] == LLINF) cout << -1 << endl;
    else cout << dp[M][(1 << N) - 1] << endl;
}


Measured memory_bytes: 64896
s = list(input())
if len(s)%2 == 0:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2:]
else:
    s1 = s[:len(s)//2]
    s2 = s[len(s)//2+1:]
#print(s1,s2)
i = 0
j = -1
cnt = 0
while len(s1) > i:
    if s1[i] != s2[j]:
        cnt += 1
    i += 1
    j -= 1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long N, M;

long long solve() {
    if (N > M) swap(N, M);
    if (N == 1 && M == 1) return 1;
    if (N == 1) return M-2;
    
    return (N-2) * (M-2);
}

int main() {
    while (cin >> N >> M) {
        cout << solve() << endl;
    }
}


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

using namespace std;
typedef unsigned long long ull;

ull PickLargestMinimumPiece(const ull _total_size, const ull _piece1_s, const ull _piece1_l, const ull _piece3_s, const ull _piece3_l){
	ull tmp = min(_piece1_s, _piece3_s);
	
	ull piece2 = _total_size - _piece1_s - _piece3_l;
	tmp = max(tmp, min(_piece1_s, piece2));

	piece2 = _total_size - _piece1_l - _piece3_s;
	tmp = max(tmp, min(_piece3_s, piece2));

	piece2 = _total_size - _piece1_l - _piece3_l;
	tmp = max(tmp, piece2);

	return tmp;
}

void CalcPiece1(int *_i2, ull *_piece1_s, ull *_piece1_l, const int _i1, const int _N, const ull _one_third_size, const int *_A){
	for (; *_i2 < _i1 + _N - 2;){
		*_piece1_s = *_piece1_l;
		*_piece1_l += _A[*_i2%_N];
		(*_i2)++;
		if (*_piece1_l > _one_third_size) break;
	}
}

void CalcPiece3(int *_i3, ull *_piece3_s, ull *_piece3_l, const int _i1, const int _N, const ull _one_third_size, const int *_A){
	for (; *_i3 < _i1 + _N - 1;){
		*_piece3_l = *_piece3_s;
		*_piece3_s -= _A[*_i3%_N];
		(*_i3)++;
		if (*_piece3_s <= _one_third_size) break;
	}
}

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

	int N;
	cin >> N;

	int *A = new int[N];
	ull total_size = 0;
	int i1_ini = 0;
	int A_max = 0;
	for(int i=0; i<N; i++){
		cin >> A[i];
		total_size += A[i];
		if (A[i] > A_max){
			A_max = A[i];
			i1_ini = i;
		}
	}
	ull one_third_size = total_size / 3;

	ull answer = 0;
	if (A_max > one_third_size){
		ull half_size = (total_size - A_max) / 2;
		ull tmp = 0;
		ull piece2 = 0;
		/*for (int i3 = i1_ini + 1; i3 < i1_ini + N - 1; i3++){
			piece2 = tmp;
			tmp += A[i3%N];
			if (tmp > half_size) break;
		}*/
		int i3 = i1_ini + 1;
		CalcPiece1(&i3, &piece2, &tmp, i1_ini + 1, N, half_size, A);
		ull piece3 = total_size - A_max - tmp;
		answer = max(piece2, piece3);
		cout << answer << endl;
		delete[] A;
		return 0;
	}

	int i2 = i1_ini;
	ull piece1_s = 0;
	ull piece1_l = 0;
	CalcPiece1(&i2, &piece1_s, &piece1_l, i1_ini, N, one_third_size, A);
	const int i1_fin = i2;

	int i3 = i2;
	ull piece3_s = total_size - piece1_l;
	ull piece3_l = 0;
	CalcPiece3(&i3, &piece3_s, &piece3_l, i1_ini, N, one_third_size, A);

	answer = PickLargestMinimumPiece(total_size, piece1_s, piece1_l, piece3_s, piece3_l);

	for (int i1 = i1_ini + 1; i1 < i1_fin; i1++){
		int A_tmp = A[(i1 - 1) % N];
		piece1_l -= A_tmp;
		if (piece1_l > one_third_size) piece1_s -= A_tmp;
		else CalcPiece1(&i2, &piece1_s, &piece1_l, i1, N, one_third_size, A);

		piece3_s += A_tmp;
		if (piece3_s <= one_third_size) piece3_l += A_tmp;
		else CalcPiece3(&i3, &piece3_s, &piece3_l, i1, N, one_third_size, A);

		answer = max(answer, PickLargestMinimumPiece(total_size, piece1_s, piece1_l, piece3_s, piece3_l));
	}

	cout << answer << endl;

	delete[] A;

	return 0;
}

Measured memory_bytes: 1532
/*
ID: varunra2
LANG: C++
TASK: p
*/

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

#ifdef DEBUG
#include "lib/debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define debug_arr(...) \
  cerr << "[" << #__VA_ARGS__ << "]:", debug_arr(__VA_ARGS__)
#pragma GCC diagnostic ignored "-Wsign-compare"
//#pragma GCC diagnostic ignored "-Wunused-parameter"
//#pragma GCC diagnostic ignored "-Wunused-variable"
#else
#define debug(...) 42
#endif

#define EPS 1e-9
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define x first
#define y second

const double PI = acos(-1.0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef vector<ll> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
#pragma GCC diagnostic ignored "-Wsign-compare"
// util functions

VVI dp;
VVI adj;
int n;

void dfs(int u, int v) {
  for (auto& x : adj[u]) {
    if (x == v) continue;
    dfs(x, u);
  }
  dp[u][0] = 1;
  dp[u][1] = 1;
  // first we calc 0 -> black
  for (auto& x : adj[u]) {
    if (x == v) continue;
    dp[u][0] *= dp[x][1];
    dp[u][0] %= MOD;
  }

  // now we calc 1 -> white

  for (auto& x : adj[u]) {
    if (x == v) continue;
    ll sm = dp[x][0] + dp[x][1];
    dp[u][1] *= sm;
    dp[u][1] %= MOD;
  }
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("p.in", "r", stdin);
  freopen("p.out", "w", stdout);
#endif
  cin.sync_with_stdio(0);
  cin.tie(0);

  cin >> n;

  dp.resize(n);
  adj.resize(n);

  for (int i = 0; i < n; i++) {
    dp[i].resize(2);
  }

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].PB(v);
    adj[v].PB(u);
  }

  dfs(0, -1);

  cout << (dp[0][0] + dp[0][1]) % MOD << endl;

  return 0;
}


Measured memory_bytes: 18208
N = int(input())
a_list = [int(input()) for _ in range(N)]

b_list = a_list.copy()
b_list.sort(reverse=True)
max_num = max(b_list)

for i in range(N):

    a = a_list[i]

    if a != max_num:
        print(max_num)
    else:
        f = True
        cnt = 0
        for b in b_list:
            if a != b:
                print(b)
                f = False
                break
            else:
                cnt += 1
                if cnt >= 2:
                    break
        if f:
            print(b)


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

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	
	string s;
	cin >> s;
	if(s.length() == 2) {
		if(s[0] == s[1]) cout << "1 2" << endl;
		else cout << "-1 -1" << endl;
		return 0;
	} else {	
		for(int i = 0; i < s.length() - 2; i++) {
			if(s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) {
				cout << i + 1 << " " << i + 3 << endl;
				return 0;
			}
		}
	}
	
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 10007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

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


 
int main() {
	string S;
    cin >> S;
    if(S[6]>'4' || S[5]>'0'){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << 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;
using P = pair<int, int>;
using namespace std;

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

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

    vector<array<int, 3>> event;
    rep(i, n) {
        int s, t, x;
        cin >> s >> t >> x;

        event.push_back({s-x, 1, x});
        event.push_back({t-x, -1, x});
    }

    event.push_back({(int)1e9, (int)1e9, (int)1e9}); // INF
    sort(event.begin(), event.end());

    set<int> s;
    int cur = 0;
    rep(i, q) {
        int d;
        cin >> d;

        while (event[cur][0] <= d) {
            if (event[cur][1] == 1) {
                s.insert(event[cur][2]);
            }
            else {
                s.erase(event[cur][2]);
            }
            ++cur;
        }

        if (s.empty()) cout << -1 << endl;
        else cout << *s.lower_bound(0) << endl;
    }
    return 0;
}


Measured memory_bytes: 15468
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a,b,c;
  cin>>a>>b;
  
  if(a=='H'&&b=='H'){
    c='H';
  }
  else if(a=='H'&&b=='D'){
    c='D';
  }
  else if(a=='D'&&b=='H'){
    c='D';
  }
  else{
    c='H';
  }
  
  cout<<c<<endl;
}


Measured memory_bytes: 256
test = False
if test:
    import time
    start = time.time()

import sys
import random


def solve(c_list, days, now):
    r = sum(c_list[i]*(now-days[i]) for i in range(26))
    return r


if test == True:
    #seed = 94
    #random.seed(seed)
    d = 365
    c = [random.randrange(0, 101) for _ in range(26)]
    s = [[random.randrange(0, 20001) for _ in range(26)] for _ in range(d)]
    c_ = ' '.join(map(str, c))
    s_ = '\n'.join([' '.join(map(str, i)) for i in s])
    with open('./input.txt', 'w') as f:
        f.write('\n'.join([str(d), c_, s_]))
else:
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _i in range(d)]


last_days = [-1 for _i in range(26)]
result = []
score = 0
for today in range(d):
    checker = [c[j]*(today-last_days[j]) for j in range(26)]
    y = sum(checker)

    finder = [s[today][j]-(y-checker[j]) for j in range(26)]
    x = finder.index(max(finder))

    if today < d-1:
        second_checker = [c[j]*(today+1-last_days[j]) for j in range(26)]
        second_finder = [s[today+1][j]-(y-checker[j]) for j in range(26)]
        second_x = second_finder.index(max(second_finder))
        if x == second_finder:
            x = finder.index(sorted(finder)[-2])
    

    last_days[x] = today
    result.append(x+1)
    score += s[today][x] - solve(c, last_days, today)
if test:
    print(score)

def change(problems, days):
    last_days = [-1 for _i in range(26)]
    score = 0
    for i in range(d):
        score += s[i][problems[i]-1]
        last_days[problems[i]-1] = i
        score -= sum([c[j]*(i-last_days[j]) for j in range(26)])
    return score

change_list = result.copy()
for i in range(9200):
    if random.randrange(2)<1:
        x, y = random.randrange(0, d), random.randrange(0, d)
        while x == y:
            y = random.randrange(0, d)
        change_list[x], change_list[y] = change_list[y], change_list[x]
        next_score = change(change_list, d)
        if next_score >= score:
            if test:print(i, score, next_score, abs(next_score-score), 'two')
            score = next_score
            result[x], result[y] = result[y], result[x]
        
        else:
            change_list[x], change_list[y] = change_list[y], change_list[x]
    else:
        x = random.randrange(0, d)
        y = random.randrange(1, 27)
        change_list[x], z = y, change_list[x]
        next_score = change(change_list, d)
        if next_score >= score:
            if test:print(i, score, next_score, abs(next_score-score), 'one')
            score = next_score
            result[x] = y
        else:
            change_list[x] = z

if test == True:
    with open('./output.txt', 'w') as f:
        f.write('\n'.join(map(str, result)))
else:
    for i in result:
        print(i)

if test:
    elapsed_time = time.time() - start
    print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")

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

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

const int N = 201;
const int M = 1e5 + 1;
const int mod = 1e9 + 7;

int n, X, E[N][M], a[N], inv[N];

inline int mul(int a, int b) {
  return (ll)a * b % mod;
}

int main() {
  inv[1] = 1;
  for (int i = 2; i < N; ++i) {
    inv[i] = mod - mul(mod / i, inv[mod % i]); 
  }

  scanf("%d %d", &n, &X);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }

  sort(a + 1, a + n + 1);

  for (int i = 0; i < M; ++i) E[0][i] = i;
  for (int i = 1; i <= n; ++i) {
    for (int x = 0; x <= X; ++x) {
      E[i][x] = mul(inv[i], E[i - 1][x % a[i]]);
      E[i][x] += mul(mod + 1 - inv[i], E[i - 1][x]);
      if (E[i][x] >= mod) E[i][x] -= mod;
    }
  }

  int ans = E[n][X]; 
  for(int i = 1; i <= n; ++i) {
    ans = mul(ans, i); 
  }

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



Measured memory_bytes: 78720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    partial class Program
    {
        static void Main(string[] args)
        {
       
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var l = input[0];
            var r = input[1];

            var min = int.MaxValue;
            //差が一周するならば 2019 以内の全組み合わせ
            if (r - l >= 2019)
            {
                for (int j = 1; j <= 2019; j++)
                {
                    for (int i = 0; i < j; i++)
                    {
                        var mod = (i % 2019) * (j % 2019) % 2019;
                        if (mod < min)
                        {
                            min = mod;
                        }
                    }
                }
            }

            //一周しない場合、l mod 2019 から 差分 だけ試せばいい

            else
            {
                for (int j = l + 1; j < r + 1; j++)
                {
                    for (int i = l; i < j; i++)
                    {
                        var mod = (i % 2019) * (j % 2019) % 2019;
                        if (mod < min)
                        {
                            min = mod;
                        }
                    }
                }
            }

            Console.WriteLine(min);
        }

    }
}

Measured memory_bytes: 13396
import std;

auto input()
{
    return readln().chomp();
}

alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long n;
    scan(n);
    auto xy = new long[][](n);
    // writeln(xy);
    foreach (i; 0 .. n)
    {
        xy[i] = aryread();
    }
    // writeln(xy);
    auto tmp = new long[](n);
    foreach (i; 0 .. n)
    {
        tmp[i] = i + 1;
    }
    long sum_dist_tmp;
    real sum_dist = 0;
    long cnt;
    do
    {
        // writeln(tmp);
        cnt += 1;
        foreach (i; 0 .. (tmp.length) - 1)
        {
            sum_dist_tmp = (xy[tmp[i] - 1][0] - xy[tmp[i + 1] - 1][0]) ^^ 2 + (
                    xy[tmp[i] - 1][1] - xy[tmp[i + 1] - 1][1]) ^^ 2;
            sum_dist += sqrt(cast(real) sum_dist_tmp);
        }
    }
    while (nextPermutation(tmp));
    // writeln(sum_dist);
    // writeln("cnt", cnt);
    writefln("%.10f", sum_dist / cnt);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

auto binary_search(long key, long[] l)
{
    long left = 0; //lの左端
    long right = l.length - 1; //lの右端
    while (right >= left)
    {
        long mid = left + (right - left) / 2; //区間の真ん中
        if (l[mid] == key)
        {
            return mid;
        }
        else if (l[mid] > key)
        {
            right = mid - 1;
        }
        else if (l[mid] < key)
        {
            left = mid + 1;
        }

    }
    return -1;
}

// auto a = [1, 14, 32, 51, 51, 51, 243, 419, 750, 910];
// auto a = aryread();
// writeln(a);
// long len_a = a.length;
// writeln(len_a);
// long ans;
// ans = binary_search(51, a);
// writeln(ans);



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  vector<double> p(n + 1, 0);
  for(int i = 1; i <= n; i++){
    cin >> p.at(i);
    p.at(i) = (p.at(i) + 1) * p.at(i) / 2 / p.at(i);
    p.at(i) += p.at(i - 1);
  }
  
  double ans = 0;
  for(int i = 0; i + k <= n; i++){
    ans = max(ans, p.at(i + k) - p.at(i));
  }
  
  cout << fixed << setprecision(10);
  cout << ans << '\n';
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int INF=1<<25;
const int maxn=50;
int  d[maxn][maxn];
int r;
int main()
{
    while(cin>>r)
	{
		if(r==0) break;
		for(int i=0;i<=11;i++)
			for(int j=0;j<=11;j++){
				if(i!=j)
					d[i][j]=INF;
				else
					d[i][j]=0;
			}
		int n;
		n=0;
		for(int i=0;i<r;i++)
		{
			int a,b,num;
			cin>>a>>b>>num;
			int t=max(a,b);
			n=max(t,n);
			d[a][b]=num;
			d[b][a]=num;
		}
		for(int k=0;k<=n;k++)
			for(int i=0;i<=n;i++)
				for(int j=0;j<=n;j++)
					d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		int minx=INF;
		int k;
		for(int i=0;i<=n;i++){
			int res=0;
			for(int j=0;j<=n;j++)
				res+=d[i][j];
			if(res<minx){
				minx=res;
				k=i;
			}
		}
		cout<<k<<" "<<minx<<endl;


	}
    return 0;
}

Measured memory_bytes: 2984
#include <stdio.h>
#include <string.h>
int main(){
	int a[26],i;
	memset(a,0,sizeof(a));
	char b;
	while(scanf("%c",&b)!=EOF){
		if(b>='a'&&b<='z'){
			a[b-'a']++;
		}
		else if(b>='A'&&b<='Z'){
			a[b-'A']++;
		}
	}
	for(i=0;i<26;i++){
		printf("%c : %d\n",'a'+i,a[i]);
	}
	return 0;
}

Measured memory_bytes: 540
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value


void solve() {

	double T, X;

	cin >> T >> X;

	cout << T / X << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;



int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  long long ans = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    if(i > 0 && a[i] < a[i - 1]) {
      ans += a[i - 1] - a[i];
      a[i] = a[i - 1];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4040
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	long a[10000],x,max=-1000000,min=1000000,gou=0;;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		gou+=a[i];
	}
	for(int i=0;i<n;++i){
		if(a[i]!=0){
		if(min>a[i]){
			swap(a[i],min);
		}else if(max<a[i]){
			swap(a[i],max);}
		}
	}
	if(min>max){
			min=0;
			max=0;}
	cout<<min<<" "<<max<<" "<<gou<<endl;
	return 0;
}


Measured memory_bytes: 3172
/*author  ADITYA BANSAL
                 //~ MNNIT ALLAHABAD     */
        #include<bits/stdc++.h>
        using namespace std;
         #define ll long long
        //~ #define ll int
        ll power(ll,ll);
        ll ncr(ll,ll);
        ll add(ll a,ll b);
        void fact();
        ll mul(ll a,ll b);
        #define watch(x) cerr<<(#x)<<"is"<<x<<nl;
        #define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        #define fi(a,b) for(ll i=a; i<b; i++)
        #define fk(a,b) for(ll k=a; k<b; k++)
        #define fri(a,b) for(ll i=a; i>b; i--)
        #define fj(a,b) for(ll j=a; j<b; j++)
        #define ffi(a,b) for(ll i=a;i*i<=b;i++)
        #define mp make_pair
        #define ff first 
        #define  tc ll t; cin>>t; while(t--)
        #define all(v) (v).begin(),(v).end()
        #define ss second
        #define pb push_back
        #define mem(v,a) memset((v),a,sizeof(v));
        #define pll pair<ll,ll>
        #define mll map<ll,ll>
        #define sll set<ll>
        #define vll vector<ll>
        #define max3(a,b,c) max(a,max(b,c))
        #define min3(a,b,c) min(a,min(b,c))
        #define nl endl
         int mod=1e9+7;
        const ll  N=100002LL;
        ll fac[N+2];
        ll inv[N+2];
     
      
        signed main(){  
    		fast
    	 //~ tc
    	
        {
		 
		ll n;
		cin>>n;
		ll a[n];
		fi(0,n) cin>>a[i];
	 ll ans=0;
		fi(0,n-1){ ll cc=0;
			fj(i+1,n) ans+=a[i]*a[j];
			
		}
		cout<<ans;
	    }
            return 0;
        }
         
         
        /******************************************************************************/
         
        ll add(ll a,ll b){
			a+=b+mod;
		   if(a>=mod) a-=mod;
		   
		   return a;
		} 
         
        ll mul(ll a,ll b){
            return ((a)*1ULL*(b))%mod;
        }
         
        ll power(ll a,ll n){
          ll res=1;
          while(n){
              if(n&1) res= mul(res,a);
             n>>=1; 
             a= mul(a,a);
          }
            return res;
        }
        void fact(){
        	inv[0]=fac[0]=1;
        	fi(1,N){
        	 fac[i]=mul(fac[i-1],i);
        	inv[i]=power(fac[i],mod-2);
        }
        }
         
        ll ncr(ll n,ll r){
        	
        	if(r>n) return 0;
        	ll e=fac[n];
        	e=mul(e,inv[r]);
        	e=mul(e,inv[n-r]);
        	return e;
        }


Measured memory_bytes: 256
#include<stdio.h>
//#include<math.h>
//#include<string>

int mypow(int a,int b){
    int r=1;
    while(b>0){
        b--;
        r*=a;
    }
    return r;
}


int process(int n,int l){
    int hole[10];

    for(int i=0;i<10;i++)
        hole[i]=0;
    for(int i=1;i<l+1;i++){
        int t= (n%mypow(10,i))/mypow(10,i-1);
        hole[t]++;
    }

    int max=0,min=0,l2=l;
    while(l2>0){
        int m=0;
        for(int i=9;i>=0;i--){
            if(hole[i]>0){
                hole[i]--;
                m=i;
                break;
            }
        }
        max+=m*mypow(10,l2-1);
        min+=m*mypow(10,l-l2);
        l2--;
    }
    return max-min;
}

int main(){

    int n[20],l,m=0,ok=0;
    while((scanf("%d%d",n,&l)==2) & (l>0)){


        while(ok==0){
            n[m+1]=process(n[m],l);
            m++;
            //chcek
            for(int j=0;j<m;j++){
                if(n[j]==n[m]){
                    printf("%d %d %d\n",j,n[j],m-j);
                    ok=1;
                    break;
                }

            }
        }
        ok=0;
        m=0;

    }
}

Measured memory_bytes: 2756
import java.util.*;
public class Main{
  public static void main(String[] args){
    int[] a = new int[4];
    Scanner s = new Scanner(System.in);
    for(int i=0; i<4; i++){
      a[i] = Integer.parseInt(s.nextLine());
    }
    int w = Math.max(a[0]-a[1], 0);
    System.out.println(w*a[3]+a[2]*(a[0]-w));
  }
}

Measured memory_bytes: 21716
#import <stdio.h>
#import <limits.h>
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>0?(a):(-(a)))
int main(){
    int N;
    int W[101] = {0};
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",W+i);
    }
    int S[101] = {0};
    for(int i=0;i<N;i++){
        S[i] = W[i] + ((i==0) ? 0 : S[i-1]);
    }
    int min = INT_MAX;
    for(int i=0;i<N;i++){
        min = MIN(min, ABS(2*S[i] - S[N-1]));
    }
    printf("%d",min);
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<long long int> b(2);
    b.at(0)=1000000001;
    b.at(1)=a[0]-1;
    int x;
    for(int i=0;i<n;i++){
        x=b.size();
        if(b.at(x-1)>=a[i]){
            b.push_back(a[i]);
            continue;
        }
        for(int j=1;j<b.size();j++){
            if(b.at(j)<a[i]){
                b.at(j)=a[i];
                break;
            }
        }
    }
    cout<<b.size()-1<<endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin>>N;
    string ans;
    N--;

    ll M = 26, cnt = 1;
    while (N >= M) N -= M, M *= 26, cnt++;

    while(N){
        ans += 'a' + N % 26;
        N /= 26;
    }

    ll an = cnt - ans.size();
    rep(i, an) ans += 'a';
    reverse(all(ans));

    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll t=1,i,j,k=0,q,p,x,y,z,n,m,a,b,r,c,d;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        string s="ACL";
        for(i=0;i<n;i++)
        {
            cout<<s;
        }
        cout<<endl;

    }
    return 0;
}



Measured memory_bytes: 3532
#include <stdio.h>
#define NUMBER 1000

int main(void) 
{
	int n, m, rt, cnt;
	int i;
	int x[NUMBER];

	while (1) {
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0)
			break;
		
		for (i = 0; i < NUMBER; i++)
			x[i] = 0;

		for (i = 0; i < n; i++)
			x[i] = 1;
		
		rt = n;
		i = 0;
		while (rt > 1) {
			cnt = 0;
			while (1) {
				if (x[i] == 1) 
					cnt++;
				if (cnt == m)
					break;
				i++;
				if (i == n)
					i = 0;
			}
			x[i] = 0; 
			rt--;
		}
		for (i = 0; i < n; i++)
			if (x[i] == 1)
				printf("%d\n", ++i);
	}
	return 0;
}

Measured memory_bytes: 604
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [a, b, c] <- getIntList
  k <- getInt

  let calkK1 bn n | bn > a = (bn, n)
                  | otherwise = calkK1 (bn*2) (n+1)

      (bn, n) = calkK1 b 0

      calkK2 cn m | cn > bn = m
                  | otherwise = calkK2 (cn*2) (m+1)

      m = calkK2 c 0

  putStrLn $ if n + m <= k then "Yes" else "No"


Measured memory_bytes: 3800
/*
 * @Author: SugarSBN
 * @Date: 2018-07-16 18:32:09
 * @Language:   C++
 */
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<fstream>
using namespace std;
const int MAXN=2e6+11;
const double pi=acos(-1);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef double dbl;
#define For(a,b,c) for (int (a)=(b);(a)<(c);(a)++)
#define foreach(iter,V) for (__typeof((V.begin()) iter=(V).begin();iter!=(V).end();iter++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n, m;
struct line{
    int p, q, c;
}rec[MAXN];
vector<pii> g[MAXN];
vi col[MAXN];
int ptr[MAXN];
int be[MAXN];
vi new_g[MAXN];
int new_vertex;
int main(){
   // freopen("in.txt", "r", stdin);
    scanf("%d%d", &n, &m);
    For(i,0,m){
        scanf("%d%d%d", &rec[i].p, &rec[i].q, &rec[i].c);
        rec[i].p--;
        rec[i].q--;
        g[rec[i].p].pb(mp(rec[i].c, rec[i].q));
        g[rec[i].q].pb(mp(rec[i].c, rec[i].p));
        col[rec[i].c].pb(rec[i].p);
        col[rec[i].c].pb(rec[i].q);
    }
    new_vertex = n;
    For(i, 0, n) {
        sort(g[i].begin(), g[i].end());
        ptr[i] = 0;
        be[i] = -1;
    }
    For(i,1,MAXN){
        if (col[i].size()==0)
            continue;
        For(j,0,col[i].size()){
            if (be[col[i][j]]!=i){
                be[col[i][j]] = i;
                queue<int> Q;
                Q.push(col[i][j]);
                new_g[col[i][j]].pb(new_vertex);
                new_g[new_vertex].pb(col[i][j]);
                while (!Q.empty()){
                    int v = Q.front();
                    Q.pop();
                    while(ptr[v]<g[v].size()&&g[v][ptr[v]].fi==i){
                        if (be[g[v][ptr[v]].se]!=i){
                            Q.push(g[v][ptr[v]].se);
                            be[g[v][ptr[v]].se] = i;
                            new_g[new_vertex].pb(g[v][ptr[v]].se);
                            new_g[g[v][ptr[v]].se].pb(new_vertex);
                        }
                        ptr[v]++;
                    }
                }
                new_vertex++;
            }
        }
    }
    int dist[MAXN];
    For(i, 0, new_vertex) dist[i] = -2;
    queue<int> Q;
    Q.push(0);
    dist[0] = 0;
    while(!Q.empty()){
        int v = Q.front();
        Q.pop();
        For(i,0,new_g[v].size()){
            if (dist[new_g[v][i]]==-2){
                dist[new_g[v][i]] = dist[v] + 1;
                Q.push(new_g[v][i]);
            }
        }
    }
    printf("%d\n", dist[n - 1] / 2);
    return 0;
}


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

#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long int

int main(void){
    fast_io();
    ll n;
    cin >> n;
    vector<string> s(n);

    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }

    for (int i = 0; i < n; i++) {
      sort(s[i].begin(),s[i].end());
    }

    sort(s.begin(),s.end());
    string buf = "";

    string &current = buf;

    ll count = 0;
    ll ans = 0;

    for (int i = 0; i < n; i++) {
      if(current != s[i]){
          count = 0;
          current = s[i];
      } else {
          count++;
          ans += count;
      }
    }

    cout << ans << endl;
    return 0;
}


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

public class Main {
    static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
    
	public static void main (String[] args) throws IOException {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		long count = 0;
		int max = Integer.MIN_VALUE;
		
		for (int i = 0; i < n; i++) {
		    int val = sc.nextInt();
		    max = Math.max(max, val);
		    
		    if (val < max) 
		        count += (max - val);
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 53992
#include <bits/stdc++.h>
#define maxN 1000000

void dfs(std::vector<std::vector<int>> &graph, int src, std::vector<bool> &vis, std::vector<int> &dp) {
    vis[src] = true;
    int ans = 1, max_ch = 0;
    for(int i =0; i < graph[src].size(); i++) {
        if (vis[graph[src][i]] == false) {
            dfs(graph, graph[src][i], vis, dp);
        }
        max_ch = std::max(max_ch, dp[graph[src][i]]);
    }
    dp[src] = ans + max_ch;
}

int main() {
    int n, m, u, v;
    std::cin>>n>>m;
    std::vector<std::vector<int>> graph(n+1, std::vector<int>());
    for(int i =0; i < m; i++) {
        std::cin>>u>>v;
        graph[u].push_back(v);
    }
    int ans = 1;
    std::vector<bool> vis(n+1, false);
    std::vector<int> dp(n+1, 1);
    for(int i = 1; i<=n;i++) {
        if(!vis[i]) {
            dfs(graph, i, vis, dp);
        }
    }
    for(int i =1; i <= n;i++) {
        ans = std::max(ans, dp[i]);
    }
    std::cout << ans - 1<< std::endl;
}

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

int main(){
int n,x,t;
 cin>>n>>x>>t;
 if(n<=x){
    cout<<t;
 }
 else if(n>x && n%x==0){
    cout<<(n/x)*t;
 }
 else
    cout<<((n/x)+1)*t;


    return 0;
}


Measured memory_bytes: 3640