akhauriyash/Code-Regression huggingface dataset:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    h,w,k = readInt()
    c = []
    for i in range(h):
        c.append(input())
    ans = 0
    for i in range(1<<h):
        for j in range(1<<w):
            res = 0
            for l in range(h):
                if (i>>l)&1:
                    for m in range(w):
                        if (j>>m)&1:
                            if c[l][m]=='#':
                                res += 1
            if res==k:
                ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9200
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    d = list(map(int,input().split()))
    if d[0] != 0:
        print(0)
    else:
        MOD = 998244353
        use = [0 for _ in range(max(d)+1)]
        for num in d:
            use[num] += 1
        if use[0] != 1:
            print(0)
        else:
            ans,pa = 1,1
            for num in use:
                ans *= pow(pa,num,MOD)
                ans %= MOD
                pa = num
            print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 11644
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=998244353;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2LL*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll a, b;
char x;

int main(void)
{
	cin>>a>>x>>b;
	if(x=='+') cout<<a+b;
	else cout<<a-b;
	return 0;
}
// 제출하기 전에 생각햇나요?
// it may be easier/harder than you think
// ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class31
    {
        static readonly long M = 998244353;
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int m = d.Max();
            var D = new int[m + 1];
            for (int i = 0; i < N; i++) D[d[i]]++;
            
            if (d[0] != 0 || D[0] != 1) { Console.WriteLine(0);return; }

            long ans = 1;
            for(int i = 1; i <= m; i++)
            {
                for(int j = 0; j < D[i]; j++)
                {
                    ans *= D[i - 1];
                    ans %= M;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 20320
#include <stdio.h>
#include <string.h>

int main(){
  char o[55], e[55];
  scanf("%s %s", o, e);
  for(int i=0; i<strlen(e); i++)
    printf("%c%c", o[i], e[i]);
  if(strlen(o)-strlen(e))
    printf("%c\n", o[strlen(o)-1]);

  return 0;
}

Measured memory_bytes: 128
import math
degree =int(input())
degree = math.radians(degree)
count = [1]
x, y = 0, 0
for i in count:
    xi, yi = math.cos(i * degree), math.sin(i * degree)
    x += xi
    y += yi
    if -0.000001 <= x<= 0.000001 and -0.000001 <= y<= 0.000001:
        print(i)
    else:
        count.append(i+1)

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

int x[1001], y[1001];
bool v[1001];
int p[1001];
double d[1001];
double edge[1001][1001];
int INF = (1 << 20);

void compute(int i, int j) {
  double temp = sqrt(((double)x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
  if (temp <= 50) edge[i][j] = temp;
}

void dijkstra(int s, int g, int n) {
  int mn,hozon,b, cnt = 0;
  int a[1001];

  // init
  
  for(int i = 0; i <= 1000; i++) {
    v[i] = false;
    p[i] = 0;
    d[i] = INF;
    a[i] = 0;
  }
  
  //cout << "init: " << v[1] << " " << p[5] << " " << d[7] << " " << a[8] << endl;

  //cout << "dijkstra in" << endl;
  d[s] = 0;

  for(;;) {
    mn = INF;

    //tmp=hozon;
    for(int i = 1; i <= 1000; i++) {
      if(mn > d[i] && !v[i]) {
	mn = d[i];
	hozon = i;
      }
    }
    //via[hozon]=tmp;
    if(mn == INF) break;

    v[hozon] = true;
    
    for(int j = 1; j <= 1000; j++) {
      if(edge[hozon][j]==INF)continue;
      if(d[j] > d[hozon] + edge[hozon][j] && !v[j]) {
	//if(hozon==19)cout<<j<<" "<<d[j]<<" "<<edge[hozon][j]<<endl;
	d[j] = edge[hozon][j] + d[hozon];
	p[j] = hozon;
	//cout<<p[j]<<" "<<j<<endl;                    1657 2225 3872
      }
    }
  }
  if(d[g] == INF) {
    cout << "NA" << endl;
  } else {
    b = p[g];// cout << "goal's p: " << p[g] << endl;   842 1800 900 3542
    while(1){
      // cout << "test" << endl;
      if (b == s){
	a[cnt++]=b;
	break;
      }
      a[cnt++] = b;
      b = p[b];
    }
    
    for(int i = cnt-1; i >= 0; i--) {
      cout << a[i] << " ";
    }
    cout <<g<< endl;
  }
}

int main (void) {
  int s, g;
  int n;
  int b, m;

  while(1) {
    
    cin >> n; if (n == 0) break;
    
    for(int i = 1; i <= n; i++) {
      cin >> b;
      cin >> x[b] >> y[b];
    }
    
    for(int i = 1; i <= 1000; i++) {
      for(int j = 1; j <= 1000; j++) {
	edge[i][j] = INF;
	if(i != j) compute(i, j);
      }
    }
    
    cin >> m; //cout << "m: " << m << endl;
    
    for(int i = 1; i <= m; i++) {
      cin >> s >> g;
      dijkstra(s, g, n);
    }
    
  }
  
  return 0;
}

Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define BIT(n) (1LL<<(n))
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
int main(void){
    // Your code here!
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    vector<int> v;
    v.push_back(a[0]);
    v.push_back(a[1]);
    v.push_back(a[2]);
    sort(ALL(v));
    
    int count;
    int max;
    int remain = (v[2]-v[1])+(v[2]-v[0]);
    if (remain%2==1){
        max = v[2]+1;
        count = 1;
        v[0] += 1;
    }
    else{
        max = v[2];
        count =0;
    }
    count += ((max-v[1])+(max-v[0]))/2;
    
    
    
    cout << count << endl;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s;
	cin>>s;
	rep(i,2){
		if(s[i]-'0'==9){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fir first
#define sec second
#define pb push_back
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 int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

bool check(int a){
	for (int i = 1; i < 130; i++){
		int d = i*i;
		if(a==d) return true;
	}
	return false;
}

int main(){
	int a;
	cin >> a;
	cout << a * a * 3 << endl;
	return 0;
}


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

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

    vector<vector<int>> g(n);
    g[x - 1].push_back(y - 1);
    g[y - 1].push_back(x - 1);
    rep (i, n - 1)
    {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }

    vector<int> ans(n);
    rep (sv, n)
    {
        vector<int> dist(n, -1);
        queue<int> que;
        dist[sv] = 0;
        que.push(sv);
        while (!que.empty())
        {
            int v = que.front();
            que.pop();
            for (int nv : g[v])
            {
                if (dist[nv] != -1)
                    continue;
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }
        rep (i, n)
            ans[dist[i]]++;
    }

    for (int i = 1; i < n; i++)
        cout << ans[i] / 2 << endl;
    return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    long long s = 0;
    for (int i = 1; i <= n; i++) {
        if (i%3 > 0 && i%5 > 0) {
            s += i;
        }
    }
    cout << s << endl;
}



Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	
	if(a == 1 && b != 1)
	{
		cout << "Alice" << endl;
	}
	else if(a != 1 && b == 1)
	{
		cout << "Bob" << endl;
	}
	else if(a > b)
	{
		cout << "Alice" << endl;
	}
	else if(a == b)
	{
		cout << "Draw" << endl;
	}
	else
	{
		cout << "Bob" << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    vector<int> B(N);
    for (int i = N; i >= 1; i--) {
        int cnt = 0;
        for (int j = N / i; j >= 2; j--) {
            cnt += B[i * j - 1];
        }
        if (cnt % 2 != A[i - 1]) {
            B[i - 1] = 1;
        }
    }
    int M = 0;
    vector<int> ans;
    for (int i = 0; i < N; i++) {
        if (B[i] == 1) {
            M++;
            ans.push_back(i + 1);
        }
    }
    cout << M << endl;
    for (int i = 0; i < ans.size(); i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << ans[i];
    }
    return 0;
}


Measured memory_bytes: 3064
from itertools import combinations


def main():
    N, M, X = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(N)]
    money = float('inf')

    for i in range(N):
        # print(f"{i=}")
        a = combinations(range(N), i + 1)
        for s in a:
            tmp_money = 0
            rikai = [0] * M
            # print(f"{s=}")
            for x in s:
                # print(f"{x=}")
                tmp_money += A[x][0]
                for m in range(M):
                    rikai[m] += A[x][m + 1]
            # print(f"{rikai=}")
            if min(rikai) >= X:
                money = min(money, tmp_money)
    if money == float('inf'):
        print(-1)
    else:
        print(money)


if __name__ == '__main__':
    main()


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

int main() {
  vector <int> V;
  for (auto i=0; i<10; i++) {
    int h;
    cin >> h;
    V.push_back(h);
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  cout << V[0] << endl;
  cout << V[1] << endl;
  cout << V[2] << endl;
}

Measured memory_bytes: 1212
import copy

def solve():
    H, W, K = map(int,input().split())
    C = [list(input()) for _ in range(H)]

    ans = 0

    for bitH in range(2**(H) - 1):
        for bitW in range(2**(W) - 1):
            Ctmp = copy.deepcopy(C)
            for i in range(H):
                if((bitH >> i) & 1):
                    Ctmp[i] = ["x" for _ in range(W)]
            Ctmp_t = [list(x) for x in zip(*Ctmp)]
            
            for j in range(W):
                if((bitW >> j) & 1):
                    Ctmp_t[j] = ["x" for _ in range(H)]
            
            Clast = [list(x) for x in zip(*Ctmp_t)]
            
            cnt = 0
            
            for s in range(H):
                cnt += Clast[s].count("#")
            
            if cnt == K:
                ans += 1
            
            # for i in range(H):

            # #     print(Clast[i])
            # # print(bitH, bitW)
            # # print(cnt)
    print(ans)

solve()

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

int main() {
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for (int i=0;i<N;i++) {
    cin >> vec.at(i);
  }
  int A=0;
  sort(vec.begin(), vec.end());
  for (int i=0;i<N-1;i++) {
    if (vec.at(i)==vec.at(i+1)) {
      A++;
    }
  }
cout << N - A << endl;    
}


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

using namespace std;

int main(){
    int AB[3][3];
    int b[3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>AB[i][j];
        }
    }
    for(int a=0;a<=100;a++){
        b[0]=AB[0][0]-a;
        b[1]=AB[0][1]-a;
        b[2]=AB[0][2]-a;
        if(AB[1][0]-b[0]==AB[1][1]-b[1]&&AB[1][1]-b[1]==AB[1][2]-b[2]&&AB[2][0]-b[0]==AB[2][1]-b[1]&&AB[2][1]-b[1]==AB[2][2]-b[2]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main(){
    int n;
    double ans = 0;
    cin >> n;
    double a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        ans += 1.0 / a[i];
    }

    ans = 1.0 / ans;
    printf("%.6f\n", ans);
    return 0;
}

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

#define maxn 55

const double PI = acos(-1.0);

template<typename T>
struct point{
	T x,y;
	point(){}
	point(const T&x,const T&y):x(x),y(y){}
	point operator+(const point &b)const{
		return point(x+b.x,y+b.y); }
	point operator-(const point &b)const{
		return point(x-b.x,y-b.y); }
	point operator*(const T &b)const{
		return point(x*b,y*b); }
	point operator/(const T &b)const{
		return point(x/b,y/b); }
	bool operator==(const point &b)const{
		return x==b.x&&y==b.y; }
	T dot(const point &b)const{
		return x*b.x+y*b.y; }
	T cross(const point &b)const{
		return x*b.y-y*b.x; }
	point normal()const{//求法向量
		return point(-y,x); }
	T abs2()const{//向量長度的平方
		return dot(*this); }
	T rad(const point &b)const{//兩向量的弧度
return fabs(atan2(fabs(cross(b)),dot(b))); }
	T getA()const{//對x軸的弧度 
		T A=atan2(y,x);//超過180度會變負的 
		if(A<=-PI/2)A+=PI*2;
		return A;
	}
};

point<double> circumcenter(const point<double> &a, const point<double> &b, const point<double> &c) {
	point<double> u = b-a, v =c-a;
	double c1 = u.abs2()/2, c2 = v.abs2()/2;
	double d = u.cross(v);
	return point<double>(a.x+(v.y*c1-u.y*c2)/d, a.y+(u.x*c2-v.x*c1)/d);
}
void solve(point<double> p[], int n, point<double> &c, double &r2){
	random_shuffle(p,p+n);
	c = p[0]; r2 = 0; // c,r2 = 圓心,半徑平方
	for(int i=1; i<n; i++)
		if( (p[i]-c).abs2() > r2) {
			c=p[i]; r2=0;
			for(int j=0; j<i; j++)
				if( (p[j]-c).abs2() > r2) {
					c.x = (p[i].x+p[j].x)/2;
					c.y = (p[i].y+p[j].y)/2;
					r2 = (p[j]-c).abs2();
					for(int k=0; k<j; k++)
						if( (p[k]-c).abs2() > r2) {
							c = circumcenter(p[i], p[j], p[k]);
							r2 = (p[i]-c).abs2();
						}
				}
		}
}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	int n; //cin >> n;
	scanf("%d",&n);
	point<double> p[maxn];

	for(int i=0; i<n; i++)
	{
		scanf("%lf%lf",&p[i].x,&p[i].y);
		//cin >> p[i].x >> p[i].y;
	}

	point<double> c;
	double r;
	solve(p,n,c,r);
	printf("%.7f\n",sqrt(r));
	return 0;
}

Measured memory_bytes: 256
N,K = map(int, input().split())
S = [[int(s) for s in input().split()] for _ in range(K)]
mod = 998244353

dp = [0]*N
dp[0] = 1
if N > 2:
    dp[1] = -1
for i in range(N):
    if N > 2:
        dp[i] += dp[i-1]
    dp[i] %= mod
    for s in S:
        if s[0]+i < N:
            dp[s[0]+i] += dp[i]
            dp[s[0]+i] %= mod
        if s[1]+i+1 < N:
            dp[s[1]+i+1] -= dp[i]
            dp[s[1]+i+1] %= mod
print(dp[-1])

Measured memory_bytes: 69800
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<math.h>
#include<cstdio>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int inf=1000000007;

struct Point{
  double x;
  double y;
  double dist2(double cx,double cy){
    double dx=(double)x-cx;
    double dy=(double)y-cy;
    double res=dx*dx+dy*dy;
    return sqrt(res);
  }
};
double rr(vector<Point> buf,double& ox,double& oy){
  int n=3;
  double x1,x2,x3,y1,y2,y3,r;
  x1=buf[0].x;x2=buf[1].x;x3=buf[2].x;
  y1=buf[0].y;y2=buf[1].y;y3=buf[2].y;
  if(y1==y2&&y1==y3){
      return (double)inf+5.0;
  }
  if(x1==x2&&x1==x3){
      return (double)inf+5.0;
  }
		ox=((y2-y1)*((y3*y3-y1*y1)+(x3*x3-x1*x1))-(y3-y1)*((y2*y2-y1*y1)+(x2*x2-x1*x1)))/
				(2*((x3-x1)*(y2-y1)-(x2-x1)*(y3-y1)));
		if(y2 != y1){
			oy=(2*(x1-x2)*ox+(y2*y2-y1*y1)+(x2*x2-x1*x1))/(2*(y2-y1));
		}else if(y1!=y3){
			oy=(2*(x1-x3)*ox+(y3*y3-y1*y1)+(x3*x3-x1*x1))/(2*(y3-y1));
		}
        else oy=inf+5.0;
		r = sqrt((ox-x1)*(ox-x1)+(oy-y1)*(oy-y1));
    return r;
}
bool judge(double r,double ox,double oy,vector<Point>& p,int n){
  bool ans=true;
  rep(i,n){
    if(p[i].dist2(ox,oy)>r)ans=false;
    }
return ans;
}
signed main(){
  int n;cin>>n;
  vector<Point> p(n);
  rep(i,n){
    Point buf;
    cin>>buf.x>>buf.y;
    p[i]=buf;
  }
  double min=(double)inf;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
          if(i==j||j==k||k==i)continue;
        vector<Point> buf(3);
        buf[0]=p[i];
        buf[1]=p[j];
        buf[2]=p[k];
        double ox=0.0;double oy=0.0;
        double tmp=rr(buf,ox,oy);
        if(min>tmp&&judge(tmp,ox,oy,p,n))min=tmp;
      }
    }
  }
  for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
          double buf;
          buf=p[i].dist2((double)p[j].x,(double)p[j].y)/2.0;
          double cx=(double)p[i].x+(double)p[j].x;
          double cy=(double)p[i].y+(double)p[j].y;
          if(min>buf&&judge(buf,cx/2.0,cy/2.0,p,n))min=buf;
      }
  }
  printf("%.16lf\n",min);
  return 0;
}


Measured memory_bytes: 256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

// lld fac[2000005]; 

// void getfac(lld p)
// {
//     fac[0] = 1; 
//     for (lld i=1 ; i<=2000005; i++) 
//         fac[i] = fac[i-1]*i%p; 
// }    

// long long int nCrmodp(lld n, lld r,lld p) 
// { 
//    // Base case 
//    if (r==0) 
//       return 1; 
     
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }



// lld maxSumSub(vector<lld>& v , lld l)
// {
//     lld x = 0;
//     lld y =0 ;
//     for(i=0;i<l;i++)
//     {
//         y += v[i];
//         if(x<y)
//         {
//             x=y;

//         }
//         if(y<0)
//             y=0;
//     }
//     return x;
// }


lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;

// bool sorter(lld a, lld b)
// {
//     vector<lld> v2;
//     vector<lld> w;
//     // cout<<"A == " <<a<<"  B== "<<b;
//     while(a>=1)
//     {
//         v2.pb(a%10);
//         a/=10;
//     }
//     while(b>=1)
//     {
//         w.pb(b%10);
//         b/=10;
//     }   
       
//     reverse(all(v2));
//     reverse(all(w));
//     lld l1 = v2.size();
//     lld l2 = w.size();
//     lld  l = (l1*l2)/__gcd(l1,l2);
//     // cout<<l1<< " "<<l2<< " "<<l<< " ";
//     for(int i=0;i<l;i++)
//     {
//         if(v2[i%l1]!=w[i%l2])
//         {
//             // cout<< "   "<< (v2[i%l1] > w[i%l2])<<"\n";
//             return v2[i%l1] > w[i%l2];
//         }
//     }
//     // printf("false\n");
//     return false;
// }


void solve()
{
    cin>>n;
    cout<< (n + n*n*(n+1));    
}

int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
   // cin>>t;
    //cout<<t;
    // getfac(p1);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3636
//~14:54
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    set<int> costs;
    int input, front_cost, back_cost = 0;
    for (int i = 0; i < m; i++){
        cin >> input;
        costs.insert(input);
    }
    
    for (int i = 0; i < x; i++){
        if(costs.count(i) == 1){//料金所
            front_cost++;
        }
    }

    for (int i = x+1; i < n; i++){
        if(costs.count(i) == 1){//料金所
            back_cost++;
        }
    }

    if(front_cost > back_cost){
        cout << back_cost << endl;
    }else{
        cout << front_cost << endl;
    }
}

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

priority_queue<int> pq;
long long sum = 0;
int x, y, a, b, c;

void add(int x) {
    pq.push(-x);
    sum += x;
    if (pq.size() > y)  sum -= -pq.top(), pq.pop();
}

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


    cin>>x>>y>>a>>b>>c;
    vector<int> red(a), green(b), white(c);

    for (int i=0; i<a; i++) cin>>red[i];
    for (int i=0; i<b; i++) cin>>green[i];
    for (int i=0; i<c; i++) cin>>white[i];
    sort(red.rbegin(), red.rend());
    sort(green.rbegin(), green.rend());
    sort(white.rbegin(), white.rend());

    int minred = max(0, x-c);
    long long redsum = 0;
    for (int i=0; i<minred; i++)    redsum += red[i];
    for (int i=0; i<x-minred; i++)  redsum += white[i];
    for (int i=x-minred; i<c; i++)  add(white[i]);
    for (int x: green)  add(x);

    long long ans = 0;

    for (int i=minred; i<=x; i++) {
        ans = max(ans, redsum + sum);
        redsum += red[i];
        if (x == i) break;
        redsum -= white[x-i-1];
        add(white[x-i-1]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 2044
n = int(input())
AB = [list(map(int,input().split())) for _ in range(n)]
CD = [list(map(int,input().split())) for _ in range(n)]

que = [[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if AB[i][0] < CD[j][0] and AB[i][1] < CD[j][1]:
      que[j].append(i)

def dfs(i,v):
  
  for a in que[i]:
    if a in v:
      continue
    v.add(a)
    if ab[a] == -1 or dfs(ab[a], v):
      ab[a] = i
      return True
  return False
      
v = [set() for _ in range(n)]   
ab = [-1]*n

print(sum(dfs(i, set()) for i in range(n))) 

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

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	for(int i=0; i<N; ++i){
		cin >> A[i] >> B[i];
	}
	cin.ignore();
	int times = 0;
	bool last = 0;
	bool ans = 0;
	for(int j=0; j<N; ++j){
		if(A[j] == B[j]){
			if(last){
				++times;
				if(times==3){
					ans = 1;
					break;
				}
			}else{
				times = 1;
			}
			last = 1;
		}else{
			last = 0;
		}
	}
	if(!ans){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef pair<int,int> P;

const int dice[7][4]={
  {},
  {5,4,2,3}, //1
  {6,3,1,4}, //2
  {5,1,2,6}, //3 
  {5,6,2,1}, //4
  {6,4,1,3}, //5
  {5,3,2,4}  //6
};
int ans[6];
int Fdice[6]; 
/*
0 -> top
1 -> front
2 -> right 
3 -> R-front
4 -> R-right
5 -> R-top
 */


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


P graph[500][500];//first -> roll, second -> height

void CreateFdiceForYou(int top,int front){
  int frontIsHere;
  rep(i,4){
    if(dice[top][i] == front){
      frontIsHere = i;
      break;
    }
  }

  Fdice[0] = top;
  Fdice[5] = 7-top;

  rep(i,4){
    if(frontIsHere == 4)frontIsHere = 0;
    Fdice[i+1] = dice[top][frontIsHere++];
  }
  /*
  rep(i,6){
    cout << i << "番目は" << Fdice[i] << endl;
  }
  */

}


void Display(){

  REP(i,240,260){
      REP(j,240,260){
	cout << graph[i][j].first<< " ";
      }
      cout << endl;
    }

}

int Boxing(int front,int dir){
  if(dir == 1){
    return 0;
  }
  if(dir == 2){
    return 1;
  }
  if(dir == 3){
    return 5;
  }
  if(dir == 4){
    return 1;

  }
}


void decideTheDestinyOfTheDice(int x,int y,int top,int front){
  P choice = P(-1,-1);
  int roll,Here;
  roll = Here = 0;
  CreateFdiceForYou(top,front);
  rep(i,4){
    P p = P(x+dx[i],y+dy[i]);
    if(graph[p.second][p.first].second < graph[y][x].second){
      if(Fdice[i+1] == 4 || Fdice[i+1] == 5 || Fdice[i+1] == 6){
	if(roll < Fdice[i+1]){
	  roll = Fdice[i+1];
	  Here = i+1;
	  choice = P(p.first,p.second);
	}
      }
    }
  }

  if(choice == P(-1,-1)){
    graph[y][x] = P(top,graph[y][x].second+1);
  }
  else{
    int dir = Boxing(front,Here);
    decideTheDestinyOfTheDice(choice.first,choice.second,7-roll,Fdice[dir]);
  }
  return;
}


int main(){
  int n,t,f;
  while(cin >> n && n){
    rep(i,500)rep(j,500)graph[i][j] = P(0,0);
    rep(i,6)ans[i] = 0;    

    rep(i,n){
      cin >> t >> f;
      decideTheDestinyOfTheDice(250,250,t,f);
    }

    REP(i,100,400){
      REP(j,100,400){
	if(graph[i][j].second != 0){
	  ans[graph[i][j].first-1]++;
	}
      }
    }

    rep(i,6){
      cout << ans[i];
      if(i != 5)cout << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    ll n,x,m;
    cin >> n >> x >> m;
    ll loop, loopsum, st;
    ll ans = 0;
    ans += x/m * m;
    x = x%m;
    VI v(m+1,0);
    v[x] = 1;
    VI sum(m+1,0);
    sum[1] = x;
    for(i=2;i<=101010;i++){
        x = (x * x) % m;
        sum[i] = sum[i-1] + x;
        if(v[x] > 0){
            loop = i - v[x];
            loopsum = sum[i] - sum[v[x]];
            st = v[x];
            break;
        }
        else {
            v[x] = i;
        }
    }
    if(n<=st+loop){
        cout<<sum[n]<<endl;
        return 0;
    }
    else{
        n -= st;
        ans += sum[st];
        ans += (n/loop) * loopsum;
        ll rest = n % loop;
        ans += sum[st+rest] - sum[st];
    }
    cout<<ans<<endl;

}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

set<int> edge[2];

int main(){
    cin.sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        if (a == 1) edge[0].insert(b);
        else if (b == 1) edge[0].insert(a);
        if (a == n) edge[1].insert(b);
        else if (b == n) edge[1].insert(a);
    }

    if (edge[0].count(n)) {
        cout << "POSSIBLE" << endl;
    } else {
        bool ok = false;
        each(i, edge[0]) {
            ok |= edge[1].count(i);
            if (ok) break;
        }
        if (ok) cout << "POSSIBLE" << endl;
        else cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {

    int N, M;
    cin >> N >> M;
    vector<pair<int, char>> D(M);
    REP(i, M) {
        int s;
        char c;
        cin >> s;
        cin >> c;
        s--;
        D[i].first = s;
        D[i].second = c;
    }

    int maxValue = pow(10, N);
    int minValue;
    if (N == 1) {
        minValue = 0;
    } else {
        minValue = pow(10, N-1);
    }
    
    int ans = -1;
    for (int x = minValue; x < maxValue; x++) {
        string num = to_string(x);
        bool flag = true;
        for (int i = 0; i < M; i++) {
            if (num[D[i].first] != D[i].second) {
                flag = false;
                break;
            }
        }
        if (flag) {
            ans = x;
            break;
        }
    }
    
    print(ans);

}

signed main() {
    solve();
}


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

using namespace std;

int64_t solve(int64_t a, int64_t b) {
  return std::max({a + b, a * 2 - 1, b * 2 - 1});
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t a;
  std::cin >> a;
  int64_t b;
  std::cin >> b;
  auto const res = solve(a, b);
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve (void)
{
  int N,K; cin>>N; cin>>K;
  vector<int> vec (N,0);
  for (int i = 0; i < K; i++)
  {
    int P;cin>>P;
    for (int j = 0; j < P; j++)
    {
      int X;cin>>X;
      X--;
      vec[X]++;
    }
    
  }
  int cnt = 0;
  for (int i = 0; i < N; i++)
  {
    if(vec[i] == 0)cnt++;
  }
  cout<<cnt<<endl;
  
  
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    deque<char> dq;
    rep(i, s.size()) dq.push_back(s[i]);
    int q;
    cin >> q;
    bool rev = false;
    rep(i,q){
        int t;
        cin >> t;
        if (t == 1){
            rev = !rev;
        }else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1){
                if (rev) dq.push_back(c);
                else dq.push_front(c);
            }else{
                if (rev) dq.push_front(c);
                else dq.push_back(c);   
            }
        }
    }
    string ans = "";
    if (rev) {
        while(!dq.empty()){
            ans += dq.back(); dq.pop_back();
        } 
    }else{
        while(!dq.empty()){
            ans += dq.front(); dq.pop_front();
        } 
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int c,d;
    cin>>c>>d;
    if(c>d){
        cout<<"a > b"<<endl;
    }
    else if(c<d){
        cout<<"a < b"<<endl;
    }
    else{
        cout<<"a == b"<<endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>

struct IO {
  IO &operator>>(int &x) {
    char c;
    do
      c = std::cin.rdbuf()->sbumpc();
    while (!isdigit(c));
    for (x = 0; isdigit(c); c = std::cin.rdbuf()->sbumpc())
      x = x * 10 + (c ^ 48);
    return *this;
  }
} io;

const int MAX_N = 100000;

int f[3];

int main() {
  int n;
  io >> n;
  for (int i = 0, a, b, c; i < n; ++i) {
    io >> a >> b >> c;
    const int u = f[0], v = f[1], w = f[2];
    f[0] = std::max(v, w) + a;
    f[1] = std::max(u, w) + b;
    f[2] = std::max(u, v) + c;
  }
  std::cout << std::max(std::max(f[0], f[1]), f[2]);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Yes(X) puts ( (X) ? "Yes" : "No")
#define YES(X) puts ( (X) ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = (a); i < (b) ; i++)
#define rep(i, n) for ( int i = 0; i < (n) ; i++)
const int MOD = 1000000007;
typedef long long ll;
typedef unsigned  u;
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}
/* main */
int main() {
  int a, b;
  cin >> a >> b;
  cout << max(max(a + b, a - b), a * b);
}


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

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)
#define SUMV(v)		(accumulate(v.begin(),v.end(),0.0))

#define INF 		2000000007
#define MOD			998244353

#define MAX 		100000

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int ll;

int dp[MAX+5];

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

	int d[] = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};

	fill(dp,dp+MAX+3,INF);
	dp[0]=0;
	for(int t:d){
		REP(i,MAX+1){
			if(i+t>MAX)break;
			dp[i+t] = min(dp[i+t],dp[i]+1);
		}
	}
	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int n;
	cin >> n;

	vector<int>a(n);

	REP(i, n) cin >> a[i];

	int ok = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				ok = 0;
				break;
			}
		}
	}

	if (ok) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;

	return 0;

}

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

/*
int main(){

 int n;
 cin>>n;

 float ans =(n/3);

 float vol =(ans*ans*ans);

 cout<<setprecision(20);
 cout<<vol<<endl;

return 0;
}

*/


bool good(string s){

 string t(s.rbegin(),s.rend());

 return t == s;
}

 int main(){

  string s; cin>>s;
  int n = s.size();

  if(good(s.substr(0,n/2)) && good(s.substr(n/2+1,n)) && good(s))
    cout<<"Yes"<<endl;
  else
     cout<<"No"<<endl;


 return 0;
 }


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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> p(n, k- q);

  rep(i, q){
    int a;
    cin >> a;
    --a;
    p[a]++;
  }

  rep(i, n){
    if(p[i] <= 0) puts("No");
    else puts("Yes");
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int dp[101][4][4][4];
int n;
const int mod=1e9+7;

int main(){
    cin>>n;
    
    dp[0][3][3][3]=1;
    for (int len=0;len<n;len++){
        for (int c1=0;c1<4;c1++){
            for (int c2=0;c2<4;c2++){
                for (int c3=0;c3<4;c3++){
                    if (dp[len][c1][c2][c3]==0) continue;
                    
                    for (int a=0;a<4;a++){
                        if (a==2 && c3==1 && c2==0) continue;
                        if (a==2 && c3==0 && c2==1) continue;
                        if (a==1 && c3==2 && c2==0) continue;
                        if (a==2 && c3==1 && c1==0) continue;
                        if (a==2 && c2==1 && c1==0) continue;
                        
                        dp[len+1][c2][c3][a]+=dp[len][c1][c2][c3];
                        dp[len+1][c2][c3][a]%=mod;
                    }
                }
            }
        }
    }
    ll ans=0;
    for (int i=0;i<4;i++){
        for (int j=0;j<4;j++){
            for (int k=0;k<4;k++){
                ans+=dp[n][i][j][k];
                ans%=mod;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
while True:
    n, m = [int(x) for x in input().split()]
    if n == 0 and m == 0:
        break

    L = []
    M = []
    for _ in range(n):
        L.append(int(input()))

    for _ in range(m):
        M.append(int(input()))

    diff = sum(M) - sum(L)
    if diff %2:
        print(-1)
        continue
    else:
        diff = diff//2

    f = 0
    setm = set(M)
    for i in sorted(set(L)):
        j = i + diff
        if j in setm:
            f += 1
            break

    if f > 0:
        print(i,j)
    else:
        print(-1)



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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

struct Edge {
    int to;     // 辺の行き先
    int cost; // 辺の重み
    Edge(int t, int c) : to(t), cost(c) { }
};

vector<ll> dijkstra(vector<vector<Edge>> &g, int s) {
    vector<ll> dist(g.size(), inf);

    using Pli = pair<ll, int>;
    priority_queue< Pli, vector<Pli>, greater<Pli> > que;
    dist[s] = 0;
    que.emplace(dist[s], s);

    while (!que.empty()) {
        ll cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if (dist[idx] < cost) continue;

        for (auto &e: g[idx]) {
            auto next_cost = cost + e.cost;
            if (dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int main()
{   
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<vector<Edge>> G(n);

    int a, b, c;
    for (int i = 0; i < n-1; i++) {
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(Edge(b, c));
        G[b].push_back(Edge(a, c));
    }

    int q, k, x, y;
    cin >> q >> k;
    k--;
    vector<ll> cost = dijkstra(G, k);
    
    for (int i = 0; i < q; i++) {
        cin >> x >> y;
        cout << cost[x-1] + cost[y-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main() {
    int N;
    cin >> N;
    vector<int> a(N+2);
    a.at(0) = 0;
    a.at(N+1) = 0;
    for(int i=1; i<N+1;i++){
        cin >> a.at(i);
    }
    int plan = 0;
    for(int j=1; j<N+2; j++){
        plan += abs(a.at(j) - a.at(j-1));
    }
    for(int i=1; i<N+1; i++){
        int fix = 0;
        fix = -abs(a.at(i)-a.at(i-1))-abs(a.at(i+1)-a.at(i)) + abs(a.at(i-1) - a.at(i+1));
        cout <<  plan + fix << endl; 
    }
}



Measured memory_bytes: 1664
#include<stdio.h>

int main()
{
	char s[3][3];
	int i,j;
	for(i=0;i<3;i++){
		scanf("%s",s[i]);
		for(j=0;j<3;j++){
			}
	}

		printf("\n");
		
			printf("%c%c%c\n",s[0][0],s[1][1],s[2][2]);
	

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)



int main(void){
	int n;
	cin>>n;
	ll s=0;
	if(n%2==0){
		reps(i,n){
			for(int j = i+1; j <= n; j++){
				if(i+j==1+n) continue;
				s++;
			}
			
		}
		cout<<s<<endl;
		reps(i,n){
			for(int j = i+1; j <= n; j++){
				if(i+j==1+n) continue;
				cout<<i<<" "<<j<<endl;
			}
			
		}

	}

	if(n%2 == 1){
		reps(i,n-1){
			for(int j = i+1; j < n; j++){
				if(i+j==n) continue;
				s++;
			}
			
		}
		reps(i,n-1){
			s++;
		}
		cout<<s<<endl;
		reps(i,n-1){
			for(int j = i+1; j < n; j++){
				if(i+j==n) continue;
				cout<<i<<" "<<j<<endl;
			}
			
		}
		reps(i,n-1){
			cout<<i<<" "<<n<<endl;
		}
	}

	return 0;
}


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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int N;
    cin >> N;
    for (int i = 1; i <= 9; i++) {
        for (int j = i; j <= 9; j++) {
            if ( N == i * j ) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    s = input().rstrip()
    t = input().rstrip()
    length_s = len(s)
    length_t = len(t)
    res = 0
    
    for i in range(length_s-length_t+1):
        temp = 0
        for j in range(length_t):
            if s[i+j] == t[j]:
                temp+=1
        res = max(res, temp)
    
    print(length_t - res)

    
     
if __name__ == "__main__":
    main()

Measured memory_bytes: 68328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define ll long long 
const int maxn=1000010;
ll a[maxn];
ll amin[maxn],amax[maxn];
ll pow2[maxn];
ll ans; int n;
int main(){
    scanf("%d",&n);
    for (int i=0;i<=n;++i){
        scanf("%lld",&a[i]);
    }
    pow2[0]=1;
    for (int i=1;i<=n&&pow2[i-1]<=100000000;++i){
        pow2[i]=pow2[i-1]<<1;
    }
    amax[n]=amin[n]=a[n];
    bool flag=true;
    for (int i=n-1;i>=0;--i){
        amin[i]=(amin[i+1]+1)/2+a[i];
        amax[i]=amax[i+1]+a[i];
        if (pow2[i]) amax[i]=min(amax[i],pow2[i]);
        if (amin[i]>pow2[i]&&pow2[i]){
            flag=false; break;
        }
    }
    if (!flag){
        printf("-1"); return 0;
    }
    if (!n&&a[0]>1){
        printf("-1"); return 0;
    }
    ans=amax[0];
    for (int i=1;i<=n;++i){
        amax[i]=min(amax[i],(amax[i-1]-a[i-1])*2);
        amin[i]=max(amin[i],(amin[i-1]-a[i-1]));
        if (amax[i]<amin[i]){
            flag=false; break;
        }
        ans+=amax[i];
    }
    if (!flag) printf("-1");
    else printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 6076