akhauriyash/Code-Regression huggingface dataset:
N=int(input())
S=input()
L1=[0]*10

count=0
for idx1 in range(len(S) -2):
    C1 = S[idx1]
    if L1[int(C1)] == 1:
        continue
    L1[int(C1)] = 1
    L2=[0]*10
    for idx2 in range(len(S) -1)[idx1 + 1:]:
        C2 = S[idx2]
        if L2[int(C2)] == 1:
            continue
        L2[int(C2)] = 1
        L3=[0]*10
        for idx3 in range(len(S))[idx2 + 1:]:
            C3 = S[idx3]
            if L3[int(C3)] == 1:
                continue            
            L3[int(C3)] = 1
            count += 1
print(count)


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

int main() {
  int n, m;
  std::cin >> n;
  std::map<std::string, int> red;
  for (int i = 0; i < n; i++) {
    std::string s;
    std::cin >> s;
    if (red.find(s) != red.cend()) {
      red[s]++;
    } else {
      red[s] = 1;
    }
  }

  std::cin >> m;
  for (int i = 0; i < m; i++) {
    std::string s;
    std::cin >> s;
    if (red.find(s) != red.cend()) {
      red[s]--;
    } else {
      red[s] = -1;
    }
  }

  int count = 0;
  for (const auto &i : red) {
    count = std::max(count, i.second);
  }

  std::cout << count <<std::endl;
  return 0;
}

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

using namespace std;

int main(void)
{
	int N, K, ans;
	
	cin >> N;
	
	vector<int> d(N);
	
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	
	sort(d.begin(), d.end());
	
	if (d[N / 2 - 1] == d[N / 2]) {
		ans = 0;
	}
	else {
		ans = d[N / 2] - d[N / 2 - 1];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;
using ll=long long;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int ans=1;
  rep(i,1,n){
    if(pow(i,2)>n){
      break;
    }else{
      ans=pow(i,2);
    }
  }
  cout<<ans<<endl;
}

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

int a, b, c, d, e, k;

int A[5];

int main() {
    for (int i = 0; i < 5; i++) {
        cin >> A[i];
    }
    cin  >> k;

    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            if (A[j] - A[i] > k) {
                printf(":(\n");
                return 0;
            }

            for (int m = j + 1; m < 5; m++) {
                if (A[m] - A[i] > k) {
                    printf(":(\n");
                    return 0;
                }
                if (A[m] - A[j] > k) {
                    printf(":(\n");
                    return 0;
                }
            }
        }
    }

    printf("Yay!\n");
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll H, N;
  IN(H,N);
  ll A_sum = 0;
  REP(i,N){
    ll A;
    IN(A);
    A_sum += A;
  }

  if(H<=A_sum){
    OUT("Yes");
  }else{
    OUT("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

template< typename flow_t >
struct Dinic {
  const flow_t INF;

  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
    int idx;
  };

  vector< vector< edge > > graph;
  vector< int > min_cost, iter;

  Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {}

  void add_edge(int from, int to, flow_t cap, int idx = -1) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx});
  }

  bool bfs(int s, int t) {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty() && min_cost[t] == -1) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return min_cost[t] != -1;
  }

  flow_t dfs(int idx, const int t, flow_t flow) {
    if(idx == t) return flow;
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        flow_t d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  flow_t max_flow(int s, int t) {
    flow_t flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      flow_t f = 0;
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return flow;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e : graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};

int main(){
  int N; cin >> N;
  vector<int> a(N), b(N), c(N), d(N);
  rep(i, N) cin >> a[i] >> b[i];
  rep(i, N) cin >> c[i] >> d[i];

  Dinic<int> dinic(2 * N + 2);
  rep(i, N){
    dinic.add_edge(2 * N, i, 1);
    dinic.add_edge(i + N, 2 * N + 1, 1);
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j){
      if (a[i] < c[j] && b[i] < d[j]) {
        dinic.add_edge(i, j + N, 1);
      }
    }
  }
  cout << dinic.max_flow(2 * N, 2 * N + 1) << endl;
}


Measured memory_bytes: 384
def main():
    L, R = map(int, input().split())
    R = min(R, L + 4038)
    ans = 2018

    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i*j) % 2019)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 64472
#include<bits/stdc++.h>
using namespace std;
long long unsigned i,j,k=0,ta,n;
char s[1000],t[1000];
int main()
{
    scanf("%llu",&n);
    i=n;
    while(i!=0){
        k=k+(i%10);
        i=i/10;
    }
   // printf("%llu",k);
    if(n%k==0)
        printf("Yes\n");

    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n;
		cin>>n;
		vll A(n);
		vll B(n);
		forn(i,n)
		{
			cin>>A[i]>>B[i];
		}	
		sort(all(A));
		sort(all(B));
		if(n&1)
		{
			cout<<B[n/2]-A[n/2]+1<<endl;

		}
		else
		{
			cout<<(B[n/2-1]+B[n/2])-(A[n/2-1]+A[n/2])+1<<endl;
		}
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 6240
#include<iostream>
#include<algorithm>
using namespace std;
static const int NMAX = 101;
static const int WMAX = 10001;

struct Item {
    int value, weight;
};

struct Item items[NMAX];
int N,W;
int C[NMAX][WMAX];

int knapsack(){

    int i,w;
    
    // init
    for(i=0;i<N;i++)C[i][0]=0;
    for(w=1;w<W;w++)C[0][w]=0;
    
    for(i=1;i<=N;i++){
	for(w=1;w<=W;w++){
	    if (items[i].weight <= w){
		C[i][w]=max(items[i].value+C[i-1][w - items[i].weight], C[i-1][w]);
	    }
	    else C[i][w]=C[i-1][w];
	}
    }
    return C[N][W];
}

int main(){
    cin >> N>>W;
    int i;

    for(i=1;i<=N;i++){
	cin>>items[i].value >> items[i].weight;
    }

    cout << knapsack() << endl;

    return 0;

}

Measured memory_bytes: 5104
A, B, K = list(map(int, input().split()))

for i in range(K):
    n = A + i
    if A<=n and n<=B:
        print(n)
for i in range(K):
    n = B - (K-1) + i
    if A<=n and n<=B and n>A + K - 1:
        print(n)


Measured memory_bytes: 3316
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n,k;cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int dp[k+1]={0};
	int mi=*min_element(a,a+n);
	for(int i=0;i<mi;i++)dp[i]=0;int c=0;
	for(int i=mi;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i-a[j]>=0){
	            if(!dp[i-a[j]])dp[i]=1;
			}
		}
	}
	if(dp[k])cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

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

#define NDEBUG
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


inline int four(vvi& a, int x1,int y1, int x2,int y2) {
    return a[x1][y1] - a[x1][y2] - a[x2][y1] + a[x2][y2];
}

int main() {
    int N, M, Q;
    scanf("%d%d%d", &N, &M, &Q);
    char buf[2010];

    vvi blue(N+1, vi(M+1, 0));
    vvi right(N+1, vi(M+1, 0));
    vvi down(N+1, vi(M+1, 0));

    rep1(i,N) {
        scanf("%s", buf);
        rep1(j,M){ if (buf[j-1] == '1') blue[i][j] = 1; }
    }
    rep1(i,N) rep1(j,M-1) {
        if (blue[i][j] && blue[i][j+1]) right[i][j] = 1;
    }
    rep1(i,N-1) rep1(j,M) {
        if (blue[i][j] && blue[i+1][j]) down[i][j] = 1;
    }

    rep(i,N+1) rep(j,M) blue[i][j+1] += blue[i][j];
    rep(j,M+1) rep(i,N) blue[i+1][j] += blue[i][j];

    rep(i,N+1) rep(j,M) right[i][j+1] += right[i][j];
    rep(j,M+1) rep(i,N) right[i+1][j] += right[i][j];

    rep(i,N+1) rep(j,M) down[i][j+1] += down[i][j];
    rep(j,M+1) rep(i,N) down[i+1][j] += down[i][j];

    rep(i,Q) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        --x1; --y1;

        int blues = four(blue,  x1,y1, x2,y2),
            rights = four(right, x1,y1, x2,y2-1),
            downs = four(down,  x1,y1, x2-1,y2),
            res = blues - (rights + downs);
        printf("%d\n", res);
    }
    return 0;
}


Measured memory_bytes: 49536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;

ll a=INF;

void r(ll n,ll d)
{
    if(n<=5){
        a=min(a,d+n);
        return;
    }
    ll x;
    for(x=1;x*6<=n;)x*=6;
    r(n-x,d+1);
    for(x=1;x*9<=n;)x*=9;
    r(n-x,d+1);
    return;
}

int main()
{
    ll n;
    cin>>n;
    r(n,0);

    cout<<a<<endl;

    return 0;
}


Measured memory_bytes: 256
'''
分かりやすい図解ページ
https://blog.bobuhiro11.net/2019/08-03-abc135ef.html
https://betrue12.hateblo.jp/entry/2019/07/28/215024
'''
import math

def swap(X,Y):
  temp=X
  X=Y
  Y=temp
  return X,Y

def keiro(count,X,Y,K):
  keirolist=[]
  oneway_surplus=int(((count*K)-X-Y)/2)
  move=0
  turncount=0
  prevX=0
  prevY=0
  while(move<count):
    if turncount==0:
      if K-prevY>=oneway_surplus:
        prevX=K-oneway_surplus
        prevY-=oneway_surplus
        turncount+=1
      else:
        prevX=0
        prevY-=K
    elif turncount==1:
      if K+prevX>X:
        prevY+=(K-(X-prevX))
        prevX=X
        turncount+=1
      else:
        prevX+=K
    else:
      prevY+=K
    keirolist.append([prevX,prevY])
    #print(keirolist)
    move+=1
  return keirolist

def ans(K,X,Y):
  anslist=[]
  count=0
  Xminus=0
  Yminus=0
  swapflag=0
  if X<0:
    Xminus=1
    X=abs(X)
  if Y<0:
    Yminus=1
    Y=abs(Y)
  if (X+Y)==K:
    count=1
    anslist.append([X,Y])
  else:
    if X<Y:
      X,Y=swap(X,Y)
      swapflag=1
    if X+Y>K:
      count=math.ceil((X+Y)/K)
      lastflag=0
      if (count*K-X-Y)%2==1:
        count+=1
        lastflag=1
      anslist=keiro(count,X,Y,K)
      
    else:
      if (X+Y)%2==0:
        count=2
        anslist=keiro(count,X,Y,K)
      else:
        count=3
        anslist.append([X,-K+X])
        Xsurplus=int((X+K-Y)/2)
        anslist.append([X+Xsurplus,X-Xsurplus])
        anslist.append([X,Y])
  for ans in anslist:
    if swapflag==1:
      ans[0],ans[1]=swap(ans[0],ans[1])
    if Xminus==1:
      ans[0]=-ans[0]
    if Yminus==1:
      ans[1]=-ans[1]
  return count,anslist



K=int(input())
X,Y=map(int,input().split())

if K%2==0 and (X+Y)%2==1:
  print(-1)
  exit()

count,anslist=ans(K,X,Y)
print(count)
for ans in anslist:
  print(ans[0],ans[1])

Measured memory_bytes: 32340
input_list = input().split(" ")
count = 0

if(input_list[0] == input_list[1]):
  count += 1

if(input_list[0] == input_list[2]):
  count += 1

if(input_list[2] == input_list[1]):
  count += 1

if (count == 1):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
N, M, Q = map(int, input().split())
S=[[0 for i in range(4)] for j in range(Q)]
for i in range(Q):
    inputS=list(map(int,input().split()))
    S[i][0]=inputS[0]
    S[i][1]=inputS[1]
    S[i][2]=inputS[2]
    S[i][3]=inputS[3]
S2=[]
maxNum=0
for a in range(1,M+1):
    for b in range(a,M+1):
        for c in range(b,M+1):
            for d in range(c,M+1):
                for e in range(d,M+1):
                    for f in range(e,M+1):
                        for g in range(f,M+1):
                            for h in range(g,M+1):
                                for i in range(h,M+1):
                                    for j in range(i,M+1):
                                        S2=[a,b,c,d,e,f,g,h,i,j]
                                        count=0
                                        for k in range(Q):
                                            if S2[S[k][1]-1]-S2[S[k][0]-1]==S[k][2]:
                                                count+=S[k][3]
                                        maxNum=max(maxNum,count)
                                       
    
print(maxNum)


Measured memory_bytes: 9296
#include<bits/stdc++.h>
#define MOD 1e9+7
using namespace std;
#define  pp push_back
#define  po pop_back
#define  mp make_pair
#define clr(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,-1,sizeof(a))
#define fas(a) memset(a,false,sizeof(a))
#define debug(x) cout<<#x<<": "<<x<<endl
#define debug1(x) cout<<#x<<": "<<x<<" "
#define rev(x) reverse(x.begin(), x.end())
#define int long long 
#define F first
#define S second
//int a[2000];
void printvector(std::vector<int> v){  for (int i = 0; i < v.size(); ++i){cout<<v[i]<<" ";}cout<<""<<endl;}
void printarray(int a[],int n){for (int i = 0; i < n; ++i){cout<<a[i]<<" ";}cout<<""<<endl;}
 
 

 

void  solve()
{
   int H,W,a,b;cin>>H>>W>>a>>b;
  char ans[H][W];
  for(int i=0;i<H;i++)
  {
     for(int j=0;j<W;j++)
     {
        if((j<a&&i<b)||(j>=a&&i>=b))ans[i][j]='0';
        else ans[i][j]='1'; 
     }
  }

  for(int i=0;i<H;i++)
  {
     for(int j=0;j<W;j++)
     {
        cout<<ans[i][j]; 
     }
     cout<<""<<endl;
  }

}




 int32_t main() 
{

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

return 0;

}

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

using namespace std;

const int INF = 1e9 + 5;

int dp[100005], h[100005];

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

    for (int i = 0; i < n; i++) scanf("%d", &h[i]);

    dp[0] = 0;

    for (int i = 1; i < n; i++) {
        dp[i] = INF;
        for (int j = 1; j <= k; j++) {
            if (i - j >= 0) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    printf("%d\n", dp[n - 1]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	string s; cin>>s;
	int n=(s[0]-'0')*10+(s[1]-'0');
	int m=(s[2]-'0')*10+(s[3]-'0');
	bool a=false; bool b=false;
	if(0<n&&n<13)a=true;
	if(0<m&&m<13)b=true;
	if(!a&&!b)cout <<"NA" << endl;
	else if(a&&b)cout <<"AMBIGUOUS" << endl;
	else{
		cout << (a?"MMYY":"YYMM")<< endl;
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,d,x;

int main(){
    cin >> n >> d >> x;
    ll ans = x;
    rep(i,n){
        ll a;
        cin >> a;
        for(ll i = 1;i <= d;i += a)ans++;
    }
    cout << ans << endl;
}

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

int sg[1<<21];
int p[1000000];
void add(int k,int l,int r,int a,int v){
	if(r-l==1){
		sg[k] = p[a]+=v;
		return;
	}
	int m=(l+r)/2;
	if(a<m){
		add(2*k+1,l,m,a,v);
	}else{
		add(2*k+2,m,r,a,v);
	}
	sg[k] = max(sg[2*k+1],sg[2*k+2]);
}
int getMaxId(int k,int l,int r){
	if(r-l==1){
		return l;
	}
	int m=(l+r)/2;
	if(sg[2*k+1]>=sg[2*k+2])return getMaxId(2*k+1,l,m);
	return getMaxId(2*k+2,m,r);
}
int main(){
	int n,q;
	cin>>n>>q;
	while(q--){
		int a,v;
		cin>>a>>v;
		add(0,0,1<<20,a-1,v);
		a = getMaxId(0,0,1<<20)+1;
		cout<<a<<' '<<sg[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 13068
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        var n = int.Parse(inputs[0]);
        var q = int.Parse(inputs[1]);
        var s = Console.ReadLine();
        int[] dps = new int[n];
        int[] dpe = new int[n];
        foreach(int i in Enumerable.Range(0, n - 1))
        {
            if(s[i] == 'A' && s[i + 1] == 'C')
            {
                dps[i]++;
                dpe[i + 1]++;
            }
        }
        foreach(int i in Enumerable.Range(1, n - 1))
        {
            dps[i] += dps[i - 1];
            dpe[i] += dpe[i - 1];
        }
        // System.Console.WriteLine(string.Join(" ", dps));
        // System.Console.WriteLine(string.Join(" ", dpe));
        foreach(int i in Enumerable.Range(0, q))
        {
            inputs = Console.ReadLine().Split();
            var l = int.Parse(inputs[0]) - 1;
            var r = int.Parse(inputs[1]) - 1;
            Console.WriteLine(dpe[r] - (l == 0 ? 0 : dps[l - 1]));
        }
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

Measured memory_bytes: 16844
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 10 19:03:54 2018

@author: Fujiichang
"""

if __name__ == "__main__":
    x = map(int, raw_input().split())
    a = x[0]
    b = x[1]

    if a < b:
        print 'a < b'
    elif a > b:
        print 'a > b'
    elif a == b:
        print 'a == b'



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

int main(){
  long long a, b, tmp;
  cin >> a >> b;

  if(a*b<=0){
    cout << "Zero" << endl;
  }else if(a>0){
    cout << "Positive" << endl;
  }else{
    tmp = b-a+1;
    if(tmp%2==0){
      cout << "Positive" << endl;
    }else{
      cout << "Negative" << endl;
    }
  }
  return 0;
};

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


int A[100000];
int n;


int partition(int p, int r){

  int work;
  int x = A[r];
  int tmp = p-1;

  for(int i=p; i<r; i++){
    if(A[i] <= x){
      tmp++;
      work = A[i];
      A[i] = A[tmp];
      A[tmp] = work;
    }
  }
      
  work = A[tmp+1];
  A[tmp+1] = A[r];
  A[r] = work;

  return tmp+1;

}


int main(){

  int q;

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

  q = partition(0,n-1);

  cout << A[0];
  for(int i=1; i<n; i++){
    if(i==q){
      cout << ' '<<'[' << A[i] << ']';
    }
    else{
      cout << ' ' << A[i];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i,N) cin >> H[i];
    int max_num=0;
    int cnt = 0;
    for(int i=N-1;i>0;i--){
        if(H[i-1]>=H[i]){
            cnt++;
        }else{
            max_num=max(max_num,cnt);
            cnt=0;
        }
    }
    max_num=max(max_num,cnt);
    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
const ll  INF = 2e5 + 9;


int n,k,arr[INF],dp[INF];
int solve (int i)
{
    if(i==n-1)     return 0;
    if(dp[i]!=-1)  return dp[i];
    int ans=abs(arr[i+1]-arr[i])+solve(i+1);
    for (int x=1; x<=k; x++)
    {
        if(i+x<n)
        {
            ans=min(ans,abs(arr[i+x]-arr[i])+solve(i+x));
        }
    }
    return dp[i]=ans;
}



int main()
{
    cin>>n>>k;
    for (int i=0; i<n; i++)
        cin>>arr[i];
        memset(dp,-1,sizeof dp);
    cout<<solve(0);
    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<utility>
#define lint long long
#define gc getchar()
#define mp make_pair
#define fir first
#define sec second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define clr(a,n) memset(a,0,sizeof(int)*((n)+1))
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
typedef pair<int,int> pii;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
#define N 5010
#define M 210
lint s[N],v[N][N];int b[M][N];int L[N],R[N],stc[N];
int main()
{
	int n=inn(),m=inn();rep(i,2,n) s[i]=s[i-1]+inn();
	rep(i,1,n) rep(j,1,m) b[j][i]=inn();
	rep(i,1,m)
	{
		int top=0;
		for(int j=1;j<=n;j++)
		{
			while(top&&b[i][j]>b[i][stc[top]]) R[stc[top--]]=j-1;
			stc[++top]=j;
		}
		rep(j,1,top) R[stc[j]]=n;
		top=0;
		for(int j=n;j>=1;j--)
		{
			while(top&&b[i][j]>=b[i][stc[top]]) L[stc[top--]]=j+1;
			stc[++top]=j;
		}
		rep(j,1,top) L[stc[j]]=1;
		rep(j,1,n) v[L[j]][j]+=b[i][j],
			v[L[j]][R[j]+1]-=b[i][j],
			v[j+1][j]-=b[i][j],
			v[j+1][R[j]+1]+=b[i][j];
//		debug(i)ln;rep(j,1,n) debug(j)sp,debug(b[i][j])sp,debug(L[j])sp,debug(R[j])ln;
	}
	lint ans=0ll;
	rep(i,1,n) rep(j,1,n)
	{
		v[i][j]=v[i][j]+v[i-1][j]+v[i][j-1]-v[i-1][j-1];
		if(i<=j) ans=max(ans,v[i][j]-(s[j]-s[i]));
	}
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 200192
import java.util.*;

public class Main {
    public static void main(String args[]) {
       //値の取得
       Scanner sc = new Scanner(System.in);
       long N = sc.nextLong();
       double root = Math.sqrt(N); //Nの平方根
       long a = 1;    //N(a,b)
       long b;
       long count = 0;    //到達に必要な移動回数

       //到達するまで移動を繰り返す
       while(a <= root) {
           if(N % a == 0) {
               b = N / a;    //N = a * b
               if(a + b - 2 < count || count == 0) {
                  count = a + b - 2; 
               }
           }
           ++a;
       }
 
       //出力
       System.out.println(count);
    }
}

Measured memory_bytes: 35724
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int a,b,c;cin>>a>>b>>c;cout<<a+b+c+max(a,max(b,c))*9<<endl;
}


Measured memory_bytes: 888
fun main(args:Array<String>){
    val (n,d) = readLine()!!.split(" ").map{it.toInt()}
    val a = Array(n){readLine()!!.split(" ").map{it.toInt()}}
    var ans = 0
    for(i in 0 until n){
        for(j in i + 1 until n){
            var sum = a[i].zip(a[j]).map{it.first - it.second}.map{it * it}.sum()
            for(i in 1 .. Math.sqrt(sum.toDouble()).toInt()){
                if(sum % i == 0 && i == sum / i) ans++
            }
        }
    }
    println(ans)
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


struct Event{
    ll time,type,d;
    bool operator<(const Event& a){
        return time < a.time;
    }
};

int main() {
    ll N,Q;
    cin >> N >> Q;
    vector<Event> X;
    REP(i,N){
        ll s,t,x;
        cin >> s >> t >> x;
        X.push_back({s-x,1,x});//add
        X.push_back({t-x,-1,x});//remove
    }

    vector<ll> D(Q);

    
    REP(i,Q){
        cin >> D[i];
    }
    sort(ALL(X));

    int k=0;
    multiset<ll> S;

    REP(i,Q){
        while(k < X.size() && X[k].time <= D[i]){
            if(X[k].type == 1){
                S.insert(X[k].d);
            }else{
                S.erase(S.find(X[k].d));
            }
            k++;
        }

        if(S.empty()){
            cout << -1 << endl;
        }else{
            cout << *S.begin() << endl;
        }
    }
    return 0;
}

//イベントソートなるものを使う


Measured memory_bytes: 23584
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n, m; cin >> n >> m;
    ll x[m], y[m];
    rep(i, m){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }

    ll red[n] = {};
    red[0] = 1;

    ll ball[n] = {};
    rep(i, n){
        ball[i] = 1;
    }

    rep(i, m){
        ll from = x[i];
        ll to = y[i];
        if(red[from] == 0){
            ball[from]--;
            ball[to]++;
        }
        else{
            if(ball[from] == 1){
                red[from] = 0;
                red[to] = 1;
                ball[from] = 0;
                ball[to]++;
            }
            else{
                red[to] = 1;
                ball[from]--;
                ball[to]++;
            }
        }
    }

    cout << accumulate(red, red + n, 0LL) << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    ll A,B,V,W,T;
    cin >> A >> V >> B >> W >> T;

    if (abs(A-B) <= (V-W)*T) cout << "YES" << endl;
    else cout << "NO" << endl;

    // output

    return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;

int main(void){
  long n,m;
  long ans=0;

  scanf("%ld %ld",&n,&m);

  if(m - n*2 >=0){
    m-= n*2;
    ans+= n;
  }
  else{
    ans+= m/2;
    m = 0;
  }

  ans+= m/4;

  printf("%ld\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#define PA 3.1415926535
int main()
{
    double a, b, c,C;
    double S, L, h;
    double radius;
    scanf("%lf %lf %lf",&a,&b,&C);
    radius = C * 2 * PA / 360;
    S = a * b * sin(radius) / 2;
    h = 2 * S / a;
    c = sqrt(a*a + b*b - 2 * a*b*cos(radius));
    L = a + b + c;
    printf("%lf \n%lf \n%lf\n",S,L,h);
    return 0;
}

Measured memory_bytes: 648
#include <cstdio>
int main(){
	int n, m, a;
	scanf("%d %d", &n, &m);
	int s = 0;
	for (int i = 0; i < m; i++){
		scanf("%d", &a);
		s += a;
	}
	if (s >= n){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

Measured memory_bytes: 128
import collections
def solve():
  n = int(input())
  odd = []
  even = []
  a = list(int(i) for i in input().split())
  for i in range(n):
    if i%2 == 0:
      odd.append(a[i])
    else:
      even.append(a[i])
  ans = 0
  c1 = collections.Counter(odd)
  c2 = collections.Counter(even)
  n1 = len(odd)
  n2 = len(even)
  if len(set(a)) == 1:
    print(n//2)
    exit()
  ans = 10**12
  if c1.most_common()[0][0]  ==   c2.most_common()[0][0]:
    if not len(c2) ==1:
     ans = min((n-c1.most_common()[0][1]-c2.most_common()[1][1]),ans)
    if not len(c1) ==1:
     ans = min((n-c2.most_common()[0][1]-c1.most_common()[1][1]),ans)
  else:
         ans = min(ans,(n1-c1.most_common()[0][1]+n2-c2.most_common()[0][1]))
  print(ans)
                  
                  
solve()

Measured memory_bytes: 23264
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

void solve(){
	x=abs(x);
	c=x/d;
	if(k>=c){
		k=k-c;
		c=(c*d);
		x=(x-c);
		if(k%2){
			x=abs(x-d);
		}
	}else{
		x=abs(x-(k*d));
	}
	
	printf("%lld\n",x);
}
int main()
{
    scanf("%lld%lld%lld",&x,&k,&d);
    solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3808
##### 解けた #####

N,M=list(map(int,input().split(" ")))
T=[0]*N # 都市

# 各道路について足してゆく
for _ in range(M):
    a,b=list(map(int,input().split(" ")))

    T[a-1]+=1
    T[b-1]+=1

# 各都市について出力
for t in T:
    print(t)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
string S, T;
int main() {
  cin >> N >> S >> T;
  string ans = "";
  rep(i, N) { ans = ans + S[i] + T[i]; }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    string s;
    cin>>s;
    int book[500];
    memset(book,0,sizeof(book));
    for(ri int i=0;i<(int)s.size();i++)
    {
        book[s[i]]++;
        if(book[s[i]]>1) { puts("no"); return 0; }
    }
    puts("yes");
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int main(){
	int n; scanf("%d",&n);
	vector<int> c(n);
	rep(i,n) scanf("%d",&c[i]);

	sort(c.begin(),c.end());

	mint ans=0;
	rep(i,n){
		ans+=(pow(mint(2),2*n-2)*(n-i-1)+pow(mint(2),2*n-1))*c[i];
	}
	printf("%d\n",ans.to_int());

	return 0;
}


Measured memory_bytes: 1024
from collections import deque
que = deque()
L = []
k = int(input())
for i in range(1, 10):
  L.append(str(i))
  que.append(str(i))
while len(L) < k:
  top = que.popleft()
  e = int(top[-1])
  for i in range(max(e-1, 0), min(e+2, 10)):
    x = top + str(i)
    L.append(x)
    que.append(x)
ans = L[k-1]
print(ans)

Measured memory_bytes: 10876
N, K = map(int, input().split())
ps = []
for i in range(N):
	ps.append(int(input()))
ps = sorted(ps)
ans = ps[K-1]-ps[0]
for i in range(N-K+1):
	ans = min(ans, ps[i+K-1]-ps[i])
print(ans)


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

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

int main() {
    //cout.precision(11);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H-h) * (W-w) << endl;
    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    int turn = 0;
    while(A > 0 and C > 0) {
        if(turn == 0) {
            C -= B;
            if(C <= 0) break;
        }
        if(turn == 1) {
            A -= D;
            if(A <= 0) break;
        }
        turn ^= 1;
    }
    if(C <= 0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
int main(void)
{
    int i,cut=0;
    char tenki[4];
    scanf("%s",tenki);
    for(i=0;tenki[i]!='\0';i++)
    {
        if(tenki[i]=='R')
        {
            cut++;
        }
    }
    if(cut==2&&tenki[1]!='R')
    {
        cut=1;
    }
    printf("%d\n",cut);
    return 0;
}

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

struct Edge{
	  int tgt_;
	  int weight_;
	  Edge(int t){
			tgt_ = t;
	  }
};

typedef vector<vector<Edge> > Adj_list;




void visit(int v, vector<int>& topological_order, vector<int>& used, Adj_list& G){

	  if( used[v] != 0 ) return;
	  used[v] = 1;

	  for( Edge& e : G[v] ){
			visit(e.tgt_, topological_order, used, G);
	  }
	  topological_order.push_back(v);
}

vector<int> toporogical_sort(Adj_list& G){

	  vector<int> topological_order;
	  vector<int> used(G.size()+1,0);

	  for(int i=0; i<G.size(); i++){
			visit(i,topological_order,used,G);
	  }
	  reverse(topological_order.begin(),topological_order.end());
	  return topological_order;
}

int main(){

	  int V,E;
	  cin >> V >> E;
	  Adj_list G(V);
	  for(int i=0; i<E; i++){
			int s,t; cin >> s >> t;
			G[s].push_back(Edge(t));
	  }
	  vector<int> ans = toporogical_sort(G);
	  for(int i=0; i<V; i++)
			cout << ans[i] << endl;

}

Measured memory_bytes: 3892
import copy

# 最後のリンゴを食べたものが勝者
"""
def func(_left, turn):
    left = []
    for i in _left:
        if i != 0:
            left.append(i)
    N = [i for i in range(len(left))]  # N = bit探索する桁数
    # Nの要素の全組み合わせが出力
    winFlag = False
    for i in range(1, 1 << len(N)):
        output = []
        copyLeft = copy.deepcopy(left)
        minus = 0
        for j in range(len(N)):
            if ((i >> j) & 1) == 1:
                output.append(j)  # このjが今回探索するindexの1つ
                if copyLeft[j] > 0:
                    copyLeft[j] -= 1
                    minus += 1
        if minus == 0:
            continue
        # if sum(copyLeft) == 0:
            # print("winner:{}({}) select:{}".format(turn, (turn+1) % 2, output))
        if func(copyLeft, turn + 1):
            winFlag = True
    return not winFlag

def answer(a, turn):
    if not func(a, turn):
        return "{}:1st".format(a)
    else:
        return "{}:2nd".format(a)
print(answer([1], 0))
print(answer([2], 0))
print(answer([3], 0))
print(answer([4], 0))
print(answer([5], 0))
print(answer([6], 0))

print(answer([1, 1], 0))
print(answer([2, 1], 0))
print(answer([2, 2], 0))
print(answer([3, 1], 0))
print(answer([3, 2], 0))
print(answer([3, 3], 0))
print(answer([4, 2], 0))
print(answer([4, 4], 0))

print(answer([1, 1, 1], 0))
print(answer([2, 1, 1], 0))
print(answer([2, 2, 1], 0))
print(answer([2, 2, 2], 0))

print(answer([1, 1, 1], 0))
print(answer([2, 1, 1], 0))
print(answer([2, 2, 1], 0))
print(answer([2, 2, 2], 0))
print(answer([3, 1, 1], 0))
print(answer([3, 2, 1], 0))
print(answer([3, 2, 2], 0))
print(answer([3, 3, 1], 0))
print(answer([3, 3, 2], 0))
print(answer([3, 3, 3], 0))
print(answer([4, 4, 4], 0))
"""
"""
print()
print(answer([4, 1, 1, 1], 0))
print(answer([4, 2, 1, 1], 0))
print(answer([4, 2, 2, 1], 0))
print(answer([4, 2, 2, 2], 0))
print(answer([4, 1, 1, 1], 0))
print(answer([4, 1, 1, 1], 0))
print(answer([4, 1, 1, 1], 0))
print(answer([4, 1, 1, 1], 0))
"""
n = int(input())
a = [0 for _ in range(n)]
for i in range(n):
    a[i] = int(input())
for _a in a:
    if _a % 2 == 1:
        print("first")
        exit()
print("second")

Measured memory_bytes: 7508
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;


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

    //check whether array include zero
    ll b[100000]={};
    rep(i,n){
        ll a;
        cin>>a;
        b[i]=a;
        if(a==0){
            cout<<0<<endl;
            return 0;
        }
    }
    //check the over 1e18
    ll ans=1;
    rep(i,n){
        if(b[i]<=(ll)1e18/ans){
            ans*=b[i];
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4420
# coding: utf-8

import sys
input = sys.stdin.readline

N = int(input())
H = list(map(int, input().split()))
# A, B = map(int, input().split())

ans = 0

for i, h in enumerate(H):
    flag = True

    for x in range(i):
        if h < H[x]:
            flag = False
        
    if flag:
        ans += 1

print(ans)



Measured memory_bytes: 3060
/*I know about "bits/stdc++.h" 
But I am not using it for some technical issue*/

#include "iostream"
#include "algorithm"
#include "iomanip"
#include "vector"
#include "set"
#include "sstream"
#include "fstream"
#include "cstring"
#include "cmath"
#include "utility"
#include "map"
#include "bitset"
#include "cassert"
#include "deque"

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define mod (int)1e9 + 7
#define For(i,a,n) for(i=a;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
bool hbe(string st,int n){
	int h = n/2;
	string s1 = string(st.begin(),st.begin()+h), s2 = string(st.begin()+h,st.begin()+n);
	return !(s1 == s2);
}
void solve(string st){
	int n = st.size() - 1;
	if(n&1) n--;
	while(hbe(st,n)){
		n -= 2;
	}
	cout<<n;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string st;
	cin>>st;
	solve(st);
  return 0;
}

Measured memory_bytes: 256