akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
int board[10][10];
int main(){
	cin>>n;
	int cc = 0;
	for(int k = 0;k< n;k++){
		bool flag[10][10];
		if(cc++ != 0) puts("");

		rep(i,10){
			rep(j,10){
				flag[i][j] = true;
			}
		}
		for(int y = 1;y <=9;y++){
			for(int x = 1;x <=9;x++){
				cin>>board[y][x];
			}
		}
		for(int y = 1; y<=9;y+=3){//3×3ブロックごとの判定
			for(int x = 1;x <=9;x+=3){
				int cnt[10]={0};
				rep(i,3){
					rep(j,3){
						cnt[board[y+i][x+j]]+=1;
					}
				}
				rep(i,3){
					rep(j,3){
						if(cnt[board[y+i][x+j]]!=1){
							flag[y+i][x+j] =false;
						}
					}
				}
			}
		}
		for(int y = 1;y <=9;y++){//横の判定
			int cnt[10]={0};
			for(int x = 1;x <=9;x++){
				cnt[board[y][x]]+=1;
			}
			for(int x = 1; x<=9;x++){
				if(cnt[board[y][x]]!=1){
					flag[y][x] =false;
				}
			}
		}
		for(int x = 1;x <=9;x++){
			int cnt[10]={0};
			for(int y =1;y <=9;y++){
				cnt[board[y][x]]++;
			}
			for(int y = 1;y <=9;y++){
				if(cnt[board[y][x]]!=1){
					flag[y][x] = false;
				}
			}
		}
		for(int i = 1;i <=9;i++){
			for(int j = 1;j <=9;j++){
				printf("%c%d",(flag[i][j]?' ':'*'),board[i][j]);
			}
			puts("");
		}
	}
	return 0;
}

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

int main(){
  int n;
  long long ans=0;
  cin >> n;
  vector<int> cnt(1000000);
  int a;
  for(int i=0;i<n;i++){
    cin >> a;
    ans += a;
    cnt.at(a)++;
  }
  int q;
  cin >> q;
  vector<int> b(q),c(q);
  for(int i=0;i<q;i++){
    cin >> b.at(i) >> c.at(i);
  }
  
  for(int i=0;i<q;i++){
    if(cnt.at(b.at(i)) == 0) cout << ans << endl;
    else {
      ans += cnt.at(b.at(i))*(c.at(i)-b.at(i));
      cnt.at(c.at(i)) += cnt.at(b.at(i));
      cnt.at(b.at(i)) = 0;
      cout << ans << endl;
    }
  }
     
  return 0;
}


Measured memory_bytes: 8032
#require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
n.times{
  i=gi
  h[i]=(h[i]+1)%2
}
puts h.to_a.map{|i|i[1]}.count(1)

Measured memory_bytes: 14076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, m);
    int k = n/4;
    if(n % 2 == 0){
        for(int i = 0; i < min(m, k); i ++) Cout(i+1, " ", n-i);
        for(int i = k; i < m; i ++) Cout(i+1, " ", n-1-i);
    }
    else{
        for(int i = 0; i < m; i ++) Cout(i+1, " ", n-i);
    }
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<double,double>P;
const double R=6378.1;
const double PI=3.14159265359;
double a,b,c,d;


int main()
{
	for(;scanf("%lf%lf%lf%lf",&a,&b,&c,&d);)
	{
		if(a==-1&&b==-1&&c==-1&&d==-1)break;
		P ang[2];
		vector<P>v;
		vector<double>p[2];
		v.push_back(make_pair(a,b));
		v.push_back(make_pair(c,d));
		for(int i=0;i<2;i++)
		{
			ang[i].first=(v[i].first/180)*PI;
			ang[i].second=(v[i].second/180)*PI;
		}
		for(int i=0;i<2;i++)
		{
			p[i].push_back(R*cos(ang[i].first)*cos(ang[i].second));
			p[i].push_back(R*cos(ang[i].first)*sin(ang[i].second));
			p[i].push_back(R*sin(ang[i].first));
		}
		double dis=sqrt(pow(p[0][0]-p[1][0],2)+pow(p[0][1]-p[1][1],2)+pow(p[0][2]-p[1][2],2));
		double difa=(R*R*2-dis*dis)/(2*R*R);
		double anp=acos(difa);
		double cmp=
		printf("%d\n",(int)(PI*R*(anp/PI)+0.5));
	}
	return 0;
}

Measured memory_bytes: 1312
#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;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vector<pair<string,int>> data(n);
    rep(i,n) {
        string s; cin >> s;
        int t; cin >> t;
        data[i] = make_pair(s,t);
    }
    string x; cin >> x;
    bool ok = false;
    int ans = 0;
    rep(i,n) {
        if (ok) ans += data[i].second;
        if (data[i].first == x) ok = true;
    }
    cout << ans << endl;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;
vector<int> edges[100000 + 1];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, m;
    cin>>n>>m;

    while(m--)
    {
        int a, b;
        cin>>a>>b;
        edges[a].pb(b);
        edges[b].pb(a);
    }

    int vis[n + 1];
    memset(vis, 0, sizeof vis);

    queue<int> q;
    q.push(1);
    vis[1] = 1;
    while(!q.empty())
    {
        int node = q.front();
        q.pop();
        
        for(auto i : edges[node])
        {
            if(vis[i] == 0)
            {
                vis[i] = node;
                q.push(i);
            }
        }
    }
    f1(i,1,n+1)
    {
        if(vis[i] == 0)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    f1(i,2,n+1)
    cout<<vis[i]<<endl;
    return 0;
}

Measured memory_bytes: 13016
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned long long
///////////////////////////////////////////////////////////
template <class T>
T absolute(const T& n);
template <class T>
void input(vector<T>& vec);
template <class T>
void output(const vector<T>& vec);
template <class T>
T sum(const vector<T>& vec);
template <class T>
void upsort(vector<T>& vec);
template <class T>
void downsort(vector<T>& vec);
template <class T>
T max(const vector<T>& vec);
template <class T>
T min(const vector<T>& vec);
template <class T>
vector<bool> isPrime(T max);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    size_t n;
    cin >> n;
    string s;
    for(int i=0;i<n;++i){
        char a;
        cin>>a;
        s.push_back(a);
    }
    if(n%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    string t, u;
    for(size_t i=0;i<n/2; ++i){
        t.push_back(s[i]);
    }
    for(size_t i=n/2;i<n; ++i){
        u.push_back(s[i]);
    }
    if(t==u){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
template <class T>
T absolute(const T& n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

template <class T>
void input(vector<T>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

template <class T>
void output(const vector<T>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

template <class T>
T sum(const vector<T>& vec)
{
    T initial = 0.0;
    T s = accumulate(vec.begin(), vec.end(), initial);
    return s;
}

template <class T>
void upsort(vector<T>& vec)
{
    sort(vec.begin(), vec.end());
}

template <class T>
void downsort(vector<T>& vec)
{
    sort(vec.begin(), vec.end(), greater<T>());
}

template <class T>
T max(const vector<T>& vec)
{
    T m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

template <class T>
T min(const vector<T>& vec)
{
    T m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}

template <class T>
vector<bool> isPrime(T max)
{
    vector<bool> isPrime(max + 1, true);
    isPrime[0] = false;
    isPrime[1] = false;
    for (size_t i = 2; i * i <= max; ++i) {
        if (isPrime[i]) {
            for (size_t j = 2; i * j <= max; ++j) {
                isPrime[i * j] = false;
            }
        }
    }
    return isPrime;
}
///////////////////////////////////////////////////////////

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

int main(){
	int ans=0;
	int n;
	std::cin>>n;

	std::vector<int> aList(n);
	std::vector<std::vector<int>> xList(n);
	std::vector<std::vector<int>> yList(n);

	for(int i=0; i< n; i++){
		std::cin>>aList[i];
		xList[i].resize(aList[i]);
		yList[i].resize(aList[i]);

		for(int j=0; j<aList[i]; j++)
			std::cin>>xList[i][j]>>yList[i][j];	
	}

	int iter= std::pow(2, n);

	std::vector<int> pow2List(n+1, 1);
	for(int i=1; i<n+1; i++)
		pow2List[i]= pow2List[i-1]*2;
	
	for(int i=0; i<iter; i++){
		bool isCorrect=true;
		std::vector<int> isHonest(n, 0);
		int tmp=i;

		for(int j=0; j<n; j++){
			isHonest[j]= tmp%2;
			tmp= tmp/2;
		}

		for(int j=0; j<n; j++){
			for(int k=0; k< aList[j]; k++){
				if(isHonest[j]){
					if(isHonest[xList[j][k]-1] !=yList[j][k])
						isCorrect=false;
				}
			}
		}

		if(isCorrect){
			int tmp_= 0;
			for(int i=0; i<n; i++)
				tmp_+= isHonest[i];

			ans= std::max(ans, tmp_);
		}
	}

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 256
dic = {}
for i in range(10):
  for j in range(10):
    if i < j:
      dic[(i, j)] = list(range(i, j + 1))
    elif i > j:
      if i <= 5:
        dic[(i, j)] = list(range(i, j - 1, -1))
      elif j <= 5:
        dic[(i, j)] = list(range(i, 10)) + list(range(5, j - 1, -1))
      else:
        dic[(i, j)] = list(range(i, 10)) + list(range(5, -1, -1)) + list(range(1, j + 1))


n = int(input())
for _ in range(n):
  s, g = map(int, input().split())
  print(*dic[(s, g)])


Measured memory_bytes: 5592
N=int(input());
L=[2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761,939587134549734843]
print(L[N])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
using LL = long long int;
LL inf = 1000000007;
int main(){
    LL n;
    cin >> n;
    vector<LL> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    LL ans = 0;
    LL uhen = 0;
    for(int i = 2;i <= n;i++){
        uhen += a[n - i + 1];
        uhen %= inf;
        ans += (a[n-i] * uhen) % inf;
        ans %= inf;
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 4700
#include<bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define pb push_back
using namespace std;

const int N = 1e6 + 6,mod = 998244353 ;

ll k = 1e18;

int dig(ll x){
        if(x == 0) return 0;
        int cnt = 0;
        while(x){
                x/=10;
                cnt++;
        }
        return cnt;
}

inline void test_case(){
        ll n,m;
        cin >> n;
        ll ans = 1;
        while(n--){
                ll x;
                cin >> x;
                if(x == 0){ ans = 0; continue;}
                if(ans == -1) continue;
                if(ans > k/x+1){
                        ans = -1;
                } else {
                        ans *= x;
                        if(ans>k){
                                ans = -1;
                        }
                }
        }
        cout << ans << endl;
}
int main(){
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

        int T = 1;
        //cin >> T;
        while(T--){
                test_case();
        }
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 10000000;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int getval(int x) {
	char u[10];
	printf("%d\n", x);
	fflush(stdout);
	scanf("%s", u);
	if (u[0] == 'V') exit(0);

	return (int)(u[0] == 'M');
}

bool isValid(int st, int en, int sv, int ev) {
	bool t1 = (st % 2 == en % 2);
	bool t2 = (sv == ev);
	return t1 != t2;
}
int main() {
	int N;
	scanf("%d", &N);
	int t1 = getval(0);
	int t2 = getval(N / 2);

	int st, en;
	if (isValid(0, N / 2, t1, t2)) st = 0, en = N / 2;
	else st = N / 2, en = N;

	int sv = (st == N / 2) ? t2 : t1;
	int ev = (en == N / 2) ? t2 : t1;
	while (st < en) {
		int mi = (st + en) / 2;

		int mv = getval(mi);
		if (isValid(st, mi, sv, mv)) {
			en = mi;
			ev = mv;
		}
		else {
			st = mi;
			sv = mv;
		}
	}
	printf("NOOO\n");
	return 0;
}
//*/

Measured memory_bytes: 852
import math
import itertools

def solve(k):
  if k == 1:
    return 1
  if k == 2:
    return 9

  ans = 0
  x = [i for i in range(1, k+1)]
  for a, b, c in itertools.combinations(x, 3):
    ans += 6*math.gcd(math.gcd(a,b), c)

  for a,b in itertools.combinations(x, 2):
    ans += 6*math.gcd(a,b)

  ans += k*(k+1)/2
  return int(ans)

if __name__ == "__main__":
  k = int(input())
  print(solve(k))


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
const double EPS = 1e-8;

namespace std {
  bool operator < (const P& a, const P& b){
    return fabs(real(a)-real(b)) < EPS ? imag(a) < imag(b) : real(a) < real(b);
  }
}
double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

bool isIntersect(L s1, L s2){
  /*  
  if(max(real(s1.first), real(s1.second)) + EPS < min(real(s2.first), real(s2.second)) ||
     max(imag(s1.first), imag(s1.second)) + EPS < min(imag(s2.first), imag(s2.second)) ||
     max(real(s2.first), real(s2.second)) + EPS < min(real(s1.first), real(s1.second)) ||
     max(imag(s2.first), imag(s2.second)) + EPS < min(imag(s1.first), imag(s1.second))) return false;
  */
  return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
  ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0 );
}

double getDistanceSP(L s, P p){
  if(dot(s.second - s.first, p - s.first) < -EPS) return abs(p - s.first);
  if(dot(s.first - s.second, p - s.second) < -EPS) return abs(p - s.second);
  return abs(cross(s.second - s.first, p - s.first) / abs(s.second - s.first));  }

double getDistanceSS(L s1, L s2){
  if(isIntersect(s1,s2)) return 0.0;
  return min( min(getDistanceSP(s1, s2.first), getDistanceSP(s1, s2.second)),
              min(getDistanceSP(s2, s1.first), getDistanceSP(s2, s1.second)));
}


double cal(L a,L b,double h){
  double d=getDistanceSS(a,b);
  if(h>d)return d;
  return (h*h+d*d)/2/h;
}

int main(){
  int n;

  while(cin>>n,n){
    double ans=1e9;
    P s,e;
    double minx,maxx,miny,maxy,h;
    cin>>s.x>>s.y>>e.x>>e.y;
    for(int i=0;i<n;i++){
      cin>>minx>>miny>>maxx>>maxy>>h;
      if(minx<=s.x&&s.x<=maxx&&miny<=s.y&&s.y<=maxy)ans=0;
      if(minx<=e.x&&e.x<=maxx&&miny<=e.y&&e.y<=maxy)ans=0;
      ans=min(ans,cal(L(s,e),L(P(minx,miny),P(minx,maxy)),h));
      ans=min(ans,cal(L(s,e),L(P(minx,maxy),P(maxx,maxy)),h));
      ans=min(ans,cal(L(s,e),L(P(maxx,maxy),P(maxx,miny)),h));
      ans=min(ans,cal(L(s,e),L(P(maxx,miny),P(minx,miny)),h));
    }
    printf("%.8lf\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3336
from bisect import bisect_left
from itertools import accumulate

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

cnt = [0] * n
for i in range(n):
    cnt[i] = n - bisect_left(c, b[i] + 1)

cnt = [0] + list(accumulate(cnt[::-1]))
cnt.reverse()

ans = 0
for i in range(n):
    ans += cnt[bisect_left(b, a[i] + 1)]

print(ans)
    

    
    

Measured memory_bytes: 31632
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
	//code
	ll x,k,d,ans;
	cin>>x>>k>>d;
	x=abs(x);
	ll c=x/d;
	
	if(k<c)
		ans=x-(k*d);
	else{
		ans=x-(c*d);
		if((k-c)%2)
			ans-=d;
	}
	cout<<abs(ans);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n+1);
    for(int i = 0; i < n; ++i){
        cin >> p[i] >> p[i+1]; 
    }
    vector<vector<int> > dp(n, vector<int>(n));
    for(int d = 1; d < n; ++d){
        for(int i = 0; i < n - d; ++i){
            int j = i + d;
            dp[i][j] = 1 << 30;
            for(int k = i; k < j; ++k){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + p[i] * p[k+1] * p[j+1]);
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}



Measured memory_bytes: 3176
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n, m, x;
	cin >> n >> m >> x;
	int s[120] = {};
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		s[a] = 1;
	}
	int ans = 0;
	for (int i = x+1; i <= n; i++) {
		if (s[i] == 1) {
			ans = ans + 1;
		}
	}
	int ks = 0;
	for (int i = x-1; i >= 0; i--) {
		if (s[i] == 1) {
			ks = ks + 1;
		}
	}
	cout << min(ks, ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
int color[101];
int A[101][101];
int d[101];
int f[101];
int time,n;
void dfs(void);
void visit(int);
int main(){
  int i,j,k,id,kn;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&kn);
    for(j=0;j<kn;j++){
      scanf("%d",&k);
      A[id][k]=1;
    }
  }
  dfs();
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}
void dfs (void){
  int i,j;
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(A[i][j]==1){
	if(color[i]==WHITE){
	  visit(i);
	}
      }
    }
  }
}
void visit(int u){
  int i;
  color[u]=GRAY;
  d[u]=++time;
  for(i=1;i<=n;i++){
    if(A[u][i]==1){
      if(color[i]==WHITE){
	visit(i);
      }
    }
  }
  color[u]=BLACK;
  f[u]=++time;
}
      
    
  
  
 



Measured memory_bytes: 2052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
int n;
lint q;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline lint nxi(){
		lint x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

namespace S{
	int cnt,tr[N][2];
	lint ans;

	void insert(const char *str,const int len){
		int p=0;
		for(int i=1; i<=len; ++i){
			int &c=tr[p][str[i]-'0'];
			if(!c) c=++cnt;
			p=c;
		}
	}

	void dfs_sg(const int x,const int dep){
		if((bool)tr[x][0]^(bool)tr[x][1]){
			ans^=(q-dep+1)&-(q-dep+1);
		}
		if(tr[x][0]) dfs_sg(tr[x][0],dep+1);
		if(tr[x][1]) dfs_sg(tr[x][1],dep+1);
	}

	bool get_sg(){
		dfs_sg(0,1);
		return (bool)ans;
	}
}

int main(){
	n=nxi(),q=nxi();
	for(int i=1; i<=n; ++i){
		static char str[N];
		scanf("%s",str+1);
		int l=strlen(str+1);
		S::insert(str,l);
	}
	puts(S::get_sg()?"Alice":"Bob");
	return 0;
}


Measured memory_bytes: 3456
N,K=map(int,input().split())
RSP=list(map(int,(input().split())))
T=input()
ans=0
cand="RSP"
def win(x):
    if x=="r":
        return 2
    elif x=="p":
        return 1
    elif x=="s":
        return 0
    else:
        return "error"
ans=0
H=""
for i in range(N):
    if i<K:
        ans+=RSP[win(T[i])]
    elif win(T[i])!=win(T[i-K]):
        ans+=RSP[win(T[i])]
    else:
        T=T[:i]+"x"+T[i+1:]

print(ans)

Measured memory_bytes: 3460
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#define endl '\n'
using namespace std;
int l[27],cnt;
int main()
{
    string s;
    cin>>s;
    int n = s.size();
    sort(s.begin(),s.end());
    //cout<<s;
    for(int i=0; i<n; i++)
    {
        int ch = s[i];
        //cout<<ch<<endl;
        l[ch]++;
    }
    for(int i = 97; i<123; i++){
            //cout<<l[i]<<endl;
            if(!l[i]){cout<<(char)i<<endl;return 0;}
    }
    puts("None");
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    
    int n1, n2;
    cin >> n1 >> n2;
    
    string s;
    cin >> s;
    
    if(s == a) n1 -= 1;
    if(s == b) n2 -= 1;
    
    cout << n1 << " " << n2;

	return 0;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

import numpy as np

a=sorted(a)
cum = np.cumsum(a)

cum=list(reversed(cum))
a=list(reversed(a))
ans=1
for i in range(1,n):
    if a[i-1]<=cum[i]*2:
        ans+=1
    else:
        break

print(ans)


Measured memory_bytes: 37116
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll x,y;cin>>x>>y;
  ll ans = 1;
  while(1){
    x *= 2;
    if(x > y)break;
    ans++;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout<< min(a*n,b) << endl;

}


Measured memory_bytes: 256
import sys
import heapq

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	k = II()
	a = [1,2,3,4,5,6,7,8,9]
	heapq.heapify(a)
	total = 0
	while(total!=k):
		i = heapq.heappop(a)
		total+=1
		li = i%10
		if(li%10==0):
			heapq.heappush(a,i*10+li)
			heapq.heappush(a,i*10+li+1)
		elif(li%10==9):
			heapq.heappush(a,i*10+li-1)
			heapq.heappush(a,i*10+li)
		else:
			heapq.heappush(a,i*10+li-1)
			heapq.heappush(a,i*10+li)
			heapq.heappush(a,i*10+li+1)
	print(i)

if __name__ == '__main__':
	main()

Measured memory_bytes: 11784
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
string a;
int main()
{
	cin>>a;
	int l=0,r=a.size()-1,pd=1,ans=0;
	while(l<r)
	{
		if(a[l]==a[r])
		{
			l++;
			r--;
		}
		if(a[l]!=a[r])
		{
			if(a[l]=='x'||a[r]=='x')
			{
				if(a[l]=='x')l++;
				if(a[r]=='x')r--;
				ans++;
			}
			else 
			{
				ans=-1;
				break;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

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

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int a,b,c;cin>>a>>b>>c;
    if(a==b&&b==c&&c==a){
        puts("Yes");
    } else{
        puts("No");
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.ExceptionServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadInts();

            var hi = 0;
            long ans = 0;
            for (int i = 0; i < N; i++)
            {
                hi = Max(hi, A[i]);
                ans += hi - A[i];
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 46280
package main

import (
	"bufio"
	"fmt"
	"os"
)

func toLower(s string) string {
	a := make([]rune, len(s))
	for i, c := range s {
		if 'A' <= c && c <= 'Z' {
			a[i] = c + 0x20
		} else {
			a[i] = c
		}
	}
	return string(a)
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	w := sc.Text()
	ans := 0
	for sc.Scan() {
		s := toLower(sc.Text())
		if s == "END_OF_TEXT" {
			break
		}
		if s == w {
			ans++
		}
	}
	fmt.Println(ans)
}



Measured memory_bytes: 1088
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

int n, k, ta, tb, tc, td, te;
vector< int > v[21][21];
char x[(1 << 20) + 1];

void pri(int a, int b) {
	for (int i = b - 1; i >= 0; i--)
		if (a & (1 << i))
			printf("1");
		else
			printf("0");
	printf("\n");
}

void pri(int a, int b, int c) {
	if (c == b)
		printf("[");
	for (int i = b - 1; i >= 0; i--) {
		if (a & (1 << i))
			printf("1");
		else
			printf("0");
		if (i == c)
			printf("[");
	}
	printf("]\n");
}

void go(int a, int b, int c, int d) {
	if (a < ta) {
		go(a + 1, b, a, d);
		go(a + 1, b + (1 << a), c, a);
	} else {
		if (a < n) {
			go(a + 1, b, c, d);
			go(a + 1, b + (1 << a), c, d);
		}
		// printf("^ "); pri(b, a ,ta);
		tb = b >> ta;
		v[a - ta][0][tb] += v[a][ta][b];
		// pri(tb, a - ta, 0);
		if (c != -1) {
			// tc = b & ((1 << (c + 1)) - 1);
			tc = b & ((1 << c) - 1);
			v[a - (ta - c - 1)][c][(tb << (c + 1)) | tc] += v[a][ta][b];
			// pri((tb << (c + 1)) | tc, a - (ta - c - 1), c);
		}
		if (d != -1) {
			tc = b & ((1 << (d + 1)) - 1);
			v[a - (ta - d - 1)][d][(tb << (d + 1)) | tc] += v[a][ta][b];
			// pri((tb << (d + 1)) | tc, a - (ta - d - 1), d);
		}
	}
}

int zz[1024], oo[1024];

inline int fz(int a, int b) {
	if (b > 10) {
		b -= 10;
		int re = zz[((a >> 10) & ((1 << b) - 1)) | (1023 - ((1 << b) - 1))];
		if (re != -1)
			return re + 10;
		b = 10;
	}
	return zz[(a & ((1 << b) - 1)) | (1023 - ((1 << b) - 1))];
}

inline int fo(int a, int b) {
	if (b > 10) {
		b -= 10;
		int re = oo[((a >> 10) & ((1 << b) - 1))];
		if (re != -1)
			return re + 10;
		b = 10;
	}
	return oo[(a & ((1 << b) - 1))];
}

int main() {
	for (int i = 0; i < 1024; i++) {
		for (int j = 9; ; j--)
			if (!(i & (1 << j))) {
				zz[i] = j;
				break;
			} else if (j == 0) {
				zz[i] = -1;
				break;
			}
		for (int j = 9; ; j--)
			if (i & (1 << j)) {
				oo[i] = j;
				break;
			} else if (j == 0) {
				oo[i] = -1;
				break;
			}
	}
	scanf("%d%d", &n, &k);
	for (int i = 0; i <= n; i++) {
		scanf("%s", x);
		ta = 1 << i;
		for (int j = 0; j <= i; j++)
			v[i][j].resize(ta);
		for (int j = 0; j < ta; j++)
			v[i][i][j] = x[j] == '1';
		// for (int j = 0; j < ta; j++) if (x[j] == '1') {printf("*"); pri(j, i);}
	}
	// for (ta = n; ta; ta--) go(0, 0, -1, -1);
	for (ta = n; ta; ta--)
		for (int i = n; i >= ta; i--) {
			te = 1 << i;
			for (int j = 0; j < te; j++) {
				// printf("%4d ", v[i][ta][j]); pri(j, i, ta);
				tb = j >> ta;
				v[i - ta][0][tb] += v[i][ta][j];
				// pri(tb, i - ta, 0);
				td = fz(j, ta);
				if (td != -1) {
					tc = j & ((1 << td) - 1);
					v[i - (ta - td - 1)][td][(tb << (td + 1)) | tc] += v[i][ta][j];
					// pri((tb << (td + 1)) | tc, i - (ta - td - 1), td);
				}
				td = fo(j, ta);
				if (td != -1) {
					tc = j & ((1 << (td + 1)) - 1);
					v[i - (ta - td - 1)][td][(tb << (td + 1)) | tc] += v[i][ta][j];
					// pri((tb << (td + 1)) | tc, i - (ta - td - 1), td);
				}
			}
		}
	for (int i = n; /*i >= 0*/; i--) {
		ta = 1 << i;
		for (int j = 0; j < ta; j++)
			if (v[i][0][j] >= k) {
				pri(j, i);
				return 0;
			}
	}
	return 0;
}


Measured memory_bytes: 167552
from bisect import bisect

INF = 10 ** 11

A, B, Q = [int(i) for i in input().split()]
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]
len_s = len(S)
len_t = len(T)

for x in X:
    sx = bisect(S, x)
    tx = bisect(T, x)

    east_s = INF
    west_s = -INF
    east_t = INF
    west_t = -INF
    if sx < len_s:
        east_s = S[sx] - x
    if sx > 0:
        west_s = S[sx-1] - x

    if tx < len_t:
        east_t = T[tx] - x
    if tx > 0:
        west_t = T[tx-1] - x

    candidates = []
    res = min(
        (east_t - west_s * 2),
        (east_t * 2 - west_s),
        (east_s - west_t * 2),
        (east_s * 2 - west_t),
        (max(east_t, east_s)),
        (-min(west_t, west_s))
    )
    print(res)


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

const int N = 2e5 + 5;
vi adj[N];
ll inc[N];
ll ans[N];
int n;

void dfs(int u , int par , ll val){
    val += inc[u];
    ans[u] = val;
    for(int nxt : adj[u]){
        if(nxt == par)continue;
        dfs(nxt , u , val);
    }
}


int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int q , x , node;
    cin >> n >> q;
    int a , b;
    loop(i,n-1){
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    loop(i,q){
        cin >> node >> x;
        inc[node] += x;
    }

    dfs(1,-1,0);
    range(i,1,n){
        cout << ans[i] << " \n"[i == n];
    }


    return 0;
}


Measured memory_bytes: 25600
#include <iostream>

using namespace std;

struct Item {
    int value;
    int weight;
};

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

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

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

    for(int i = 1; i <= N; i++)
    {
        for(int w = 1; w <= W; w++)
        {
            if(w >= items[i].weight)
                dp[i][w] = max(dp[i - 1][w],
                               dp[i - 1][w - items[i].weight] + items[i].value); 
            else
                dp[i][w] = dp[i - 1][w];
        }
    }

    cout << dp[N][W] << endl;
}


Measured memory_bytes: 7028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

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

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<P> A;
    rep(i,N){
        int a;
        cin>>a;
        A.push_back({a,i+1});
    }
    sort(all(A));
    rep(i,N){
        cout<<A[i].second;
        if(i==N-1)cout<<endl;
        else cout<<" ";
    }
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
  ll A,B,C; cin>>A>>B>>C;
  if(A==B && B==C) cout<<"No"<<endl;
  else if(A==B || B==C || C==A) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, k;cin >> n >> k;
    int ans = 1;
    while(true){
        if(n/k > 0){
            n /= k;
            ans++;
        }
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#ABC144-D Water Bottle
import math
a, b, x = map(int, input().split())
if x < a*a*b*0.5:
    tang = 0.5*b*b*a/x
else:
    tang = 2*(a*a*b-x)/(a*a*a)
print(math.degrees(math.atan(tang)))

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

const int N = 5;

int main(){
    string str;
    cin >> str;
    int n = str.size();

    string num_str="";
    int sum=0;

    for (int tmp = 0; tmp < (1 << n-1); tmp++) {
        bitset<N> s(tmp);
        vector<string> nums;
        num_str = "";
        sum = 0;
        
        sum += stoi(str.substr(0, 1));
        num_str += str.at(0);

        rep(i, n-1){
            if(s.test(i)){
                num_str += "+";
                sum += stoi(str.substr(i+1, 1));
                num_str += str.at(i+1);
            }else{
                num_str += "-";
                sum -= stoi(str.substr(i+1, 1));
                num_str += str.at(i+1);
            }
        }
        if (sum==7){
            break;
        }

    }
    
    if(sum==7){
        cout << num_str << "=7" << endl;
    }

}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    string S;
    cin >> S;
    int a[500005];
    fill(a, a+500005, 0);
    long long ans=0LL;
    for(int i=0; i<S.length(); i++) {
        if (S[i] == '<'){
            a[i+1] = a[i]+1;
        }
    }
    for(int i=S.length()-1; i>=0; i--) {
        if (S[i]=='>') {
            a[i] = max(a[i+1] + 1,a[i]);
        }
    }
    for(int i=0; i<=S.length(); i++) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2820
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)


int main(void)
{
    int N;
    cin >> N;

    for(int i = N; i <= 999; i++){
        string s = to_string(i);
        if(s[0]==s[1] && s[1] == s[2])
        {
            cout << i << endl;
            return 0;
        }
    }

    

    return 0;
}


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

#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
typedef long long ll;

template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


ll N, M;
struct mint {
    long long x;
    mint(long long _x=0):x((_x%M+M)%M){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= M) x -= M;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += M-a.x) >= M) x -= M;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= M;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint Mpow(long long t) const {
        if (!t) return 1;
        mint a = Mpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime M
    mint inv() const {
        return Mpow(M-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& a){
        os << a.x;
        return os;
    }
};

vec<mint> dp, ans;
vvec<int> G;

mint dfs1(int cur, int pre) {
    mint res = 1;
    for(auto& nv: G[cur]){
        if(nv == pre)continue;
        res *= (dfs1(nv, cur) + 1);
    }
    dp[cur] = res;
    return res;
}

//rerooting
void dfs2(int cur, int pre){
    ans[cur] = dp[cur];
    
    int sz = G[cur].size();
    //子のdpの値の左右の累積積
    deque<mint> l(sz+1,1), r(sz+1,1);
    rep(i,sz){
        l[i+1] = l[i] * (dp[G[cur][i]] + 1);
    }
    for(int i = sz-1; i >= 0; i--){
        r[i] = r[i+1] * (dp[G[cur][i]]+1); 
    }
    //print(l);print(r);
    rep(i, sz){
        int nv = G[cur][i];
        if(nv == pre)continue;
        // dp[cur] / dp[nv]をしたいが、modの値が素数でないので逆元は使えない
        //ここで、左右からの累積積を持っておくとそこを除いた計算が素早くできる
        mint tmp_cur = dp[cur];
        mint tmp_nv = dp[nv];
        dp[cur] = l[i] * r[i+1];//親との縁切り　実質割り算
        dp[nv] *= (dp[cur] + 1);//繋ぎかえ　俺が親になってやるぜー
        dfs2(nv, cur);
        dp[cur] = tmp_cur;
        dp[nv] = tmp_nv;
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> N >> M;
    G.resize(N);
    dp.assign(N, -1);
    ans.resize(N);
    rep(i,N-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs1(0, -1);
    dfs2(0, -1);
    //print(dp);print(ans);
    rep(i,N){
        cout << ans[i] <<endl;
    }
}

Measured memory_bytes: 114944
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X;
  cin>>X;
  if(X==2) cout<<2<<endl;
  else{
  int i=0;
  
  while(i>=0){
    bool prime=true;
    int k=X+i;
    int t=sqrt(k);
    int a=1;
    while(a<=t){
      a++;
      if(k%a==0){
        prime=false;
       
        break;
      }
    }
    if(prime==true)break;
    else i++;
  }
  cout<<X+i<<endl;
  }
}


Measured memory_bytes: 256