akhauriyash/Code-Regression huggingface dataset:
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 32


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


def llmi(n):
    return [lmi() for _ in range(n)]


H, W = lmi()
S = [input().strip() for _ in range(W)]

import functools


@functools.lru_cache(maxsize=None)
def solve(h, w, last_b=False):
    if h < 0 or w < 0:
        return INF
    if h == 0 and w == 0:
        return int(S[0][0] == '#') and (not last_b)
    b = bool(S[h][w] == '#')
    if b:
        return min(solve(h - 1, w, last_b=True) + (not last_b),
                   solve(h, w - 1, last_b=True) + (not last_b),
                   )
    return min(
        solve(h - 1, w, last_b=False),
        solve(h, w - 1, last_b=False),
        solve(h - 1, w, last_b=True) + 1,
        solve(h, w - 1, last_b=True) + 1,
        # solve(h - 1, w, last_b=False) + b,
        # solve(h, w - 1, last_b=False) + b,
    )


print(solve(H - 1, W - 1))


Measured memory_bytes: 66264
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n; cin >> n;
  vector<int> m(n); REP(i,n) m[i] = INF;
  vector<int> p(n); REP(i,n) cin >> p[i];
  int ans = 1;
  m[0] = p[0];
  FOR(i,1,n){
    m[i] = min(p[i],m[i-1]);
    if(p[i] == m[i])
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> iipair;
typedef pair<unsigned,unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;
typedef vector<ull> ullvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ull h,n;
    cin>>h>>n;
    ullvec a(n);
    for(unsigned i=0;i<n;cin>>a[i++]);
    ull sum=accumulate(a.begin(),a.end(),0ULL);
    if(sum>=h) cout<<"Yes";
    else cout<<"No";
    

}

Measured memory_bytes: 1024
n = input()
if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9':
  print("hon")
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9116
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int dp[1<<17],a[1005],b[1005],c[1005];
int main()
{
	int N,M;
	cin>>N>>M;
	for(int i=1;i<=M;i++)
	{
		cin>>a[i]>>b[i];
		for(int j=1;j<=b[i];j++)
		{
			int temp;
			cin>>temp;
			c[i]+=1<<(temp-1);
		}
	}
	int n=(1<<N)-1;
	
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=1;j<=M;j++){
				
					dp[i|c[j]]=min(dp[i|c[j]],dp[i]+a[j]);
				
			
		}			
	}
	if(dp[n]==0x3f3f3f3f)
	cout<<-1;
	else
	cout<<dp[n];
}

Measured memory_bytes: 768
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <algorithm>
#include <functional>
using namespace std;



int main(){


	int i, j;
	int N,K;


	string S;

	cin >> K;
	cin >> S;
	
	if (S.size() <= K){
		cout << S;
	}
	else{
		cout << S.substr(0, K) + "...";

	}
	return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main()
{
    int h, w, i, j;
    while(1){
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0){
            break;
        }
        for(i = 1;i <= h;i++){
            for(j = 1;j <= w;j++){
                if((i + j) % 2 == 0){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  string S;
  cin>>S;
  ll cnt=0;
  ll now=0;
  rep(i, 3){
    if(S.at(i)=='S'){
		cnt=max(cnt, now);
      	now=0;
    }
    else{
      now++;
    }
  }
  cnt=max(cnt, now);
  cout<<cnt<<endl;
}

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


int main()
{
   int a[3][3];
   int i,j,n;
   for(i=0;i<3;i++)
   {
       for(j=0;j<3;j++)
       {
           cin>>a[i][j];
       }
   }
   cin>>n;
   while(n--)
   {
       int x;
       cin>>x;
        for(i=0;i<3;i++)
   {
       for(j=0;j<3;j++)
       {
           if(a[i][j]==x)
           {
               a[i][j]=0;
           }
       }
   }
   }
        if(a[0][0]==0 && a[0][1]==0 && a[0][2]==0) cout<<"Yes";
   else if(a[1][0]==0 && a[1][1]==0 && a[1][2]==0) cout<<"Yes";
   else if(a[2][0]==0 && a[2][1]==0 && a[2][2]==0) cout<<"Yes";
   else if(a[0][0]==0 && a[1][0]==0 && a[2][0]==0) cout<<"Yes";
   else if(a[0][1]==0 && a[1][1]==0 && a[2][1]==0) cout<<"Yes";
   else if(a[0][2]==0 && a[1][2]==0 && a[2][2]==0) cout<<"Yes";
   else if(a[0][0]==0 && a[1][1]==0 && a[2][2]==0) cout<<"Yes";
    else if(a[0][2]==0 && a[1][1]==0 && a[2][0]==0) cout<<"Yes";
   else cout<<"No";
}


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


int main()
{
	int N;
	double V[20];
	double C[20];
	double XY=0;
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> V[i];
	}
	for (int i = 0; i < N; i++){
		cin >> C[i];
	}
	for (int i = 0; i < N; i++) {
		if (V[i] > C[i]) {
			XY += V[i] - C[i];
		}
	}
	cout << XY << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int N;
    int T[114514],A[114514];
    cin >> N;
    REP(i,N){cin >> T[i];}
    REP(i,N){cin >> A[i];}
    int top=-1;
    if(T[N-1]!=A[0]){cout << 0 << endl;return 0;}
    if(N==1){cout << 1 << endl;return 0;}
    REP(i,N){
        if(T[i]==A[i])top=i;
    }
    if(top==-1){cout << 0 << endl;return 0;}
    if(T[top]<T[N-1]){cout << 0 << endl;return 0;}
    int Ans=1;
    for(int i=1;i<N-1;i++){
        if(T[i]==T[i-1]&&A[i]==A[i+1]){
            Ans=(Ans*min(T[i],A[i]))%MOD;
        }
    }
    cout << Ans << endl;
    return 0;
}   


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node Node;

void insert(int);
void inorder(Node*);
void preorder(Node*);
   


Node *NIL,*root;
int main(){
  int N,i,v,t;
  char o[7];
  scanf("%d",&N);

  for(i=0;i<N;i++){
 
    scanf("%s",o);
    t=strcmp(o,"insert");

    if(t==0){
      scanf("%d",&v);
      insert(v);
    }
    else {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }

  }
  return 0;
}

void insert(int k){

  Node *z;
  Node *x;
  Node *y;
  z=(Node *)malloc(sizeof(Node));

  z->key=k;
  z->left=NIL;
  z->right=NIL;
  y=NIL;
  x=root;
 
  while(x!=NIL){
    y=x;
    if( z->key < x->key )x=x->left;
    else x=x->right;
     
  }
  z->parent=y;


  if(y==NIL)root=z;
  else if(z->key < y->key) y->left=z;
    else y->right=z;

}

    void inorder(Node *u){

      if(u==NIL)return;
      inorder(u->left);
      printf(" %d",u->key);
      inorder(u->right);
    }

    void preorder(Node *u){

      if(u==NIL) return;
      printf(" %d",u->key);
      preorder(u->left);
      preorder(u->right);
    }

Measured memory_bytes: 24040
n, k = map(int, input().split())
p = list(map(int, input().split()))

total = 0
for i in range(k):
    total += p[i]

total_max = total
for i in range(n-k):
    total += p[i+k] - p[i]
    total_max = max(total, total_max)

print((total_max + k) / 2)

Measured memory_bytes: 24804
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    vi p(n);
    rep(i, 0, n) cin >> p[i];
    int cnt = 0;
    rep(i, 1, n - 1)
    {
        if (((p[i - 1] < p[i]) && (p[i + 1] > p[i])) || ((p[i - 1] > p[i]) && (p[i + 1] < p[i])))
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    bool f = 0;
    ll dp[1000005],a;
    dp[n.length()] = 0;
    for(int i = n.length()-1;i >= 0;i--){
        a = n[i]-'0';
        if (f) a++;
        f = 0;
        if (a >= 10){
            f = 1;
            a -= 10;
        }
        if (a < 5){
            dp[i] = dp[i+1]+a;
        }
        else if (a == 5){
            dp[i] = dp[i+1]+5;
            if (i == 0 || n[i-1]-'0' < 5) continue;
            else f = 1;
        }
        else{
            dp[i] = dp[i+1]+10-a;
            f = 1;
        }
    }
    if (f) dp[0]++;
    PRINT(dp[0]);
}

Measured memory_bytes: 9116
a,b = map(int,input().split())
c = list(map(int,input().split()))
# c_list = list(c)
# c_list = [int(s) for s in c ]
count = 0
for i in range (0,b):
    count += c[i]

if count >= a:
    print("Yes")
else:
    print("No")


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

#define REP(A, H) for(int A = 0; A < H; A++)
#define RREP(A, B, H, W) for(int A = 0; A < H; A++) for (int B = 0; B < W; B++)
#define MAX(A, B) (A = std::max(A, B))
#define MIN(A, B) (A = std::min(A, B))

typedef long long ll;

struct POINT {
  int x; int y;
  POINT(int x, int y) : x(x), y(y) {}
};

POINT operator +(const POINT& a, const POINT& b) {
  return POINT(a.x + b.x, a.y + b.y);
}

POINT operator -(const POINT& a, const POINT& b) {
  return POINT(a.x - b.x, a.y - b.y);
}

/* std::cout << ;*/
/* std::cout << << std::endl; */

int main(void) {

  int n; std::cin >> n;
  std::vector<int> ps(n);
  REP(i, n) std::cin >> ps[i];
  
  int cnt = 0;
  REP(i, n - 2) {
    std::vector<int> ts;
    REP(j, 3) ts.push_back(ps[i + j]);
    sort(ts.begin(), ts.end());
    if (ps[i + 1] == ts[1]) cnt++;
  }

  std::cout << cnt << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[1000100];
bool b[1000100];
long long gcd(long long a, long long b) {
	if (a % b == 0) {
		return (b);
	}
	else {
		return (gcd(b, a % b));
	}
}
int main() {
#define int long long
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 1000010; i++) {
		b[i] = true;
	}
	sort(a, a + n);
	bool bo = true;
	for (int i = 0; i < n; i++) {
		if (!b[a[i]]) {
			bo = false;
			break;
		}
		for (int k = 1; k * k <= a[i]; k++) {
			if (a[i] % k == 0) {
				if (!b[k] || k == 1) {
				}
				else {
					for (int j = k; j < 1000010; j += k) {
						b[j] = false;
					}
				}
				if (!b[a[i] / k]) {
				}
				else {
					if (a[i] / k != 1) {
						for (int j = a[i] / k; j < 1000010; j += a[i] / k) {
							b[j] = false;
						}
					}
				}
			}
		}
	}
	if (bo) {
		cout << "pairwise coprime" << endl;
		return 0;
	}
	long long g = a[0];
	for (int i = 1; i < n; i++) {
		g = gcd(g, a[i]);
	}
	if (g == 1) {
		cout << "setwise coprime" << endl;
		return 0;
	}
	cout << "not coprime" << endl;
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  ll N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];

  ll ans = 0;
  REP(i, N) {
    if (A[i] > 0) {
      ans += A[i] / 2LL;
      if (A[i] % 2LL == 1LL and i < N-1 and A[i+1] > 0) ans++, A[i+1]--;
    }
    //cout << i << ' ' << ans << endl;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
///spaesk

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define pi acos(-1)
#define int long long int
#define ld long double
#define ar array
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<int> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const int ths = 1LL << 40;
const int NN = 5e3 + 6;

const int maxN = 100007;

///
///

void solve()
{

    int a;
    cin>>a;
    if(a >= 400 and a <= 599)
        cout<<8;
    else if(a >= 600 and a <= 799)
        cout<<7;
    else if(a <= 999)
        cout<<6;
    else if(a <= 1199)
        cout<<5;
    else if(a <= 1399)
        cout<<4;
    else if(a <= 1599)
        cout<<3;
    else if(a <= 1799)
        cout<<2;
    else if(a <= 1999)
        cout<<1;

    cout<<"\n";
    return ;
}

/*
*/

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
# ソートしてカウント
# (2以上の場合、)個数のn*(n-1)/2

n = int(input())
d = dict()
for i in range(n):
    s = list(input())
    s.sort()
    sl = ''.join(s)
    if d.get(sl) == None:
        d[sl] = 1
    else:
        d[sl] = d[sl] + 1

ans = 0
for k in d.keys():
    ans = ans + d[k] * (d[k] - 1) // 2

print(ans)


Measured memory_bytes: 22312
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,b = 0;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        b += a[i];
    }
    int c = 0,d = 10000000;
    for(int i = 0; i < N; i++){
        c += a[i];
        d = min(d,abs(b - 2 * c));
    } 
cout << d << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
      int h,w;
      cin>>h>>w;
      while(h!=0&&w!=0){
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					if((i+j)%2==0){
						cout<<"#";
					}
					else{
						cout<<".";
					}
				}
				cout<<endl;
			}
			cout<<endl;
			cin>>h>>w;
	  }  
}



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

int N;

int balance(vector<int> &W) {
    int left = 0;
    int right = N - 1;
    int S1 = 0;
    int S2 = 0;
    while (left <= right) {
        if (S1 < S2) {
            S1 += W[left];
            left++;
        } else {
            S2 += W[right];
            right--;
        }
    }

    return abs(S1 - S2);
}

int main() {
    cin >> N;
    vector<int> W(N);
    for (int i = 0; i < N; i++) {
        cin >> W[i];
    }

    int ans = balance(W);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename T>
struct PrimalDual{
  struct edge{
    Int to;
    T cap,cost;
    Int rev;
    edge(){}
    edge(Int to,T cap,T cost,Int rev):to(to),cap(cap),cost(cost),rev(rev){}
  };
  
  T INF;
  vector<vector<edge> > G;
  vector<T> h,dist;
  vector<Int> prevv,preve;

  PrimalDual(){}
  PrimalDual(Int n,T INF):INF(INF),G(n),h(n),dist(n),prevv(n),preve(n){}
  
  void add_edge(Int from,Int to,T cap,T cost){
    G[from].emplace_back(to,cap,cost,G[to].size());
    G[to].emplace_back(from,0,-cost,G[from].size()-1);
  }

  T flow(Int s,Int t,T f,Int &ok){    
    T res=0;
    fill(h.begin(),h.end(),0);
    while(f>0){
      struct P{
        T first;
        Int second;
        P(T first,Int second):first(first),second(second){}
        bool operator<(const P&a) const{return first>a.first;}
      };      
      priority_queue<P> que;
      fill(dist.begin(),dist.end(),INF);
      
      dist[s]=0;
      que.emplace(dist[s],s);
      while(!que.empty()){
        P p=que.top();que.pop();
        Int v=p.second;
        if(dist[v]<p.first) continue;
        for(Int i=0;i<(Int)G[v].size();i++){
          edge &e=G[v][i];
          if(e.cap==0) continue;
          if(dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
            dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
            prevv[e.to]=v;
            preve[e.to]=i;
            que.emplace(dist[e.to],e.to);
          }
        }
      }
      if(dist[t]==INF) return ok=0;
      
      for(Int v=0;v<(Int)h.size();v++) h[v]+=dist[v];

      T d=f;
      for(Int v=t;v!=s;v=prevv[v])
        d=min(d,G[prevv[v]][preve[v]].cap);
      
      f-=d;
      res+=d*h[t];
      for(Int v=t;v!=s;v=prevv[v]){
        edge &e=G[prevv[v]][preve[v]];
        e.cap-=d;
        G[v][e.rev].cap+=d;
      }
    }
    ok=1;
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  const Int INF = 1e15;
  PrimalDual<Int> G(2*n+6,INF);
  Int S=2*n+4,T=2*n+5;
  
  const Int OFS = 1e10;
  Int sum=0;
  for(Int i=0;i<n;i++){
    Int rx,ry,rc;
    cin>>rx>>ry>>rc;
    sum+=rc;
    G.add_edge(S,i,rc,0);    
    G.add_edge(i,2*n+0,10,OFS-(+rx+ry));
    G.add_edge(i,2*n+1,10,OFS-(+rx-ry));
    G.add_edge(i,2*n+2,10,OFS-(-rx+ry));
    G.add_edge(i,2*n+3,10,OFS-(-rx-ry));
  }
  
  for(Int i=0;i<n;i++){
    Int bx,by,bc;
    cin>>bx>>by>>bc;
    G.add_edge(2*n+0,n+i,10,OFS-(-bx-by));
    G.add_edge(2*n+1,n+i,10,OFS-(-bx+by));
    G.add_edge(2*n+2,n+i,10,OFS-(+bx-by));
    G.add_edge(2*n+3,n+i,10,OFS-(+bx+by));
    G.add_edge(n+i,T,bc,0);
  }
  
  Int ok=1;
  Int ans=G.flow(S,T,sum,ok);
  assert(ok);
  cout<<OFS*2*sum-ans<<endl;
  return 0;
}


Measured memory_bytes: 1488
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>
const long long INF=1e18;

using namespace std;

int main(void) {
    int X;
    cin>>X;
    if(400<=X&&X<=599){
        cout<<8<<endl;
    }else if(600<=X&&X<=799){
        cout<<7<<endl;
    }else if(800<=X&&X<=999){
        cout<<6<<endl;
    }else if(1000<=X&&X<=1199){
        cout<<5<<endl;
    }else if(1200<=X&&X<=1399){
        cout<<4<<endl;
    }else if(1400<=X&&X<=1599){
        cout<<3<<endl;
    }else if(1600<=X&&X<=1799){
        cout<<2<<endl;
    }else if(1800<=X&&X<=1999){
        cout<<1<<endl;
    }
}


Measured memory_bytes: 3592
n = int(input())
h = list(map(int,input().split()))
g = [[1] * (n+1) for i in range(max(h))]
for i in range(n):
  for j in range(h[i]):
    g[j][i] = 0
c = 0
for i in range(max(h)):
  for j in range(n):
    if g[i][j] == 0 and g[i][j+1] == 1:
      c += 1
print(c)

Measured memory_bytes: 3064
s = input()
cnt = 0
for i in range(len(s)):
  if i % 2 == 0 and s[i] == 'h':
    cnt += 1
  elif i % 2 == 1 and s[i] == 'i':
    cnt += 1
if len(s) % 2 == 0 and cnt == len(s):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
program prob5
    implicit none
    integer :: i, j, L, ans, m, n
    character(100005) :: s
    character(1) :: a, b
    read(*,*) s
    L = len_trim(s)

    i = 0
    j = L+1
    ans = 0
    do while(.true.)
        m = 0
        n = 0
        i = i + 1
        j = j - 1
        do while(.true.)
            if(i > L)then
                a = 'x'
                exit
            end if
            if(s(i:i) == 'x')then
                m = m + 1
                i = i + 1
            else
                a = s(i:i)
                exit
            end if
        end do
        do while(.true.)
            if(j < 1)then
                b = 'x'
                exit
            end if
            if(s(j:j) == 'x')then
                n = n + 1
                j = j - 1
            else
                b = s(j:j)
                exit
            end if
        end do        

        if(a /= b)then
            write(*,*) -1
            stop
        end if
        
        ans = ans + abs(m - n)

        if(i > L .or. j < 1)then
            exit
        end if
        
    end do

    write(*,*) ans/2

    stop
contains
end program prob5

Measured memory_bytes: 3176
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func abs(x int) int {
	if x < 0 {
		return -1 * x
	} else {
		return x
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	//sc.Buffer(nil, 100000000)

	x, k, d := nextInt(), nextInt(), nextInt()

	dt := abs(x) / d

	if dt > k {
		if x > 0 {
			fmt.Println(abs(x - (k * d)))
		} else {
			fmt.Println(abs(x + (k * d)))
		}
		return
	}

	var rest int
	if x > 0 {
		rest = x - (dt * d)
	} else {
		rest = x + (dt * d)
	}
	restK := k - dt

	if restK%2 == 0 {
		fmt.Println(abs(rest))
	} else {
		if rest > 0 {
			fmt.Println(abs(rest - d))
		} else {
			fmt.Println(abs(rest + d))
		}
	}
}


Measured memory_bytes: 1776
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    S = input()
    d = [0]*2019
    dn = [0]*2019
    ans = 0
    for s in S:
        sn = int(s)
        dn[sn] += 1
        for i in range(2019):
            dn[(i*10+sn)%2019] += d[i]
        d, dn = dn, d
        for i in range(2019):
            dn[i] = 0
        ans += d[0]
    print(ans)






main()



Measured memory_bytes: 75572
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;

int main() {
    string S;
    ll K;
    cin >> S >> K;
    for (ll i = 0; i < K; i++) {
        if (S[i] != '1') {
            cout << S[i] << endl;
            return 0;
        }
        else {
            if (i == S.length() - 1) {
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
/**                                                     **\
 *    author:       Divianshu Bansal                     *
 *    e-mail id:    god_coder@icloud.com                 *
**/                                                     
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define int long long
#define BIG 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
int max3(int a,int b,int c){
    return max(a,max(b,c));
}
int min3(int a,int b,int c){
    return min(a,min(b,c));
}
int32_t main(){
    int n;  cin>>n;
    string s;   cin>>s;
    if(n>=3200){
        cout<<s;
    }
    else{
        cout<<"red";
    }
    return 0;
}

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

int main(){
    int n;
    int p,d1,d2;
    while(1){
    	cin >> n;
    	if(n == 0) break;
    	int msum=0,mnum=0;
        for(int i=0;i<n;i++){
            cin >> p >> d1 >> d2;
            msum = max(msum,d1+d2);
            if(msum == d1+d2) mnum = p;
        }
        cout << mnum << " " << msum << endl;
    }
}

Measured memory_bytes: 1160
import java.io.*;

public class Main{
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	while(true){
	    String str[]=br.readLine().split(" ");

	    int d=Integer.parseInt(str[0]);
	    int e=Integer.parseInt(str[1]);

	    if(d==0&&e==0)
		break;

	    double min=Double.MAX_VALUE;
	    for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
		    if(i+j==d){
			double dist=Math.sqrt(i*i+j*j);

			double value=Math.abs(dist-e);
			min=Math.min(min,value);
		    }
		}	
	    }

	    System.out.println(min);
	}
    }
}



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


void solve(long long K, long long N, std::vector<long long> A){
    ll max_dist = A[0];
    for(int i = 1;i<N;i++) { 
        if(A[i] - A[i-1] > max_dist)
            max_dist = A[i] - A[i-1];
    }
    if(K - A[N-1] + A[0] > max_dist)
        max_dist = K - A[N-1] + A[0];
    cout << K - max_dist << endl;
    
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;

int main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);cout.tie(0);
	int n;
	
	cin>>n;
	cout<<n+n*n+n*n*n;
 	return 0;
}



Measured memory_bytes: 3544
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int cc[55],vv[55];
int main(){
	int n;cin>>n;rep(i,1,n)cin>>cc[i];
	rep(i,1,n)cin>>vv[i];
	int ans=0;
	rep(i,1,n)ans+=max(cc[i]-vv[i],0);
	cout<<ans<<endl;
	return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node
{
	string s;
	int t;
	bool friend operator < (node a,node b){
		if(a.t==b.t){
			return a.s<b.s;
		}
		return a.t>b.t;
	}
}w[200005];
string a[200005];
map<string,int> m;
int main()
{
	ios::sync_with_stdio(false);
	int n,p=0;
	cin>>n;
	for(int i=0;i<n;i++){
		string ss;
		cin>>ss;
		if(!m[ss]){
			a[p++]=ss;
		}
		m[ss]++;
	}
	for(int i=0;i<p;i++){
		w[i].s=a[i];
		w[i].t=m[a[i]];
	}
	sort(w,w+p);
	cout<<w[0].s<<endl;
	for(int i=1;i<p;i++){
		if(w[i].t==w[i-1].t){
			cout<<w[i].s<<endl;
		}else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 29696
#include <stdio.h>
#include <stdlib.h>
#define INF 900000000000000000

long long min(long long a,long long b){
  if(a < b){
    return a;
  }
  return b;
}

long long max(long long a,long long b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  int A,B,Q;
  long long lezinzya,rizinzya;
  long long letera,ritera;
  scanf("%d%d%d",&A,&B,&Q);

  long long s[A+2],t[B+2],x;
  for(int i = 1;i <= A;i++) scanf("%lld",&s[i]);
  for(int i = 1;i <= B;i++) scanf("%lld",&t[i]);
  s[0] = 0; t[0] = 0;
  s[A+1] = INF;
  t[B+1] = INF;

  for(int k = 0;k < Q;k++){
    long long ans;
    scanf("%lld",&x);
    int le = 0;
    int ri = A+1;
    int mid = (ri+le)/2;
    while(ri-le > 1){
      mid = (ri+le)/2;
      if(x < s[mid])
        ri = mid;
      else
        le = mid;
    }
    if(s[le] == 0) lezinzya = INF;
    else lezinzya = llabs(x-s[le]);
    if(s[ri] == INF) rizinzya = INF;
    else rizinzya = llabs(x-s[ri]);

    le = 0;
    ri = B+1;
    mid = (ri+le)/2;
    while(ri-le > 1){
      mid = (ri+le)/2;
      if(x < t[mid])
        ri = mid;
      else
        le = mid;
    }
    if(t[le] == 0) letera = INF;
    else letera = llabs(x-t[le]);
    if(t[ri] == INF) ritera = INF;
    else ritera = llabs(x-t[ri]);

    ans = min(max(lezinzya,letera),max(rizinzya,ritera));
    ans = min(ans,min(lezinzya*2+ritera,rizinzya*2+letera));
    ans = min(ans,min(letera*2+rizinzya,ritera*2+lezinzya));
    printf("%lld\n",ans);
  }

  return 0;
}

Measured memory_bytes: 2816
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: BufRead> {
  reader: R,
  iter: std::vec::IntoIter<String>
}

#[allow(dead_code)]
impl<R: BufRead> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader, iter: vec![String::new()].into_iter() }
  }
  fn new_line(&mut self) {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    self.iter = line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>().into_iter();
  }
  fn get<T: FromStr>(&mut self) -> T {
    self.iter.next().unwrap().parse().ok().unwrap()
  }
  fn get_line(&mut self) -> String {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    line.trim().to_string()
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  sc.new_line();
  let (a, b, d) = scan!(sc; f64, f64, f64);
  let r = d / 180.0 * std::f64::consts::PI;
  let h = b * r.sin();
  let s = a * h / 2.0;
  let c = ((a * a) + (b * b) - (2.0 * a * b * r.cos())).sqrt();
  let l = a + b + c;
  println!("{}\n{}\n{}", s, l, h);
}



Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n;
  cin >> n;
  vector<ll>a(n);
  rep(i,n) cin >> a[i];
  ll ans =a[0];
  rep(i,n-1) ans^=a[i+1];
  rep(i,n){
    ll num = ans^a[i];
    cout << num << endl;
  }
  return 0;
}


Measured memory_bytes: 4720
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var a, b, c int
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)
	fmt.Fscan(r, &c)

	x := c - a - b
	if x < 0 {
		fmt.Println("No")
		return
	}
	if 4*a*b < x*x {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    final int dataCount = Integer.valueOf(input.readLine());
    int[][] array = new int[dataCount][2];

    for (int i = 0; i < dataCount; i++)
    {
      String[] INPUT_STR = input.readLine().split(" ");
      array[i][0] = Integer.valueOf(INPUT_STR[0]);
      array[i][1] = Integer.valueOf(INPUT_STR[1]);
    }

    int max = -1;
    int index = -1;
    for (int i = 0; i < array.length; i++)
    {
      if (max < array[i][1])
      {
        max = array[i][1];
        index = array[i][0];
      }
      else if (max == array[i][1] && index > array[i][0])
      {
        index = array[i][0];
      }
    }
    System.out.println(index + " " + max);
  }
}



Measured memory_bytes: 24512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n, w, d;
int p[110], s[110];
typedef tuple<int, int, int, int> tup;

int main(void){
	while(1){
		cin >> n >> w >> d;
		if(n == 0 && w == 0 && d == 0) break;
		rep(i, n){
			cin >> p[i] >> s[i];
		}
		priority_queue<tup, vector<tup>, greater<tup>> q[2]; //??\???????????? ??¢??? ????????????
		q[0].push(make_tuple(-1, w * d, w, d));
		rep(i, n){
			rep(j, p[i] - 1){
				int num, men, x, y; 
				tie(num, men, x, y) = q[i % 2].top(); q[i % 2].pop();
				q[(i + 1) % 2].push(make_tuple(num, men, x, y));
			}

			//?????????
			int num, men, x, y; 
			tie(num, men, x, y) = q[i % 2].top(); q[i % 2].pop();
			int len = s[i];
			len %= (x * 2 + y * 2);
			rep(j, 2){
				if(len - x < 0){
					int x1 = x - len, x2 = len;
					q[(i + 1) % 2].push(make_tuple(i, x1 * y, x1, y));
					q[(i + 1) % 2].push(make_tuple(i, x2 * y, x2, y));
					break;
				}
				len -= x;
				if(len - y < 0){
					int y1 = y - len, y2 = len;
					q[(i + 1) % 2].push(make_tuple(i, x * y1, x, y1));
					q[(i + 1) % 2].push(make_tuple(i, x * y2, x, y2));
					break;
				}
				len -= y;
			}

			while(!q[i % 2].empty()){
				int num, s, x, y; 
				tie(num, s, x, y) = q[i % 2].top(); q[i % 2].pop();
				q[(i + 1) % 2].push(make_tuple(num, s, x, y));
			}
		}
		vector<int> ans;
		rep(i, 2){
			while(!q[i].empty()){
				int num, men, x, y; 
				tie(num, men, x, y) = q[i].top(); q[i].pop();
				ans.pb(men);
			}
		}
		sort(all(ans));
		rep(i, ans.size()){
			if(i == ans.size() - 1) printf("%d\n", ans[i]);
			else printf("%d ", ans[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 3128
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5;
const int INF = INT_MAX;
const db PI = acos(-1);

void test();

int main() {
    fast_io();
    test();
    return 0;
}

void test() {
    string s;
    cin >> s;
    int n = s.size(), cnt = 15 - n;
    for (int i = 0; i < n; ++i) {
        cnt += (s[i] == 'o');
    }
    cout << (cnt > 7 ? "YES\n" : "NO\n");
}


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

int main()
{
	int n;
	while (cin >> n && n != 0)
	{
		int count = 0;
		for (int i = n + 1; i <= 2 * n; i++)
		{
			bool flag = false;
			for (int j = 2; j*j <= i; j++)
			{
				if (i % j == 0)
				{
					flag = true;
					break;
				}
			}
			if (!flag)count++;
		}

		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=100010,O=1000000007;
int pre[N][2],nxt[N];
bool vis[N];
int ring[N];
int f[N];
inline int Main(){
	int n=ni;
	memset(pre,0,sizeof(pre));
	for(int i=1;i<=n;i++){
		nxt[i]=ni;
		if(pre[nxt[i]][0]==0){
			pre[nxt[i]][0]=i;
		}else if(pre[nxt[i]][1]==0){
			pre[nxt[i]][1]=i;
		}else return 0;
	}
	memset(ring,0,sizeof(ring));
	lint ans=1;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			int j=i,sz=0;
			for(;!vis[j];vis[j]=true,j=nxt[j]);
			for(int p=j,q;sz++,q=nxt[p],pre[q][0]!=p?swap(pre[q][0],pre[q][1]):void(),p=q,p!=j;);
			int p=j;
			bool flag=true;
			int cur=1;
			do if(pre[p][1]){
				flag=false;
				int a=pre[p][0],b=pre[p][1];
				for(;vis[b]=true,pre[b][0];a=pre[a][0],b=pre[b][0]){
					if(pre[a][1]||pre[b][1])return 0;
				}
				if(pre[a][1]==0){
					cur=(cur<<1)%O;
				}
			}while(p=nxt[p],p!=j);
			if(flag){
				assert(cur==1);
				ring[sz]++;
			}else{
				(ans*=cur)%=O;
			}
		}
	}
	for(int i=1;i<=n;i++){
		bool flag=(i&1)&&i!=1;
		f[0]=1,f[1]=flag+1;
		for(int j=2;j<=ring[i];j++){
			f[j]=((lint)f[j-2]*(j-1)%O*i%O+(f[j-1]<<flag))%O;
		}
		(ans*=f[ring[i]])%=O;
	}
	return ans;
}
int main(){
	printf("%d\n",Main());
	return 0;
}

Measured memory_bytes: 2304
from queue import Queue

N = int(input())
node_array = [[] for i in range(N)]

for _ in range(N - 1):
    i, j = map(int, input().split())
    node_array[i - 1].append(j - 1)
    node_array[j - 1].append(i - 1)

c_array = sorted(map(int, input().split()), reverse=True)
ans = sum(c_array[1:])
ans_array = [-1] * N

edge = Queue()

edge.put(0)
ans_array[0] = 0

for i in range(N):
    item = edge.get()
    ans_array[item] = str(c_array[i])
    for j in node_array[item]:
        if ans_array[j] == -1:
            edge.put(j)
            ans_array[j] == 0

print(ans)
print(" ".join(ans_array))


Measured memory_bytes: 52820
import java.io.*;
import java.util.StringTokenizer;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        String s = sc.next(), t = sc.next();
        int a = sc.nextInt() , b = sc.nextInt();
        if ((sc.next().equals(s)))a--;
        else b--;
        out.println(a + " " + b);
        out.flush();
        out.close();
    }


    static class Scanner {

        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        boolean ready() throws IOException {
            return br.ready();
        }


        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }

}

Measured memory_bytes: 21332