akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();


        int[] ABC;
        int[] Haiku = { 5, 5, 7 };
        void solve() {
            ABC = new int[3];
            for (int i = 0; i < 3; i++)
                ABC[i] = cin.nextInt();

            Array.Sort(ABC);

            bool isHaiku = ABC.SequenceEqual(Haiku);

            Console.WriteLine(isHaiku?"YES":"NO");

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
        }
        class Mathf {
            private int mod = 1000000007;//10^9+7
            public int Mod { get; set; }
            public Mathf() { }
            public Mathf(int mod) { this.mod = mod; }
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;}
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}
template<typename T>T power(T a,T b){
  T tmp = 1;
  rep(i,b){
    tmp *= a;
  }
  return tmp;
}
int main(){
  int n;cin>>n;
  int t,a;cin>>t>>a;
  vector<int> h(n);rep(i,n)cin>>h[i];
  vector<int> c(n);
  rep(i,n){
    c[i] = t*1000 - h[i]*6;
    c[i] = abs(a*1000 - c[i]);
  }
  int ans = min_element(all(c)) - c.begin();
  ans++;
  print(ans)
  return 0;
}


Measured memory_bytes: 256
import bisect
import math
N,D,A=map(int,input().split())
tmp=[list(map(int,input().split())) for i in range(N)]
tmp.sort(key=lambda x:x[0])
monster=[];X=[]
for i in range(N):
    monster.append(tmp[i][1]);X.append(tmp[i][0])
minus=[0]*(N+1)
ans=0
damage=0
for i in range(N):
    damage-=minus[i]
    monster[i]=max(0,monster[i]-damage)
    if(monster[i]==0):
        continue
    cnt=math.ceil(monster[i]/A)
    monster[i]=0
    ans+=cnt
    b=bisect.bisect_left(X,X[i]+2*D+1)
    minus[b]+=cnt*A
    damage+=A*cnt
print(ans)

Measured memory_bytes: 124376
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666
int arr[N];
signed main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		int t;
		cin>>t;
		for(int j=1;j<=t;j++){
			int ss;
			cin>>ss;
			arr[ss]=1;
		}
	}
	int s=0;
	for(int i=1;i<=n;i++) if(!arr[i]) s++;
	cout<<s; 
	return 0;
} 

Measured memory_bytes: 3596
# スペース区切りの文字列の入力
K, N = (int(x) for x in input().split())
A = [int(x) for x in input().split()]

ans = 0
max = 0

for i in range(N):
  if(i == N - 1):
    A2 = K + A[0]
  else:
    A2 = A[i+1]
    
  # 距離が最大のもの以外をansに加算
  if(max < abs(A2 - A[i])):
      ans += max
      max = abs(A2 - A[i])
  else:
    ans += abs(A2 - A[i])

print(ans)


Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int A, B, C;
	//long long N, M;
	//double d, e;
	//string s, t;
	//vector<int> v;
	//vector<pair<int, int>> pl;

	//while() {}
	//for(int i=0; i<N; i++) {}
	
	cin >> A >> B >> C;
	int ans;
	if(A < B) {
		if(B < C) ans = A + B;
		else ans = A + C;
	} else {
		if(A < C) ans = A + B;
		else ans = B + C;

	}
	cout << ans;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



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

typedef struct{
    int i1;
    int i2;
    int dist;
} bridge;

typedef pair<int, int> P;

int n;
vector< bridge > d;

P dfs(int cur, int prev){
    vector< P > ld(1, P(0, 0));
    int i;
    for(i = 0; i < n-1; i++){
        if( d[i].i1 == cur && d[i].i2 != prev ){
            P d1 = dfs(d[i].i2, cur);
            if( d1.first < 0 ){
                ld.push_back( P(0, 0) );
            }else{
                ld.push_back( P(d1.first + d[i].dist,
                                d1.second + 2*d[i].dist) );
            }
        }
        if( d[i].i2 == cur && d[i].i1 != prev ){
            P d1 = dfs(d[i].i1, cur);
            if( d1.first < 0 ){
                ld.push_back( P(0, 0) );
            }else{
                ld.push_back( P(d1.first + d[i].dist,
                                d1.second + 2*d[i].dist) );
            }
        }
    }
    if( ld.size() == 1 ) return P(-1, 0);
    sort( ld.begin(), ld.end() );
    int res = 0, max_diff = 0;
    for(i = 0; i < ld.size(); i++){
        res += ld[i].second;
    }
    for(i = 0; i < ld.size(); i++){
        if( ld[i].second - ld[i].first > max_diff ){
            max_diff = ld[i].second - ld[i].first;
        }
    }
    return P( res - max_diff, res );
}

int main(){
    while( cin >> n, n ){
        d = vector< bridge >(n-1);
        for(int i = 0; i < n-1; i++){
            cin >> d[i].i1 >> d[i].i2 >> d[i].dist;
        }
        cout << dfs(1, 0).first << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
start = Time.now
N = gets.to_i
XYD = $<.map{|s|
  x, y, d = s.split
  [x.to_i, y.to_i, d.intern]
}
f = ->n{
  tbl = {
    R: [1, 0],
    L: [-1, 0],
    U: [0, 1],
    D: [0, -1],
  }
  min_x = min_y = 1.0/0
  max_x = max_y = -1.0/0
  XYD.each{|x, y, d|
    x *= 2
    y *= 2
    mul_x, mul_y = tbl[d]
    x += n * mul_x
    y += n * mul_y
    min_x = x if x < min_x
    max_x = x if x > max_x
    min_y = y if y < min_y
    max_y = y if y > max_y
  }
  (max_x - min_x) * (max_y - min_y)
}

l = 0
r = 10**9
# p f[0]
50.times{|i|
  if f[(l * 2 + r) / 3] < f[(l + r * 2) / 3]
    r = (l + r * 2) / 3
  else
    l = (l * 2 + r) / 3
  end
  break if Time.now - start > 4.9
}
p f[(l + r) / 2].fdiv 4

Measured memory_bytes: 11644
#include<iostream>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<cmath>
    #include<tuple>
    #include<string>
    typedef long long ll;
    #define rep(i,a,b) for(int i=(a);i<(b);i++)
    #define repm(i,a,b) for(int i=(a);i>(b);i--)
    #define F first
    #define S second
    using namespace std;
    const ll INF = 1e12;
    const double PI = 3.1415926535897932;
    const int i_INF = 2147483647;
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
     
     
	int main() {
		int n;
		cin >> n;
		vector<char> s(n);
		rep(i, 0, n)cin >> s[i];
		bool judge = true;
		if ((n % 2) == 1)judge = false;
		else {
			rep(i, 0, n / 2) {
				if (s[i] != s[n / 2 + i])judge = false;
			}
		}
		if (judge) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
		return 0;
	}

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

int main() {
  ll N, D;
  cin >> N >> D;

  ll ans = 0;
  rep(i,0,N-1)
  {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= D * D)
    {
      ans++;
    }
  }

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


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
vector<int> v[100010];
bool visit[100010];
int d[100010];
vector<int> tp;
void dfs(int x)
{
	visit[x]=1;
	for (int i=0;i<v[x].size();i++)
	{
		int xi=v[x][i];
		if (!visit[xi]) dfs(xi);
	}
	tp.push_back(x);
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++)
	{
		int x,y;
		cin >>x>>y;
		v[x-1].push_back(y-1);
	}
	for (int i=0;i<n;i++) if (!visit[i]) dfs(i);
	for (int i=0;i<n;i++)
	{
		int x=tp[i];
		for (int j=0;j<v[x].size();j++)
		{
			int xi=v[x][j];
			d[x]=max(d[x],d[xi]+1);
		}
	}
	cout <<*max_element(d,d+n);
	return 0;
}

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

using namespace std;

int main() {
    int k;
    cin >>k;
    for(int i = 0;i < k; i++){
        int x,y;
        cin >> x >>y;
        int p;
        cin >>p;
        vector<vector< vector<int> > > flag(x+1 ,vector< vector<int> > (y+1,vector<int>(2,1)));
        for(int s =0; s<= x;s++){
          for(int t = 0; t <= y ;t++){
              if(s==0) {
                flag[s][t][1] = 0;//左から
              }
              if(t==0) {
                flag[s][t][0] = 0; //上から
              }
            }
          }
        if(p != 0){
          vector<vector<int> > mata(p,vector<int>(4));

        for(int j = 0; j<p; j++){
          cin >>mata[j][0] >>mata[j][1] >>mata[j][2]>>mata[j][3];

          if(mata[j][0] == mata[j][2] ){//上から
            if(mata[j][1]>mata[j][3]){
              flag[mata[j][0]][mata[j][1]][0] = 0;
            }
            else {
              flag[mata[j][0]][mata[j][3]][0] = 0;
            }
          }
          if(mata[j][1] == mata[j][3]) {
            if(mata[j][0] > mata[j][2]) {
              flag[mata[j][0]][mata[j][1]][1] = 0;
            }
            else {
              flag[mata[j][2]][mata[j][1]][1] = 0;
            }
          }
        }

        }
        vector<vector<int> > dp(x+1 ,vector<int> (y+1,0));
		dp[0][0] =1;
        for(int n =0;n <= x;n++){
          for(int m = 0; m <= y; m++ ){
            if(flag[n][m][0] == 1){
              dp[n][m] +=dp[n][m-1];
            }
            if(flag[n][m][1] == 1){
              dp[n][m] +=dp[n-1][m];
            }
          }
        }
        if(dp[x][y]==0){
          cout << "Miserable Hokusai!\n";
        }
        else{
          cout << dp[x][y] << endl;
        }

    }


    return 0;

}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ld long double

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * c, max(a * d, max(b * c, b * d)));
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N,M;
    cin >> N >> M;
    
    pair<ll,ll> AB[100000];
    for(int i=0; i<N; i++){
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB,AB+N);
    
    ll ans=0;
    for(int i=0; i<N; i++){
        if(AB[i].second >= M){
            ans += M*AB[i].first;
            break;
        }else{
            ans += AB[i].second*AB[i].first;
            M-=AB[i].second;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

int main(){
    int H,W;
    for(int k = 0;;k++){
        scanf("%d%d",&H,&W);
        if(H != 0 && W != 0){
            for(int i = 0;i < H;i++){
                for(int j = 0;j < W;j++){
                    printf("#");
                    }
            printf("\n");
            }
        printf("\n");
        continue;
        }
    break;
    }
    return 0;
}


Measured memory_bytes: 2588
/**** Last Updated 19-June-2020*****/
/*
*
*/
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define sets            set<string> //insert() .top()
#define seti            set<int>
#define pii             pair<int,int>
#define vi              vector<int> //push_back()
#define mii             map<int,int>
#define pqb             priority_queue<int> //insert()
#define pqs             priority_queue<int,vi,greater<int> >
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int32_t main()
{
    FIO;
   string s,t;cin>>s>>t;
   int c=0;
    for(int i=0;i<s.size();i++)
    {
            if(s[i]==t[i])
            {

            }
            else c++;

    }
    cout<<c<<endl;
}



Measured memory_bytes: 3836
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,K;
int sum=0;
#define Maxn 505
int A[Maxn],B[Maxn];
inline bool Judge(int c){
	int d=0;
	for(register int i=1;i<=n;++i){
		B[i]=A[i]%c;
		d+=B[i];
	}
	d/=c;
	d=n-d;
	int tmp=0;
	sort(B+1,B+n+1);
	for(register int i=1;i<=d;++i)tmp+=B[i];
	if(tmp<=K)return true;
	return false;
}
int main(){
	scanf("%d%d",&n,&K);
	for(register int i=1;i<=n;++i){
		scanf("%d",&A[i]);
		sum+=A[i];
	}
	int Ans=0;
	for(register int i=1;i<=sqrt(sum);++i)
	    if(sum%i==0){
	    	if(Judge(i))Ans=max(Ans,i);
	    	if(Judge(sum/i))Ans=max(sum/i,Ans);
		}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// Problem : D - Anything Goes to Zero
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

int binpow(int x,int y, int m){
    x %= m;
    int res = 1;
    while(y){
        if(y&1) res = (res*x)%m;
        x = (x*x)%m;
        y = y/2;
    }
    return res;
}

int f(int x){
    int cnt = 0;
    while(x != 0){
        int z = __builtin_popcount(x);
        x = x%z;
        cnt++;
    }
    return cnt;
}

void solve(){
    int n;
    string s;
    cin>>n>>s;
    int pc = 0;
    for(char c : s) if(c == '1') pc++;
    int val1 = 0;
    for(int i=0;i<n;i++){
        if(s[i] == '1') val1 = (val1+binpow(2,n-i-1,pc+1))%(pc+1);
    }
    int val2 = 0;
    if(pc - 1 == 0);
    else{
        for(int i=0;i<n;i++){
            if(s[i] == '1') val2 = (val2+binpow(2,n-i-1,pc-1))%(pc-1);
        }
    }
    for(int i=0;i<n;i++){
        if(s[i] == '1'){
            if(pc-1 == 0){
                cout<<0<<'\n';
                continue;
            }
            int x = (val2-binpow(2,n-i-1,pc-1)+(pc-1))%(pc-1);
            cout<<f(x)+1<<'\n';
        } else {
            int x = (val1+binpow(2,n-i-1,pc+1))%(pc+1);
            cout<<f(x)+1<<'\n';
        }
    }
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3776
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int a, b, x;
	cin >> a >> b >> x;
	bool ans = x >= a && x <= a + b;
	cout << (ans ? "YES" : "NO") << endl;
}


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

int main(){

  int A, B;
  cin >> A >> B;
    
  int x1, x2;
  x1 = max(A, B);
  x2 = max(max(A, B)-1, min(A, B));
  
  cout << x1+x2 << endl;
 
}

Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int main(){
		int n;
		long long l[87];

		cin>>n;

		l[0]=2;
		l[1]=1;
		for(int i=2;i<n+1;i++)
			l[i]=l[i-1]+l[i-2];
		cout<<l[n]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    int i;
    while(a>0 && c>0){
    	c=c-b;
    	if(c<=0){
    		cout<<"Yes";
    		return 0;
		}
    	a=a-d;
    	if(a<=0){
    		cout<<"No";
    		return 0;
		}
	}
  return 0;
}

Measured memory_bytes: 3624
n = int(input())
s = input()
ans = 1001001001
ll = [0]
rl = [0]
l = 0
r = 0
for i in range(1, len(s)):
    if s[i - 1] == 'W':
        l += 1
    ll.append(l)
    if s[-i] == 'E':
        r += 1
    rl.append(r)
rl.reverse()

# print(ll)
# print(rl)

for a, b in zip(ll, rl):
    ans = min(ans, a + b)
print(ans)


Measured memory_bytes: 17644
#!/usr/bin/ruby
W=17
Z=100
n=0
q=[]
r=[]
sheat=Array.new(W)
t=0
loop{
	if t%5==0
		q << t/5
	end
	W.times{|i|
		if sheat[i]
			sheat[i]-=1
			sheat[i]=nil if sheat[i]==0
		end
	}
	while q.size>0
		l=(q[0]%5==1 ? 5 : 2)
		_p=(0..W-l).find{|i|sheat[i,l]==[nil]*l}
		break if !_p
		_p.step(_p+l-1){|i|
			sheat[i]=17*(q[0]%2)+3*(q[0]%3)+19
		}
		r<<t-q[0]*5
		q.shift
	end
	break if r.length>Z
	t+=1
}
while gets
p r[$_.to_i]end

Measured memory_bytes: 2456
//yashverma

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define Pi 3.141592653589793
#define MOD 1000000007
// For i/o
#define sd1(a) scanf("%d",&a)
#define sd2(a,b) scanf("%d %d",&a,&b)
#define sd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sf scanf
#define pf printf
// For debugging
#define deb(a) printf("deb%d\n",a)

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

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << "ABC" << n << endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
g=0
p=0
point=0
for i in range(len(s)):
    o=s[i]
    if o=="g":
        if p+1<=g:
            point+=1
            p+=1
        else:
            g+=1
    else:
        if p+1<=g:
            p+=1
        else:
            point-=1
            g+=1
print(point)

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define int long long
const int inf = 100100100100100;
const int mod = 1000000007;

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

    int n, k;
    cin >> n >> k;

    vector< pair<int,int> > arr;
    rep(i,0,n){
        int w,d;
        cin >> w >> d;
        arr.push_back(make_pair(w,d));
    }

    int left = 0;
    int right = 3e18;
    rep(i,0,200){
        int mid = (left + right)/2;
        int cnt = 0;
        
        rep(j,0,n){
            if (mid < arr[j].first) continue;
            cnt += (mid - arr[j].first)/arr[j].second + 1;
        }

        if(cnt >= k){
            right = mid;
        }else{
            left = mid+1;
        }
    }

    cout << left << endl;
}

Measured memory_bytes: 2420
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;
map<string,int>sp;
string s[man];

int main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    int n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >>s[i];
        sp[s[i]]++;
    }   
    int max = -1;
    for(auto it:sp){
        if(it.second > max)max = it.second;
    }
    vector<string>a;
    for(auto it:sp){
        if(it.second==max){
            a.push_back(it.first);
        }
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < a.size();i++)cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 28404
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;




signed main() {
    ll n; 
    cin >> n;
    ll r = 0;
    
    r += n/100;
    n %= 100;
    r += n/10;
    n %= 10;
    r += n/1;
    mes(r);
}

Measured memory_bytes: 3608
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on
 
constexpr int powm(int a, int b, const int& m) {
  int c = 1;
  while (b) {
    if (odd(b)) c = (c * a) % m;
    b >>= 1;
    a = (a * a) % m;
  }
  return c;
}
struct modint {
  int v;
  modint(int a = 0)
    : v(((a % MOD) + MOD) % MOD) {
  }
  modint operator+(const modint& b) const {
    return (v + b.v) % MOD;
  }
  modint operator-(const modint& b) const {
    return (v - b.v + MOD) % MOD;
  }
  modint operator*(const modint& b) const {
    return (v * b.v) % MOD;
  }
  modint operator/(const modint& b) const {
    return (v * powm(b.v, MOD - 2, MOD)) % MOD;
  }
};
bool operator==(const modint& a, const modint& b) {
  return a.v == b.v;
}
modint& operator+=(modint& a, const modint& b) {
  return a = a + b;
}
modint& operator-=(modint& a, const modint& b) {
  return a = a - b;
}
modint& operator*=(modint& a, const modint& b) {
  return a = a * b;
}
modint& operator/=(modint& a, const modint& b) {
  return a = a / b;
}
 
ostream& operator<<(ostream& out, const modint& a) {
  return out << a.v;
}
istream& operator>>(istream& in, modint& a) {
  int v;
  in >> v;
  a = modint(v);
  return in;
}
 
void solve() {
  int n;
  cin >> n;
  vector<modint> factorial(n + 2);
  factorial[0] = 1;
  loop(i, 1, factorial.size()) factorial[i] = modint(i) * factorial[i - 1];
  auto ncr = [&](int n, int r) {
    return factorial[n] / (factorial[r] * factorial[n - r]);
  };
  int l, r;
  map<int, int> m;
  rep(i, n + 1) {
    int a;
    cin >> a;
    if (m.count(a)) {
      l = m[a];
      r = i;
    } else {
      m[a] = i;
    }
  }
  int t = l + (n - r);
  loop(k, 1, n + 2) {
    modint b = ncr(n + 1, k);
    if (t >= k - 1) b -= ncr(t, k - 1);
    cout << b << endl;
  }
}

Measured memory_bytes: 8192
#include <stdio.h>
#define MAXn 10000
#define MAXq 500

int main(){
  int Snum[MAXn],Tq[MAXq],cnt=0,i,j,Sn,Tqn;
  
  scanf("%d",&Sn);
  for(i=0;i<Sn;i++){
    scanf("%d",&Snum[i]);
  }
  scanf("%d",&Tqn);
  for(i=0;i<Tqn;i++){
    scanf("%d",&Tq[i]);
  }
  for(j=0;j<Tqn;j++){
    for(i=0;i<Sn;i++){
      if(Snum[i]==Tq[j]){
        cnt++;
        break;
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    
    int N;
    cin >> N;
    
    vector<string> values;
    
    string x;
    for (int i = 0; i < N; i++) {
        cin >> x;
        values.push_back(x);
    }
    
    sort(values.begin(), values.end());
    
    string last = values[0];
    int count = 1;
    for (int i = 1; i < N; i++) {
        if (values[i] != last) {
            count++;
            last = values[i];
        }
    }
    
    cout << count;

    return 0;
}

Measured memory_bytes: 11660
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  print_newline ();
  preorder (fun e -> print_string " "; print_int e) t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let delete x t =
  let rec dudu = function
    | Nil -> assert false
    | Node (x, Nil, _) -> x
    | Node (_, l, _) -> dudu l
  and wa = function
    | Nil -> assert false
    | Node (_, Nil, r) -> r
    | Node (x, l, r) -> Node (x, wa l, r)
  and doit = function
    | Nil -> assert false
    | Node (y, l, r) ->
      if x = y then
        if l = Nil then r
        else if r = Nil then l
        else Node (dudu r, l, wa r)
      else if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let t = ref (create ()) in
  for _ = 0 to m - 1 do
    match read_line () |> split_on_char ' ' with
    | ["insert"; n] -> t := insert (int_of_string n) !t
    | ["find"; n] -> print_endline (if find (int_of_string n) !t then "yes" else "no")
    | ["delete"; n] -> t := delete (int_of_string n) !t
    | _ -> print !t
  done

Measured memory_bytes: 25264
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){

    int n, i, j, k, v;

    scanf("%d", &n);

    int A[n];

    for( i = 0 ; i < n ; i++ ){

        scanf( "%d", &A[i] );

    }

     for( k=0 ; k < n ; k++ ){

        if( k > n-2 ){

            printf("%d\n", A[k] );

         }else{

            printf("%d ", A[k] );

        }
     }

    for( i = 1 ; i < n ; i++ ){

            v = A[i];
            j = i - 1;
    
        while( j >= 0 && A[j] > v ){

                A[j+1] = A[j];

                j--;

        }

        A[j+1] = v;

        for( k=0 ; k < n ; k++ ){


            if( k > n-2 ){

                printf("%d\n", A[k] );

            }else{

                printf("%d ", A[k] );

            }
        }

    }

    return 0;

}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define isFile 0
#define NAME "taskA"
#define scan 1
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define ins insert
#define all(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define bit(n, i) (n >> i) & 1
#define bpc(x) __builtin_popcountll(x)
#define rev(a) reverse(all(a))
#define skip continue
#define read(a) for(auto &i : a) cin >> i
#define print(a) for(auto i : a) cout << i << ' '
#define unique(a) sort(all(a));    a.resize(unique(all(a)) - a.begin())

//                D  R  U   L
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void faster() {
    if (isFile) {
        freopen(NAME".in", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    if (scan) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
}

const ll  INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ld  PI = acos(-1);
const ld  EPS = 3E-16;
const int ALPHA = 27;
const int N = (int)3e3 + 5;
const int M = 123;

double dp[N];
int n;

void solve() {
    cin >> n;

    dp[0] = 1;
    for(int i = 0; i < n; i++) {
        double p;
        cin >> p;
        for(int j = i + 1; j >= 0; j--) {
            dp[j] = (j == 0 ? 0 : dp[j - 1] * p) + dp[j] * (1 - p);
        }
    }

    double ans = 0;
    for(int i = 0; i <= n; i++) {
        if (i > (n - i)) {
            ans += dp[i];
        }
    }

    cout << fixed << setprecision(10) << ans << endl;
}

int main() {
    faster();
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


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

public class Main {
    public static void main(String[] args) throws java.io.IOException {
        final int MAX = 300000;
        Scanner sc = new Scanner(System.in);
        boolean[] msprime = new boolean[MAX + 1];
        int limit = MAX / 7;
        for (int i = 0; i <= limit; i++) {
            if ((7 * i + 1) > MAX)
                break;
            msprime[7 * i + 1] = true;
            if ((7 * i + 6) > MAX)
                break;
            msprime[7 * i + 6] = true;
        }
        msprime[1] = false;

        for (int i = 0; i < MAX + 1; i++) {
            if (msprime[i]) {
                if(i*6>MAX)continue;
                msprime[i * 6] = false;
                for (int j = 1; j <= limit; j++) {
                    if (i * (7 * j + 1) > MAX)
                        break;
                    msprime[i * (7 * j + 1)] = false;
                    if (i * (7 * j + 6) > MAX)
                        break;
                    msprime[i * (7 * j + 6)] = false;
                }
            }
        }
       // System.out.println(Arrays.toString(msprime));
        while (true) {
            int n = sc.nextInt();
            if (n == 1)
                break;
            System.out.print(n + ":");
            if(6>n)continue;
            if (n % 6 == 0)
                System.out.print(" 6");
            for (int i = 1; i<= n; i++) {
                if((7*i+1)>n)break;
                if (msprime[7 * i + 1] && n % (7 * i + 1) == 0)
                    System.out.print(" " + (7 * i + 1));
                if((7*i+6)>n)break;
                if (msprime[7 * i + 6] && n % (7 * i + 6) == 0)
                    System.out.print(" " + (7 * i + 6));
            }
            System.out.println();
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define v(T) vector<T>
#define imposs      \
  {                 \
    cout << "-1\n"; \
    return 0;       \
  }
#define LL_MAX LLONG_MAX
#define LL_MIN LLONG_MIN

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef set<int> si;
typedef multiset<int> msi;
template <typename T>
string join(const v(T) & v)
{
  stringstream s;
  rep(i, sz(v)) s << ' ' << v[i];
  return s.str().substr(1);
}
template <typename T>
inline ostream &operator<<(ostream &o, const v(T) & v)
{
  if (sz(v))
    o << join(v);
  return o;
}

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

  int n;
  cin >> n;
  vi a(n + 1);
  ll s = 0;

  rep(i, n + 1)
  {
    cin >> a[i];
    s += a[i];
  }

  ll bef = 1;
  ll ans = 1;

  if (n==0) {
    if (a[0] == 1) {
      cout << "1\n";
    } else {
      cout << "-1\n";
    }
    return 0;
  } else {
    if (a[0] != 0) {
      cout << "-1\n";
      return 0;
    } else {
      bef = 1;
      ans = 1;
    }
  }

  rrep(i, n)
  {
    if (a[i] > bef * 2) {
      cout << "-1\n";
      return 0;
    }

    bef = min(s, bef*2);

    ans += bef;

    bef -= a[i];
    s -= a[i];
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n, a[100100];
ll ans[2];

ll solve(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(int k = 0; k < 2; ++k){
        ll sum = 0;
        for(int i = 0, j = -1 + 2 * k; i < n; ++i, j *= -1){
            sum += a[i];
            if(sum * j > 0) continue;
            ans[k] += abs(sum - j);
            sum = j;
        }
    }
    return min(ans[0], ans[1]);
}

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

    cout << solve() << "\n";
    
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int ans = 0;
vector<vi> g;
void dfs(int v, int n, vector<bool> visited) {
    if (count(all(visited), true) == n) {
        ++ans;
        return;
    }
    for (int to : g[v]) {
        if (visited[to]) continue;
        visited[to] = true;
        dfs(to, n, visited);
        visited[to] = false;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    g = vector<vi>(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    vector<bool> visited(n);
    visited[0] = true;
    dfs(0, n, visited);
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    vector<int> ans(26,50);
    for(int i = 0; i < n; i++){
        vector<int> check(26,0);
        for(char c : s[i]){
            check[int(c - 'a')]++;
        }
        for(int j = 0; j < 26; j++){
            if(check[j] < ans[j]) ans[j] = check[j];
        }
    }
    for(char c = 'a'; c <= 'z'; c++){
        cout << string(ans[int(c - 'a')], c);
    }
    cout << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int f1[2000005],f2[2000005],a[2000005],n,m,s;
int main()
{
	scanf("%d",&n);
	m=(1<<n);
	for (int i=0;i<m;i++)
		scanf("%d",&a[i]);
	for (int i=0;i<m;i++)
		for (int j=i;j>=0;j=(j-1)&i)
		{
			if (a[j]>f1[i]) f2[i]=f1[i],f1[i]=a[j];
			else if (a[j]>f2[i]) f2[i]=a[j];
			if (j==0) break;
		}
	for (int i=1;i<m;i++)
	{
		s=max(s,f1[i]+f2[i]);
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
int p[100];

bool judge(int n){
    for(int i = 0; i < 100; i++){
        if(p[i] == n){
            return true;
        }
    }
    return false;
}

int main(){
    int x,n;
    cin >> x >> n;
    for(int i = 0; i < 100; i++){
        p[i] = -10000;
    }
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        p[i] = temp;
    }
    for(int i = 0; i < 100;i++){
        int temp1,temp2;
        temp1 = x - i;
        temp2 = x + i;
        bool a1,a2;
        a1 = judge(temp1);
        if(!a1){
            cout << temp1 << endl;
            return 0;
        }
        a2 = judge(temp2);
        if(!a2){
            cout << temp2 << endl;
            return 0;
        }
    }

}

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

using namespace std;


int main()
{
  int H, W, N;
  cin >> H >> W >> N;
  vector< int > vc[200000];
  for(int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    vc[--a].emplace_back(--b);
  }
  vector< int > beet(W);
  iota(begin(beet), end(beet), 0);

  auto getPos = [&](int height, int row)
  {
    height %= 2 * W;
    while(height > 0) {
      int temp = 0;
      if((height + row) % 2 == 0) temp = -min(height, row);
      else temp = min(height, W - row - 1);
      row += temp;
      height -= abs(temp);
      --height;
    }
    return (row);
  };

  for(int i = 0; i < H; i++) {
    for(auto &c : vc[i]) swap(beet[getPos(i, c)], beet[getPos(i, c + 1)]);
  }

  vector< int > ans(W);
  for(int i = 0; i < W; i++) {
    ans[beet[getPos(H, i)]] = i + 1;
  }
  for(auto &s : ans) cout << s << endl;

}

Measured memory_bytes: 13160
#include<stdio.h>

int main() {
	int n, m, X, Y, i, max, min, temp;
	if (scanf("%d%d%d%d", &n, &m, &X, &Y) == 0) return 1;
	max = X;
	for (i = 0; i < n; i++) {
		if (scanf("%d", &temp) == 0) return 1;
		if (temp > max) max = temp;
	}
	min = Y;
	for (i = 0; i < m; i++) {
		if (scanf("%d", &temp) == 0) return 1;
		if (temp < min) min = temp;
	}
	printf(min > max ? "No War" : "War");
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramD
    {
        struct Bridge
        {
            public int a;
            public int b;
        }
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = int.Parse(inputs[0]);
            var m = int.Parse(inputs[1]);

            var list = new Bridge[m];
            for (var i = 0; i < m; i++)
            {
                var inputs1 = Console.ReadLine().Split(" ");
                var a = int.Parse(inputs1[0]) - 1;
                var b = int.Parse(inputs1[1]) - 1;
                list[i] = new Bridge() { a = a, b = b };
            }

            var rList = new List<int>();
            list = list.OrderBy(x => x.b).ToArray();

            var result = 0;
            foreach (var b in list)
            {
                var isPath = true;
                foreach (var r in rList)
                {
                    if (b.a <= r && r < b.b)
                    {
                        isPath = false;
                        break;
                    }
                }

                if (isPath)
                {
                    rList.Add(b.b - 1);
                    result++;
                }
            }

            Console.WriteLine(result);
        }
    }
}


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

int main()
{ //freopen("in.txt","r",stdin);
 //freopen("out.txt","w",stdout);
int  n;
cin>>n;
 int ans,ma=0;
 cin>>ans;
 int count=1;
 for(int i=1;i<n;i++){
 	cin>>ma;
 	if(ma>=ans)
 	 count++,ans=ma;
 }
 cout<<count;
}


Measured memory_bytes: 256
from math import *
x,n=map(int,input().split())
a=[int(x) for x in input().split()]
s=[i for i in range(-100,105)]
s=set(s)-set(a)
s=list(s)
s.sort()
dif=10**18
#a.sort()
ans=s[0]
for i in range(len(s)):
	if abs(s[i]-x)<dif:
		dif=abs(s[i]-x)
		ans=s[i]
print(ans)		


Measured memory_bytes: 62184
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#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 = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t 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;
	cin >> N;
	vector<ll> Ais(N);
	rep(i,0,N) {
		cin >> Ais[i];
	}
	vector<ll> max_idx(N, 0);
	rep(i,1,N) {
		if (Ais[i] <= Ais[max_idx[i-1]]) {
			max_idx[i] = max_idx[i-1];
		} else {
			max_idx[i] = i;
		}
	}
	struct Stones {
		ll idx;
		ll Ai;
	};
	vector<Stones> sorted;
	rep(i,0,N) {
		sorted.push_back({i, Ais[i]});
	}
	sort(sorted.begin(), sorted.end(), [](Stones lhs, Stones rhs){ 
		return lhs.Ai < rhs.Ai || (lhs.Ai == rhs.Ai && lhs.idx < rhs.idx);
	});
	vector<ll> idx_map(N);
	rep(i,0,N) {
		idx_map[sorted[i].idx] = i;
	}
	vector<ll> sum_sorted(N+1);
	rep(n,1,N+1) {
		sum_sorted[n] += sum_sorted[n-1] + sorted[N-n].Ai;
	}
	vector<ll> sum_above(N);
	rep(idx,0,N) {
		ll sorted_idx = idx_map[idx];
		ll Ai = Ais[idx];
		sum_above[idx] = sum_sorted[N-sorted_idx] - (N-sorted_idx) * Ai;
	}
	ll sum = sum_sorted[N];
	vector<ll> ans(N);
	ll idx = max_idx[N-1];
	while (true) {
		if (idx == 0) {
			ans[idx] = sum - sum_above[0];
			break;
		}
		ll next_idx = max_idx[idx-1];
		ans[idx] = sum_above[next_idx] - sum_above[idx];
		idx = next_idx;
	}
	rep(i,0,N) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 7408