akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const int UnionFindTree_MAX_V = 100000;	//最大の頂点数
struct UnionFindTree{
	int par[UnionFindTree_MAX_V+10],r[UnionFindTree_MAX_V+10];
	void init(int n = UnionFindTree_MAX_V){
		for(int i = 0 ; i < n+10 ; i ++){
			par[i] = i;
			r[i] = 0;
		}
	}
	int find(int x){
		if(par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit(int x,int y){
		if(same(x,y))return;
		x = find(x);
		y = find(y);
		if(r[x] < r[y]){
			par[x] = y;
		}
		else {
			par[y] = x;
			if(r[x] == r[y]){
				r[x] ++;
			}
		}
	}
}uf;

int main(){
	static int n,m;
	static int a[100010],b[100010];
	scanf("%d%d",&n,&m);
	rep1(i,m){
		scanf("%d%d",&a[i],&b[i]);
	}
	if(n == 1){
		puts("No");
		return 0;
	}
	
	static int cnt[100010] = {};
	rep1(i,m){
		cnt[a[i]] ++;
		cnt[b[i]] ++;
	}
	
	int ret = 0;
	int root = -1;
	rep1(i,n){
		if(cnt[i]%2 == 1){
			puts("No");
			return 0;
		}
		if(cnt[i] > 2)root = i;
		ret += (cnt[i]-2)/2;
	}
	if(ret <= 1){
		puts("No");
		return 0;
	}
	if(ret >= 3){
		puts("Yes");
		return 0;
	}
	
	uf.init();
	rep1(i,m){
		if(a[i] == root || b[i] == root)continue;
		uf.unit(a[i],b[i]);
	}
	set<int> S;
	for(int i = 1 ; i <= n ; i ++){
		S.insert(uf.find(i));
	}
	if(S.size() == 2){
		puts("No");
	}
	else puts("Yes");
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;
using namespace std;

const int N = 1e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    string s;
    cin>>s;
    if((s[0] == s[1]&&s[0] == s[2]) || (s[2] == s[1]&&s[1] == s[3]))
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define         rep(i,n)       for (int i = 0;i<(int)(n);i++)
#define         pi             3.14159265359
#define         nl             printf("\n")
#define         gcd(a,b)       __gcd(a,b)
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pf             printf
#define         sf             scanf
const int N = 2e5+5;
typedef long long int ll;
int i,j,k,temp,n,f=0,x;

int main()
{

    cin>>i;
    cout<<pow(i,3)<<endl;
    return 0;
}


Measured memory_bytes: 256
def solve(N, nd):
    dire = [(0,-1), (-1,0), (0,1), (1,0)]
    table = [[0]*(2*N+1) for i in range(2*N+1)]
    table[N][N] = 1
    position = [None]*N
    position[0] = (N, N)
    for i,ndi in enumerate(nd,start=1):
        n, d = ndi
        y, x = position[n]
        ny, nx = y+dire[d][0], x+dire[d][1]
        table[ny][nx] = 1
        position[i] = (ny, nx)

    left, right, top, bottom = 2*N, 0, 2*N, 0
    for i in range(2*N):
        for j in range(2*N):
            if (table[i][j]):
                left = min(left, j)
                right = max(right, j)
                top = min(top, i)
                bottom = max(bottom, i)
    return (right-left+1, bottom-top+1)

def main():
    ans = []
    while True:
        N = int(input())
        if (not N):
            break
        nd = [list(map(int, input().split())) for i in range(N-1)]
        ans.append(solve(N, nd))
    for i in ans:
        print(*i)
    
main()


Measured memory_bytes: 6928
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main()
{
    ll n,m,d;
    cin >> n >> m >> d;
    if(d==0){
        long double ans=m-1;
        ans/=n;
        cout << fixed << setprecision(10);
        cout << ans << endl; 
    }
    else{
        long double ans=2*(n-d)*(m-1);
        ans/=n*n;
        cout << fixed << setprecision(10);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  int K, A, B; cin >> K >> A >> B;

  for (int i = A; i <= B; i++){
    if (i % K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}


int main(){
  ll N, C, K;
  cin >> N >> C >> K;
  vector <ll> T(N);
  rep(i,N) cin >> T.at(i);
  sort(T.begin(), T.end());
  
  ll res = 0;
  
  ll i = N - 1;
  ll j, tempo;
  
  while (i>=0){
    res++;
    //cout << res << " " << T.at(i) << endl;
    if(i<=0) break;
    
    j = i; tempo = 1;
    while(T.at(i)-T.at(j)<=K && tempo <= C){
      if(j>0){
        j--; tempo++;
      }else{
        j--; tempo++;
        break;
        //cout << j << "break" << endl;
      }
    }
    
    i = j;
  }
    
  cout << res;  
    
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
// #define ss second
const int inf=0x3f3f3f3f3f3f3f3f;

void zz(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

int32_t main(){
zz();
int n;cin>>n;
string s;cin>>s;
vi v[2];
map<int,int>mp;
for(int i=0;i<n;i++){
    if(s[i]=='R')v[0].eb(i+1);
    else if(s[i]=='G')v[1].eb(i+1);
    else mp[i+1]=1;
}
int ss=1;
for(int i=0;i<2;i++)ss*=(int)v[i].size();
// cout<<mp.size()<<" ";
ss*=mp.size();
for(auto a:v[0]){
    for(auto b:v[1]){
      if((a+b)%2==0 && mp.count((a+b)/2))ss-=1;
      if(mp.count((2*a-b)))ss-=1;
      if(mp.count((2*b-a)))ss-=1;
}
}
cout<<ss<<endl;
}

Measured memory_bytes: 3780
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();
		int max=0;

		if(a*10+b+c>max){
			max=a*10+b+c;
		}
		if(a+b*10+c>max){
			max=a+b*10+c;
		}
		if(a+b+c*10>max){
			max=a+b+c*10;
		}
		System.out.println(max);


	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;


int main(){
	/*****input*****/
	int a[3][3];
	bool check[3][3];
	int n;
	for(int i = 0; i < 3; i++){
		for(int j =0; j<3; j++ ){
			cin >> a[i][j];
			check[i][j] = false;
		}
	}
	cin >> n;
	int b[100];
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}

	/*****calc*****/
	if(n < 3){
		cout<< "No" <<endl;
		return 0;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			for(int k = 0; k < n; k++){
				if(a[i][j] == b[k]){
					check[i][j] = true;
					continue;
				}
			}
		}
	}
	/*横列*/
	for(int i = 0; i < 3; i++){
		if(check[i][0]&&check[i][1]&&check[i][2]){
			cout<< "Yes" <<endl;
			return 0;
		}
	}
	/*縦列*/
	for(int i = 0; i < 3; i++){
		if(check[0][i]&&check[1][i]&&check[2][i]){
			cout<< "Yes" <<endl;
			return 0;
		}
	}

	/*斜め列*/
	if(check[0][0]&&check[1][1]&&check[2][2]){
		cout<< "Yes" <<endl;
		return 0;
	}
	if(check[0][2]&&check[1][1]&&check[2][0]){
		cout<< "Yes" <<endl;
		return 0;
	}

	cout<< "No" <<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		if (a<=8 &&b<=8){
        	System.out.println("Yay!");
        }else{
        System.out.println(":(");
        }
    }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <algorithm>

#define maxn 100000
#define ll long long

int a[maxn];

ll det(int n, int a[], int l) {
    int sum = 0;
    ll rez = 0;
    for (int i = 1; i <= n; i++, l = 1 - l) {
        sum += a[i];
        if (l == 0 && sum <= 0) {
            rez += 1 - sum;
            sum = 1;
        }
        else if (l == 1 && sum >= 0) {
            rez += 1 + sum;
            sum = -1;
        }
    }
    return rez;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    ll c1 = det(n, a, 0);
    ll c2 = det(n, a, 1);
    ll rez = std::min(c1, c2);
    printf("%lld", rez);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <deque>
#include <climits>
using namespace std;

int main() {
    array<array<int, 2>, 4> dm = {{
        { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 },
    }};
    array<array<int, 2>, 25> dw = {{
        { -2, -2 }, { -2, -1 }, { -2, 0 }, { -2, 1 }, { -2, 2 },
        { -1, -2 }, { -1, -1 }, { -1, 0 }, { -1, 1 }, { -1, 2 },
        { 0, -2 }, { 0, -1 }, { 0, 0 }, { 0, 1 }, { 0, 2 },
        { 1, -2 }, { 1, -1 }, { 1, 0 }, { 1, 1 }, { 1, 2 },
        { 2, -2 }, { 2, -1 }, { 2, 0 }, { 2, 1 }, { 2, 2 },
    }};

    int h, w; cin >> h >> w;
    array<int, 2> c; for (auto &e : c) { cin >> e; --e; }
    array<int, 2> d; for (auto &e : d) { cin >> e; --e; }
    vector<string> field(h);
    for (auto &e : field) cin >> e;

    vector<vector<int>> cost(h, vector<int>(w, INT_MAX));
    cost[c[0]][c[1]] = 0;

    deque<array<int, 3>> que;
    que.push_front({ c[0], c[1], 0 });

    while (!que.empty()) {
        auto [cy, cx, cc] = que.front(); que.pop_front();

        for (auto [dy, dx] : dm) {
            int ny = cy + dy, nx = cx + dx;
            if (ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
            if (field[ny][nx] == '#') continue;

            if (cc < cost[ny][nx]) {
                cost[ny][nx] = cc;
                que.push_front({ ny, nx, cc });
            }
        }

        for (auto [dy, dx] : dw) {
            int ny = cy + dy, nx = cx + dx;
            if (ny < 0 || nx < 0 || h <= ny || w <= nx) continue;
            if (field[ny][nx] == '#') continue;

            if (cc + 1 < cost[ny][nx]) {
                cost[ny][nx] = cc + 1;
                que.push_back({ ny, nx, cc + 1 });
            }
        }
    }

    int ans = cost[d[0]][d[1]];

    if (ans != INT_MAX) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  bool result = true;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  for(int i = 0; i < n - 1; i++){
    if(a.at(i) == a.at(i + 1)){
      result = false;
      break;
    }
  }
  if(result){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl

int h,w;
string s;
bool black[405][405];
bool block[405][405];
bool vis[405][405];
ll bl=0,wh=0;

void dfs(int i,int j)
{
	if(black[i][j])
		bl++;
	else
		wh++;
	vis[i][j]=1;
	for(int di=-1;di<=1;di++)
		for(int dj=-1;dj<=1;dj++)
			if(abs(di)+abs(dj)==1&&!block[i+di][j+dj]&&!vis[i+di][j+dj]&&black[i][j]!=black[i+di][j+dj])
				dfs(i+di,j+dj);
}

int main()
{
	SPEED;
	memset(block,1,sizeof block);
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		cin>>s;
		for(int j=1;j<=w;j++)
		{
			block[i][j]=0;
			if(s[j-1]=='#')
				black[i][j]=1;
		}
	}
	ll ans=0;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(!vis[i][j])
			{
				bl=0,wh=0;
				dfs(i,j);
				ans+=bl*wh;
			}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15744
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int i,K;
	string moji;

	cin >> K;
	cin >> moji;

	if (size(moji) <= K)
	{
		cout << moji << endl;
	}
	else
	{
		for (i = 0; i < K; i++)	cout << moji[i];
		cout << "..." << endl;
	}
	return 0;
}

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


int main() {
	int N,D,res=0;
	double x,y;

	scanf("%d%d", &N, &D);

	while(N--) {
		scanf("%lf%lf",&x,&y);

		if (sqrt(x*x + y*y) <= D) {
			res++;
		}
	}
	printf("%d\n", res);
	
	return 0;
}

Measured memory_bytes: 3820
from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
z,*q=[0]*50*M
v=[[]for _ in q]
for a,b in t:v[a-1]+=b,
for i in v[:M]:[heappush(q,-j)for j in i];z-=heappop(q)
print(z)

Measured memory_bytes: 374404
n,m = map(int,input().split())
abc = [list(map(int, input().split())) for i in range(m)]

d = [[0]*n for i in range(n)]
e = [[0]*n for i in range(n)]

for i in range(n):
    for j in range(n):
        if i!=j:
            d[i][j]=float('inf')
            e[i][j]=float('inf')

for i in range(m):
    d[abc[i][0]-1][abc[i][1]-1]=abc[i][2]
    d[abc[i][1]-1][abc[i][0]-1]=abc[i][2]
    e[abc[i][0]-1][abc[i][1]-1]=abc[i][2]
    e[abc[i][1]-1][abc[i][0]-1]=abc[i][2]

for i in range(n):
    for j in range(n):
        for k in range(n):
            if d[j][k]>d[j][i]+d[i][k]:
                d[j][k] = d[j][i]+d[i][k]

f = 0

for i in range(n):
    for j in range(n):
        if d[i][j]!=e[i][j] and e[i][j]!=float('inf'):
            f+=1

print(f//2)

Measured memory_bytes: 4080
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	string N;
	cin >> N;
	for(int i = 0; i < 4; i++){
		if(N[i] == '1'){
			N[i] = '9';
		}
		else{
			N[i] = '1';
		}
	}
	cout << N << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> x(4);
vector<int> y(4);
int main() {
    cin >> x.at(0) >> y.at(0) >> x.at(1) >> y.at(1);
    int dx = x.at(1) - x.at(0);
    int dy = y.at(1) - y.at(0);
    x.at(2) = x.at(1) - dy;
    y.at(2) = y.at(1) + dx;
    x.at(3) = x.at(2) - dx;
    y.at(3) = y.at(2) - dy;
    cout << x.at(2) << " " << y.at(2) << " " << x.at(3) << " " << y.at(3) << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc119/tasks/abc119_c
/**
 * 
 * We must notice that the operation of adding or subtracting 1 does not affect the operation of 'combining' two or more bamboos. 
 * For every bamboo, there are 4 options - 
 * 1. It is not touched. 
 * 2. It is added to the total of A.
 * 3. It is added to the total of B. 
 * 4. It is added to the total of C.

-----------

Let us brute force through all these possibilities. There are only 8 bamboos. We can brute force through these 4^8 = 2^16 possibilities. 

Let us say a = b = c = 0 at the beginning. 

We will brute force through these possibilities and add 10 to the cost at each step.

When we have finished processing all bamboos, we can then increment and decrement as many times as we want to so that we get A, B and C.

So the final cost is |a - A| + |b - B| + |c - C| - 30

--------

Why do we subtract 30 in the end ?

Because the process of adding one bamboo to one of (a, b, c) corresponds to the operation of choosing a bamboo for one of (a, b, c). 

The process of choosing the second bamboo of (a, b, c) corresponds to addition.

There is only cost of adding. There is no cost for choosing a bamboo. So we subtract the first 10 for each of (a, b, c).

----------

What do we do when do not add anything to any of (a, b, c) ? 

We must reject it and return oo. 

Why ? 

Because we have not chosen a bamboo for (a, b, c).

We cannot apply addition/subtraction if we have not chosen a pre-existing bamboo. (It is not allowed to increment a bamboo from scratch.)

So, not choosing a bamboo is not valid. 

-----------
 *
 * Explanation credits: @mathprogrammer
 * 
 */
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define forn(n) for (int i = 0; i < n; i++)
#define min_3(a, b, c) std::min(a, std::min(b, c))
#define min_4(a, b, c, d) std::min(std::min(a, b), std::min(c, d))
using std::cin;
using std::cout;
using std::endl;

typedef long long ll;

const int oo = 1e9;
std::vector<int> bamboo_list;
int A, B, C;

int dfs(int n, int a, int b, int c)
{
    if (n == 0)
        return (min_3(a, b, c) > 0) ? abs(A - a) + abs(B - b) + abs(C - c) - 30 : oo;
    int do_nothing = dfs(n - 1, a, b, c);
    int sum_a      = dfs(n - 1, a + bamboo_list[n], b, c) + 10;
    int sum_b      = dfs(n - 1, a, b + bamboo_list[n], c) + 10;
    int sum_c      = dfs(n - 1, a, b, c + bamboo_list[n]) + 10;

    return min_4(do_nothing, sum_a, sum_b, sum_c);
}
int main()
{
    int bamboo_count;
    cin >> bamboo_count;
    cin >> A >> B >> C;
    bamboo_list.resize(bamboo_count + 1);
    for (int i = 1; i <= bamboo_count; i++)
        cin >> bamboo_list[i];
    int answer = dfs(bamboo_count, 0, 0, 0);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

int main(){
    vector<bool> a(6,false);
    rep(i,5){
        ll x; cin>>x;
        a[x]=true;
    }
    ll ans;
    rep(i,6) if(!a[i]) ans=i;
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int h,w,k;
char ipt[310][310];
int ans[310][310],tfil[310] = {0};
int main() {
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		cin>>ipt[i];
	}
	int tim = 0;
	for(int i=0;i<h;i++){
		int cnt = 0;
		for(int j=0;j<w;j++){
			if(ipt[i][j]=='#'){
				cnt+=1;
				tim++;
				ans[i][j] = tim;
			}
		}
		if(cnt==0){
			tfil[i] = 1;
		}else{
			for(int j=1;j<w;j++){
				if(ans[i][j-1] && !ans[i][j])ans[i][j] = ans[i][j-1];
			}
			for(int j=w-2;j>=0;j--){
				if(ans[i][j+1] && !ans[i][j])ans[i][j] = ans[i][j+1];
			}
		}
	}
	for(int i=1;i<h;i++){
		if(tfil[i] && !tfil[i-1]){
			memcpy(ans[i],ans[i-1],sizeof(ans[i]));
			tfil[i] = 0;
		}
	}
	for(int i=h-2;i>=0;i--){
		if(tfil[i] && !tfil[i+1]){
			memcpy(ans[i],ans[i+1],sizeof(ans[i]));
			tfil[i] = 0;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<ans[i][j];
			if(j!=w-1)putchar(' ');
		}
		putchar('\n');
	}
	return 0;
}


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

int main() {
    int k;
    string s;
    cin >> k >> s;
    string ans = s.substr(0, k);
    s.size() <= k 
        ? cout << s
        : cout << ans << "...";
    return 0;
}


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

int main() {
	int n;
	cin>>n;
	bool flag=0;
	for(int i=1;i<=9;++i){
	    if(!(n%i)&&(n/i)<10){flag=1;break;}
	}
	if(flag)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,k,p,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&k);
		scanf("%d",&p);
		if(k%p==0){
			printf("%d\n",p);
		}
		else{
			printf("%d\n",k%p);
		}
	}
	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define VIN(x) for(auto&youso_: (x) )cin>>youso_
#define VOUT(x, delim) for(auto&youso_: (x) )cout<<youso_<<delim;cout<<endl

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) i64 __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    CIN(X);
    Yes(X >= 30);

    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>

int main(void){
  int N;
  int L[200]={0};
  int i,j,tmp;
  int sum;
  scanf("%d",&N);
  N*=2;
  for(i=0;i<N;i++){
    scanf("%d",&L[i]);
  }
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      if(L[i]>L[j]){
	tmp=L[i];
	L[i]=L[j];
	L[j]=tmp;
      }
    }
  }

  sum=0;
  for(i=0;i<N;i+=2){
    sum+=L[i];
  }
  printf("%d\n",sum);

  return 0;
}

Measured memory_bytes: 128
#import <Foundation/Foundation.h>
typedef long long INT;
#define M 2019
int main(){
    INT L,R;
    scanf("%lld %lld",&L,&R);
    INT ans = M;
    for(INT i=L;i<=MIN(L+M,R-1);i++){
        for(INT j=i+1;j<=MIN(i+M,R);j++) {
            ans = MIN((i%M)*(j%M)%M,ans);
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 7496
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main(){

  ll h,w,n;
  cin>>h>>w>>n;
  ll mx = max(h,w);
  ll ans = (n/mx)+((n%mx)!=0);
  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    char c,C[5]={'a','i','u','e','o'};
    int flag=0;
    cin >> c;
    for(int i=0;i<5;i++){
        if(C[i]==c){
            flag=1;
            break;
        }
    }
    if(flag) cout<<"vowel";
    else cout<<"consonant";
}


Measured memory_bytes: 256
from sys import stdin
from collections import deque, defaultdict as ddic
from itertools import combinations, permutations, product
import bisect
import heapq

rs = lambda: stdin.readline().strip()
ri = lambda: int(rs())
rsl = lambda: stdin.readline().split()
rim = lambda: map(int, rsl())
ril = lambda: list(rim())


s = rs()
one_even = []
one_odd = []
for i, char in enumerate(s):
    if i % 2 == 0 and char == '1':
        one_even.append(True)
    elif i % 2 == 1 and char == '0':
        one_even.append(True)
    else:
        one_even.append(False)

for i, char in enumerate(s):
    if i % 2 == 1 and char == '1':
        one_odd.append(True)
    elif i % 2 == 0 and char == '0':
        one_odd.append(True)
    else:
        one_odd.append(False)

one_even.sort()
one_odd.sort()
index1 = 0
for i, boolean in enumerate(one_even):
    if boolean:
        index1 = i
        break

index2 = 0
for i, boolean in enumerate(one_odd):
    if boolean:
        index2 = i
        break

print(min(index1, index2))


Measured memory_bytes: 5356
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

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

template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	
	map<int, int> mp;
	int tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		mp[tmp]++;
	}

	if (mp.size() <= K) cout << 0 << "\n";
	else {
		
		vector<int> mem;
		mem.reserve(mp.size());
		for (const auto &e : mp) mem.emplace_back(e.second);
		sort(mem.begin(), mem.end());

		int ans = 0;
		for (int i = 0; i < mp.size() -K; i++) {
			ans += mem[i];
		}

		cout << ans << "\n";
	}


	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <string>
int main(){
	std::string S;
	std::cin >> S;
	int a = 0;
	for (int i = 0; i < S.size(); i++){
		if (S[i] == '+') a++;
		else a--;
	}
	std::cout << a << std::endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    readLine()!!.toInt()
    val list = readLine()!!.split(' ').map { it.toInt() }
    val (parted, q) = partition(list)

    println(parted.mapIndexed { i, v -> if (i == q) "[$v]" else "$v" }.joinToString(" "))
}

private fun partition(list: List<Int>): Pair<List<Int>, Int> {
    val p = 0
    val r = list.lastIndex
    val mutableList = list.toMutableList()

    val x = mutableList[r]
    var i = p - 1

    for (j in p until r) {
        if (mutableList[j] <= x) {
            i++
            val t = mutableList[i]
            mutableList[i] = mutableList[j]
            mutableList[j] = t
        }
    }

    val t = mutableList[i + 1]
    mutableList[i + 1] = mutableList[r]
    mutableList[r] = t

    return mutableList to i + 1
}


Measured memory_bytes: 67700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    ll n,s=0;
    cin>>n;
    bool flag=0;
    for(int i=1;i<=2e7;i++)
    {
        s=(s*10+7)%n;
        if(s==0){printf("%d\n",i);flag=1;break;}
    }
    if(!flag)printf("-1\n");
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int cal(int x){
	int sum=0;
	while(x/10){
		sum+=x%10;
		x/=10;
	}
	sum+=x;
	return sum;
}
int main(){
	int n;
	while(~getI(n)){
		int ans=INF;
		F(a,1,n){
			int b=n-a;
			int aDig=cal(a),bDig=cal(b);
			if(aDig+bDig<ans) ans=aDig+bDig;
		}
		printf("%d\n",ans);
	}
}


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

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template<typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
	return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
	return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
	string _s = #args;   \
	replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}
#define error(args...) {  \
    string _s = #args;  \
    replace(_s.begin(), _s.end(), ',', ' ');  \
    stringstream _ss(_s);  \
    istream_iterator<string> _it(_ss);  \
    err(_it, args);  \
    cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}

char s[N];
int vis[N];

void Solve() {
	cin>>s;
	int n=strlen(s);
	for(int i=0;i<n;i++){
		switch(s[i]){
			case'N':vis[0]=1;break;
			case'W':vis[2]=1;break;
			case'S':vis[1]=1;break;
			case'E':vis[3]=1;break;
		}
	}
	int ok=1;
	for(int i=1;i<=4;i++)if(vis[i]^vis[i^1])ok=0;
	if(ok)cout<<"Yes\n";
	else cout<<"No\n";
}


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//  freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}


Measured memory_bytes: 3616
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, X; cin >> N >> X;
    vector<int> v(N);
    rep(i,0,N) cin >> v[i];

    int ans = 0;
    rep(i,1,N) {
        int ad = max(0LL, v[i] + v[i-1] - X);
        ans += ad;
        v[i] -= min(v[i], ad);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>

using namespace std;
int weight[]={200,300,500,1000,1200,1500};
int money[]={380,550,850,380*4,550*4*0.85,850*3*0.88};

int check(int i,int sum)
{
  //cout<<i<<"  "<<sum<<endl;
  if(sum<0|| i>5)
    return 99999;
  if(sum==0)
    return 0;
  return min(check(i+1,sum),money[i]+check(i,sum-weight[i]));
}

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      int ans=99999;
      cout<<check(0,n)<<endl;
    }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int res = 0;
    rep(i, S.size()) {
        int c = i;
        while(c < S.size() &&
              (S[c] == 'A' || S[c] == 'C' || S[c] == 'G' || S[c] == 'T')) {
            c++;
        }
        res = max(res, c - i);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def linear_search_2(sequence, key):
    i = 0
    sequence_guard = sequence[:]
    sequence_guard.append(key)

    while sequence_guard[i] != key:
        i += 1

    if i == len(sequence):
        return "NOT_FOUND"

    return i



n = int(input())
S = list(map(int, input().split()))

q = int(input())
T = list(map(int, input().split()))

cnt = 0

for t in T:
    
    result = linear_search_2(S, t)
    
    if result == "NOT_FOUND":
        continue
    
    cnt += 1


print(cnt)



Measured memory_bytes: 6556
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct P {
    bool operator<(const P& p) const {
        if (y == p.y) return x < p.x;
        return y < p.y;
    }
    double x, y;
};

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

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    int i00 = min_element(p.begin(), p.end()) - p.begin();

    vector<int> b;
    double pi = 4 * atan(1), z = pi / 2;
    for (int i = i00;;) {
        b.push_back(i);
        int k = 0;
        if (i == i00 && i == k) k = 1;
        for (int j = k + 1; j < n; j++) {
            if (j == i) continue;
                
            double cx = p[k].x - p[i].x;
            double cy = p[k].y - p[i].y;
            double dx = p[j].x - p[i].x;
            double dy = p[j].y - p[i].y;
            double c2 = cx * cx + cy * cy;
            double d2 = dx * dx + dy * dy;

            double a = cx * dy - cy * dx;
            //cout << d2 << ' ' << c2 << endl;
            if (a < 0 || (a == 0 && d2 > c2)) k = j;
        }
        i = k;
        if (i == i00) break;
    }

    int m = b.size();
    vector<double> c(m);
    vector<double> d(n);
    for (int i0 = 0; i0 < m; i0++) {
        int j0 = i0 + 1; if (j0 >= m) j0 -= m;
        int i = b[i0], j = b[j0];
        double dx = p[j].x - p[i].x;
        double dy = p[j].y - p[i].y;
        double t = atan2(dy, dx);
        c[i0] = t;
    }
    for (int i0 = 0; i0 < m; i0++) {
        int j0 = i0 + 1; if (j0 >= m) j0 -= m;
        double t = c[j0] - c[i0];
        if (t < 0) t += pi * 2;
        d[b[j0]] = t;
    }
    double s = 0;
    for (int i = 0; i < n; i++) {
        s += d[i];
    }
    for (int i = 0; i < n; i++) {
        d[i] /= s;
    }

    //cout << b.size() << endl;
    for (int i = 0; i < n; i++) {
        printf("%.15f\n", d[i]);
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int col[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  col[u]=GRAY;
  tt++;
  d[u]=tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(col[v]==WHITE) dfs_visit(v);
  }
  col[u]=BLACK;
  tt++;
  f[u]=tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++){col[u]=WHITE;}
  tt=0;

  for(u=0;u<n;u++){
    if(col[u]==WHITE) dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){M[i][j]=0;}
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
}


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


int main(){
  int N;
  cin >> N;
  vector<int> x(N);
  rep(i,N) cin >> x[i];
  sort(x.begin(),x.end());
  x.erase(unique(x.begin(),x.end()),x.end());
  if(x.size() % 2 == 0) cout << x.size() - 1 << endl;
  else cout << x.size() << endl;
  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 1000040
 
const int  m = 1000033;
//const int  m2= 1000003;
//7069 - 60
char stack[MAX][15];
int h1(long long);
int h2(long long);
int insert(long long,int);
long long sti(char *);
 
int main(){
  int val,i,j,n,dic=0,dicc=MAX,index2=0,vall;
  char op[15],s[15];
  int exist=-1,index=0;
 
  while(scanf("%d",&n) != EOF){
    dic=0,dicc=MAX;
    for(i=0;i<=MAX;i++)strcpy(&stack[i][0],"not");
    for(i=0;i<n;i++){
      exist=-1;
      scanf("%s %s",op,s);
      if(op[0] == 'i'){
    index=0;
    while(1){
      val = insert(sti(&s[0]),index);
      if(strcmp(&stack[val][0],"not") == 0){
        strcpy(&stack[val][0],&s[0]);
        break;
      }
      else index++;
      if(index == MAX)break;
    }
      }
      else if(op[0] =='f'){
    index2=0;
    while(1){
      vall=insert(sti(s),index2);
      if(strcmp(stack[vall],s) == 0){
        exist=1;
        break;
      }
      else if(strcmp(&stack[vall][0],"not") == 0){
        break;
      }
      index2++;
      if(index2 == MAX)break;
    }
    if(exist == 1)printf("yes\n");
    else printf("no\n");
      }
    }
  }
  return 0;
}
 
 
int h1(long long k){
  return k%m;
}
 
int h2(long long k){
  return 1+k%(m-1);
}
 
int insert(long long k,int i){
  return (h1(k) + i*h2(k))%m;
}
 
long long sti(char *s){
  long long i=0,sum=0;
  while(s[i] != '\0'){
    sum*=10;
    sum+=s[i]-'A'+1;
    i++;
  }
  return sum;
}

Measured memory_bytes: 15252
from collections import Counter
from itertools import product
import numpy as np
from copy import copy
H, W, K, *data = map(str, open(0).read().split())

H = int(H)
W = int (W)
K = int(K)

# Set . to 0, set # to + 1, let red be 0

encoder = dict()
encoder["."] = 0
encoder["#"] = +1

mat = np.zeros([H,W], dtype=int)
for i, row_raw in enumerate(data):
    row = [encoder[char] for char in row_raw]
    mat[i,:] = row

counter = 0
for H_red in product([True, False], repeat=H):
    for W_red in product([True, False], repeat=W):
        mat_c = copy(mat)
        mat_c[H_red, :] = 0
        mat_c[:, W_red] = 0
        black_count = np.sum(mat_c)
        if black_count == K:
            counter += 1

print(counter)

Measured memory_bytes: 27256
#include <iostream>
#include <vector>
using namespace std;
int main(void){

    string S;
    bool ans = true;
    cin >> S;
    
    
    for(int i = 0; i < S.size(); i++){
        
        // 奇数
        if( (i+1) % 2 == 1 ){
            if( !( S[i] == 'R' ||  S[i] == 'U' || S[i] == 'D' ) ) {
                ans = false;
            }
        }
        
        // 偶数
        if( (i+1) % 2 == 0 ){
            if( !( S[i] == 'L' ||  S[i] == 'U' || S[i] == 'D' ) ) {
                ans = false;
            }
        }
    }
    
    cout << (ans ? "Yes\n" : "No\n");
    
}



Measured memory_bytes: 256
require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n').some(function(i){j=i.split(' ');if(j.length==6)a=j[0],b=j[1],c=j[2],d=j[3],e=j[4],f=j[5],g=a*a,h=b*b,k=c*c,l=d*d,m=e*e,n=f*f,p=((b-f)*(h-l+g-k)-(b-d)*(h-n+g-m))/(2*(b-f)*(a-c)-2*(b-d)*(a-e)),q=((a-e)*(g-k+h-l)-(a-c)*(g-m+h-n))/(2*(a-e)*(b-d)-2*(a-c)*(b-f)),console.log(p.toFixed(3),q.toFixed(3),Math.sqrt((a-p)*(a-p)+(b-q)*(b-q)).toFixed(3))})

Measured memory_bytes: 7908
s = list(str(input()))
flag = False
a1 = int(s[0])

for i in range(2):
    if i == 0:
        a2 = a1 + int(s[1])
        t1 = "+"
    else:
        a2 = a1 - int(s[1])
        t1 = "-"
    for j in range(2):
        if j == 0:
            a3 = a2 + int(s[2])
            t2 = "+"
        else:
            a3 = a2 - int(s[2])
            t2 = "-"
        for r in range(2):
            if r == 0:
                if a3 + int(s[3])!=7:
                    continue
                else:
                    print(s[0] + t1 + s[1] + t2 + s[2] + "+" + s[3] + "=7")
                    flag = True
                    break
            else:
                if a3 - int(s[3])!=7:
                    continue
                else:
                    print(s[0] + t1 + s[1] + t2 + s[2] + "-" + s[3] + "=7")
                    flag = True
                    break
        if flag:
            break
    if flag:
        break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

template <typename T>
T ceil(T a, T b){ return (a+b-1)/b; }


template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
vector<int> parent(300005), cnt(300005);
void make_set(int u) {
    parent[u] = u;
    cnt[u] = 1;
}
int find_set(int u) {
    if(u==parent[u]) 
        return u;
    return find_set(parent[u]);
}
void union_set(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if(a!=b) {
        if(cnt[a]<cnt[b]) {
            swap(a, b);
        }
        parent[b] = a;
        cnt[a] += cnt[b];
    }
}
void solve(){
    int n, m; cin>>n>>m;
    FOR(i, 1, n+1) {
        make_set(i);
    }
    FOR(i, 0, m) {
        int a, b; cin>>a>>b;
        if(find_set(a)!=find_set(b)) {
            union_set(a, b);
        }
    }
    int res=0;
    FOR(i, 1, n+1) {
        res = max(res, cnt[i]);
    }
    cout<<res;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}

Measured memory_bytes: 7840
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
int main(){

    //freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
        
    int n, k, q; cin >> n >> k >> q;
    int a[n + 1] = {0};
    

    forn(i, q){
        int x; cin >> x;
        a[x] ++;
    }

    forn1(i, n){
        if(a[i] + k > q) cout <<"Yes" << endl;
        else cout <<"No" << endl;
    }

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int e,y,y2,e2,i;
	char wa[5]="MTSH";
	int reki[5]={1868,1912,1926,1989,2017};
	scanf("%d %d",&e,&y);
	if(e==0){
		for(i=0;i<4;i++){
			if(y<reki[i+1]){
				e2=i;
				y2=y-reki[i]+1;
				break;
			}
		}
		printf("%c%d\n",wa[e2],y2);
	}
	else{
		y2=reki[e-1]+y-1;
		printf("%d\n",y2);
	}
	return 0;
}


Measured memory_bytes: 2116