akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int mod=1000000007;
int n,f[100005],g[100005];
long long A,B,s[100005];
int main()
{
    scanf("%d%lld%lld",&n,&A,&B);
    for(long long i=1;i<=n;i++)
        scanf("%lld",&s[i]);
    if (A>B) swap(A,B);
    for(long long i=3;i<=n;i++)
        if (s[i]-s[i-2]<A) {printf("0\n");return 0;}
    s[0]=-2000000000000000000ll,s[n+1]=2000000000000000000ll;
    f[0]=g[0]=1;
    int l=0,r=0;
    for(int i=1,l=0,r=0;i<=n+1;i++)
    {
        while (r<i-1 && s[i]-s[r+1]>=B) r++;
        if (l<=r) f[i]=(g[r]+mod-(l?g[l-1]:0))%mod;
        g[i]=(g[i-1]+f[i])%mod;
        if(i>1 && s[i]-s[i-1]<A) l=i-1;
    }
    printf("%d\n",f[n+1]);
    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define rg register
#define ll long long
#define CL(a,b) memset(a,b,sizeof a)
const int N=2e5+7,inf=0x3f3f3f3f;
char s[N];
int a[N];
int black[N],white[N];
int main()
{
    int n;
    cin>>n>>s;
    for(int i=0;i<n;i++)
        if(s[i]=='.')
        a[i+1]=0;
        else a[i+1]=1;
        int ans=inf;
    for(int i=1;i<=n;i++)
        if(a[i]==0)
        {
            white[i]=white[i-1]+1;
            black[i]=black[i-1];
        }
        else
        {
            black[i]=black[i-1]+1;
            white[i]=white[i-1];
        }
    white[n+1]=white[n];
    for(int i=0;i<=n;i++)
        ans=min(black[i]+white[n]-white[i+1],ans);
        cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2816
h,w,m=map(int,input().split())
p=[]
for i in range(m):
  p.append(tuple(map(lambda x:int(x)-1,input().split())))
p.sort()
hc=[0 for i in range(h)]
wc=[0 for i in range(w)]
hm=0
wm=0
hp=[]
wp=[]
for i in p:
  hc[i[0]]+=1
  if hc[i[0]]>hm:
    hm=hc[i[0]]
    hp=[i[0]]
  elif hc[i[0]]==hm:
    hp.append(i[0])
   
  wc[i[1]]+=1
  if wc[i[1]]>wm:
    wm=wc[i[1]]
    wp=[i[1]]
  elif wc[i[1]]==wm:
    wp.append(i[1])

f=0
for i in hp:
  for j in wp:
    s,t=0,m
    while t-s>1:
      x=(s+t)//2
      if p[x]>(i,j):
        t=x
      else:
        s=x
    if p[s]!=(i,j):
      f=1
      break
  if f:
    break

print(hm+wm-1+f)
    
    


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	while(cin >> n >> q && n+q) {
		vector<int64> a(n);
		REP(i, n) cin >> a[i];
		int64 res = 0;
		REP(i, n) {
			REP(j, n) {
				if (i == j) continue;
				if (a[i]+a[j] <= q) {
					res = max(res, a[i]+a[j]);
				}
			}
		}
		if (res > 0)
			cout << res << endl;
		else
			cout << "NONE" << endl;
	}
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <tuple>
#include <string>

#define printhere cout << "HERE\n"
#define printV(v, n)    \
    for (int i = 0; i < n; i++) \
        cout << v[i] << " ";
#define readV(v, n)     \
    for (int i = 0; i < n; i++) \
        cin >> v[i];
#define pb(v, t) v.push_back(t)
#define mp(a, b) make_pair(a, b)
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;



    double theta_h = (M_PI * h / 6.0);
    double theta_m = (M_PI * m / 30.0);

    theta_h = 0.5 * (60 * h + m);
    theta_m = 6 * m;
    double delta = theta_h - theta_m;
    double delta_rad = delta * M_PI / 180.0;


    std::cout<<std::setprecision(15) << (double) sqrt(a*(1.0*a) + (1.0*b)*b - 2.0 * a * b * cos(delta_rad)) << "\n";
}

Measured memory_bytes: 4224
x, y, z, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)
# print(a,b,c,x,y,z,k)
ans = []
for xi in range(x): # search a at first
    if xi+1 > k: # k より大きい数は探索不要
        break
    for yi in range(y):
        if (xi+1)*(yi+1) > k:
            break
        for zi in range(z):
            if (xi+1)*(yi+1)*(zi+1) > k:
                break
            ans.append(a[xi]+b[yi]+c[zi])
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Measured memory_bytes: 8756
from bisect import bisect_left
A,B,Q=map(int,input().split())
inf=float("inf")
S=[-inf]+[int(input()) for i in range(A)]+[inf]
T=[-inf]+[int(input()) for i in range(B)]+[inf]
X=[int(input()) for i in range(Q)]
S.sort()
T.sort()
for x in X:
  s_index=bisect_left(S,x)
  t_index=bisect_left(T,x)
  s_l=abs(S[s_index-1]-x)
  s_r=abs(S[s_index]-x)
  t_l=abs(T[t_index-1]-x)
  t_r=abs(T[t_index]-x)
  print(min(max(s_l,t_l),max(s_r,t_r),2*s_l+t_r,2*s_r+t_l,2*t_l+s_r,2*t_r+s_l))


Measured memory_bytes: 127064
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n, m;
    cin >> n >> m;

    // 指定された各桁の値を格納する配列
    vector<Int> v(n, -1);

    // 条件を満たす整数が存在するかどうかの真偽値
    bool result = true;
    for (Int i = 0; i < m; ++i) {
        Int s, c;
        cin >> s >> c;
        --s;
        if (v[s] == -1) { // まだ指定されていない場合
            v[s] = c;
        } else if (v[s] != c) { // 既に異なる値を指定していた場合
            result = false;
        }
    }

    // 配列内の値を題意に合うように変更する
    // 一番上の桁を処理
    if (n == 1) {
        if (v[0] == -1) {
            v[0] = 0;
        }
    } else {
        if (v[0] == 0) {
            result = false;
        } else if (v[0] == -1) {
            v[0] = 1;
        }
    }
    // 上から二番目以降の桁を処理
    for (Int i = 1; i < n; ++i) {
        if (v[i] == -1) {
            v[i] = 0;
        }
    }

    Int answer = 0;
    if (!result) {
        answer = -1;
    } else {
        // 配列内の要素を整数に整形する
        for (Int i = 0; i < n; ++i) {
            answer *= 10;
            answer += v[i];
        }
    }
    cout << answer << endl;
    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define SQ(a) (a)*(a)
#define all(v) v.begin(), v.end()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool used[26];

int main() {
    string s; cin >> s;
    if(s.length() != 26) {
        M00(i, (int)s.length()) used[s[i] - 'a'] = 1;
        string res = s;
        M00(i, 26) {
            if(!used[i]) {
                res += (char)('a' + i);
                break;
            }
        }
        cout << res << "\n";
    } else {
        vector<char> v;
        M00(i, s.length()) v.PB(s[i]);
        if(next_permutation(all(v))) {
            bool flag = 0;
            M00(i, (int)v.size()) {
                if(!flag) cout << v[i];
                if(v[i] != s[i]) flag = 1;
            }
            cout << "\n";
        } else {
            cout << "-1\n";
        }
    }
}


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

int main() {
	int h, a; cin >> h >> a;

	int ans = 0;
	while (h > 0) {
		h -= a;
		ans++;
	}

	dunk(ans);
}

Measured memory_bytes: 256
import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional, std.typecons;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;

alias M = Tuple!(int, "r", int, "c");
 
long count;
long[][] dp;
M[] list;

 
void main()
{
    int N = readln().strip.to!int;
    dp.length = N;
    dp.each!((ref a)=>a.length = N);
    dp.each!((ref a)=>a[] = -1);

    foreach(i; 0..N)
    {
        auto input = readln().split.to!(int[2]);
        list ~= M(input[0], input[1]);
    }
    foreach(i; 0..N)
    {
        dp[i][i] = 0;
    }
    foreach(i; 0..N-1)
    {
        dp[i][i+1] = list[i].r*list[i].c*list[i+1].c;
    }
    writeln(rec(0, N-1));
}


long rec(int r, int c)
{
    if(dp[r][c]!=-1)
    {
        return dp[r][c];
    }

    long minCost=long.max;
    foreach(s; r..c)
    {
        minCost = min(minCost, rec(r, s) + rec(s+1,c) + list[r].r*list[s].c*list[c].c);
    }
    dp[r][c] = minCost;
    return minCost;
}



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

int towers[1000];

int main() {
  for (int i = 1; i <= 999; i++)
    towers[i] = towers[i - 1] + i;
  int a, b;
  cin >> a >> b;
  for (int i = 1; i < 999; i++)
    if (b - a == towers[i + 1] - towers[i]) {
      cout << (towers[i] - a) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

int main() {
    int t=1;
    //cin >> t;
    while(t--){
        ll a,b,k;
        cin >> a >> b >> k;
        cout << max((ll)0,a-k) << " " << max((ll)0,b-max((ll)0,k-a));
    }
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  cin>>n>>k;
  long long x[n];
  for(int i=0; i<n; i++){
    cin>>x[i];
  }
  long long ans=10000000000000;
  for(int i=0; i<=n-k; i++){
    ans=min({ans,x[i+k-1]-x[i]+abs(x[i+k-1]),x[i+k-1]-x[i]+abs(x[i])});
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(){

	int a;
	int b;
	int c;

	cin >> a >> b >> c;

	if(b - a == c - b){
		cout << "YES";
	}else{
		cout << "NO";
	}

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
        int o = i % 10;
      	if(o==2||o==4||o==5||o==7||o==9){
          System.out.println("hon");
        }else if(o==0||o==1||o==6||o==8){
          System.out.println("pon");
    	}else if(o==3){
          System.out.println("bon");
        }
    }
}



Measured memory_bytes: 35752
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	int a;
	int total = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		total += a;
	}

	int ans = max(-1, n - total);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
from collections import deque

N, M = map(int, input().split())

g = [[] for _ in range(N + 1)]

for _ in range(M):
    A, B = map(int, input().split())
    g[A].append(B)
    g[B].append(A)

    #print("->", g)


def bfs(u):
    queue = deque([u])
    d = [None] * (N + 1)
    d[0] = 0
    d[u] = 0

    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                #d[i] = d[v] + 1
                d[i] = v
                queue.append(i)
    
    return d

d = bfs(1)

if None in d:
    print("No")
else:
    print("Yes")
    for i in d[2:]:
        print(i)



Measured memory_bytes: 34792
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

inline ld dist(ld &x1, ld &y1, ld &x2, ld &y2)
{
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  ld x[8], y[8];
  rep(i,n) cin >> x[i] >> y[i];
  vector<int> p(n);
  iota(all(p), 0);
  ld sum = 0.0;
  do
  {
    rep(i, n - 1)
    {
      sum += dist(x[p[i]], y[p[i]], x[p[i + 1]], y[p[i + 1]]);
    }
  } while (NP(p));
  ld f = 1.0;
  REP(i, 1, n + 1)
  f *= i;
  cout << sum / f << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
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;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	double a,b;
	cin>>a>>b;
	cout<<ceil((a+b)/2)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

void solve(){
	ll n;
	cin >> n;
	cout << 180*n-360 << ln;
}


int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve();
    return 0;
}

Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
using namespace std;

int main() {

    string s;
    cin >> s;
    
    if (s == "RRR"){cout << 3 << endl;}
  
    else if (s == "SSS"){cout << 0 << endl;}
    
    else if (s == "RRS" or s == "SRR"){cout << 2 << endl;}
    else cout << 1;
    return 0;        
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


Measured memory_bytes: 3636
// C.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int n = (int)s.length();
	list<int> a;
	for (int i = 0; i < n; ++i) {
		a.push_back(s[i] != '0');
	}
	int ans = 0;
	list<int>::iterator it = a.begin();
	while (it != a.end()) {
		list<int>::iterator next = it;
		++next;
		if (next == a.end()) {
			break;
		}
		if (*it == *next) {
			++it;
		} else {
			ans += 2;
			it = a.erase(it);
			it = a.erase(it);
			if (it != a.begin()) {
				--it;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class UnionFind {
  vector<int> par, sz;
public:
  UnionFind(int n) : par(n), sz(n, 1) {
    for (int i = 0; i < n; i++)
      par[i] = i;
  }
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sz[root(x)];
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (sz[x] >= sz[y]) {
      sz[x] += sz[y];
      par[y] = x;
    } else {
      sz[y] += sz[x];
      par[x] = y;
    }
    return true;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    uf.unite(a, b);
  }
  set<int> st;
  rep(i, n)
    st.insert(uf.root(i));
  cout << (int)st.size()-1 << endl;
  return 0;
}

Measured memory_bytes: 7940
#include <iostream>
using namespace std;
typedef long long ll;
ll B;

int main(){
	while(cin >> B && B>0){
		ll a = 0,n = 0;
		for(ll i=1;i*i<=2*B;i++){
			if(n<i && (2*B-(i-1)*i)%(2*i)==0 && (2*B-(i-1)*i)/(2*i)>=1){
				n = i;
				a = (2*B-(i-1)*i)/(2*i);
			}
		}
		cout << a << " " << n << endl;
	}
}


Measured memory_bytes: 3056
fun main(args: Array<String>){
    val n: Int = readLine()!!.toInt()
    var a: String = "Yes"
    for(i in 1..9){
        if(n % i == 0 && n / i < 10){
            a = "Yes"
            break
        }else{
            a = "No"
        }
    }
    println(a)
}


Measured memory_bytes: 29892
import heapq


def solve(priority_queue, amount):
    need_price = 0

    while amount > 0:
        price, count = heapq.heappop(priority_queue)
        need_price += price * min(amount, count)
        amount -= count

    return need_price


def main():
    n, m = map(int, input().split())

    priority_queue = list()
    for _ in range(n):
        item = list(map(int, input().split()))
        heapq.heappush(priority_queue, item)

    ans = solve(priority_queue, m)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27380
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstring>
#include <functional>
#include <algorithm>

using namespace std;
#define all(c) (c).begin(), (c).end()

struct graph {
  int L, R;
  vector<vector<int>> adj;
  graph(int L, int R) : L(L), R(R), adj(L+R) { }
  void add_edge(int u, int v) {
    adj[u].push_back(v+L);
    adj[v+L].push_back(u);
  }
  int maximum_matching() {
    vector<int> visited(L), mate(L+R, -1);
    function<bool(int)> augment = [&](int u) { // DFS
      if (visited[u]) return false;
      visited[u] = true;
      for (int w: adj[u]) {
        int v = mate[w];
        if (v < 0 || augment(v)) {
          mate[u] = w;
          mate[w] = u;
          return true;
        }
      }
      return false;
    };
    int match = 0;
    for (int u = 0; u < L; ++u) {
      fill(all(visited), 0);
      if (augment(u)) ++match;
    }
    return match;
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int>> r, b;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    r.emplace_back(pair<int, int>(x, y));
  }
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    b.emplace_back(pair<int, int>(x, y));
  }
  graph g(n, n);
  for (int i = 0; i < n; i++) {
    auto &er = r[i];
    for (int j = 0; j < n; j++) {
      auto &eb = b[j];
      if (er.first < eb.first && er.second < eb.second) {
        g.add_edge(i,j);
      }
    }
  }
    
  cout << g.maximum_matching() << endl;
  return 0;
}


Measured memory_bytes: 256
# BFS
import sys
input = sys.stdin.readline
import queue

n, q = map(int, input().split())

graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

q = queue.Queue()
q.put(0)
seen = [0] * n
ans = [0] * n

while True:
    if q.empty(): break
    v = q.get()
    seen[v] = 1
    ans[v] += counter[v]

    for next_v in graph[v]:
        if seen[next_v]: continue
        q.put(next_v)
        ans[next_v] += ans[v]

print(*ans)


Measured memory_bytes: 100240
fun main() {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map{ it.toLong() }
    
    for(i in 0..n-1) {
        if(a[i] == 0L) {
            println(0)
            return
        }
    }
    
    val MAX = Math.pow(10.0, 18.0).toLong()
    var result = a[0]
    for(i in 1..n-1) {
        if(!check(result, a[i])) {
            print(-1)
            return
        }
        result *= a[i]
        if(result > MAX) {
            println(-1)
            return
        }
    }
    print(result)
}

fun check(a: Long, b: Long): Boolean {
    val result = a * b
    return(a == result / b)
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();

        int P[] = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
        }

        Arrays.sort(P);

        int sum = 0;
        for(int i = 0; i < K; i++){
            sum+=P[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 30276
import math

N = int(input())
B = list(map(int, input().split())) 
import numpy as np
A=np.zeros([N])
for i in range(N):
    if i == 0:
        A[i] = B[i]
    elif i== N-1:
        A[i] = B[i-1]
    else:
        A[i] = min(B[i-1],B[i])

print(int(A.sum()))

Measured memory_bytes: 13116
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int dp[5005][5005];

int main(){
  int n; string s; cin >> n >> s;
  
  for(int i = n-1; i >= 0; i--){
    for(int j = n-1; j >= 0; j--){
      if(s[i] != s[j]) dp[i][j] = 0;
      else dp[i][j] = dp[i+1][j+1]+1;
    }
  }
  
  int ans = 0;
  rep(i,n)rep(j,n){
    if(i >= j) continue;
    int tmp = min(dp[i][j], j-i);
    chmax(ans,tmp);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 98048
n, q = map(int, input().split())
S = input()
lr = []
s = [0]*(n+1)
count = 0

for i in range(q):
    LR = list(map(int, input().split()))
    lr.append(LR)

for i in range(n-1):
    if S[i:i+2] == "AC":
        count += 1
        s[i+1] = count
    else:
        s[i+1] = s[i]
        
for i in range(q):
    print(s[lr[i][1] - 1] - s[lr[i][0] - 1])

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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	long long int dp[n+1][n+1], x = pow(10, 9) + 7;
	if (s[0] == '<'){
		dp[2][1] = 0;
		dp[2][2] = 1;
	}
	else{
		dp[2][1] = 1;
		dp[2][2] = 0;
	}
	for (int i=3;i<=n;i++){
		if (s[i-2] == '<'){
			dp[i][1] = 0;
			for (int j=2;j<=i;j++){
				dp[i][j] = ((dp[i][j-1]%x) + (dp[i-1][j-1]%x))%x;
			}
		}
		else{
			dp[i][i] = 0;
			for (int j= i-1;j>=1;j--){
				dp[i][j] = ((dp[i][j+1]%x) + (dp[i-1][j]%x))%x;
			}
		}
	}
	long long int ans = 0;
	for (int i=1;i<=n;i++){
		ans = ((ans%x) + (dp[n][i]%x))%x;
	}
	cout<<ans;
}

Measured memory_bytes: 70400
n,m = map(int,input().split())
par = []
for i in range(n):
    par.append(-1)  #初期親
rank = [1 for i in range(n)] #初期ランク
cut = []
def find(n): #親検索andランク短縮
    global cut
    if par[n] < 0:
        for i in range(len(cut)):
            par[cut[i]] = n
        cut = []
        return n
    else:
        cut.append(n)
        find(par[n])
        return find(par[n])
def shorten(n): # 根に直接接続する
    global cut
    if par[n] < 0:
        for i in range(len(cut)):
            par[cut[i]] = n
        cut = []
    else:
        cut.append(n)
        shorten(par[n])
def unite(a,b): #グループ併合
    x = find(a)
    y = find(b) #根っこ同士をくっつける
    if x == y: 
        return    #既に同一ユニオンなら何もしない
    if rank[x] < rank[y]:
        par[y] += par[x]
        par[x] = y 
    elif rank[x] == rank[y]:
        par[x] += par[y]
        par[y] = x
        rank[x] += 1
    else:
        par[x] += par[y]
        par[y] = x
def judge(a,b):
    return par[a] == par[b]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    unite(a,b)
ans = 0
for i in range(n):
    ans = max(ans,-par[i])
print(ans)

Measured memory_bytes: 100488
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  {
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl; 
  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int a,b;
    char op;
    
    while (1) {
        scanf("%d %c %d", &a, &op, &b);
    
        if (op=='+') {
        printf("%d\n",a+b);
        }else if(op=='-'){
        printf("%d\n",a-b);
        }else if(op=='*'){
        printf("%d\n",a*b);
        }else if(op=='/'){
        printf("%d\n",a/b);
        }
        if (op=='?') {
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll infl = 1ll<<60;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    cout << t+s <<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m, x = map(int, input().split())
a = sorted(list(map(int, input().split())))

to_zero = [i for i in a if i < x]
to_n = [i for i in a if i > x]
print(min(len(to_zero), len(to_n)))


Measured memory_bytes: 61896
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,k;
    cin >> n >> k;
    if(n <= k) {
        cout << min(n,k-n) << endl;
    } else {
        ll l = (n-k)%k;
        cout << min(l,k-l) << endl;
    }
}


Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
#include <cmath>
typedef long long ll;
const int N = 1000000;
int n;
int a[N], c[N];
int main()
{
    scanf("%d", &n);
    for (int i = 1;  i<= n ; i ++)
        scanf("%d", &a[i]);
    sort(a + 1, a+ n + 1);
    c[0] = 1;
    for (int i= 1;  i<= n ; i ++)
        if (a[c[0]] != a[i]) a[++c[0]] = a[i], c[c[0]] = 1;
        else
            c[c[0]] ++;
    if (c[0] != 3) {
        if (c[0] == 1 && a[1] == 0) {
            printf("Yes");
            return 0;
        }
        if (c[0] == 2 && !a[1]) {
            if (c[1] * 2 == c[2]) {
                printf("Yes");
                return 0;
            }
            printf("No");
            return 0;
        }
        printf("No");
        return 0;
    }
    if (c[1]!= c[2] || c[1] != c[3] || (a[1] ^ a[2] ^ a[3]) != 0 ){
        printf("No");
        return 0;
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 4608
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	int dx[] = { -1,0,1,0 };
	int dy[] = { 0,-1,0,1 };
	while (cin >> n, n) {
		vector<int>x(n, 0), y(n, 0);
		for (int i = 1; i < n; i++) {
			int where, tmp;
			cin >> where >> tmp;
			x[i] = x[where] + dx[tmp];
			y[i] = y[where] + dy[tmp];
				
		}
		sort(x.begin(), x.end());
		sort(y.begin(), y.end());
		cout << x[n - 1] - x[0] + 1 << " " << y[n - 1] - y[0] + 1 << endl;
	}
	return 0;
}

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

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

int main() {
  string N;
  cin >> N;
  bool ans = false;
  rep(i, 3) {
    if (N[i] == '7') {
      ans = true;
    }
  }
  if (ans == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int T;
int n;
int ti[101];
int d[101];
int dp[101][31];
int finD;

const int INF=1000000000;
int dfs(int pos,int tm){
	if(pos==finD+1)return 0;
	if(dp[pos][tm]!=-1)return dp[pos][tm];
	int res=INF;
	// JtFCðùÞ
	res=min(res,dfs(pos+1,1%T)+1);
	// ÔÉ¤êÍAùÜÈ¢Æ¢¤Iðà è
	if(d[pos]==-1||d[pos]>=ti[tm])res=min(res,dfs(pos+1,(tm+1)%T));
	return dp[pos][tm]=res;
}

int main(){

	while(cin>>T&&T){
		for(int i=0;i<T;i++)cin>>ti[i];
		cin>>n;
		memset(dp,-1,sizeof(dp));
		memset(d,-1,sizeof(d));
		finD=0;
		for(int i=0;i<n;i++){
			int da,m;
			cin>>da>>m;
			finD=max(finD,da);
			if(d[da]==-1)d[da]=m;
			else d[da]=min(d[da],m);
		}
		int res=dfs(1,0);
		cout<<res<<endl;
	}

	return 0;
}

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

#define ll long long int
#define fun() ll t; cin>> t; while (t--)
#define arr() ll n;cin>> n;
#define ip() ll a[n]; for(ll x=0;x<n;x++){cin>>a[x];} 
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t;cin>>t;
  if(t>=30)
    cout<<"Yes";
  else
    cout<<"No";
    return 0;
}

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

int main()
{
    int arr[5][5];

    for(int i = 1; i <= 3; i++){
        for(int j = 1; j <= 3; j++){
            cin >> arr[i][j];
        }
    }

    int n;
    cin >> n;

    for(int i = 1; i <= n; i++){
        int val;
        cin >> val;
        for(int j = 1; j <= 3; j++){
            for(int k = 1; k <= 3; k++){
                if(arr[j][k] == val) arr[j][k] = 0;
            }
        }
    }

    int flag = 0;

    for(int i = 1; i <= 3; i++){
        int cnt1 = 0, cnt2 = 0;
        for(int j = 1; j <= 3; j++){
            cnt1 += arr[i][j];
            cnt2 += arr[j][i];
        }

        if(!cnt1 || !cnt2) flag = 1;
    }

    if(!(arr[1][1]+arr[2][2]+arr[3][3]) || !(arr[1][3]+arr[2][2]+arr[3][1])) flag = 1;

    if(flag) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}

Measured memory_bytes: 3592
S = input()

dire = ['dream','dreamer','erase','eraser']

DP = [0] * 100000

DP[0] = 1

for s in range(len(S)):
    if DP[s] != 1:
        continue

    for i in range(4):
        tmp = S[s: s+len(dire[i])]
        if tmp == dire[i]:
            DP[s + len(dire[i])] = 1

if DP[len(S)] == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3956
n, m = input().split(' ',2)
a = []
for ii in range(int(n)):
    a.append(0)
for ii in range(int(m)):
    tmpA, tmpB = input().split(' ',2)
    a[int(tmpA) - 1] += 1
    a[int(tmpB) - 1] += 1
for ii in range(int(n)):
    print(a[ii])

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void)
{
  int A, B, C;
  cin >> A >> B >> C;
  int max = A;
  if(max < B){
    max = B;
  }
  if(max < C){
    max = C;
  }
  cout << max * 10 + (A+B+C-max) << endl;
  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++)
using ll = long long;

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

  ll n;
  cin >> n;

  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<int> xor_arr(60);
  for (int i = 0; i < n; i++) {
    for (int bit = 0; bit < 60; bit++) {
      if(1 & (a[i] >> bit)) {
        xor_arr[bit]++;
      }
    }
  }

  for (int i = 0; i < 60; i++) {
    xor_arr[i] = (xor_arr[i] % 2);
  }

  ll xor_val = 0;
  for (int i = 0; i < 60; i++) {
    if(xor_arr[i]) {
      xor_val += (1 << i);
    }
  }

  vector<ll> ans(n);
  for (int i = 0; i < n; i++) {
    ans[i] = (a[i] ^ xor_val);
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << '\n';
}


Measured memory_bytes: 6316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b) {
            if(b < c) System.out.printf("%d %d %d\n", a, b, c);
            else if(a < c) System.out.printf("%d %d %d\n", a, c, b);
            else System.out.printf("%d %d %d\n", c, a, b);
        } else {
            if (a < c) System.out.printf("%d %d %d\n", b, a, c);
            else if(b < c) System.out.printf("%d %d %d\n", b, c, a);
            else System.out.printf("%d %d %d\n", c, b, a);
        }
    }
}


Measured memory_bytes: 26332
#include <stdio.h>
#include <math.h>

int main () {
	int n , i;
	double ax,ay , bx,by , cx,cy , a , b , c , d , e ,f , x, y, r;
	scanf("%d",&n);
	for ( i = 0; i < n; i++ ) {
		scanf("%lf %lf %lf %lf %lf %lf",&ax,&ay,&bx,&by,&cx,&cy);
		a = 2 * ( ax - bx );
		b = 2 * ( ay - by );
		c = ax*ax - bx*bx + ay*ay - by*by;
		d = 2 * ( bx - cx );
		e = 2 * ( by - cy );
		f = bx*bx - cx*cx + by*by - cy*cy;
		
		if ( (c*e - b*f) == 0 ) x = 0;
		else x = ( c*e - b*f ) / ( a*e - b*d );
		if ( (c*d - a*f ) == 0 ) y = 0;
		else y = ( c*d - a*f ) / ( b*d - a*e );
		r = sqrt((x-ax)*(x-ax) + (y-ay)*(y-ay));
		
		printf("%5.3f %5.3f %5.3f\n",x,y,r);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws java.io.IOException {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		char bor[][] = new char[3][3];

		while (true){
			if(sc.hasNextInt())break;
			for (int i = 0; i < 3; i++) {
				bor[i] = sc.nextLine().toCharArray();
			}
//			System.out.println(bor[0]);
//			System.out.println(bor[1]);
//			System.out.println(bor[2]);
			
			char ans = 'u';
			for (int i = 0; i < 3; i++) {
				if (bor[i][0] == bor[i][1] && bor[i][0] == bor[i][2]) {
					if (bor[i][0] == 'w') {
						ans = 'w';
						break;
					} else if (bor[i][0] == 'b') {
						ans = 'b';
						break;
					} else
						continue;
				}
			}
			if (ans != 'u') {
				System.out.println(ans);
				continue;
			}

			for (int i = 0; i < 3; i++) {
				if (bor[0][i] == bor[1][i] && bor[0][i] == bor[2][i]) {
					if (bor[0][i] == 'w') {
						ans = 'w';
						break;
					} else if (bor[0][i] == 'b') {
						ans = 'b';
						break;
					} else
						continue;
				}
			}
				if (ans != 'u') {
					System.out.println(ans);
					continue;
				}
				if (bor[0][0] == bor[1][1] && bor[0][0] == bor[2][2]) {
					char j = bor[0][0];
					if (j == 'w')
						ans = 'w';
					else if (j == 'b')
						ans = 'b';
				}
				
				if (ans != 'u') {
					System.out.println(ans);
					continue;
				}
				
				if (bor[0][2] == bor[1][1] && bor[0][2] == bor[2][0]) {
					char j = bor[1][1];
					if (j == 'w')
						ans = 'w';
					else if (j == 'b')
						ans = 'b';
				}
				
				if (ans != 'u') {
					System.out.println(ans);
				}
				else System.out.println("NA");
				

			}
		}
	}

Measured memory_bytes: 12000
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
  double x1,x2,y1,y2,qx,qy;
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&qx,&qy)!=EOF){
        if(x1==x2){
            printf("%.6lf %.6lf\n",2*x1-qx,qy);
            continue;
        }
        if(y1==y2){
            printf("%.6lf %.6lf\n",qx,2*y1-qy);
            continue;
        }

      double a1,a2,b1,b2,x,y,t;
      a1=(y2-y1)/(x2-x1);
      a2=(-1)/a1;
      b1=y1-a1*x1;
      b2=qy-a2*qx;
      t=(b2-b1)/(a1-a2);
      x=2*t-qx;
      y=x*a2+b2;
        printf("%.6lf %.6lf\n",x,y);
    }
}


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

using namespace std;

int ans, n, k, d[100], a[100][100];
vector<int> v;

int main(){
	cin >> n >> k;
	v.resize(n);
	for(int i = 0; i < k; ++i){
		cin >> d[i];
		for(int j = 0; j < d[i]; ++j){
			cin >> a[j][d[i]];
			v[--a[j][d[i]]]++;
		}
	}
	for(int i = 0; i < n; ++i) if(v[i] == 0) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 3632
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""
 
"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""
 
"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""
 
# 最大公約数 と 最小公倍数
"""def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g"""
 
# 二分探索
"""import bisect # 二分探索
print(A,bisect.bisect_left(A,4))
print(C,n - bisect.bisect_right(C,4))
print(sum(bisect.bisect_left(A,b) * (n-bisect.bisect_right(C,b)) for b in B))"""
 
# 円周率 pi
"""import math
pi_ = math.pi"""
 
# エラトステネスの篩
"""def Erato(n):
    prime = []
    is_prime = [True] * (n+1)
    p = 0
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,n+1):
      if is_prime[i] == True:
        prime.append(i)
        p += 1
        for j in range(2 * i,n+1,i):
          is_prime[j] = False
    return p"""
 
def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  Fizz = [0] * n
  for i in range(1,n+1):
    if i % 15 == 0:
      pass
    elif i % 3 == 0:
      pass
    elif i % 5 == 0:
      pass
    else:
      Fizz[i-1] = i
  print(sum(Fizz))
if __name__ == '__main__':
  main()

Measured memory_bytes: 33380
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int h,w;
    	while(true){
    		h = scan.nextInt();
    		w = scan.nextInt();
    		if(h == 0 && w == 0) break;
     		for(int i=0;i<h;i++){
    			for(int j=0;j<w;j++){
    				if(i == 0 || i == h-1 || j == 0 || j == w-1) System.out.print("#");
    				else System.out.print(".");
    			}
    			System.out.println();
    		}
     		System.out.println();
    	}
    }
}

Measured memory_bytes: 24616
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

bool isKaibun(string S){
    bool ret = true;
    rep(i, S.size()/2){
        ret &= (S[i] == S[S.size()-1-i]);
    }
    return ret;
}

bool isSame(string l, string r){
    bool ret = true;
    rep(i, min(l.size(), r.size())){
        ret &= (l[i] == r[r.size()-1-i]);
    }
    return ret;
}

int N;
string S[50];
ll C[50];

map<pair<string, string>, ll> dp;
ll solve(string l, string r){
    if(dp.count({ l,r })) return dp[{l, r}];
    dp[{l, r}] = 1e18L;
    ll ret = 1e18L;
    if(l.size() == 0){
        if(isKaibun(r)) return dp[{l, r}] = 0;
        rep(j, N){
            if(isSame(S[j], r)){
                string sl = S[j];
                string sr = r;
                if(sl.size() > sr.size()){
                    sl = sl.substr(sr.size(), sl.size()-sr.size());
                    sr = "";
                }
                else{
                    sr = sr.substr(0, sr.size()-sl.size());
                    sl = "";
                }
                ret = min(ret, solve(sl, sr) + C[j]);
            }
        }
    }
    if(r.size() == 0){
        if(isKaibun(l)) return dp[{l, r}] = 0;
        rep(j, N){
            if(isSame(l, S[j])){
                string sl = l;
                string sr = S[j];
                if(sl.size() > sr.size()){
                    sl = sl.substr(sr.size(), sl.size()-sr.size());
                    sr = "";
                }
                else{
                    sr = sr.substr(0, sr.size()-sl.size());
                    sl = "";
                }
                ret = min(ret, solve(sl, sr) + C[j]);
            }
        }
    }
    return dp[{l, r}] = ret;
}

signed main(){
    cin >> N;
    rep(i, N){
        cin >> S[i] >> C[i];
    }

    ll ans = 1e18L;
    rep(i, N){
        ans = min(ans, solve(S[i], "") + C[i]);
    }
    if(ans == 1e18L) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3692
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30, mod=1e9+7;
const int maxn=23333;

int n,k;
int a[maxn];

int main(){
	int ans=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		int cnt=0, cnt2=0;
		for(int j=i+1;j<=n;j++){
			if(a[i] > a[j])++ cnt;
		}
		for(int j=1;j<=i-1; j++)
			if(a[i]>a[j]) ++ cnt2;
		(ans += 1ll*k*(k+1)/2 % mod * cnt % mod )%=mod;
		(ans += 1ll*k*(k-1)/2 % mod * cnt2 % mod )%=mod;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem173d(n, a))
}

fun problem173d(n: Int, a: List<Long>): Long {
    val a = a.sortedDescending()
    var ans = 0L

    ans += a[0]
    var current = 1
    var count = 0
    for (i in 1 until n - 1) {
        if (count == 2) {
            count = 0
            current++
        }
        ans += a[current]
        count++
    }
    return ans
}

Measured memory_bytes: 68380
#!/usr/bin/env python

from sys import stdin, stderr

def main():
   S = stdin.readline().strip()
   if (len(S) % 2) != 0:
      print('No')
      return 0
   for i in xrange(0, len(S), 2):
      if S[i:i+2] != 'hi':
         print('No')
         return 0
   print('Yes')

   return 0

if __name__ == '__main__': main()


Measured memory_bytes: 2568
/**
 *      ABC 61 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 21:37:52
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, M; cin >> N >> M;
    int a[M] = {}; int b[M] = {};
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
    }
    int count[N + 10] = {};
    for (int i = 0; i < M; ++i) {
        ++count[a[i]];
        ++count[b[i]];
    }
    for (int i = 1; i <= N; ++i) {
        cout << count[i] << endl;
    }

    return 0;
}


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

int main(){
	string str;
	int a=0,b=0,o=0,ab=0;
	while(cin >> str){
		if(str[str.size () -1] == 'A') a += 1;
		else if(str[str.size() - 1] == 'B') {
			if(str[str.size() -2] == 'A') ab += 1;
			else b += 1;
		}
		else if (str[str.size() - 1]) o += 1;

	}
	cout << a << endl << b << endl << ab << endl << o << endl;
	return 0;
}

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

using namespace std;

#define ll long long

const int maxn = 1e5 + 5;

int n, k;
ll sol, sum;
ll a[maxn];
ll b[maxn];

int main(){
	cin >> n >> k;
	
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	for(int i = 1; i <= n; i++) b[i] = b[i - 1] + a[i];
	
	for(int i = k + 1; i <= n; i++) sum += max(0LL, a[i]);
	
	for(int i = 1; i <= n - k + 1; i++){
		ll x = sum + max(0LL, b[i + k - 1] - b[i - 1]);
		
		sol = max(sol, x);
		
		sum += max(0LL, a[i]);
		
		sum -= max(0LL, a[i + k]);
	}
	
	cout << sol;
	
	return 0;
}

Measured memory_bytes: 5164
from operator import itemgetter

def solve():
    N = int(input())
    X = []
    for i in range(N):
        xx, ll = map(int, input().split())
        X.append((xx-ll, xx+ll))
    X.sort(key=itemgetter(1))
    count = 0
    cur = -float('inf')
    for i in range(N):
        c, d = X[i]
        if cur <= c:
            count += 1
            cur = d
    return count

print(solve())


Measured memory_bytes: 18276