akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	int d, n;//??\??°??????????¨????
	cin >> d >> n;
	vector<int> t(d);
	rep(i, d) cin >> t[i];
	vector<int> a(n), b(n), c(n);//??????????????§????´???????
	rep(i, n) cin >> a[i] >> b[i] >> c[i];

	int dp[201][201];//dp[i][j] i(0~d-1)??\??????j(0~n-1)????????????????????????????????§???
	rep(i, 201)rep(j, 201) dp[i][j] = -1;//?????????
	//0??\?????????????????????dp???0?????\??????
	rep(j, d){
		if(a[j] <= t[0] && t[0] <= b[j]){
			dp[0][j] = 0;
		}
	}
	reps(i, 1, d){//??\
		rep(j, n){//????????????
			rep(k, n){//?????????????????¨??¢?´¢??§??¢????????????
				if(a[k] <= t[i] && t[i] <= b[k] && dp[i - 1][j] != -1){
					dp[i][k] = max(dp[i][k], dp[i - 1][j] + abs(c[k] - c[j]));
				} 
			}
		}
	}


	int ans = 0;
	rep(i, n){
		ans = max(ans, dp[d - 1][i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <cstdlib>

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

using namespace std;

vector<string> split(string &str,char delim)
{
	vector<string> res;
	size_t current = 0,found;
	while((found = str.find_first_of(delim,current)) != string::npos)
	{
		res.push_back(string(str,current,found  - current));
		current = found + 1;
	}
	res.push_back(string(str,current,str.size() - current));
	return res;
}

int main()
{
	string s;
	while(getline(cin,s))
	{
		double ans;
		stack<double> res;
		vector<string> _s = split(s,' ');
		rep(i,_s.size())
		{
			if(_s[i] == "+")
			{
				double temp = res.top();
				res.pop();
				double temp2 = res.top();
				res.pop();
				res.push(temp2 + temp);
			}
			else if(_s[i] == "-")
			{
				double temp = res.top();
				res.pop();
				double temp2 = res.top();
				res.pop();
				res.push(temp2 - temp);
			}
			else if(_s[i] == "*")
			{
				double temp = res.top();
				res.pop();
				double temp2 = res.top();
				res.pop();
				res.push(temp2 * temp);
			}
			else if(_s[i] == "/")
			{
				double temp = res.top();
				res.pop();
				double temp2 = res.top();
				res.pop();
				res.push(temp2 / temp);
			}
			else
			{
				res.push(atof(_s[i].c_str()));
			}
		}

		cout << fixed;
		cout.precision(6);
		cout << res.top() << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll D, G;
vector<pair<ll, ll>> a;
ll memo[10][1010];
ll solve(ll i, ll k) {
    if (k == 0) return 0;
    if (i == D) return 0;
    if (memo[i][k] != -1) return memo[i][k];
    ll p = a[i].first, c = a[i].second;
    ll res = 0;
    for (int j = 0; j <= p && j <= k; j++) {
        ll e = (i+1)*100*j;
        if (j == p) e += c;
        res = max(res, e+solve(i+1, k-j));
    }
    return memo[i][k] = res;
}
int main () {
    for (int i = 0; i < 10; i++)
        for (int j = 0; j <= 1000; j++)
            memo[i][j] = -1;
    cin >> D >> G;
    for (int i = 0; i < D; i++) {
        a.push_back(make_pair(0, 0));
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 0;; i++) {
        if (solve(0, i) >= G) {
            cout << i << endl;
            return 0;
        }
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n; string s;
  	cin >> n >> s;
  	
  	vi cnt(n+1);
  	cnt[0] = 0;
  	int mn = 0;
  	rep(i,n) {
    	if(s[i] == '(') cnt[i+1] = cnt[i]+1;
        else if(s[i] == ')') cnt[i+1] = cnt[i]-1;
      	mn = min(mn, cnt[i+1]);
    }
  
  	/*
  	cout << mn << endl;
  	rep(i,n+1) cout << cnt[i] << " ";
    cout << endl;
  	//*/
  
  	if(mn < 0) rep(i,-mn) cout << '(';
	cout << s;
  	if(cnt[n]-mn>0) rep(i, cnt[n]-mn) cout << ')';
  	cout << endl;

  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def main():
    na = list(map(int, input().split()))
    N, X = na[0], na[1]
    m = []
    for i in range(N):
        m.append(int(input()))

    r = N + int((X - sum(m)) / min(m))

    print(r)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



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

    int _;
    cin >> _;
    string s;
    cin >> s;
    int n = s.length();
    vector<vector<int>> cnts(n + 1, vector<int>(26, 0));

    for (int i = 0; i < n; ++i) {
        cnts[i + 1] = cnts[i];
        cnts[i + 1][s[i] - 'a'] += 1;
    }

    int res = 0;
    for (int i = 1; i < n; ++i) {
        int cnt = 0;
        for (int j = 0; j < 26; ++j) {
            if (cnts[i][j] > 0 && cnts[n][j] > cnts[i][j]) {
                ++cnt;
            }
        }
        res = max(res, cnt);
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    agc028a()
}

fun agc028a() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!
    val t = readLine()!!

    val gcd = gcd(n.toLong(), m.toLong())
    val lcm = n / gcd * m

    val all = (0 until gcd).all { s[(it * n / gcd).toInt()] == t[(it * m / gcd).toInt()] }
    val answer = if (all) lcm else -1

    println(answer)
}

private tailrec fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}


Measured memory_bytes: 41200
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll n , m ; cin >> n >> m;
    vector<ll> h(n);
    rep(i,n) cin >> h.at(i);
    vector<vector<ll>> hen(n,vector<ll>(0));
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--; b--;
        hen.at(a).push_back(b);
        hen.at(b).push_back(a);
    }
    ll ans = 0;
    rep(i,n){
        //h.at(i)が高さ
        bool chk = true;
        for(auto a:hen.at(i)){
            if(h.at(i) <= h.at(a)) chk = false;
        }
        if(chk){
            ans++;
            //cout << i << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9808
#include<bits/stdc++.h>
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; }

int main(){
  int N,L;
  cin >> N >> L;
  int aji = 0;
  int lost = 1000;
  for(int i=0;i<N;++i){
    aji += L + i;
    lost = min(lost,abs(L+i));
  }
  if(N+L>0)cout << aji-lost<<endl;
  else cout << aji+lost<<endl;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		scan.nextLine();
		String s= scan.nextLine();
		String t="";
		for(int i=0;i<n;i++) {
			if(i==k-1) {
			t+=s.toLowerCase().charAt(i);
			}
			else {
				t+=s.charAt(i);
			}
		}
		System.out.println(t);
	

}
}

Measured memory_bytes: 39360
A = input()
n = len(A)
S = []
R = [A[n-1]]
for i in range(n):
    S.append(A[i])
    R.append(A[i])
K = int(input())
s = 0
p = S[0]
q = S[n-1]
for i in range(n-1):
    x = S[i]
    y = S[i+1]
    if x == y:
        S[i+1] = 1
        s += 1
t = 0
for j in range(n):
    x = R[j]
    y = R[j+1]
    if x == y:
        R[j+1] = 1
        t += 1
if p != q:
    ans = s*K
else:
    if S[n-1] == 1:
        ans = s*K
    else:
        if R[n] == 1:
            k = K//2
            ans = (K-k)*s + k*t
        else:
            ans = s + (K-1)*t
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll sum = (n / 500) * 1000;
    n = n % 500;
    sum += (n / 5) * 5;
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 256
def main():
    from builtins import int, map, list, print, min
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    A = input_number_list()
    B = input_number_list()
    ans = 0
    for i in range(N):
        hp = B[i]
        if A[i] > 0:
            hp = B[i] - A[i]
            ans += B[i] if A[i] > B[i] else A[i]
        if hp > 0:
            ans += hp if A[i+1] > hp else A[i+1]
            A[i + 1] -= hp

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl dp(45,0);
    dp[0]=1;
    dp[1]=1;
    rep(i,43){
        dp[i+2]=dp[i+1]+dp[i];
    }
    cout << dp[n] <<endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

ll mod = 1e9 + 7;

// O(log n)
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    
    sort(ALL(A));
    ll ans = 0;
    reps(k, 1, N + 1){
        ll tmp = mod_pow(2, 2 * N - k, mod);
        ll tmp2 = 1;
        if (k == 1){
            tmp2 = 1;
        } else {
            tmp2 = mod_pow(2, k - 2, mod) * (k + 1) % mod;
        }
        //cout << k << " " << tmp << " x " << tmp2 << endl;
        (tmp *= tmp2) %= mod;
        (tmp *= A[N - k]) %= mod;
        (ans += tmp) %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	int n,ans = -1;
	bool flag = true;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n;i++) {
		cin >> a[i];
	}
	while (flag) {
		ans++;
		for (int i = 0; i < n;i++) {
			if (a[i]%2 == 0) {
				a[i] /= 2;
			}
			else {
				flag = false;
				break;
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(int argc,char **argv)
{
    int x,a,b;
    scanf("%d%d%d",&x,&a,&b);
    if((1>a||a>1000)||(1>b||b>1000)||((a+b)>x)||(x>10000))
    {
        scanf("%d%d%d",&x,&a,&b);
    }
    printf("%d\n",(x-a)%b);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

const double EPS=1e-8;
const double INF=1e9;

typedef complex<double>Point;

#define EQ(a,b) (fabs((a)-(b))<EPS)
#define EQV(a,b) (abs((a)-(b))<EPS)
struct Segment{
    Point p1,p2;
    Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};

typedef Segment Line;

struct Circle{
    Point c;
    double r;
    Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

typedef vector<Point>Polygon;

double dot(Point a,Point b){
    return real(a)*real(b)+imag(a)*imag(b);
}

double cross(Point a,Point b){
    return real(a)*imag(b)-imag(a)*real(b);
}

bool isOrthogonal(Point a,Point b){
    return EQ(dot(a,b),0.0);
}

bool isOrthogonal(Point a1,Point a2,Point b1,Point b2){
    return isOrthogonal(a1-a2,b1-b2);
}

bool isOrthogonal(Line s1,Line s2){
    return isOrthogonal(s1.p2-s1.p1,s2.p2-s2.p1);
}

bool isParallel(Point a,Point b){
    return EQ(cross(a,b),0.0);
}

bool isParallel(Point a1,Point a2,Point b1,Point b2){
    return isParallel(a1-a2,b1-b2);
}

bool isParallel(Line s1,Line s2){
    return isParallel(s1.p2-s1.p1,s2.p2-s2.p1);
}


int main(){
    int N;
    scanf("%d",&N);
    while(N--){
        Point a,b,c,d;
        scanf("%lf%lf",&a.real(),&a.imag());
        scanf("%lf%lf",&b.real(),&b.imag());
        scanf("%lf%lf",&c.real(),&c.imag());
        scanf("%lf%lf",&d.real(),&d.imag());
        if(isParallel(Segment(a,b),Segment(c,d)))puts("2");
        else if(isOrthogonal(Segment(a,b),Segment(c,d)))puts("1");
        else puts("0");
    }

    return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<int> e(1e5 + 1, 0), o(1e5 + 1, 0);
	REP(i, n) {
		int v; cin >> v;
		if (i % 2) o[v]++;
		else e[v]++;
	}

	int maxE = max_element(e.begin(), e.end()) - e.begin();
	int maxO = max_element(o.begin(), o.end()) - o.begin();
	int res = 0;
	if (maxE != maxO) res = n - e[maxE] - o[maxO];
	else {
		sort(e.rbegin(), e.rend());
		sort(o.rbegin(), o.rend());
		res = min(n - e[0] - o[1], n - e[1] - o[0]);
	}

	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef pair<int ,int> P;
int inf = 100000000;

int main(){
    string s;
    cin >> s;
    pair<char,int> a ,b ,c;
    a.first = s[0]; a.second = 1;
    b.first = s[1]; b.second = 2;
    if(a.first == b.first){
        cout << 1 << " " << 2 <<endl;
        return 0;
    }
    for(int i=2;i<s.size();i++){
        c.first = s[i];
        c.second = i+1;
        if(b.first == c.first){
            cout << b.second << " " << c.second <<endl;
            return 0;
        }
        if(a.first == c.first){
            cout << a.second << " " << c.second <<endl;
            return 0;
        }
        a = b;
        b = c;
    }
    cout << -1 << " " << -1 <<endl;
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c, x int
		count      int
	)

	fmt.Scan(&a, &b, &c, &x)

	for i := a; i >= 0; i-- {
		for j := b; j >= 0; j-- {
			for k := c; k >= 0; k-- {
				if (x - 500*i - 100*j - 50*k) == 0 {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
N = int(input())

def judge(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n%i == 0:
      divisors.append(i)
      if i != n//i:
        divisors.append(n//i)
  return divisors

divisors = judge(N)
divisors.sort()
if len(divisors) % 2 == 0:
  while len(divisors) >= 3:
    divisors.pop(0)
    divisors.pop(-1)
  print(max(1, sum(divisors)-2))
else:
  while len(divisors) >= 2:
    divisors.pop(0)
    divisors.pop(-1)
  print(max(1, sum(divisors)*2-2))

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s1,s2;
    cin>>s1;
    s2=s1;
    reverse(s1.begin(),s1.end());
    for(int i=0;i<s1.size();++i){
        if(s1[i]=='b') s1[i]='d';
        else if(s1[i]=='d') s1[i]='b';
        else if(s1[i]=='p') s1[i]='q';
        else if(s1[i]=='q') s1[i]='p';
    }
    if(s1 == s2) cout<<"Yes";
    else cout<<"No";
    return 0;
}///

Measured memory_bytes: 512
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <functional>
#include <queue>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10,18);
const int MOD = pow(10,9) + 7;
/* contest template */
int N;
string s;

int main()
{
    cin >> N;
    N=N / 3;

    cout << N << endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>//next_permutation
using namespace std;


bool is_prime(int x){
    if(x<=1) return 0 ;

      for(int i=2;i*i<=x;i++){
          if(x%i==0){
              return 0 ;
          }
      }
    return 1;
}

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

    int p = x ;
    while(!is_prime(p)) p++ ;

    cout  << p << endl;
  return 0;
}

Measured memory_bytes: 256
# V: 鬼の移動速度
# W: 逃げの移動速度
# T秒後までに鬼がつかまえることができるか
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

D = abs(B-A)
v_r = V - W

if v_r * T < D:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 9168
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<queue>
#include<iostream>
using namespace std;
long long int gcd(long long int u, long long int v) {
	long long int r;
	while (0 != v) {
		r = u % v; u = v; v = r; /* swap */
	}
	return u;
}
int main()
{
	int i, j, l, n, p, q,N,T;
	long long int sum, flag,cc,cnt,key,k,m;
	sum = 0;
	flag = 0;
	cc = 0;
	cnt = 1;
	cin >> T;
	vector<long long int>A(T);
	vector<long long int>B(T);
	vector<long long int>C(T);
	vector<long long int>D(T);
	for (i = 0; i < T; i++) {
		cin >> A[i] >> B[i] >> C[i] >> D[i];
	}
	
	for (i = 0; i < T; i++) {
		key = gcd(B[i], D[i]);
		if (A[i] < C[i]) {
			m = A[i];
		}
		else if ((A[i] - C[i]) % B[i] == 0) {
			m = C[i] + B[i];
		}
		else {
			m = A[i] - ((A[i] - C[i]) / B[i])*B[i];
		}
		if (B[i] > D[i]) {
			cout << "No" << endl;
		}
		else if (B[i] == D[i]) {
			if (m < B[i]) {
				cout << "No" << endl;
			}
			else
				cout << "Yes" << endl;
		}
		else {
			if (m < B[i]) {
				cout << "No" << endl;
			}
			else {
				k = (A[i] - B[i]) / key;
				if (C[i] <= A[i] - (k + 1)*key - 1) {
					cout << "No" << endl;
				}
				else
					cout << "Yes" << endl;
			}
			
		}
	}

    return 0;
}



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

ll a[100010],b[100010];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    for(int i=0;i<N;++i) cin >> a[i] >> b[i];
    ll ans = 0;
    for(int i=N-1;i>=0;--i){
        a[i] += ans;
        if(a[i]==0) continue;
        ans += b[i]*((a[i]+b[i]-1)/b[i]) - a[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N, X, T;
    cin >> N >> X >> T;
    if (N % X == 0)
    {
        cout << N / X * T << endl;
    }
    else
    {
        cout << N / X * T + T << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
X = int(input())

def sieve(n):
    prime = []

    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    
    for i in range(2, n + 1):
        if is_prime[i]:
            prime.append(i)
            
            for j in range(2 * i, n + 1, i):
                is_prime[j] = False
                
    return prime

for v in sieve(100007):
    if v >= X:
        print(v)
        break


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

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

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))

constexpr ll MOD = 1e9+7;
// constexpr int INF = 1<<25;
// constexpr ll  INF = 1LL<<50;

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T checkmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T checkmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

// Forward declaration
template <typename T>
void dumpContents(const T& v, const string& msg="");

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  vi M(5);
  for (int i=0; i<5; i++) {
    cin >> M[i];
  }

  sort(begin(M), end(M), [](const int lhs, const int rhs) {
                    if (lhs%10==0) {
		      return true;
		    }
                    if (rhs%10==0) {
		      return false;
		    }
                    return lhs%10 > rhs%10;
		  });

  int ret = M[4];
  for (int i=0; i<4; i++) {
    if (M[i]%10 > 0) {
      ret += (M[i]/10+1)*10;
    } else {
      ret += M[i];
    }
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9


int main()
{
    int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}

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

int main(int argc, char const *argv[]) {
	// ios::sync_with_stdio(false);
	// cin.tie(NULL);
	int n,k;
	double sum = 0;
	double maxSum = 0;;
	cin>>n>>k;
	vector<double> nums(n);
	for (int i = 0; i < n; i++) {
		cin>>nums[i];
		nums[i] = (nums[i]+1)/2;
		if (i>=k) {
			sum -= nums[i-k];
		}
		sum+=nums[i];
		maxSum = max(maxSum, sum);
	}
	printf("%.8f\n", maxSum);
	// cout<<maxSum<<'\n';
	return 0;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int X = sc.nextInt();
        ans += X/500 * 1000;
        X %= 500;
        ans += X/5 * 5;
        X%=5;
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 23252
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.buffer.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7


n, m = map(int, input().split())
data = [list(map(int, input().split())) for i in range(m)]





l, r = 0, 10**6
for i, j in data:
	l = max(l, i)
	r = min(r, j)
print(max(0, r-l+1))


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D){
    cout << "Left" << endl;
  } else if(A + B < C + D){
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	string out = "APPROVED";
    int count;
    cin >> count;
  	for (int i=0; i<count; i++) {
      int tmp;
      cin >> tmp;
      
      if (tmp%2!=0) {
        continue;
      }
      
      if (tmp%3!=0 && tmp%5!=0) {
        out = "DENIED";
        break;
      }
    }
  
    cout << out << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}

ll solve(const vector<bitset<23>> &sch, vector<ll> &cost, int n, int k, bitset<23> now, ll c) {
  if(n == k) {
    return c;
  } else {
    if((sch[k] & now).any()) {
      return solve(sch, cost, n, k+1, now, c);
    } else {
      return max(solve(sch, cost, n, k+1, now, c), solve(sch, cost, n, k+1, now | sch[k], c + cost[k]));
    }
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    vector<bitset<23>> sch(n);
    vector<ll> cost(n);
    for(int i=0;i<n;++i) {
      int m; cin >> m >> cost[i];
      auto bs = bitset<23>();
      for(int j=0;j<m;++j) {
        int l, r; cin >> l >> r;
        bs |= bitset<23>(((1ll<<r)-1) - ((1ll<<l)-1));
      }
      sch[i] = bs;
    }

    auto now = bitset<23>();
    cout << solve(sch, cost, n, 0, now, 0) << endl;
  }
}



Measured memory_bytes: 3060
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
k = inp()
x = inpl()
res = 0
for i in x:
    res += min(i,abs(i-k))*2
print(res)

Measured memory_bytes: 38544
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = int(input())
    aa = LI()
    c4 = c2 = 0
    for a in aa:
        if a % 4 == 0:
            c4 += 1
        elif a % 2 == 0:
            c2 += 1
    max_len = 0
    if c4 > 0 and c2 > 1:
        max_len = c4 * 2 + c2
    elif c4 > 0:
        max_len = c4 * 2 + 1
    elif c2 > 1:
        max_len = c2
    if n <= max_len:
        print("Yes")
    else:
        print("No")

main()


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

int main()
{
	int n;
	cin >> n;
	int score_taro = 0;
	int score_hanako = 0;
	for (int i = 0; i < n; i++) {
		string animal_taro, animal_hanako;
		cin >> animal_taro >> animal_hanako;
		if (animal_taro < animal_hanako) score_hanako += 3;
		else if (animal_taro == animal_hanako == 1) score_taro += 1, score_hanako += 1;
		else score_taro += 3;
	}
	cout << score_taro << " " << score_hanako << endl;
}


Measured memory_bytes: 3220
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		sc.nextLine();
		String s = sc.nextLine();
		if(a < 3200)
		{
			System.out.print("red");
		}
		else if(a >= 3200)
			System.out.print(s);
	}
}

Measured memory_bytes: 22868
n, m = map(int, input().split())
c = [0 for _ in range(n+1)]
for _ in range(m):
    l, r = map(int, input().split())
    c[l-1] += 1
    c[r] -= 1
cur = ans = 0
for i in range(n):
    cur += c[i]
    c[i] = cur
    if c[i] == m:
        ans += 1
print(ans)

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

int main() {
  string s;
  long ans = 0;

  cin >> s;

  string kari = "0";
  for (int i = 0; i < (int)s.size(); i++) {
    string substr = s.substr(i, 1);
    if (kari == substr && i != (int)s.size() - 1) {
      substr = s.substr(i, 2);
      i++;
      ans++;
    } else if (kari != substr) {
      ans++;
    }
    kari = substr;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 644
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from itertools import product
    n=int(input())
    A=[list(map(int,list(input()))) for _ in range(n)]
    for i,j in product(range(n),repeat=2):
        if(i==j): continue
        if(A[i][j]==0): A[i][j]=INF
    B=[a[:] for a in A] # deep copy
    E=[[] for _ in range(n)]
    for i,j in product(range(n),repeat=2):
        if(i==j): continue
        if(A[i][j]==1): E[i].append(j)

    # bipartile check
    d=[-1]*n # -1: unvisited
    def dfs(v,p=-1)->bool:
        # initialize
        if(p==-1):
            if(d[v]!=-1): return True
            else: d[v]=0
        # iterate
        res=True
        for nv in E[v]:
            if(nv==p): continue
            if(d[nv]==-1):
                d[nv]=d[v]^1
                res=min(res,dfs(nv,v))
            else:
                res=min(res,d[nv]^d[v])
        return res

    for v in range(n):
        if(not dfs(v)):
            print(-1)
            return

    # Warshall-Floyd
    for k,i,j in product(range(n),repeat=3):
        B[i][j]=min(B[i][j],B[i][k]+B[k][j])

    # output
    diam=0
    for i,j in product(range(n),repeat=2):
        if(B[i][j]==INF): continue # connectedなので必要ない
        diam=max(diam,B[i][j])
    print(diam+1)
resolve()

Measured memory_bytes: 58332
from itertools import accumulate

N = int(input())
W = [int(x) for x in input().split()]

A = [x for x in accumulate(W)]
B = [x for x in accumulate(W[::-1])]

ans = float('inf')
for i in range(N - 1):
    d = abs(A[i] - B[N - i - 2])
    ans = min(ans, d)
print(ans)


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

int main() {
  string S;
  int Q;
  cin >> S >> Q;

  list<char> ls;
  rep(i, S.length()) ls.push_back(S[i]);

  bool isRev = false;
  rep(i, Q) {
    int a;
    cin >> a;

    if (a == 1) {
      isRev = (isRev) ? false : true;
    }
    else {
      int f;
      char c;
      cin >> f >> c;

      if (isRev) {
        if (f==1) ls.push_back(c);
        else ls.push_front(c);
      }
      else {
        if (f==2) ls.push_back(c);
        else ls.push_front(c);
      }
    }
  }

  if (isRev) {
    for (auto it = ls.end(); it != ls.begin(); it--) {
      if (it == ls.end()) continue;
      cout << *it;
    }
    cout << ls.front();
  }
  else {
    for (auto it = ls.begin(); it != ls.end(); it++) {
      cout << *it;
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
int a[maxn], b[maxn];
int f[maxn][maxn], n;
bool path(int a, int b, long long msk){
	if(a < b) return false;
	if(a == b) return true;
	if(f[a][b] != -1) return f[a][b];
	for(int i = 50; i >= 1; i--){
		if((msk>>i)&1){
			int na = a % i;
			if(na != a){
				if(path(na, b, msk)) return f[a][b] = 1;
			}
		}
	}
	return f[a][b] = 0;
}
bool can(long long msk){
	memset(f, -1, sizeof(f));
	for(int i = 0; i < n; i++){
		if(!path(a[i], b[i], msk)){
			return false;
		}
	}
	return true;
}
int main(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	long long msk = 0;
	for(int i = 0; i <= 50; i++) msk ^= 1ll<<i;
	if(!can(msk)){
		cout << -1 << endl;
		return 0;
	}
	for(int i = 50; i >= 0; i--){
		msk ^= 1ll<<i;
		if(!can(msk)){
			msk ^= 1ll<<i;
		}
	}
	cout << msk << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
m = map(int,read().split())
AB = list(zip(m,m))
#print(N,m,AB)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    #print(a,b)
#print(graph)
root = 1
parent = [0] * (N+1)
order = []
stack = [root]
#print(stack)
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)
#print(order,parent) 
color = [-1] * (N+1)
for x in order:
    ng = color[x]
    c = 1
    for y in graph[x]:
        if y == parent[x]:
            continue
        if c == ng:
            c += 1
        color[y] = c
        c += 1
#print(color)
answer = []
append = answer.append
for a,b in AB:
    if parent[a] == b:
        append(color[a])
    else:
        append(color[b])
 
K = max(answer)
print(K)
print('\n'.join(map(str,answer)))

Measured memory_bytes: 38292
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CSwaps {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<int> A(N), B(N);
	    REP(i,0,N) in >> A[i];
	    REP(i,0,N) in >> B[i];

	    vector<int> index(N);
	    REP(i,0,N) {
	        index[i] = i;
	    }
	    sort(all(index), [&](int a, int b) -> bool {
	        return B[a] < B[b] || B[a] == B[b] && A[a] <= A[b];
	    });
	    set<pair<int, int>> aIndex; // A[i], i
	    REP(i,0,N) {
	        aIndex.insert({-A[i], i});
	    }
	    int cnt = 0;
	    REP(k,0,N) {
	        const int i = index[k];
            aIndex.erase({-A[i], i});
	        if (A[i] <= B[i]) continue;
	        auto itr = aIndex.lower_bound({-B[i], 0});
	        if (itr == aIndex.end()) {
	            out << "No" << "\n";
	            return;
	        }
	        const int j = itr->second;
            aIndex.erase(itr);
            swap(A[i], A[j]);
            aIndex.insert({-A[j], j});
            cnt++;
	    }
	    if (cnt > N - 2) {
            out << "No" << "\n";
            return;
	    } else {
            out << "Yes" << "\n";
            return;
	    }
	}
};


signed main() {
	CSwaps solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int i;
    cin >> n;
    string a[n];
    int cnt_a=0, cnt_w=0, cnt_t=0, cnt_r=0;
    for (i=0; i<n ;i++){
        cin >> a[i];
        if (a[i] == "AC"){cnt_a++;}
        else if (a[i] == "WA"){cnt_w++;}
        else if (a[i] == "TLE"){cnt_t++;}
        else if (a[i] == "RE"){cnt_r++;}
    }
    cout << "AC" << " x " << cnt_a << endl;
    cout << "WA" << " x " << cnt_w << endl;
    cout << "TLE" << " x " << cnt_t << endl;
    cout << "RE" << " x " << cnt_r << endl;
    
    return 0;
}

Measured memory_bytes: 6680
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
N, M = map(int, input().split())

X = [[] for i in range(N*3)]
for i in range(M):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

Q = deque([0])
ANS = [-1] * N
ANS[0] = -2
while Q:
    x = Q.popleft()
    for c in X[x]:
        if ANS[c] == -1:
            ANS[c] = x
            Q.append(c)
print("Yes")
print("\n".join(map(str, [a + 1 for a in ANS[1:]])))

Measured memory_bytes: 110888
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = (int) 1e5;
ll N, x;
ll a[MAX_N];

void solve() {
    ll ans = 0;
    if (a[0] > x) {
        ans += (a[0] - x);
        a[0] = x;
    }
    REP(i, N - 1) {
        if (a[i] + a[i + 1] > x) {
            ll temp = min(a[i + 1], a[i] + a[i + 1] - x);
            a[i + 1] -= temp;
            ans += temp;
        }
    }
    cout << ans << endl;
}

int main() {
    cin >> N >> x;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		new Main().solveA();
		//		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String topping = "";

		try {
			scanner = new Scanner(System.in);
			topping = scanner.next();

			int res = 700;

			for (int i = 0; i < topping.length(); i++) {
				switch (topping.charAt(i)) {
				case 'o':
					res += 100;
					break;
				case 'x':
					break;

				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;
		int numX = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numX = scanner.nextInt();

			int[] wk = new int[numN];

			int res = 0;
			for (int i = 0; i < numN; i++) {
				wk[i] = scanner.nextInt();
				res++;
				numX -= wk[i];
			}

			Arrays.sort(wk);

			boolean isExit = false;
			while (!isExit) {
				if (numX >= wk[0]) {
					numX -= wk[0];
					res++;
				} else {
					isExit = true;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N ;
  vector<pair<int, int>> A(N);
  for (int i = 1; i <= N; i++){
    int a;
    cin >> a;
    A.at(i-1) = make_pair(a, i);
  }
  sort(A.begin(), A.end());
  cout << A.at(0).second;
  for (int i = 1; i < N; i++){
    cout << " " << A.at(i).second;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1664
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
const int maxn=2e5+5;
int n,nxt[maxn][26],f[maxn];
string s;
int main(){
	cin>>s;s=' '+s;n=s.size()-1;
	memset(nxt,-1,sizeof(nxt));
	for(int i=n;i>0;i--)
		for(int j=0;j<26;j++)
			nxt[i][j]=(s[i]==j+'a'?i:nxt[i+1][j]);
	memset(f,0x3f,sizeof(f));
	for(int i=n;i>0;i--){
		for(int j=0;j<26;j++){
			if(nxt[i][j]==-1){f[i]=1;break;}
			f[i]=min(f[i],f[nxt[i][j]+1]+1);
		}
	}
	int len=f[1],pos=1;
	while(len--){
		if(!len)for(int i=0;i<26;i++)
				if(nxt[pos][i]==-1)return 0*putchar(i+'a');
		for(int i=0;i<26;i++)
			if(f[pos]==f[nxt[pos][i]+1]+1){
				pos=nxt[pos][i]+1;
				putchar(i+'a');break;
			}
	}
	return 0;
}

Measured memory_bytes: 21824
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
const double PI = acos(-1);
int n;
ll d;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> d;
  d = d*d;
  int ans = 0;
  FOR(_, 0, n){
    ll x, y;
    cin >> x >> y;
    ans += x*x+y*y<=d;
  }
  cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    int x[n], y[n], a[n];
    rep(i, n) cin >> x[i] >> y[i];
    rep(i, n) a[i] = i;

    double ans = 0;
    int cnt = 0;
    do {
        rep(i, n - 1) {
            double dx = pow(x[a[i]] - x[a[i + 1]], 2);
            double dy = pow(y[a[i]] - y[a[i + 1]], 2);
            ans += sqrt(dx + dy);
        }
        cnt++;
    } while (next_permutation(a, a + n));

    printf("%.10f\n", ans / cnt);
    return 0;
}


Measured memory_bytes: 3764
import math
text=input().split()
for i,v in enumerate(text):
    text[i]=int(v)
while text[0] or text[1]:
    for i in range(text[0]):
        print('#'*text[1])
    text=input().split()
    print()
    for i,v in enumerate(text):
        text[i]=int(v)



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

const int MAX_N = 300001;
vector<int> MSN, P;
bool isMSN[MAX_N], isP[MAX_N];

void make() {
  MSN.push_back(1);
  MSN.push_back(6);
  for(int i = 1; MSN.back() < MAX_N; ++i) {
    MSN.push_back(7*i+1);
    MSN.push_back(7*i+6);
  }
  fill(isMSN,isMSN+MAX_N,false);
  for(int i = 0; i < MSN.size(); ++i) {
    if(MSN[i] < MAX_N) isMSN[MSN[i]] = true;
  }

  fill(isP,isP+MAX_N,false);
  for(int i = 1; i < MSN.size(); ++i) {
    bool flag = true;
    for(int j = 1; j < i && MSN[j] <= sqrt(MSN[i]); ++j) {
      if(MSN[i] % MSN[j] == 0) {
	flag = false;
	break;
      }
    }
    if(flag) {
      isP[MSN[i]] = true;
      P.push_back(MSN[i]);
    }
  }
}

int main() {
  make();
  int n;
  while(cin >> n && n!=1) {
    cout << n << ":";
    for(int i = 0; i < P.size() && P[i] <= n; ++i) {
      if(n%P[i] == 0 && isMSN[n/P[i]]) cout << " " << P[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2224
MM,DD =map(int,input().split())
cnt = 0

for m in range(2,MM+1):
  for d in range(2,DD+1):
    d10 = d//10;d1 = d%10
    if d10*d1 == m and d10>=2 and d1>=2:
      #print(m,d10,d1)
      cnt+=1
print(cnt)

Measured memory_bytes: 3060