akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{

  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if (a <= b) cout << c * a << endl;
  else cout << b* c + (a - b) * d << endl;
  return 0;
}


Measured memory_bytes: 3572
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;


public class Main {	
	static class Team{
		int id;
		int slove;
		boolean flag[];
		int pena[];
		int time;
		Team(int nid,int P){
			this.id=nid;
			this.slove=0;
			this.flag=new boolean[P+1];
			this.pena=new int[P+1];
			Arrays.fill(this.flag, false);
			Arrays.fill(this.pena, 0);
			time=0;
		}
	}
	
	public static void main(String[] args) throws FileNotFoundException {
		//System.setOut(new PrintStream(new File("result.txt")));
		Scanner sc = new Scanner(System.in);
		int t,p=0,r,tid,pid,ttime;
		int i,j;
		String str;
		Team team[];
		while(sc.hasNext()){
			t=sc.nextInt();
			p=sc.nextInt();
			r=sc.nextInt();
			if(t+p+r==0) break;
			team=new Team[t+1];
			
			for(i=0;i<=t;i++){
				team[i]=new Team(i,p);
			}
			
			for(i=0;i<r;i++){
				tid=sc.nextInt();
				pid=sc.nextInt();
				ttime=sc.nextInt();
				str=sc.next();
				if(str.equals("CORRECT")){
					if(!(team[tid].flag[pid])){
						team[tid].slove++;
						team[tid].time+=team[tid].pena[pid]*1200+ttime;
						team[tid].flag[pid]=true;
					}
				}
				else{
					team[tid].pena[pid]++;
				}
			}//for
			int max;
			Team temp;
			temp=new Team(-1,0);
			for(i=1;i<=t;i++){
				max=i;
				for(j=i;j<=t;j++){
					if(team[max].slove<team[j].slove){
						max=j;
					}
					else if(team[max].slove==team[j].slove){
						if(team[max].time>team[j].time){
							max=j;
						}
						else if(team[max].time==team[j].time){
							if(team[max].id>team[j].id){
								max=j;
							}
						}
					}
				}//
				temp=team[i];
				team[i]=team[max];
				team[max]=temp;
			}
			for(i=1;i<=t;i++){
				System.out.println(team[i].id+" "+team[i].slove+" "+team[i].time);
			}
		}
	}
}

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

typedef long long ll;

const int mod = 1000000007;
const int Maxb = 62;

ll L, R;

int All(ll mask, int lvl, int my)
{
    int res = 1;
    for (int i = my; i >= 0; i--)
        if (i <= lvl) res = ll(res) * 3ll % mod;
        else if (mask & 1ll << ll(i)) res = ll(res) * 2ll % mod;
    return res;
}

int Solve2(ll mask, int lvl, ll lim)
{
    if (mask) {
        int res = 0;
        int pnt = Maxb - 1;
        while (!(mask & 1ll << ll(pnt))) pnt--;
        ll cur = 1ll << ll(pnt);
        if (cur > lim) return 0;
        int mult = 1;
        for (int i = pnt - 1; i >= 0; i--) {
            if (cur + (1ll << ll(i)) <= lim) {
                int my = mult;
                if (i <= lvl) my = 2ll * mult % mod;
                res = (res + ll(All(mask, lvl, i - 1)) * my) % mod;
                if (i > lvl && !bool(mask & 1ll << ll(i))) return res;
                cur |= 1ll << ll(i);
            } else if (i <= lvl) mult = 2ll * mult % mod;
        }
        res = (res + mult) % mod;
        return res;
    } else {
        int res = 0;
        for (int i = lvl; i >= 0; i--)
            res = (res + Solve2(1ll << ll(i), i - 1, lim)) % mod;
        return res;
    }
}

int Solve(ll lim1, ll lim2)
{
    int res = 0;
    ll cur = 0;
    for (int i = Maxb - 1; i >= 0; i--)
        if (lim1 & 1ll << ll(i)) {
            res = (res + Solve2(cur, i - 1, lim2)) % mod;
            cur |= 1ll << ll(i);
        }
    res = (res + Solve2(cur, -1, lim2)) % mod;
    return res;
}

int main()
{
    cin >> L >> R;
    int res = (Solve(R, R) - Solve(R, L - 1) + mod) % mod;
    printf("%d\n", res);
    return 0;
}


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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    
    int min_num;
    double min_diff = DBL_MAX;
    double n, t, a; cin >> n >> t >> a;
    for (int i = 1; i <= n; i++) {
        double temp; cin >> temp;
        double val = abs(a - (t - (double)0.006 * temp));
        if (min_diff > val) {
            min_diff = val;
            min_num = i;
        }
    }
    
    cout << min_num << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
using namespace std;
int num[10001];
int main()
{
	int a,b,c;
	int ans=0;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<=a;i++)
	{
		scanf("%d",&num[i]);
		if(num[i]<b||num[i]>=c)
		  ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATakoyaki solver = new ATakoyaki();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATakoyaki {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int t = in.nextInt();

            int res = (n + x - 1) / x * t;

            out.print(res);
        }

    }

    static class FastReader {
        public BufferedReader br;
        public StringTokenizer st;
        String context = null;

        public FastReader(InputStream in) {
            this(new InputStreamReader(in));
        }

        public FastReader(InputStreamReader input) {
            br = new BufferedReader(input);
        }

        public String next() {
            if (context != null) {
                System.err.print("[" + context + "] Wait for input ...");
            }
            while (st == null || !st.hasMoreElements()) {
                try {
                    String s = br.readLine();
                    if (s == null)
                        return null;
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    throw new RuntimeException("Could not read");
                }
            }
            String res = st.nextToken();
            if (context != null) {
                System.err.println("[" + context + "] ... received : " + res);
            }
            return res;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 32776
#include <iostream>

struct Element {
	int value;
	Element *pNext;
	Element *pPrev;
};

class DoublyLinkedList {
public:
	DoublyLinkedList()
	{
		pFirst = new Element{0, NULL, NULL};
		pLast = new Element{0, NULL, NULL};
		pFirst->pNext = pLast;
		pLast->pPrev = pFirst;
	}
	~DoublyLinkedList()
	{
		while (pFirst->pNext != pLast) {
			deleteFirst();
		}
		delete pFirst;
		delete pLast;
	}
	void insertX(int x) {
		Element *pInsert = new Element{x, pFirst->pNext, pFirst};
		pFirst->pNext->pPrev = pInsert;
		pFirst->pNext = pInsert;
	}
	void deleteX(int x) {
		Element *pSearch = pFirst->pNext;
		while (pSearch != pLast) {
			if (pSearch->value == x) {
				pSearch->pPrev->pNext = pSearch->pNext;
				pSearch->pNext->pPrev = pSearch->pPrev;
				delete pSearch;
				break;
			}
			pSearch = pSearch->pNext;
		}
	}
	void deleteFirst() {
		Element *pDelete = pFirst->pNext;
		if (pDelete != pLast) {
			pDelete->pPrev->pNext = pDelete->pNext;
			pDelete->pNext->pPrev = pDelete->pPrev;
		}
	}
	void deleteLast() {
		Element *pDelete = pLast->pPrev;
		if (pDelete != pFirst) {
			pDelete->pPrev->pNext = pDelete->pNext;
			pDelete->pNext->pPrev = pDelete->pPrev;
		}
	}
	void show() {
		Element *pSearch = pFirst->pNext;
		std::cout << pSearch->value;
		pSearch = pSearch->pNext;
		while (pSearch != pLast) {
			std::cout << " " << pSearch->value;
			pSearch = pSearch->pNext;
		}
		std::cout << std::endl;
	}
private:
	Element *pFirst;
	Element *pLast;
};

int main() {
	int n;
	std::cin >> n;
	std::string command;
	int x;
	DoublyLinkedList list;
	for (int i = 0; i < n; i++) {
		std::cin >> command;
		if (command == "insert") {
			std::cin >> x;
			list.insertX(x);
		} else if (command == "delete") {
			std::cin >> x;
			list.deleteX(x);
		} else if (command == "deleteFirst") {
			list.deleteFirst();
		} else if (command == "deleteLast") {
			list.deleteLast();
		}
	}
	list.show();
	return 0;
}


Measured memory_bytes: 37444
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int x; cin >> x;
  int a = (x/500) * 1000;
  x %= 500;
  a += (x/5) * 5;
  cout << a << endl;

}

// EOF


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string ans="No";
  for(int i=0;i<20;i++){
    for(int j=0;j<20;j++){
      if(i*4+j*7==N){
        ans="Yes";
        break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::set<int> set;

  int x;

  for (int i = 0; i < 2; i ++) {
    std::cin >> x;

    set.insert(x);
  }

  for (int i = 1; i <= 3; i ++)
    if (set.count(i) == 0)
      std::cout << i << std::endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])

time=0
for i in range(N):
  time+=AB[i][0]
  if time<=AB[i][1]:
    continue
  else:
    print("No")
    exit()
print("Yes")

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

signed main(){
    io();
    ld n; cin >> n;
    vector<pair<ll, ll>> v(n);
    for(int i = 0; i < n; ++i){
        ll x, y; cin >> x >> y;
        v[i] = {x, y};
    }
    ld sum = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            ld x = v[i].first - v[j].first;
            ld y = v[i].second - v[j].second;
            ld add = sqrt((x*x)+(y*y));
            sum += add;
        }
    }
    cout << fixed << setprecision(9);
    cout << 2*sum/n << '\n';
    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
ll A[4][N],dp[N][4];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>A[1][i]>>A[2][i]>>A[3][i];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=3;j++){
            for(int k=1;k<=3;k++){
                if(j!=k)
                dp[i][j]=max(dp[i][j],dp[i-1][k]+A[j][i]);
            }
        }
    }
    ll res=max(dp[n][1],max(dp[n][2],dp[n][3]));
    cout<<res;



}


Measured memory_bytes: 9044
## main

loop do
  m = gets.strip.to_i
  break if m == 0

  cnstl = []
  m.times do
    x, y = gets.strip.split(' ').map{|s| s.to_i}
    cnstl << [x, y]
  end

  cnstl.sort!{|a, b| (cmp = a[1] <=> b[1]) != 0 ? cmp : a[0] <=> b[0]}

  corg = cnstl[0]
  cox, coy = corg
  for i in (1...m)
    x1, y1 = cnstl[i]
    cnstl[i] = [x1 - cox, y1 - coy]
  end
  #p cnstl

  n = gets.strip.to_i

  stars = []
  exists = {}

  n.times do
    x, y = gets.strip.split(' ').map{|s| s.to_i}
    stars << [x, y]
    exists[[x,y]] = true
  end
  #p stars
  #p exists

  for st in stars
    x0, y0 = st
    found = true

    for i in (1...m)
      dx, dy = cnstl[i]
      if exists[[x0 + dx, y0 + dy]].nil?
        found = false
        break
      end
    end

    if found
      puts [x0 - cox, y0 - coy].join(' ')
      break
    end
  end
end

Measured memory_bytes: 6124
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

    int h1, w1;
    int h2, w2;
    

    scanf("%d %d %d %d", &h1, &w1, &h2, &w2);


    printf("%d", (h1-h2)*(w1-w2));


    return 0;

}


Measured memory_bytes: 128
n = int(input())
li = list(map(int,input().split()))
ans = 10000000000000
x = 0
y = sum(li)

for i in range(0,n-1):
    x += li[i]
    y -= li[i]
    z = abs(x-y)
    if z < ans:
        ans = z

print(ans)

Measured memory_bytes: 76752
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep1(i,n){
    int temp = n - i;
    if(temp != i)ans++;
  }
  cout << ans / 2<<endl;
  return 0;
} 

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

using namespace std;

using int64 = long long;

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

  int n;
  int64 a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int64 t = b - a;
  bool valid = false;
  for (int i = 0; i <= n - 1; i++) {
    int64 l = i * c + (n - 1 - i) * (-d);
    int64 u = i * d + (n - 1 - i) * (-c);
    if (l <= t && t <= u) {
      // cout << "i:" << i << endl;
      valid = true;
      break;
    }
  }
  if (valid) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> like(M);
  for(int i=0;i<N;i++){
    int K;
    cin>>K;
    for(int j=0;j<K;j++){
      int a;
      cin>>a;
      like[a-1]++;
    }
  }
  int ans = 0;
  for(int i=0;i<M;i++){
    if(like[i] == N)
      ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define ll long long
#define inf 1e9
using namespace  std;

int main(){

	ll n,w;
	cin>>n>>w;

	ll sacks[n+1][2];

	for(ll i=1;i<=n;i++){
		cin>>sacks[i][0]>>sacks[i][1];
	}

	ll dp[n+1][w+1];

	for(ll i=0;i<=n;i++){
		for(ll j=0;j<=w;j++){
			if(i==0||j==0){
				dp[i][j]=0;
			}else{
				if(j<sacks[i][0]){
					dp[i][j]= dp[i-1][j];
				}else{
					dp[i][j] = max(dp[i-1][j],sacks[i][1]+dp[i-1][j-sacks[i][0]]);
				}
			}
		}
	}

	cout<<dp[n][w]<<endl;

	return 0;
}

Measured memory_bytes: 82508
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <iostream>
#define maxn 5009
using namespace std;
int a[maxn];
bool dp[maxn][maxn];
int main(){
	int n,k;
	scanf("%d%d", &n, &k);
	int m = 0;
	for(int i = 1; i <= n; i++){
		int x;
		scanf("%d", &x);
		if(x >= k)
			continue;
		a[++m] = x;
	}
	sort(a + 1, a + m + 1);
	dp[m + 1][0] = 1;
	for(int i = m; i >= 1; i--){
		for(int j = 0; j <= k; j++){
			dp[i][j] = dp[i + 1][j];
			if(j >= a[i])
				dp[i][j] |= dp[i + 1][j - a[i]];
		}
	}
	int ans = 0;
	int sum = 0;
	for(int i = 1; i <= m; i++){
		int x = 0;
		for(int j = k - 1; j >= 0; j--){
			if(dp[i + 1][j]){
				x = j;
				break;
			}
		}
		if(x + sum < k - a[i]){
			ans++;
		}
		sum += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 24704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

int main() {
    string s; cin >> s;
    int n = s.size();
    vint n_question(n+1,0), n_C(n+1,0);
    REP(i,n+1) {
        n_question[i] += n_question[i-1];
        n_C[i] += n_C[i-1];
        if (s[i-1] == '?') n_question[i]++;
        if (s[i-1] == 'C') n_C[i]++;
    }
    vector<mint> T(n-1,0);
    REP(i,n-1) {
        if (s[i] != 'B' && s[i] != '?') continue;
        int z = n_question[n] - n_question[i+1];
        int c = n_C[n] - n_C[i+1];
        T[i] += mint(3).pow(z)*c;
        if (z != 0) T[i] += mint(3).pow(z-1)*z;
        T[i] *= mint(3).pow(n_question[i]);
    }
    REP(i,n-1) T[i] += T[i-1];
    mint ans = 0;
    rep(i,n-2) {
        mint v = 0;
        if (s[i] == 'A' || s[i] == '?') {
            v += (T[n-2]-T[i])/mint(3).pow(n_question[i+1]);
            v *= mint(3).pow(n_question[i]);
        }
        ans += v;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5080
#common subsequence
n,m=map(int,input().split())
mod=10**9+7
a=list(map(int,input().split()))
b=list(map(int,input().split()))
dp=[[0 for i in range(m+1)] for j in range(n+1)]
#dp[i][j]=aのi番目、bのj番目まででの個数
#求めたいのはdp[n][m]
for i in range(m+1):
    dp[0][i]=1
for i in range(n+1):
    dp[i][0]=1
dp[0][0]=1
for i in range(1,n+1):
    for j in range(1,m+1):
        if a[i-1]==b[j-1]:
            dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod
        else:
            dp[i][j]=(dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1])%mod
print(dp[n][m])

Measured memory_bytes: 74332
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    
    vector<int> x(n), y(n), h(n);
    int able;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] > 0) able = i;
    }
    
    int ansx = -1, ansy = -1, ansh = -1;
    for (int i = 0; i <= 100; i++)
    {
        bool ok;
        ansh = -1;
        for (int j = 0; j <= 100; j++)
        {
            ok = true;
            ansh = h[able]+abs(i-x[able]) + abs(j-y[able]);
            for (int k = 0; k < n; k++)
            {
                int tmp = max(0, ansh-abs(i-x[k])-abs(j-y[k]));
                if (tmp != h[k]) ok = false;
            }
            if (ok) {
                ansy = j;
                break;
            }
        }
        if (ok) {
            ansx = i;
            break;
        }
    }

    cout << ansx << ' ' << ansy << ' ' << ansh << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  int a,b,c,ans;
  cin>>a>>b>>c;

  if(b/a>c) ans=c;
  else ans=b/a;

  cout<<ans<<endl;
}

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

vector < int > G[9];
int N, M;

int dfs(int v, int bit)
{
    int ret = 0;
    if(bit == (1 << N) - 1) {
        return (1);
    }
    for(int i = 0; i < G[v].size(); i++) {
        int u = G[v][i];
        if(((bit >> u) & 1) == 0) {
            ret += dfs(u, bit | (1 << u));
        }
    }
    return (ret);
}
int main()
{

    cin >> N >> M;

    while(M--) {
        int a, b;
        cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << dfs(0, 1) << endl;

    return (0);
}


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

int main() {
    int a,b;
    cin >> a >> b;
    if(abs(a-b) <= 2)cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	long ans = 1;
	for(int i = 1; i<=N; i++) {
	    ans *= i;
	    if(ans>Math.pow(10,9)+7) ans %= Math.pow(10,9)+7;
	}
	System.out.println((long)ans%((long)Math.pow(10,9)+7));
    }
}

Measured memory_bytes: 21844
N = int(input())
AB = 0
bx, ba, xa = 0, 0, 0
for i in range(N):
  S = input()
  for j in range(len(S)-1):
    if S[j:j+2] == "AB":
      AB += 1
  if S[0] == 'B' and S[len(S)-1] == 'A':
    ba += 1
  elif S[0] == 'B' and S[len(S)-1] != 'A':
    bx += 1
  elif S[0] != 'B' and S[len(S)-1] == 'A':
    xa += 1
#print(xa, ba, bx)
if ba > 0:
  if xa > 0 and bx > 0:
    xa -= 1
    bx -= 1
    AB += ba + 1
  elif xa > 0 and bx == 0:
    xa -= 0
    AB += ba
  elif bx > 0 and xa == 0:
    bx -= 1
    AB += ba
  elif xa == 0 and bx == 0:
    AB += ba - 1
AB += min(xa, bx)
print(AB)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = 0;
    if(a >= 13)c = b;
    else if(a >= 6)c = b/2;
    else c = 0;
    System.out.println(c);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int K ,N;
    cin >> K >>N;
    int data[N];
    for(int i=0;i<N;i++){
        cin >>data[i];
    }
    int sum=0;
    for(int i=1;i<N;i++){
        int ans=0;
        ans = data[i]-data[i-1];
        sum =max(sum,ans);
     }
      int kuma=0;
      kuma=max(data[0]+K-data[N-1],sum);
      cout << K-kuma <<endl;
}

Measured memory_bytes: 4404
#include<stdio.h>
#define INF 10000000

int time[101][101],cost[101][101],m;

void warshall_floyd_time(void);
void warshall_floyd_cost(void);
int min(int,int);
void init(void);

int main(void){
  int i,j,n,k,a,b,cos,tim,p,q,r;

  while(scanf("%d %d",&n,&m),n,m){

    init();
    
    for(i=0;i<n;i++){
      scanf("%d %d %d %d",&a,&b,&cos,&tim);
      cost[a][b]=cost[b][a]=cos;
      time[a][b]=time[b][a]=tim;
    }

    warshall_floyd_time();
    warshall_floyd_cost();

    scanf("%d",&k);
    for(i=0;i<k;i++){
      scanf("%d %d %d",&p,&q,&r);
      printf("%d\n",r?time[p][q]:cost[p][q]);
    }
  }
  return 0;
}

void warshall_floyd_time(void){
  int i,j,k;
  for(k=0;k<=m;k++)
    for(i=0;i<=m;i++)
      for(j=0;j<=m;j++)
	time[i][j]=time[j][i]=min(time[i][j],time[i][k]+time[k][j]);
}

void warshall_floyd_cost(void){
  int i,j,k;
  for(k=0;k<=m;k++)
    for(i=0;i<=m;i++)
      for(j=0;j<=m;j++)
	cost[i][j]=cost[j][i]=min(cost[i][j],cost[i][k]+cost[k][j]);
}

int min(int x,int y){
return x<y?x:y;
}

void init(void){
  int i,j;
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      time[i][j]=cost[i][j]=INF;     
    }
    time[i][i]=cost[i][i]=0;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.math.BigDecimal;
public class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        double a = s.nextInt();
        double b = s.nextInt();
        
        double ave = (a + b) / 2;
        BigDecimal bd = new BigDecimal(ave);
        BigDecimal bd1 = bd.setScale(0, BigDecimal.ROUND_HALF_UP);
        System.out.println(bd1);
    }
}


Measured memory_bytes: 21844
import sys
input = sys.stdin.readline

n=int(input())
ans = [0]*int(1e5+1)
for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            ans[x*x + y*y + z*z + x*y + y*z + z*x]+=1
print(*ans[1:n+1])


Measured memory_bytes: 69392
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//mapのキー：p->first mapのバリュー：p->second
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto i = begin; i != end; i++) {}
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	char c[3][3];
	rep(i, 3) rep(j, 3) cin >> c[i][j];

	cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

Measured memory_bytes: 256
use std::cell::RefCell;
use std::cmp::{max, min};
use std::io::{self, stdout, BufWriter, Read, Write};
use std::iter::FromIterator;

#[allow(dead_code)]
struct Source {
    chars: Box<Iterator<Item = char>>,
}

#[allow(dead_code)]
impl Source {
    fn next_chr(&mut self) -> char {
        self.chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .next()
            .expect("eof")
    }

    fn next_str(&mut self) -> String {
        let it = self
            .chars
            .by_ref()
            .skip_while(|c| char::is_whitespace(*c))
            .take_while(|c| !char::is_whitespace(*c));
        let s = String::from_iter(it);
        if s.is_empty() {
            panic!("eof")
        } else {
            s
        }
    }

    fn from_stdin() -> Self {
        let mut data = String::new();
        io::stdin().read_to_string(&mut data).expect("Input error");
        Self::from_str(&data)
    }

    fn from_str(s: &str) -> Self {
        let data = String::from(s);
        let chars = data.chars().collect::<Vec<char>>().into_iter();
        Source {
            chars: Box::new(chars),
        }
    }
}

thread_local!(static SRC: RefCell<Source> = RefCell::new(Source::from_stdin()));

#[allow(unused_macros)]
macro_rules! input {
    ($($elem:tt)*) => {
        input_inner!(SRC, $($elem)*)
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($src:expr) => {};
    ($src:expr,) => {};
    ($src:expr, $var:ident : mut $ty:tt $($rest:tt)*) => {
        let mut $var = $src.with(|src| {
            let mut src = src.borrow_mut();
            parse!(src, $ty)
        });
        input_inner!($src $($rest)*)
    };
    ($src:expr, $var:ident : $ty:tt $($rest:tt)*) => {
        let $var = $src.with(|src| {
            let mut src = src.borrow_mut();
            parse!(src, $ty)
        });
        input_inner!($src $($rest)*)
    };
}

#[allow(unused_macros)]
macro_rules! parse {
    ($src:expr, ( $($ty:tt),* )) => {
        ( $(parse!($src,$ty)),* )
    };
    ($src:expr, char) => {
        $src.next_chr()
    };
    ($src:expr, [ $ty:tt; $len:expr ]) => {
        (0..$len).map(|_| parse!($src,$ty)).collect::<Vec<_>>()
    };
    ($src:expr, $ty:tt) => {
        parse_str!($src,$ty)
    };
}

#[allow(unused_macros)]
macro_rules! parse_str {
    ($src:expr, chars) => {
        $src.next_str().chars().collect::<Vec<char>>()
    };
    ($src:expr, $ty:ty) => {
        $src.next_str().parse::<$ty>().expect("Parse error")
    };
}

fn main() {
    input! { s: chars }

    let l = s.len();
    let c = s.into_iter().filter(|c| *c == '0').count();

    println!("{}", 2 * min(c, l - c))
}


Measured memory_bytes: 4352
class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[y] += 1
            self.p[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)

n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
    a,b = map(int,input().split())
    uf.unite(a-1,b-1)

ans = 0
for i in range(n):
    ans = max(ans,uf.size[uf.find(i)])
print(ans)


Measured memory_bytes: 86680
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
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;}
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
// clang-format on

ll counter(ll x) {
  if (x == 0)
    return 0;
  return counter(x >> 1) + (x & 1);
}

void solve(ll N, vector<ll> A, vector<vector<ll>> X, vector<vector<ll>> Y) {
  ll ans = 0;
  for (ll bits = 1; bits < (1 << N); bits++) {
    bool ok = true;
    rep(i, N) {
      if (!(bits & (1 << i)))
        continue;
      rep(j, A[i]) {
        if (((bits >> (X[i][j] - 1)) & 1) ^ Y[i][j])
          ok = false;
      }
    }
    if (ok)
      ans = max(ans, counter(bits));
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  vector<vector<ll>> X(N);
  vector<vector<ll>> Y(N);
  rep(n, N) {
    scanf("%lld", &A[n]);
    vector<ll> x(A[n]);
    vector<ll> y(A[n]);
    rep(a, A[n]) { scanf("%lld %lld", &x[a], &y[a]); }
    X[n] = x;
    Y[n] = y;
  }
  solve(N, move(A), move(X), move(Y));
  return 0;
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int h,w,d[4] = {0,1,0,-1};
    cin >> h >> w;
    P s,g;
    cin >> s.first >> s.second >> g.first >> g.second;
    s.first--;s.second--;g.first--;g.second--;
    string c[1010];
    for (int i = 0;i < h;++i) cin >> c[i];
    deque<P> dq;
    vector<vector<int>> dist(h,vector<int>(w,1e9));
    dist[s.first][s.second] = 0;
    dq.push_back(s);
    while (!dq.empty()) {
        P t = dq.front();dq.pop_front();
        for (int i = 0;i < 4;++i) {
            int x = t.first+d[i],y = t.second+d[i^1];
            if (x < 0 || x >= h || y < 0 || y >= w || c[x][y] == '#' || dist[x][y] <= dist[t.first][t.second]) continue;
            dq.push_front({x,y});
            dist[x][y] = dist[t.first][t.second];
        }
        for (int i = -2;i < 3;++i) if (t.first+i >= 0 && t.first+i < h) for (int j = -2;j < 3;++j) {
            int x = t.first+i,y = t.second+j;
            if (y < 0 || y >= w || c[x][y] == '#' || dist[x][y] <= dist[t.first][t.second]+1) continue;
            dq.push_back({x,y});
            dist[x][y] = dist[t.first][t.second]+1;
        }
    }
    int ans = dist[g.first][g.second];
    if (ans == 1e9) ans = -1;
    cout << ans << newl;
}

Measured memory_bytes: 9564
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int x, a;
	cin >> x >> a;
	if (x < a)
		cout << 0 << endl;
	else
		cout << 10 << endl;
}

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

using namespace std;

int main(){

    int n,q;
    string name[1001];
    int duration[1001];
    int start[1001];
    while(cin>>n>>q&&!(q==0&&n==0)){
        for(int i = 0; i < n; i++)
            cin>>name[i]>>duration[i]>>start[i];
        for(int i = 0; i < q; i++){
            int y;
            cin>>y;
            bool b=false;
            for(int j = 0; j < n; j++){
                if(start[j]>=y&&start[j]-duration[j]+1<=y){
                    cout<<name[j]<<" "<<y-start[j]+duration[j]<<endl;
                    b=true;
                    break;
                }
            }
            if(!b)
                cout<<"Unknown"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 980
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var X = ReadLong();
            if(X <= 599)
            {
                return 8;
            }
            if(X<= 799)
            {
                return 7;
            }
            if (X <= 999)
            {
                return 6;
            }
            if (X <= 1199)
            {
                return 5;
            }
            if (X <= 1399)
            {
                return 4;
            }
            if (X <= 1599)
            {
                return 3;
            }
            if (X <= 1799)
            {
                return 2;
            }

            return 1;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int ans=1000000000;
  for(int i=0;i<n-k+1;i++){
    int j=i+k-1;
    int p=min(abs(a[i]),abs(a[j]));
    ans=min(ans,a[j]-a[i]+p);
  }
  cout << ans << endl;
}

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

int main() {
    ll x;
    cin >> x;
    int ans=0;
    ll m=100;
    while(x>m){
      m+=m/100;
      ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int S[1000000],n;
int search(int t, int S[], int n) {
	int left = 0;
	int right = n ;
	int mid;
	while (left < right) {
		mid = (right + left) / 2;
		if (S[mid] == t)return 1;
		else if (S[mid] < t)left = mid+1;
		else if(S[mid]>t)right = mid;
	}
	return 0;
}


int main() {
	int  q,key;
	int cont = 0;
	
	scanf("%d", &n);
	for (int t = 0; t < n; t++) {
		scanf("%d", &S[t]);
	}
	
	scanf("%d", &q);
	for (int t = 0; t < q; t++) {
		scanf("%d", &key);
		if (search(key, S, n))cont++;
	}

	cout << cont << "\n";

	return 0;
}


Measured memory_bytes: 3500
import sys
N,K = map(int, input().split())
lis = [int(i) for i in input().split()]
if N == 1:
  print(0)
  sys.exit()
if N<=K:
  print(1)
  sys.exit()
ind = lis.index(1)+1
if (N-1)%(K-1)==0:
  print(int((N-1)/(K-1)))
else:
  print(int((N-1)//(K-1))+1)

Measured memory_bytes: 13880
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
//

     signed main(){
       string s;
       cin>>s;
       if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
       else cout<<"No";
   }
         


        


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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

int calc_gcd(int a, int b) {
    if (b > a) swap(a, b);
    if (a % b == 0) {
        return b;
    } else {
        return calc_gcd(b, a % b);
    }
}

void solve() {
    int N, X;
    cin >> N >> X;
    vector<int> y(N);
    REP(i, N) cin >> y[i];
    y.push_back(X);
    sort(y.begin(), y.end());
   
    vector<int> d;
    REP(i, y.size()-1) {
        d.push_back(y[i+1] - y[i]);
    }

    int gcd = d[0];
    for (int i=1; i<d.size(); ++i) {
        gcd = calc_gcd(d[i], gcd);
    }
    print(gcd);
}

signed main() {
    solve();
}


Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
int main(){
  double W,H,x,y;
  cin>>W>>H>>x>>y;
  double S;
  S=W*H/2;
  if(x==W/2&&y==H/2){
    cout <<S<<endl;
    cout <<1<<endl;
  }
  else{
    cout <<S<<endl;
    cout <<0<<endl;
  }
}


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

typedef long long LL;
typedef unsigned long long ULL;

const int PI = 3.141592653589793;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 200007;

int main(){

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

        int a, b, c, k;
        cin >> a >> b >> c >> k;
        int ans = a;
        if (k < a) {
                cout << k << endl;
        }
        else if (k <= a + b) {
                cout << ans << endl;
        }
        else {
                cout << ans - (k - a - b) << endl;
        }
        return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
using namespace std;
signed main() {
    int n;
    cin >> n;
    map<string, int> m;
    string s[n];
    char e;
    int flag = 1;
    cin >> s[0];
    e = s[0][(int)s[0].size() - 1];
    m[s[0]]++;
    for(int i = 1; i < n; i++) {
        cin >> s[i];
        if(s[i][0] != e) {
            flag = 0;
            break;
        }
        e=s[i][(int)s[i].size()-1];
        m[s[i]]++;
    }
    for(auto i:m){
        if(i.second>1) flag=0;
    }
    if(flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations
def run():
    N = int(input())
    A = [0] + list(map(int, sysread().split()))
    to = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u,v = map(int, sysread().split())
        to[u].append(v)
        to[v].append(u)
    seen = [False] * (N+1)
    dp = [float('inf')] * (N+2)
    dp[0] = -float('inf')
    ddp2 = [0]
    paths = []
    actions = []# (idx, pre, pro)
    ans = [0] * (N+1)
    def dfs(node, parent=None):

        a = A[node]
        seen[node] = True
        if parent == None:
            actions.append((1, dp[1], a, 1))
            dp[1] = a
            ddp2[0] += 1
        else:
            idx = bin_search(dp, a)
            if dp[idx] == float('inf'):
                actions.append((idx, dp[idx], a, 1))
                ddp2[0] += 1
            else:
                actions.append((idx, dp[idx], a, 0))
            dp[idx] = a
        ans[node] = ddp2[0]
        for next in to[node]:
            if not seen[next]:
                dfs(next, node)

        idx, pre, pro, change = actions.pop()
        dp[idx] = pre
        ddp2[0] -= change

    dfs(1)
    for s in ans[1:]:
        print(s)
    return None

def bin_search(A, x):
    '''
    return index which is lowest in values more than or equal to x
    '''
    low = 0
    high = len(A) - 1
    c = (low + high) // 2
    if A[-1] < x: return float('inf')
    while high - low > 1:
        if A[c] < x:
            low = c
            c = (low + high) // 2

        elif A[c] > x:
            high = c
            c = (high + low) // 2
        else:
            return c
    return high

if __name__ == "__main__":
    run()

Measured memory_bytes: 294208
#include<bits/stdc++.h>
using namespace std;
#define MAXN 3000

int N;
double dp[MAXN + 3][MAXN + 3], p[MAXN + 3], answer;

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++)
        cin >> p[i];

    dp[0][0] = 1;
    for (int head = 1; head <= N; head++)
        dp[0][head] = 0;

    for (int i = 1; i <= N; i++)
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);

    for (int i = 1; i <= N; i++) {
        for (int head = 1; head <= i; head++) {
            dp[i][head] = dp[i - 1][head] * (1 - p[i]) + dp[i - 1][head - 1] * p[i];
        }
    }

    answer = 0;
    for (int head = 0; head <= N; head++) {
        if (head > N - head)
            answer += dp[N][head];
    }

    printf("%.10f\n", answer);
}


Measured memory_bytes: 68992
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
string S;
int A,B;
int main() {
	cin>>A>>B;
	cin>>S;

	int R=0;
    for(int i=0;i<A+B+1;i++){
    	if(i==A){
    		if(S[i]=='-')R++;
    	}else{
    		if(S[i]!='-')R++;
    	}
    }
    if(R==(A+B+1)){
    	cout<<"Yes"<<endl;
    }else{
    	cout<<"No"<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    {
       int n;
       cin>>n;
       int c=0;
       for(int i=1;i<=n;i++)
       {
           for(int j=1;j<=n;j++)
           {
               if(i*j<n)
               c++;
               else
               break;
           }
       }
       cout<<c;
}
}
// 🍪 🍪 🍪


Measured memory_bytes: 3648
import numpy as np
N, A, B = map(int,input().split())
N,A,B=int(N),int(A),int(B)
AB=A+B
x=int(N/AB)
y=int(N%AB)
if y>=A:
    print(A*x+A)
else:
    print(A*x+y)

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for(int i=0; i<N; i++) cin >> a[i];
    for(int i=0; i<N; i++) cin >> b[i];

    vector<int> c[29];
    for(int i=0; i<29; i++){
        c[i].resize(N);
        for(int j=0; j<N; j++) c[i][j] = b[j] % (1<<(i+1));
        sort(c[i].begin(), c[i].end());
    }

    vector<int> cnt(29, 0);
    for(int i=0; i<29; i++){
        for(int j=0; j<N; j++){
            int d = a[j] % (1<<(i+1));
            cnt[i] += lower_bound(c[i].begin(), c[i].end(), (1<<(i+1))-d)
                    - lower_bound(c[i].begin(), c[i].end(), (1<<i)-d);
            cnt[i] += lower_bound(c[i].begin(), c[i].end(), (1<<(i+2))-d)
                    - lower_bound(c[i].begin(), c[i].end(), (1<<i) + (1<<(i+1)) - d);
            //if( !(d & (1<<i)) )
            //    cnt[i] += c[i].end()
            //            - lower_bound(c[i].begin(), c[i].end(), (1<<i) - d);
            //else
            //    cnt[i] += upper_bound(c[i].begin(), c[i].end(), (1<<i) - d) - c[i].begin();
        }
        //cerr << cnt[i] << " ";
    }
    //cerr << endl;

    int ans = 0;
    for(int i=0; i<29; i++)
        if(cnt[i] % 2)
            ans |= 1<<i;
    cout << ans << endl;

    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	unordered_map<int,int>cnt;
	char c;
	for(int i=0;i<n;++i){
		cin>>c;
		++cnt[c-'a'];
	}
	int64_t ans=1,mod=1e9+7;
	for(auto&i:cnt){
		ans*=(i.second+1);
		ans%=mod;
	}
	cout<<ans-1<<"\n"s;
}

Measured memory_bytes: 256