akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ')
            .Select(q => Int32.Parse(q)).ToArray();
        var a = l[0]; var b = l[1]; var c = l[2]; var x = l[3]; var y = l[4];
        var res = 0L;
        var pizas = new List<Int32[]>();
        pizas.Add(new Int32[] { a, x });
        pizas.Add(new Int32[] { b, y });
        pizas = pizas.OrderBy(q => q[1]).ToList();
        if (a + b > c * 2)
        {
            res += c * pizas[0][1] * 2;
            if (pizas[1][0] > c * 2) res += c * (pizas[1][1] - pizas[0][1]) * 2;
            else res += pizas[1][0] * (pizas[1][1] - pizas[0][1]);
        }
        else
        {
            res += a * x + b * y;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13524
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

int main()
{
  long long H, W,N;
  cin >> W >> H >> N;
  bool dp[W + 1][H + 1];
  for (int i = 0; i < W;i++){
    for (int j = 0; j < H;j++){
      dp[i][j] = false;
    }
  }



  for (int l = 0; l < N;l++){
    int a, x, y;
    cin >> x >> y >> a;
    if(a==1){
      for (int i = 0 ; i < x;i++){
        for (int j = 0; j < H;j++)
          dp[i][j] = true;
      }
    }
    if(a==2){
      for (int i = x; i<W; i++)
      {
        for (int j = 0; j < H; j++)
          dp[i][j] = true;
      }
    }
    if (a == 3)
    {
      for (int i = 0; i < W; i++)
      {
        for (int j = 0; j < y; j++)
          dp[i][j] = true;
      }
    }
    if (a == 4)
    {
      for (int i = 0; i < W; i++)
      {
        for (int j = y; j < H; j++)
          dp[i][j] = true;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j <W; j++)
    {
      if(dp[j][i]==0)ans++;
    }
    //cout << endl;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, m, x;
cin >>x;
cin >> n >> m;
for(int i = n; i <= m; i++){
	if(i % x == 0){
		cout << "OK";
		return 0;
	}
}
cout << "NG";
return 0;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline
def print_ans(H, W, h, w):
    """Test Case
    >>> print_ans(3, 2, 2, 1)
    1
    >>> print_ans(5, 5, 2, 3)
    6
    >>> print_ans(2, 4, 2, 4)
    0
    """
    print((H - h) * (W  -w))


if __name__ == '__main__':
    H, W = map(int, input().rstrip().split())
    h, w = map(int, input().rstrip().split())
    print_ans(H, W, h, w)




Measured memory_bytes: 3060
N,a,b = map(int,input().split())
c = 0

for i in range(N+1):
    i = str(i)
    listi = list(i)
    listi = [int(s) for s in listi]
    sumi = sum(listi)
    
    if sumi <= b and sumi >= a:
        c = c + int(i)

print(c)

Measured memory_bytes: 3060
n, h = map(int, input().split())
a, b = zip(*(tuple(map(int, input().split())) for _ in range(n)))
m = max(a)
c = 0
for v in sorted(b)[::-1]:
    if h<=0 or v<m:
        break
    h -= v
    c += 1
print(c + (max(0,h)+m-1)//m)

Measured memory_bytes: 24420
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <climits> 

long gcd(long C, long D)
{
    if(C<D){
        std::swap(C,D);
    }
    if(C%D==0){
        return D;
    }else{
        return gcd(D,C%D);
    }
}

int main()
{
    long A,B,C,D;
    std::cin >> A >> B >> C >> D;
    if(C<D){
        std::swap(C,D);
    }

    long gcd_number=C*D/gcd(C,D);
    long result=(B-B/C-B/D+B/gcd_number)-(A-A/C-A/D+A/gcd_number);
    if(A%C!=0 && A%D!=0){
        result++;
    }
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
  
int main() {
    ll h, w;
    cin >> h >> w;

    map<ll, ll> mp;
    rep(i, h) {
        rep(j, w) {
            char c;
            cin >> c;
            mp[c]++;
        }
    }

    ll cntOdd = 0;  // 奇数個ある英字の種類数
    for(auto p : mp) {
        if(p.second%2 == 1) {
            cntOdd++;
        }
    }

    bool ok = true;
    if(h%2 == 1 && w%2 == 1) {
        if(cntOdd != 1) {
            ok = false;
        }
    }
    else {
        if(cntOdd != 0) {
            ok = false;
        }
    }
    
    ll cnt4 = 0;  // 作れる4個組の個数
    for(auto p : mp) {
        cnt4 += p.second/4;
    }
    if(cnt4 < (h/2)*(w/2)) {
        ok = false;
    }

    if(ok) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <functional>
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
using namespace std;

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

  int  n=0;
  ll x, now=100;
  cin >> x;

  while (now < x){
    now += now / 100;
    n++;
  }
  
  cout << n << endl;

}
  

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N;
  cin>>N;
  ll ans=0;
  ll max=0;
  for(ll i=0;i<N;i++) {
ll H;
    cin>>H;
    if(H>=max) {
ans++;
      max=H;
    }
  }
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef long double ld;


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

ll inf = 10000000;
ll mod = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;
    int switches[15][15];
    REP(i, M) {
        cin >> switches[i][0];
        REP(j, switches[i][0]) {
            cin >> switches[i][j + 1];
        }
    }
    int p[M];
    REP(i, M) {
        cin >> p[i];
    }//入力終了

    int ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        bool on = true;
        REP(i, M) {//i番目の電球について
            int sum = 0;
            REP(j, switches[i][0]) {//k_i個のswitch考える
                int s = switches[i][j + 1] - 1;
//                cout<<bit<<" ";//デバッグ用！！！！！！！！！！！！！
                if ((bit >> s) & 1) {//s番目のスイッチが付いているなら
                    sum += 1;
//                    cout<<bit<<" "<<i<<" "<<endl;//デバッグ用！！！！！！！！！！！！！
                }
            }
            if (sum % 2 != p[i]) { on = false; }
//            cout<<sum<<endl;//デバッグ用！！！！！！！！！！！！！
        }
        if (on) { ans++; }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int mi = INT_MAX;
    for(int i = 1; i < N/2+1; i++){
        int A = i, B = N-i;
        int sum = 0;
        while(A != 0){
            sum += A %10;
            A /= 10;
        }
        while(B != 0){
            sum += B %10;
            B /= 10;
        }
        mi = min(mi,sum);
    }

    cout << mi << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int q;
    cin >> q;
    multimap<string, int> mp;
    for(int i = 0; i < q; i++)
    {
        int com, x;
        string key;
        cin >> com;
        if(com == 0)
        {
            cin >> key >> x;
            mp.insert(make_pair(key, x));
        }
        else if(com == 1)
        {
            cin >> key;
            auto itr = mp.equal_range(key);
            for(auto it = itr.first; it != itr.second; it++) cout << it->second << endl;
        }
        else if(com == 2)
        {
            cin >> key;
            mp.erase(key);
        }
        if(com == 3)
        {
            string l, r;
            cin >> l >> r;
            auto left = mp.lower_bound(l);
            auto right = mp.upper_bound(r);
            while(left != right)
            {
                cout << left->first << " " << left->second << endl;
                left++;
            }
        }
    }
    return 0;
}




Measured memory_bytes: 24880
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    FOR(i, 1, 1000000) {
        ans += (N - 1) / i;
    }
    cout << ans << endl;
    return 0;
}

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

void solve(){
 int r,b;
  cin >> r >> b;
  int low = (r > b ? b : r);
  if(8-low >= abs(r-b)){
  	cout << "Yay!";
  }else{
	cout << ":(";
  }
}
int main(){
  solve();
return 0;
}

Measured memory_bytes: 3500
#include<iostream>
#include<stdio.h>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{
    int parent;
    int left;
    int right;
};

Node N[MAX];
int D[MAX]; //節点の深さを保存するためのリスト

int setDepth(int u, int p){ //節点の深さを再帰的に求める
    D[u] = p;
    if ( N[u].right != NIL ) setDepth( N[u].right, p);
    if ( N[u].left != NIL ) setDepth( N[u].left, p + 1);
}

void print(int u){

    cout << "node " << u << ": ";
    cout << "parent = " << N[u].parent <<", ";
    cout << "depth = " << D[u] << ", ";
    
    if ( N[u].parent == NIL ) cout << "root, ";
    else if ( N[u].left == NIL ) cout << "leaf, ";
    else cout << "internal node, ";
    
    if ( N[u].left == NIL ) cout << "[]" << endl;
    else{
        cout << "[" << N[u].left;
        int c = N[u].left;
        while ( c != NIL ){
            if ( c != N[u].left ) cout << ", " << c;
            c = N[c].right;
        }
        cout << "]" << endl;
    }
}

int main(){
    int n, num, m, a, chil;
    cin >> n; //node数を読み込む
    for ( int i = 0; i < n; i++ ){ //左子右兄弟表現の実装
       N[i].parent = N[i].left = N[i].right = NIL;
    }
    
    for (int i = 0; i < n ; i++ ){
        cin >> num >> m;
        for ( int j = 0; j < m; j++ ){
            cin >> chil;
            if ( j == 0) N[num].left = chil;
            else N[a].right = chil;
            a = chil;
            N[chil].parent = num;
        }
    }
    int r;
    for ( int i = 0; i < n; i++ ){
        if ( N[i].parent == NIL ) r = i;
    }
    
    setDepth(r, 0);
    
    for ( int i = 0; i < n; i++ ) print(i);
    
    return 0;
}




Measured memory_bytes: 7764
var x,y:array[1..100000]of longint;
    i,j,n,tmp,lastt,lastx,lasty:longint;
begin
  readln(n);
  for i:=1 to 100000 do
  begin
    x[i]:=10000000;
    y[i]:=10000000;
  end;
  for i:=1 to n do
  begin
    read(tmp);
    readln(x[tmp],y[tmp]);
  end;
  for i:=1 to 100000 do
  begin
    if x[i]=10000000 then continue;
    if abs(lastx-x[i])+abs(lasty-y[i])>i-lastt then
    begin
      writeln('No'); exit;
    end;
    if ((i-lastt)-(abs(lastx-x[i])+abs(lasty-y[i]))) mod 2<>0 then
    begin
      writeln('No'); exit;
    end;
    lastt:=i;
    lastx:=x[i];
    lasty:=y[i];
  end;
  writeln('Yes');
end.

Measured memory_bytes: 896
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    
    int a = 0, b = 0, c = 0;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(sc.next());
      if(n <= A){
        a++;
      }else if(n <= B){
        b++;
      }else{
        c++;
      }
    }
    System.out.println(Math.min(a, Math.min(b, c)));
  }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, M;
vector<int> G[100000];
int U[100000], R[100000];
vector<int> r;
bool used[100000];

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

void unite(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return;
  if (R[x] < R[y]) swap(x, y);
  U[y] = x;
  R[x] += R[y];
  R[y] = 0;
}

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

void dfs(int x) {
  if (used[x]) return;
  used[x] = true;
  r.pb(x);
  for (int t : G[x]) {
    if (used[t]) continue;
    dfs(t);
    break;
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M;
  for (int i=0; i<N; i++) U[i] = i, R[i] = 1;
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].pb(b);
    G[b].pb(a);
    unite(a, b);
  }
  vector<P> vs;
  for (int i=0; i<N; i++) {
    vs.pb(P(G[i].size(), i));
  }
  sort(all(vs));
  for (int i=0; i<N; i++) {
    int s = vs[i]._2;
    rep(i, N) used[i] = false;
    r.clear();
    dfs(s);
    int t = r.back();
    bool f = true;
    for (int x : G[s]) {
      if (!used[x]) {
        f = false;
        break;
      }
    }
    if (!f) continue;
    for (int x : G[t]) {
      if (!used[x]) {
        f = false;
        break;
      }
    }
    if (!f) continue;

    cout << r.size() << "\n";
    for (int x : r) cout << x+1 << " ";
    cout << "\n";
    return 0;
  }
  return 1;
}


Measured memory_bytes: 12020
#include <iostream>

using namespace std;

int main()
{
    int n, m, t[110], h[110], ha, ta, a1, a2, best;
    bool ok;
    while (1)
    {
        ha=0; ta=0; ok=false; best=500;
        cin>>n>>m;
        if (n==0 && m==0) break;
        for (int i=0; i<n; i++) { cin>>t[i]; ta+=t[i]; }
        for (int i=0; i<m; i++) { cin>>h[i]; ha+=h[i]; }
        for (int i=0; i<n; i++)
        {
            for (int j=0; j<m; j++)
            {
                if (ta-t[i]+h[j]==ha-h[j]+t[i]) { ok=true; if (t[i]+h[j]<best) { a1=t[i]; a2=h[j]; best=a1+a2; } }
            }
        }
        if (!ok) cout<<"-1\n";
        else cout<<a1<<' '<<a2<<'\n';
    }
    return 0;
}



Measured memory_bytes: 2984
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define M 200010


int main(){
    IOS;
 	
 	ll n,k;cin>>n>>k;
 	ll a[n];
 	rep(i,0,n)cin>>a[i];
 	vector<pair<ld,ll>>v;
 	ll d=0;
 	rep(i,0,n){
 		if(!a[i]){d++;continue;}
 		ld x=log2(abs(a[i]));
 		v.pb({x,i});
 	}
 	if(n-d<k){
 		cout<<"0";
 		return 0;
 	}
 	sort(all(v));
 	reverse(all(v));
 	ll ok=1;
 	rep(i,0,k){
 		if(a[v[i].se]<0)ok*=-1;
 	}
 	if(k==n){
 		if(d)cout<<0;
 		else {
	 		ll ans=1;
	 		rep(i,0,n)(ans*=a[i])%=md,(ans+=md)%=md;
	 		cout<<ans;
 		}
 		return 0;
 	}
 	if(ok==1){
 		ll ans=1;
 		rep(i,0,k)(ans*=a[v[i].se])%=md,(ans+=md)%=md;
 		cout<<ans;
 		return 0;
 	}
 	ld x=0;
 	ll cnt=0;
 	rep(i,0,k)if(a[v[i].se]<0)cnt++;
 	ll ans=1,c=0;
 	rep(i,0,k){
 		if(a[v[i].se]<0){
 			c++;
 			if(c==cnt)continue;
 		}
 		(ans*=a[v[i].se])%=md,(ans+=md)%=md;
 		x+=v[i].fi;
 	}
 	if(!cnt)x=-1e9;
	ok=0;
 	rep(i,k,sz(v)){
 		if(a[v[i].se]>0){	 ok=1;
	 		(ans*=a[v[i].se])%=md,(ans+=md)%=md;
	 		x+=v[i].fi; break;
 		}
 	}
 	if(!ok)x=-1e9;
 	ld y=0;
 	ll cnt1=0;
 	rep(i,0,k)if(a[v[i].se]>0)cnt1++;
 	ll ans1=1;c=0;
 	rep(i,0,k){
 		if(a[v[i].se]>0){
 			c++;
 			if(c==cnt1)continue;
 		}
 		(ans1*=a[v[i].se])%=md,(ans1+=md)%=md;
 		y+=v[i].fi;
 	}
 	if(!cnt1)y=-1e9; ok=0;
 	rep(i,k,sz(v)){
 		if(a[v[i].se]<0){	 ok=1;
	 		(ans1*=a[v[i].se])%=md,(ans1+=md)%=md;
	 		y+=v[i].fi; break;
 		}
 	}
 	if(!ok)y=-1e9;
 	if(x<0 and y<0){
 		if(d){
 			cout<<"0";
 			return 0;
 		}
 		ans=1;
 		reverse(all(v));
 		rep(i,0,k)(ans*=a[v[i].se])%=md,(ans+=md)%=md;
 		cout<<ans;
 	}
 	else if(x>y)cout<<ans;
 	else cout<<ans1;
    return 0;
}

Measured memory_bytes: 13384
/******************************************************************************
 
                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
 
*******************************************************************************/
 
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int n, k;
int a[100005];
int ans=1e9;
 
int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort (a+1, a+n+1);
    k--;
    for (int i = k+1; i <= n; i++) ans=min(ans, a[i]-a[i-k]);
    cout << ans;
 
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod = 1e9+7;
int maxn;
int vis[100005];
LL fac[100005]={1,1};
LL inv[100005]={1,1};
LL fi[100005]={1,1}; 
void init()
{
    for(int i=2; i<=100005; ++i)
    {
        fac[i] = fac[i-1]*i%mod;
        inv[i] = (mod-mod/i)*inv[mod%i]%mod;
        fi[i] = fi[i-1]*inv[i]%mod;
    }
}
LL c(LL n, LL m)
{
    return fac[n]*fi[n-m]%mod*fi[m]%mod;
}
int main()
{
	init();
	int n,dist;
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++)
	{
		int temp;
		scanf("%d",&temp);
		if(vis[temp]) 
			dist = vis[temp] + n - i;	
		vis[temp] = i;
	}	
	long long ans;
	for(int i=1;i<=n+1;i++)
	{
		ans = c((long long)(n+1),(long long)(i))%mod;
		if(dist>=i-1)
		{
			ans= (ans -c((long long)dist, (long long)(i-1)) + mod)%mod;
		}
		printf("%lld\n",ans);	
	}
	return 0;
}

Measured memory_bytes: 3968
length, Max, q = map(int,input().split())
query = [[0]*4 for _ in range(q)]
for i in range(q):
    a,b,c,d = map(int,input().split())
    query[i] = [a-1,b-1,c,d]
ans = 0
def dfs(A):
    if len(A) == length:
        global ans
        score = 0
        for i in range(q):
            a,b,c,d = query[i]
            if A[b] - A[a] == c:
                score += d
        ans = max(ans, score)
        return
    last = A[-1]
    for i in range(last,Max+1):
        A.append(i)
        dfs(A)
        A.pop()
dfs([1])
print(ans)





Measured memory_bytes: 9204
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    s = S()
    if s[2] == s[3] and s[4] == s[5]:
        print("Yes")
    else:
        print("No")
main()

Measured memory_bytes: 74628
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=next[i])
#define repvc(i,vc) for(int i=0,_sz=vc.size();i<_sz;++i)
using namespace std;

const int INF=1<<30;
typedef long long ll;

inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

int main()
{
	int a[4];
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	cout<<a[1]+a[2]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"

using namespace std;
using ll = long long int;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long int MOD = 1000000007;
	int h, w, d, n;
	cin >> h >> w >> d >> n;
	vector<string>s(h);
	for (auto &i : s)cin >> i;
	vector<int>r(d);
	for (auto &i : r)cin >> i;
	vector<vector<int>>can(h, vector<int>(w, 1));
	vector<vector<int>>reach(h, vector<int>(w,MOD));
	for (int i = 0; i < n; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		if (!c) {
			for (int j = 0; j < h; j++) {
				for (int k = 0; k < w; k++) {
					if (max(abs(j - y), abs(k - x))>r[0]) {
						can[j][k] = 0;
					}
				}
			}
		}
		else if (c == d) {
			for (int j = 0; j < h; j++) {
				for (int k = 0; k < w; k++) {
					if (max(abs(j - y), abs(k - x)) <= r.back()) {
						can[j][k] = 0;
					}
				}
			}
		}
		else {
			for (int j = 0; j < h; j++) {
				for (int k = 0; k < w; k++) {
					if (max(abs(j - y), abs(k - x)) <= r[c - 1] || max(abs(j - y), abs(k - x)) > r[c]) {
						can[j][k] = 0;
					}
				}
			}
		}
	}
	int sy, sx;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == 'D')sy = i, sx = j;
		}
	}
	reach[sy][sx] = 0;
	queue<pair<int,int>>Q;
	Q.push({ sy,sx });
	int dir[] = { 1,0,-1,0,1 };
	while (!Q.empty()) {
		int cy = Q.front().first;
		int cx = Q.front().second;
		Q.pop();
		for (int i = 0; i < 4; i++) {
			int ny = cy + dir[i];
			int nx = cx + dir[i + 1];
			if (ny < 0 || nx < 0 || ny >= h || nx >= w)continue;
			if (s[ny][nx] == '#')continue;
			if (reach[ny][nx]>reach[cy][cx] + 1) {
				reach[ny][nx] = reach[cy][cx] + 1;
				Q.push({ ny,nx });
			}
		}
	}
	int flag = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#')can[i][j] = 0;
			flag += can[i][j];
		}
	}
	if (!flag) {
		cout << "Broken\n";
		return 0;
	}
	int box = flag;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (reach[i][j] == MOD&&can[i][j])flag--;
		}
	}
	if (!flag) {
		cout << "No\n";
	}
	else if (box == flag) cout << "Yes\n";
	else cout << "Unknown\n";
}


Measured memory_bytes: 3256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n+1)
	bs := make([]int, n)

	for i := range as {
		fmt.Scan(&as[i])
	}

	for i := range bs {
		fmt.Scan(&bs[i])
	}

	var sum int
	for i := 0; i <= n-1; i++ {
		a := as[i]
		b := bs[i]
		if a <= b {
			sum += a
			b -= a
			an := as[i+1]
			if an <= b {
				sum += an
				as[i+1] = 0
			} else {
				sum += b
				as[i+1] -= b
			}
		} else {
			sum += b
		}
	}
	fmt.Println(sum)
}


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

int main(){
    int x,y;
    cin>>x>>y;
    if(y>=2*x && 4*x>=y && (4*x-y)%2==0 && (y-2*x)%2==0)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int n;
	cin >> n;
	int l[n], r[n];
	rep (i, n) cin >> l[i] >> r[i];

	vector<ll> sum(100010, 0);
	rep (i, n) {
		sum[l[i] - 1]++;
		sum[r[i]]--;
	}

	rep (i, 100005) sum[i + 1] += sum[i];
	int cnt = 0;
	rep (i, 100001) if (sum[i]) cnt++;

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
K, S = map(int, input().split())

out = 0

# 全探査だと間に合わない
# zはあるかないかの２択なので外せる
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z <= K:
            out += 1
print(out)


Measured memory_bytes: 40684
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int x, y, z;
    cin >> x >> y >> z;

    if (x == y && x != z) cout << "Yes" << endl;
    else if (y == z && y != x) cout << "Yes" << endl;
    else if (x == z && x != y) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define repprev(i,a,b) for(ll i=b-1;i>=a;i--)
#define reprev(i,n) repprev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
struct UnionFind {
    vector<ll> par, rank;
 
    UnionFind(ll n) : par(n , -1), rank(n, 0) { }
    void init(ll n) { par.assign(n, -1), rank.assign(n, 0); }
 
    ll root(ll x) {
        if (par[x] == -1) return x;
        else return par[x] = root(par[x]);
    }
 
    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }
 
    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};
 
int main(){
    ll n,q; cin >> n >> q;
  	string str; cin >> str;
  	vector<ll> s(n+1, 0);
    rep(i,n) {
      if(i+1 < n && str[i] == 'A' && str[i+1] == 'C') s[i+1] = s[i] + 1;
      else s[i+1] = s[i];
    }
    rep(i,q){
      ll l, r;
      cin >> l >> r;
      --l;
      --r;
      cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline

MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci
frac, fraci = frac(1341398)
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%MOD

N, K = map(int, readline().split())
A = list(map(int, readline().split()))
if K == 1:
    ans = 0
else:

    A.sort()
    
    
    table = [comb(K+i-2, i) for i in range(N)]
    
    for i in range(1, N):
        table[i] = (table[i] + table[i-1]) % MOD
    
    Mx = 0
    for i in range(K-1, N):
        a = A[i]
        j = i - (K-1)
        Mx = (Mx + table[j]*a)%MOD
    
    Mi = 0
    for i in range(N-K+1):
        a = A[i]
        j = N-K-i
        Mi = (Mi + table[j]*a)%MOD
    ans = (Mx - Mi)%MOD
print(ans%MOD)


Measured memory_bytes: 118108
n,w = map(int,input().split())
weight = [0 for i in range(n)]
value = [0 for i in range(n)]
for i in range(n):
    weight[i],value[i] = map(int,input().split())
    

#dp[i][j]: i番目の品物までの中から選び、重さがj以下になる時の、価値の総和の最大値
dp = [[None for i in range(w+1)] for j in range(n+1)]
dp[1][weight[0]] = value[0]

for i in range(1,n):
    for j in range(w+1):
        if j - weight[i] >= 0:
            if dp[i][j-weight[i]] != None and dp[i][j] != None:
                dp[i+1][j] = max(dp[i][j-weight[i]]+value[i],dp[i][j])
            elif dp[i][j-weight[i]] == None and dp[i][j] != None:
                dp[i+1][j] = dp[i][j]
            elif dp[i][j-weight[i]] != None and dp[i][j] == None:
                dp[i+1][j] = dp[i][j-weight[i]]+value[i]
            else:
                dp[i+1][weight[i]] = value[i]
        else:
            dp[i+1][j] = dp[i][j]
            
print(max(i for i in dp[n] if i is not None))


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

int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++)
    cin >> V.at(i);
  
  int ans = 1000000;
  for (int j = 0; j < 100; j++) {
    int count = 0;
    for (int k = 0; k < N; k++) 
      count += (V.at(k) - j)*(V.at(k) - j);
    if (count < ans)
      ans = count;
  }
  cout << ans << endl;
      
}

Measured memory_bytes: 256
W,H,N=map(int, raw_input().split())
C=[]
for i in range(N):
	x,y,a=map(int, raw_input().split())
	C.append((x,y,a))

R=[[ 0 for i in range(H)] for j in range(W)]


for i in C:
	if i[2]==1:
		for x in range(i[0]):
			for y in range(H):
				R[x][y]=1
	elif i[2]==2:
		for x in range(i[0],W):
			for y in range(H):
				R[x][y]=1
	elif i[2]==3:
		for x in range(W):
			for y in range(i[1]):
				R[x][y]=1
	elif i[2]==4:
		for x in range(W):
			for y in range(i[1],H):
				R[x][y]=1


ans=0
for i in R:
	ans+=len(filter(lambda n:n==0, i) )

print ans


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

public class Main {
	
	static int w, h;
	static boolean[][] ice;
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int k = sc.nextInt();
		int n = sc.nextInt();
		boolean[] home = new boolean[k];
		for(int i = 0;i < n;i ++) {
			home[sc.nextInt()] = true;
		}
		int first = 0, pre = 0, now = 0;
		int interval = 0;
		for(int i = 0;i < k;i ++) {
			if(home[i]) {
				first = i;
				break;
			}
		}
		now = first;
		for(int i = first + 1;i < k;i ++) {
			if(home[i]) {
				pre = now;
				now = i;
				interval = Math.max(interval, now - pre);
			}
		}
		interval = Math.max(first + k - now, interval);
		println(k - interval);
	}
	
	static int[] dx = {1, 0, -1, 0};
	static int[] dy = {0, 1, 0, -1};
	
	public static void println(String s) {System.out.println(s);}
	public static void println(long s) {System.out.println(s);}
	public static void println(int s) {System.out.println(s);}
	
	public static void prt(String s) {
		System.out.print(s);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 25352
N = int(input())
#S = str(input())
#A, B = map(int, input().split())
L = list(map(int, input().split()))

count = 0
for i in range(N):
  for j in range(i + 1, N):
    if L[i] != L[j]:
      for k in range(j + 1, N):
        if (L[i] != L[k]) and (L[j] != L[k]):
          m = L[i] + L[j] + L[k]
          s = max(L[i] , L[j] , L[k])
          if s < m - s:
            count += 1

print(count)


Measured memory_bytes: 68244
use proconio::{input,fastout};
#[fastout]
fn main() {
    input!{
        n: usize,
        d: i64,
    }
    let mut ans: usize = 0;
    for _ in 0..n {
        input!{
            x: i64,
            y: i64,
        }
        if x * x + y * y <= d * d {
            ans += 1;
        }

    }
    println!("{}", ans);
}


Measured memory_bytes: 4908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
 map<string,int> memo;
 int n;
 cin>>n;
 for (int i = 0; i < n; i++)
 {
     /* code */
     string s;
     cin>>s;
     memo[s]+=1;
 }

 int maxv=0;
 for (auto itr = memo.begin(); itr != memo.end(); ++itr)
 {
     /* code */
     int v=itr->second;
     if (v > maxv) maxv = v;
 }
 
 for (auto itr = memo.begin(); itr != memo.end(); ++itr)
 {
     if (itr->second == maxv) {
  cout << itr->first << endl;
 }
 


}
}


    

Measured memory_bytes: 27008
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int i = 0;
      	while(i < 3){
        	System.out.print(sc.nextLine().charAt(i));
          	i++;
        }
      	System.out.println();
    }
}

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

int a[100005];

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

    int ma = 0;
    for(int i=0; i < n; i++){
        int temp;
        cin >> temp;
        ma = max(ma, temp);
        a[temp] += 1;
    }


    int flag = 0;
    int Flag = 0;
    while(ma > 0){
        if(a[ma] == 2) flag = 1;
        if(flag == 0) Flag = 1;
        flag = 0;
        ma -= 2;
    }

    long long res = 1;
    for(int i=0; i < n/2; i++){
        res *= 2;
        res %= 1000000007;
    }
    if(Flag) cout << 0 << endl;
    else if(n % 2 == 1 and a[0] == 1) cout << res << endl;
    else if(n % 2 == 0 and a[0] == 0) cout << res << endl;
    else cout << 0 << endl;

    return 0;

}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

void delMapKey(map<long long, int> &m, long long k){
	if(m.count(k) == 0){
		return;
	}
	m[k]--;
	if(m[k] == 0){
		m.erase(m.find(k));
	}
}

void addMapKey(map<long long, int> &m, long long k){
	if(m.count(k) == 0){
		m[k] = 1;
	}
	else{
		m[k]++;
	}
}

long long N, M;
map<long long, int> A;
vector<long long> B, C;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	for(int i=0; i<N; i++){
		long long a;
		cin >> a;
		addMapKey(A, a);
	}

	for(int i=0; i<M; i++){
		long long b, c;
		cin >> b >> c;
		B.push_back(b);
		C.push_back(c);
	}
	for(int i=0; i<M; i++){
		//if(i<M-1 && B[i+1]==N && C[i+1]>=C[i]) continue;
		long long b = B[i];
		long long c = C[i];
		long long w = b;
		while(w > 0){
			long long u, v;
		    for(auto itr = A.begin(); itr != A.end(); itr++){
		    	u = itr->first;
		    	v = itr->second;
		    	if(u >= c) break;
		    	if(v <= w){
		    		A.erase(A.find(u));
		    		if(A.count(c)==0){
		    			A[c] = v;
		    		}
		    		else{
		    			A[c] += v;
		    		}
		    		w -= v;
		    	}
		    	else if(v > w){
		    		A[u] = v - w;
		    		if(A.count(c)==0){
		    			A[c] = w;
		    		}
		    		else{
		    			A[c] += w;
		    		}
		    		w = 0;
		    	}
		    	break;
		    }
			if(u >= c || w <= 0){
				break;
			}
		}
	}
	long long ans = 0;
	for(auto itr = A.begin(); itr != A.end(); itr++){
		long long u = itr->first;
		long long v = (long long)itr->second;
		ans += (u * v);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 11180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll h,w;
    cin>>h>>w;
    if(h==1||w==1){
        cout<<1;
        return 0;
    }
    cout<<(h*w+1)/2;
}


Measured memory_bytes: 256
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int res = 0;

void merge(vector<int> &A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1 + 1), R(n2 + 1);
	for (int i = 0;i < n1;i++) L[i] = A[left + i];
	for (int i = 0;i < n2;i++) R[i] = A[mid + i];
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	int i = 0, j = 0;
	for (int k = left;k < right;k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
		}
		res++;
	}
}

void mergeSort(vector<int> &A, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

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

	int n;
	cin >> n;
	vector<int> S(n);
	REP(i, n) cin >> S[i];
	mergeSort(S, 0, n);
	REP(i, n) {
		if (i < n - 1) cout << S[i] << " ";
		else cout << S[i] << "\n";
	}
	cout << res << "\n";

	return 0;
}


Measured memory_bytes: 6724
using System;
using System.Runtime.CompilerServices;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            string S = cin.Next();
            string ans = "No";

            if (S[2] == S[3])
            {
                if (S[4] == S[5])
                {
                    ans = "Yes";
                }
            }
            Console.WriteLine(ans);
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 25796
#include<stdio.h>
int s[10], c[10], n, m;
int main() {
    int i, ss, cc;
    scanf("%d%d", &n, &m);
    for(i = 1; i <= m; ++i) { 
        scanf("%d%d", &ss, &cc);
        if(s[ss]) { 
            if(c[ss] != cc) { 
                printf("-1\n");
                return 0; 
            }
        }
        if(ss == 1 && cc == 0 && n != 1) {
            printf("-1\n");
            return 0; 
        }
        s[ss] = 1; 
        c[ss] = cc; 
    }
    for(i = 1; i <= n; ++i) {
        if(s[i]) printf("%d", c[i]); 
        else if(i != 1 || n == 1) printf("0");
        else printf("1");
    }
    puts(""); 
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    ll sum = accumulate(begin(a), end(a), 0LL);

    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (1LL * a[i] * n <= sum) ans++;
    }

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



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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int a , b ; 
    cin >> a >> b ; 
    
    int ans = 1 + ( a - 1 ) / b ; 
    cout << ans ; 
    
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
from numba import jit, njit, i8
import numpy as np


@njit(i8(i8, i8, i8), cache=True)
def modpow(a, p, m):
  r = 1
  while p:
    if p & 1: r = r * a % m
    a = a * a % m
    p >>= 1
  return r


@njit(i8[:](i8[:], i8[:]), cache=True)
def ntt(s, t):
  mod = 998244353
  pr = 5
  sl, tl = len(s), len(t)
  k = 1
  M = 2
  while M < sl + tl - 1:
    k += 1
    M *= 2
  w = np.zeros(M // 2, np.int64)
  y = np.zeros(M // 2, np.int64)

  def init():
    nonlocal w, y, M, mod, pr
    z = modpow(pr, (mod - 1) // M, mod)
    x = modpow(z, mod - 2, mod)
    j = M // 4
    while j:
      w[j] = z
      z = z * z % mod
      y[j] = x
      x = x * x % mod
      j //= 2
    y[0] = 1
    w[0] = 1
    j = M // 2
    js = 2
    while js < j:
      z = w[js]
      x = y[js]
      for k2 in range(js):
        w[k2 + js] = w[k2] * z % mod
        y[k2 + js] = y[k2] * x % mod
      js *= 2

  def fft(a, k):
    nonlocal w, y, mod
    m = 2 ** k
    u = 1
    v = m // 2
    i = k
    while i:
      jh = 0
      while jh < u:
        wj = w[jh]
        j = jh * v * 2
        je = j + v
        while j < je:
          ajv = wj * a[j + v] % mod
          a[j + v] = a[j] + mod - ajv
          if a[j + v] >= mod:
            a[j + v] -= mod
          a[j] = a[j] + ajv
          if a[j] >= mod:
            a[j] -= mod
          j += 1
        jh += 1
      u *= 2
      v //= 2
      i -= 1

  def ifft(a, k):
    nonlocal w, y, mod
    m = 2 ** k
    u = m // 2
    v = 1
    i = 1
    while i <= k:
      jh = 0
      while jh < u:
        wj = y[jh]
        j = jh * v * 2
        je = j + v
        while j < je:
          ajv = a[j] + mod - a[j + v]
          if ajv >= mod:
            ajv -= mod
          a[j] = a[j] + a[j + v]
          if a[j] >= mod:
            a[j] -= mod
          a[j + v] = wj * ajv % mod
          j += 1
        jh += 1
      u //= 2
      v *= 2
      i += 1

  init()
  u = np.zeros(M, np.int64); u[:sl] = s; fft(u, k)
  v = np.zeros(M, np.int64); v[:tl] = t; fft(v, k)
  u *= v; u %= mod; ifft(u, k)
  u *= modpow(2 ** k, mod - 2, mod); u %= mod
  return u[:sl + tl - 1]



import sys
readline = sys.stdin.buffer.readline
N, M = map(int, readline().split())
A = np.array(readline().split(), np.int64)
B = np.array(readline().split(), np.int64)
print(' '.join(map(str, ntt(A, B))))

Measured memory_bytes: 204444