akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	int n;
	cin >> n;
	int k = n%10;
	n = n/10;
	int k1 = n%10;
	n = n/10;
	if(k==7 || k1==7 || n==7){
		cout <<"Yes";
	}
	else{
		cout <<"No";
	}
}





Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define INF 1LL<<61
#define fi first
#define se second

int main(){
    int n;
    vector<vector<pair<int,int>>> G(100100);
    int A[100100] = {};
    rep(i,100100) A[i] = -1;
    cin >> n;
    for(ll i=0;i<n-1;i++){
        int a,b;
        int c;
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    queue<int> que;
    que.push(0);
    A[0] = 1;
    while(!que.empty()){
        int n = que.front();
        que.pop();
        for(pair<int,int> o:G[n]){
            if(A[o.fi]==-1){
                if(o.se%2==0){
                    A[o.fi] = A[n];
                }else{
                    if(A[n]==1) A[o.fi] = 0;
                    else A[o.fi] = 1;
                }
                que.push(o.fi);
            }
        }
    }

    rep(i,n){
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

int main(){
  int N;
  cin>>N;
  int ma,ma2;
  ma=1;
  ma2=1;
  int hold[N];
  rep(i, N){
    
    cin >> hold[i];
    
    if(max(ma,hold[i])>ma||ma==hold[i]){
    ma2=ma;
      ma=hold[i];
    }
    
    else if(max(ma2,hold[i])>ma2){
    ma2=hold[i];
    }
    
  }
  rep(i, N){
  if(hold[i]==ma)
    cout << ma2 << endl;
    else
    cout << ma << endl;      
  }
  
  
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int l[3002][3002];
int main()
{
 string s1,s2;
 cin>>s1>>s2;
 int m=s1.size(),n=s2.size();
 
 for(int i=0;i<=m;++i)
 for(int j=0;j<=n;++j)
 {    if(i==0||j==0)
      l[i][j]=0;
      else if(s1[i-1]==s2[j-1])
            l[i][j]=1+l[i-1][j-1];
       else l[i][j]=max(l[i-1][j],l[i][j-1]) ;    
 } int i=m,j=n;
 int k=l[i][j];char arr[k];
 while(i!=0&&j!=0)
 {  
    
    if(l[i-1][j]==l[i][j])
       i=i-1;
       else if (l[i][j-1]==l[i][j]) 
	   j=j-1;
	   else {arr[k-1]=s1[i-1];k--;i=i-1;j=j-1;}
	
 }
 	
 for(int i=0;i<l[m][n];++i)
  cout<<arr[i];	
	
	
	
	
}

Measured memory_bytes: 35456
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;

	if (a < b)
	cout << "a < b" <<endl;
		else if (a > b)
        cout << "a > b" <<endl;
    		else if(a == b)
    		cout << "a == b" <<endl; 

}

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

int main()
{
  int m,d;
  int result = 0;
  scanf("%d%d",&m,&d);

  for(int dd=22; dd<=d; dd++){
    int d1 = dd%10;
    int d10 = dd/10;  
    if(d1>=2&&d10>=2){
      for(int mm=4; mm<=m; mm++){
    	if(d1*d10==mm){
//          printf("%d %d%d\n",mm,d10,d1);
          result++;
        }
      }
    }
  }
  printf("%d\n",result);
  return 0;
}

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

int a[200000];
int n,l,s,maxn;

int main(){
    while(true){
        maxn=-100000000;
        s=0;
        cin>>n>>l;
        if(n==0 && l==0){break;}
        for(int i=0;i<n;i++){
            cin>>a[i];
            if(i<l){s+=a[i];}
        }
        maxn=s;
        for(int i=0;i<n-l;i++){
            s-=a[i];
            s+=a[i+l];
            maxn=max(s,maxn);
        }
        cout<<maxn<<endl;
    }
}

Measured memory_bytes: 1548
/************************************************
 * Au: Hany01
 * Date: Oct 23rd, 2018
 * Prob: agc018b
 * Email: hany01dxx@gmail.com & hany01@foxmail.com
 * Inst: Yali High School
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
#define Rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define X first
#define Y second
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define SZ(a) ((int)(a).size())
#define ALL(a) a.begin(), a.end()
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

template <typename T> inline T read() {
	static T _, __; static char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


const int maxn = 305;

int n, m, a[maxn][maxn];

inline bool check(int x) {
	static int ban[maxn], cnt[maxn], id;
	Set(ban, 0);
	while (1) {
		Set(cnt, 0), id = 0;
		For(i, 1, n) For(j, 1, m) if (!ban[a[i][j]]) {
			++ cnt[a[i][j]];
			if (cnt[a[i][j]] > cnt[id]) id = a[i][j];
			break;
		}
		if (cnt[id] <= x && cnt[id]) return 1;
		if (!cnt[id]) return 0;
		ban[id] = 1;
	}
}

int main()
{
#ifdef hany01
	freopen("agc018b.in", "r", stdin);
	freopen("agc018b.out", "w", stdout);
#endif

	n = read<int>(), m = read<int>();
	For(i, 1, n) For(j, 1, m) a[i][j] = read<int>();

	int l = 1, r = n, mid;
	while (l < r) if (check(mid = (l + r) >> 1)) r = mid; else l = mid + 1;
	printf("%d\n", l);

	return 0;
}

Measured memory_bytes: 640
#include <atcoder/scc>;
#include <atcoder/convolution>
#include <atcoder/modint>
#include <atcoder/math>
#include <atcoder/fenwicktree>
#include <atcoder/dsu>
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using namespace atcoder;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll mod = 998244353;
int main() {
	ll N, Q;
	cin >> N >> Q;
	vector<ll> t(Q);
	vector<ll> u(Q);
	vector<ll> v(Q);
	fenwick_tree<long long> fw(N);
	rep(i, N) {
		ll a;
		cin >> a;
		fw.add(i, a);
	}
	rep(i,Q) {
		cin >> t.at(i) >> u[i] >> v[i];

	}

	rep(i, Q) {
		if (t[i] == 0) {
			fw.add(u[i], v[i]);
		}
		else {
			cout << fw.sum(u[i], v[i]) << endl;;
		}
	}
}

Measured memory_bytes: 19948
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    String s = sc.next();
    int ans = 0;

    for(int i = 0; i < n - 2; i++){
      if(s.charAt(i) == 'A' && s.charAt(i + 1) == 'B' && s.charAt(i + 2) == 'C'){
        ans += 1;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 21716
import Control.Applicative

main = do
  [wstr, hstr, xstr, ystr, rstr] <- words <$> getLine
  let w = read wstr :: Int
  let h = read hstr :: Int
  let x = read xstr :: Int
  let y = read ystr :: Int
  let r = read rstr :: Int

  if ( (x >= r) && (x <= w - r) && (y >= r) && (y <= h - r)) then
    putStrLn "Yes"
  else
    putStrLn "No"

Measured memory_bytes: 3580
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a + b + c >= 22)
	{
		cout << "bust" << endl;
	}
	else
	{
		cout << "win" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
// Thanks to robs77 for this template
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <iomanip>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <cstdlib>
/***********MACROS***************/
//#define int long long
#define inf 100000000000000000 
#define ll  long long 
#define LL long long
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
#define fi first 
#define se second 
//#define mod 1000000007
/*********VARIABLE****************/
using namespace std;
typedef pair<int,int> ii;
/******************************/

ll dp[100021],a,i,j,n,m,b[100001],d,s,e,x[100001];
/*********FUNCTIONS**************/
/***********MAIN**************/
 
signed main(){ cin>>n;
	cout<<pow(n,3);
}

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

int main () {
   char c;
   cin >> c;
   string str1, str2;
   str1 = "vowel";
   str2 = "consonant";

   if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
       cout << str1 << endl;
   }

   else {
       cout << str2 << endl;
   }

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	string s[3];
	int i[3];
	int turn = 0;
	string res = "ABC";
	REP(j, 3){
		cin >> s[j];
		i[j] = 0;
	}
	while(1){
		if(s[turn][i[turn]] == 'a'){
			i[turn]++;
			turn = 0;
			if(i[turn] >= s[turn].size())
				break;
		}else if(s[turn][i[turn]] == 'b'){
			i[turn]++;
			turn = 1;
			if(i[turn] >= s[turn].size())
				break;
		}else{
			i[turn]++;
			turn = 2;
			if(i[turn] >= s[turn].size())
				break;
		}
	}
	cout << res[turn] << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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[] b = new long[n];
    for(int i = 0; i < n; i++) {
      long t = sc.nextLong();
      a[i] = t;
      b[i] = t; 
    }
    long min1 = 0;
    long min2 = 0;
    long[] s1 = new long[n];
    s1[0] = a[0];
    long[] s2 = new long[n];
    s2[0] = b[0];
    // 部分和を+-+-にする場合
    for(int i = 0; i < n; i++) {
      if(i > 0) s1[i] = s1[i - 1] + a[i];
      if(i % 2 == 0) {
        if(s1[i] <= 0) {
          min1 += (1 - s1[i]);
          s1[i] = 1;
        }
      } else {
        if(s1[i] >= 0) {
          min1 += (1 + s1[i]);
          s1[i] = -1;
        }
      }
    }

    // 部分和を-+-+にする場合
    for(int i = 0; i < n; i++) {
      if(i > 0) s2[i] = s2[i - 1] + b[i];
      if(i % 2 == 0) {
        if(s2[i] >= 0) {
          min2 += (1 + s2[i]);
          s2[i] = -1;
        }
      } else {
        if(s2[i] <= 0) {
          min2 += (1 - s2[i]);
          s2[i] = 1;
        }
      }
    }
    
    long ans = Math.min(min1, min2);
    System.out.println(ans);
  }
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    double r;
    cin>>r;
    cout<<r*PI*2<<endl;
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  if(n >= m)
  {
    cout << "0";
    return 0;
  }
  vector <int> x(m);
  for(int i=0; i < m; i++)
    cin >> x[i];
  sort(x.begin(), x.end());
  vector <int> cons(m-1);
  for(int i=1; i < m; i++)
  {
    cons[i-1] = x[i] - x[i-1];
  }
  
  sort(cons.begin(), cons.end());

  int ans = 0;
  for(int i=0; i < m - n; i++)
    ans = ans + cons[i];
  cout << ans;
  return 0;

}

Measured memory_bytes: 4020
//SILENT KILLER
#include<bits/stdc++.h>
//typedef long long ll;
using namespace std;
//vector<int>v;
int main()
{
    int n,x,t,ans=0;
    cin>>n>>x>>t;
    if(n%x!=0){
    ans=(n/x+1)*t;
    cout<<ans;

    }
    else
       {
            ans=(n/x)*t;
           cout<<ans;
       }

}





Measured memory_bytes: 3632
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=3e5+5;



int main()
{ 

IOS;

ll n;cin>>n;

ll pp=-1;

string s;cin>>s;

ll cnt=0;

for(int i=0;i<n;i++){
  if(s[i]=='1')cnt++,pp=i;
}

if(cnt==0){
  for(int i=1;i<=n;i++)cout<<1<<endl;
    return 0;
}

vpll mm(n);

vl ans(n,1);

if(cnt==1){
  ll gf=powM(2,n-pp-1,2);
  for(int i=0;i<n;i++){
   if(i==pp){
    cout<<0<<endl;
    continue;
   }
   gf+=powM(2,n-i-1,2);
    if(gf%2==0)cout<<1<<endl;
  else cout<<2<<endl;
  }

  return 0;
}

vl x(n),y(n);
//x:cnt+1,y=cnt-1

ll s1=0,s2=0;
for(int i=0;i<n;i++){
if(s[i]=='1'){
  x[i]=powM(2,n-i-1,cnt+1);
  s1+=x[i];
  y[i]=powM(2,n-i-1,cnt-1);
  s2+=y[i];
}

}

for(int i=0;i<n;i++){
  ll d=0;
  if(s[i]=='1'){
     d=(s2-y[i])%(cnt-1);
     d=(d+cnt-1)%(cnt-1);
  }
  else {
  d=(s1+powM(2,n-i-1,cnt+1))%(cnt+1);
  }
 // cout<<d<<endl;
  mm[i].ff=d;
  ll t=0;
  while(d){
   if(d&1) t++;
    d>>=1;
  }
  mm[i].ss=t;

}

ll flag=0;

while(!flag){

  ll cc=0;

  //cout<<"hi"<<" "<<mm[0].ff<<endl;

  for(int i=0;i<n;i++){
    if(mm[i].ff==0){
      cc++;
      continue;
    }
  //  if(i==n-1){
    //  cout<<"hi"<<" "<<mm[i].ss<<endl;
    //}
    ans[i]++;
    ll f=mm[i].ff;
    ll temp=0;
    ll cn=0;
    ll pos=0;
    while(f){
      if(f&1){
       // cn++;
        temp+=powM(2,pos,mm[i].ss);
        temp%=(mm[i].ss);
       }
       f>>=1;
       pos++;
    }
    mm[i].ff=temp;
    while(temp){
      if(temp&1)cn++;
      temp>>=1;
    }
   // if(i==n-1)cout<<"blah"<<" "<<endl;
    
    mm[i].ss=cn;
  }
  if(cc==n){
    flag=1;
   // break;
  }

}

for(auto p:ans){
  cout<<p<<endl;
}






return 0;
 
}



Measured memory_bytes: 11212
import java.util.Scanner; 
public class Main { 
	public static void main(String[] args) { 
		// ?¨??????\??????????????????????????????????????? 
		Scanner sc = new Scanner(System.in); 
		int w = sc.nextInt(); 
		int n = sc.nextInt(); 
		int[] values = new int[w]; 
		for (int i = 0; i < values.length; i++) { 
			values[i] = i + 1; 
		} 
		for (int i = 0; i < n; i++) { 
			String str = sc.next(); 
			String[] ab = str.split(","); 
			int a = Integer.parseInt(ab[0]) - 1; 
			int b = Integer.parseInt(ab[1]) - 1; 
			int c = values[a];
			values[a] = values[b];
			values[b] = c;
		} 
		for(int i=0;i<w;i++){
			System.out.println(values[i]);
		}
	} 
}

Measured memory_bytes: 25988
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define For_Arr     for(i=0;i<n;i++)
using namespace std;
int main()
{
    ll n,i,x,prev=0;
    cin>>n;
    ll maxi=-1,cnt=0;
    for(i=0;i<n;i++)
    {
        cin>>x;
        if(prev>=x){
            cnt++;
        }
        else{
        maxi=max(maxi,cnt);
        cnt=0;
        }
        prev=x;
    }
    cout<<max(maxi,cnt)<<endl;


    return 0;
}





Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;


int main(){
  ll X;cin>>X;
  for(ll i=-1010;i<=1010;i++)
    for(ll j=-1010;j<=1010;j++)
      if(i*i*i*i*i-j*j*j*j*j==X){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
      
  return 0;
}

Measured memory_bytes: 3628
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    a = LI()

    color = [0] * 9
    for i in a:
        if 0 <= i < 400:
            color[0] += 1
        elif 400 <= i < 800:
            color[1] += 1
        elif 800 <= i < 1200:
            color[2] += 1
        elif 1200 <= i < 1600:
            color[3] += 1
        elif 1600 <= i < 2000:
            color[4] += 1
        elif 2000 <= i < 2400:
            color[5] += 1
        elif 2400 <= i < 2800:
            color[6] += 1
        elif 2800 <= i < 3200:
            color[7] += 1
        else:
            color[8] += 1
    
    ans_min = len([i for i in color[:8] if i > 0]) 
    if ans_min == 0:
        print(1, color[8])
    else:
        print(ans_min, ans_min + color[8])

if __name__ == '__main__':
    resolve()


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

using namespace std;

using ll = long long;

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length() <= k)cout <<s;
    else{
        for(int i = 0; i < k; ++i){
            cout << s[i];
        }
        cout <<"...";
    }
    return 0;

}


Measured memory_bytes: 3620
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if ((B-A)%2 == 0) {
        cout << (B-A)/2 << endl;
    } else {
        ll ans0 = A + (B-A-1)/2;
        ll ans1 = (N-B+1) + (B-A-1)/2;
        cout << min(ans0, ans1) << endl;
    }
}



Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int N;
  cin >> N;
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  VSORT(A);
  while(true) {
    for (int i = 1; i < N; i++) {
      A[i] = A[i] % A[0] ? A[i] % A[0] : A[0];
    }
    VSORT(A);
    if(A[0] == A[N-1]) break;
  }
  cout << A[0] << endl;
}


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

int main(void){
	int t;
	cin >> t;
	long long n[2]= {0, 0};
	while(t--){
		long long a, b;
		cin >> a >> b;
		long long k = max(n[0]/a +(n[0]%a!=0), n[1]/b + (n[1]%b!=0));
		if(!k)k=1;
		n[0] = a*k;
		n[1] = b*k;
	}
	cout << *n +*(n+1) << endl;	
}

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

int main() {
    int N, Q; cin >> N;
    vector<int> bucket(100000, 0);
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        bucket.at(x-1)++;
        sum += x;
    }
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int b, c; cin >> b >> c;
        sum += (c - b) * bucket.at(b-1);
        bucket.at(c-1) += bucket.at(b-1);
        bucket.at(b-1) = 0;
        cout << sum << endl;
    }
}

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

#define fore(i, a, b) for(int i = a; i < b; i++)
#define forn(i, n) fore(i, 0, n)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ford(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;

typedef long long ll;

const int N = 100005;

int n;
ll v[N];

int main(){
	
	scanf("%d", &n);

	forn(i, n) scanf("%lld", v+i);

	int inv = 0;

	{
		ll a = 0, b = 0;
		forn(i, n) if(v[i] > 0) a = max(a, v[i]);
				   else if(v[i] < 0) b = max(b,-v[i]);
		if(b > a){
			inv = 1;
			reverse(v, v+n);
			forn(i, n) v[i] = -v[i];
		}
	}
	vector<pair<int, int> > ans;

	int id = 0;

	forn(i, n) if(v[i] >= v[id]) id = i;

	if(id != n-1){
		while(v[id] > v[n-1]){
			v[n-1] += v[id];
			ans.eb(id, n-1);
		}
	}

	for(int i = 1; i < n; i++){
		if(v[i-1] <= v[i]) continue;
		while(v[i-1] > v[i]+v[n-1]){
			v[n-1] += v[n-1];
			ans.eb(n-1, n-1);
		}
		if(v[i-1] > v[i]) v[i] += v[n-1], ans.eb(n-1, i);
	}

	printf("%d\n", int(ans.size()));

	if(inv){
		for(pair<int, int> &o : ans){
			o.ff = n-1-o.ff, o.ss = n-1-o.ss;
		}
	}

	for(pair<int, int> o : ans)
		printf("%d %d\n", o.ff+1, o.ss+1);

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int64_t ans=0;
  int64_t pre;
  int64_t A;
  cin >> pre;
  for(int i=1;i<N;i++){
    cin >> A;
    if(A<pre){
      ans+=pre-A;
      A=pre;
    }
    pre=A;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
n=int(input())
s=input()

a=0
b=0
e=[]
w=[0]
ans=[]

for i in s:
    if i==("E"):
        a+=1
    else:
        b+=1
    e.append(a)
    w.append(b)
        
for i in range(n):
    ans.append(e[n-1]-e[i]+w[i])

print(min(ans))

Measured memory_bytes: 29700
#include <iostream>
	#include <cstdio>
	#include <algorithm>
	#include <string>
	#include <cstring>
	#include <cctype>
	#include <cmath>
	#include <stack>
	#include <queue>
	#include <vector>
	#include <set>
	#include <map>
	#include <list>
	#include <stdio.h>
	#include <string.h>
	#include <cstdlib>
	#include <math.h>
	#include <bitset>
	#include <iterator>
	#include <iomanip>
	#include <sstream>
	#include <numeric>
	#include <cassert>
	using namespace std;
	int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
	long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
	long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
	#define INF 2000000000
	#define MOD 1000000007
	#define sym cout<<"---------"<<endl;
	#define ll long long
	#define mk make_pair
	#define en endl
	#define RE return 0
	#define int ll
	#define P pair<int,int>
	
	int dp[305][305];

signed main(){
	int n;
	while(cin>>n&&n){
		int w[305];
		memset(dp, 0, sizeof(dp));
		for(int i=0; i<n; i++) cin>>w[i];
		
		for(int W=2; W<=n; W++){
			for(int l=0; l<n; l++){
				int r=l+W;
				if(r>n) continue;
				
				if(dp[l+1][r-1]==W-2&&abs(w[l]-w[r-1])<=1) dp[l][r]=W;
				
				for(int mid=l; mid<=r; mid++){
					dp[l][r]=max(dp[l][r], dp[l][mid]+dp[mid][r]);
				}
			}
		}
		cout<<dp[0][n]<<en;
	}
}



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

int main(){
	int K;
	cin >> K;
	while(K != 0){
		int tmp1, tmp2;
		tmp1 = 0;
		for(int i = 0; i < K*(K-1)/2; i++){
			cin >> tmp2;
			tmp1 += tmp2;
		}
		cout << tmp1 / (K -1) << endl;
		cin >>K;
	}
	return 0;
}


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N, X;
        N = scan.nextInt();
        X = scan.nextInt();
        int[] x = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = scan.nextInt();
        }
        int [] dif = new int[N];
        for (int i = 0; i < N; i++) {
            dif[i] = Math.abs(x[i] - X);
        }
        Arrays.sort(dif);
        
        // for (int i = N - 1; i >= 0; i--) {
        //     System.out.println(dif[i]);
        // }
        
        boolean f = true;
        if (check(dif, dif[0])) {
            System.out.println(dif[0]);
            f = false;
        }
        for (int i = (int)(dif[0] / 2); i > 0 && f; i--) {
            if (dif[0] % i == 0) {
                if (check(dif, i)) {
                    System.out.println(i);
                    break;
                }
            }
        }
    }
    
    public static boolean check(int[] array, int num) {
        for (int i = array.length - 1; i > 0; i--) {
            if (array[i] % num != 0) {
                return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 48232
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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 S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000003;

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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll Q;
combination comb( 1000002 );

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

  rep( q, Q ) {
    ll x, d, n;
    std::cin >> x >> d >> n;

    if( !d ) {
      std::cout << mint(x).pow(n).x << std::endl;

      continue;
    }

    mint D = mint(d).inv();
    mint X = D*x;

    if( mod-X.x <= n-1 || !X.x ) {
      std::cout << 0 << std::endl;

      continue;
    }

    mint ans = comb.fact[X.x+n-1]*comb.ifact[X.x-1]*mint(d).pow(n);

    std::cout << ans.x << std::endl;
  }

  return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  int s[M][N];
  vector<int> p(M);
  for(int i=0; i<M; i++){
    for(int j=0; j<N; j++) s[i][j]=0;
  }
  for(int i=0; i<M; i++){
    int K;
    cin >> K;
    for(int j=0; j<K; j++){
      int t;
      cin >> t;
      s[i][t-1]=1;
    }
  }
  for(int i=0; i<M; i++) cin >> p.at(i);
  
  int bitnum=pow(2, N);
  
  int ans=0;
  for(int i=0; i<bitnum; i++){
    int tem=i;
    vector<int> bitar(N);
    for(int j=0; j<N; j++){
      if(tem%2==1) bitar.at(j)=1;
      tem=tem/2;
    }
    
    int ant=0;
    for(int k=0; k<M; k++){
      int cnt=0;
      for(int l=0; l<N; l++){
        if(s[k][l]==1 && bitar.at(l)==1) cnt++;
      }
      if(cnt%2==p.at(k)) ant++;
    }
    if(ant==M) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<LL, LL> pLL;

int main(void)
{
	LL N, ans;
	cin >> N;

	ans = (1000 - (N % 1000)) % 1000;
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3568
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

type st struct {
	ind int
	min int64
}

func main() {
	var L int
	var R int
	var d int
	fmt.Scan(&L)
	fmt.Scan(&R)
	fmt.Scan(&d)
	// sc.Split(bufio.ScanWords)
	t := L / d
	n := R / d
	j := 0
	if L%d == 0 {
		j = 1
	}
	fmt.Print(n - t + j)

}
func chc(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for i, l := range m {
		tmp := []bool{}
		for _, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[i] = tmp
	}
	return ret
}
func chl(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for j, l := range m {
		tmp := []bool{}
		for i, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[j] = tmp
	}
	return ret
}
func helper(ma [][]bool) int {
	count := 0
	for _, l := range ma {
		for _, c := range l {
			if c == true {
				count++
			}
		}
	}
	return count
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
ll a[N];

void solve(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    
    sort(a + 1,a + n + 1);
    int mn = 2 * INF; 
    int ans = 0;
    for(int i = 1; i < n; ++i) {
        if(abs(a[i] - a[n] / 2) <= mn) {
            ans = a[i];
            mn = abs(a[i] - a[n] / 2);
        }
    }
    cout << a[n] << " " << ans;
}
 
int main(){
    speed();
     int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

int main(){
  int h, w, n;
  int ans;
  
  std::cin>>h>>w>>n;
  int div = fmax(h,w);
  if(n%div ==0){
  ans= n/div;
  }else{
  ans = (n/div)+1;
  }
  
  
  std::cout<<ans<<std::endl;
  
  
 return 0; 
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
//#pragma GCC target("avx,avx2,sse4.2")
#define re register
#define rep(q, a, b) for (re int q = a, q##_end_ = b; q <= q##_end_; ++q)
#define dep(q, a, b) for (re int q = a, q##_end_ = b; q >= q##_end_; --q)
#define mem(a, b) memset(a, b, sizeof a)
#define debug(a) cerr << #a << ' ' << a << "___" << endl
using namespace std;
//char buf[10000000], *p1 = buf, *p2 = buf;
#define Getchar() getchar()//p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 10000000, stdin), p1 == p2) ? EOF : *p1++
template<typename T>
void in(T &r) {
    static char c;
    r = 0;
    while (c = Getchar(), c < 48)
        ;
    do
        r = (r << 1) + (r << 3) + (c ^ 48);
    while (c = Getchar(), c > 47);
}
const int mn=2019;
int n,m;
int main(){
	in(n),in(m);
	int ans=mn;
	if(m-n>=2019){
		ans=0;
	}else{
		n%=mn,m%=mn;
		if(n<=m){
			rep(q,n,m)rep(w,q+1,m)ans=min(ans,q*w%mn);
		}else{
			rep(q,0,2018)if(q>=m||q<=n)rep(w,0,2018)if(w>=m||w<=n)
			ans=min(ans,q*q%mn);
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
    ll A,B,C; cin >> A >> B >> C;
    ll K; cin >> K;

    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K - i; j++) {
            for (int k = 0; k <= K - i -j; k++) {
                ll A1, B1, C1;
                A1 = A * (ll)pow(2,i);
                B1 = B * (ll)pow(2,j);
                C1 = C * (ll)pow(2,k);
                if (A1 < B1 && B1 < C1) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3992
// 解答不能.
// kort0n氏.
// https://atcoder.jp/contests/abc153/submissions/9738954
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL dp[20005];

int main(){
    LL H, N;
    scanf("%lld %lld", &H, &N);
    rep(i, 2e4 + 1) dp[i] = 1e18;
    dp[0] = 0;
    rep(i, N){
        LL a, b;
        scanf("%lld %lld", &a, &b);
        rep(j, H + 1) dp[j + a] = min(dp[j + a], dp[j] + b);
    }
    LL ans = 1e18;
    repx(i, H, 2e4 + 1) ans = min(ans, dp[i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include <string>
#include <iostream>
using namespace std;
int main(){
  string a,b; cin >> a >> b;
  string ans;
  for(int i=0;i<b.length();i++){
    ans += a[i];
    ans += b[i];
  }
  if(a.length()!=b.length()) ans+=a[a.length()-1];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A, B;
  cin >> A >> B;
  int N = B - A;
  vector<int> vec(999);
  rep(i, 999) {
    if(i == 0) {
      vec.at(i) = 1;
    }
    else {
      vec.at(i) = vec.at(i-1)+i+1;
    }
  }
  cout << vec.at(N-1) - B << endl;
}

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

#define pb push_back
#define sz size()
#define clr clear()
#define rep(i,a) for(int i=0;i<(int)(a);i++)
using namespace std;
typedef long double D;
typedef vector<D> vec;
typedef vector<vec> mat;
const double EPS = 1e-3;

struct matrix{
  mat m;
  int r,c;

  matrix(void){r=c=0;m.clr;}

  matrix(mat a){
    r = a.sz;c = a[0].sz;
    m.resize(r);
    rep(i,r)m[i].resize(c);
    rep(i,r)rep(j,c)m[i][j] = a[i][j];
  }
};

vec gauss_jordan(const mat& A, const vec& b){
  int n = A.size();
  mat B(n,vec(n+1));
  rep(i,n)rep(j,n)B[i][j] = A[i][j];
  rep(i,n)B[i][n] = b[i];

  rep(i,n){
    int p = i;
    for(int j=i;j<n;j++){
      if(abs(B[j][i]) > abs(B[p][i]))p = j;
    }
    swap(B[i],B[p]);
    
    if(abs(B[i][i]) < EPS)return vec();
    
    for(int j=i+1;j<=n;j++)B[i][j] /= B[i][i];
    rep(j,n){
      if(i != j){
	for(int k=i+1;k<=n;k++)B[j][k] -= B[j][i] * B[i][k];
      }
    }
  }
  vec x(n);
  rep(i,n)x[i] = B[i][n];
  return x;
}

int main(){
  int d;
  while(cin >> d,d){
    vec v(d+3);
    rep(i,d+3)cin >> v[i];

    int ans = 0;
    rep(i,d+3){
      rep(j,i){
	mat A; vec b;
	rep(k,d+3){
	  if(i==k || j==k)continue;
	  vec tmp(d+1); D pow = 1;
	  rep(l,d+1){
	    tmp[l] = pow;
	    pow *= k;
	  }
	  A.push_back(tmp);
	  b.push_back(v[k]);
	}
	vec x = gauss_jordan(A,b);

	D val1 = 0, val2 = 0;
	D pow1 = 1, pow2 = 1;
	rep(k,x.size()){
	  val1 += pow1 * x[k]; pow1 *= i;
	  val2 += pow2 * x[k]; pow2 *= j;
	}

	D dif1 = abs(val1-v[i]), dif2 = abs(val2-v[j]); 
	if(dif1<EPS && dif2+EPS>1.0){ans = j; break;}
	else if(dif1+EPS>1.0 && dif2<EPS){ans = i; break;}
      }
    }

    cout << ans << endl;
  }
}

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

int main()
{
  int N;

  cin >> N;

  vector<int> A(N);

  for (int i = 0; i < N - 1; i++)
  {
    cin >> A.at(i);
  }

  vector<int> ans(N);

  for (int i = 0; i < N - 1; i++)
  {
    ans.at(A.at(i) - 1)++;
  }

  for (int i = 0; i < N; i++)
  {
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 4824
#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define fore(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1000000007
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
char a[1005][1005];
long long dp[1005][1005];
long long grid(int h,int w){
if(a[h][w]=='#') return 0;
else if(h==1&&w==1) return 1;
else if(w==1) return dp[h][w]=grid(h-1,w)%MAX;
else if(h==1) return dp[h][w]=grid(h,w-1)%MAX;
else if(dp[h][w]!=-1) return dp[h][w]%MAX;
return dp[h][w]=grid(h-1,w)%MAX+grid(h,w-1)%MAX;
}
int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	int H,W;
	cin>>H>>W;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=H;i++){
	for(int j=1;j<=W;j++)
	cin>>a[i][j];
	}
	long long ans=grid(H,W);
	cout<<ans%MAX;
	return 0;
}



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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;
vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=1e18;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{    
    

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

    string s;

    cin>>s;

    li a=0,b=0;

    f(i,0,2)
    {
        if(s[i]=='A')
            a++;
        else
            b++;
    }

    if(a==3 || b==3)
        cout<<"No";
    else
        cout<<"Yes";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1000000000000000007
#define pb emplace_back
typedef vector<ll> vi;

void solve(){
int n=0,k=0,w=0;
ll sum;
ll bal=0,ans=0;
cin>>n>>w;
vi dp(1000*n+1,INF);
vi a(n),b(n);
dp[0]=0;
for(int i=0;i<n;i++)
cin>>a[i]>>b[i];
for(int x:b)
bal+=x;
for(int i=0;i<n;i++){
	for(int j=bal;j>=b[i];j--){
		dp[j]=min(dp[j],dp[j-b[i]]+a[i]);
	}
}
for(ll i=0;i<=bal;i++){
	if(dp[i]<=w){
		ans=max(ans,i);
	}
}
cout<<ans<<"\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
   int t=1;
   //cin>>t;
     while(t--){
     	solve();
	 }
     return 0;
} 

Measured memory_bytes: 3988
#include<cstdio>
#include<iostream>

using namespace std;

bool solve(int a,int b,int c){
	if(a==b&&b==c) return false;
	if(a!=b&&b!=c&&a!=c) return false;
	return true;
}

int main(){
	//freopen("in","r",stdin);
	int a,b,c;  cin >> a >> b >> c;
	if(solve(a,b,c)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256