akhauriyash/Code-Regression huggingface dataset:
n,y = map(int,input().split())

s = y//1000

if n > s:
    print("-1 -1 -1")
elif n == s:
    print("0 0 "+str(s))
else:
    flag = False
    sup = s-n
    f = 0
    t = 0
    for i in range(sup//4+max(1-sup%4,0)):
        if (sup-4*i)%9 == 0:
            f = i
            t = (sup-4*i)//9
            if s-(f*5+t*10) >= 0:
                flag = True
                # print(i)
                break
            else:
                flag = False
    if flag:
        print(t,f,s-(f*5+t*10))
    else:
        print("-1 -1 -1")



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

int main(){
    int n;
    cin >> n;
    int l[n];
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }

    int ans = 0;

    sort(l,l+n);

    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[k] + l[j] > l[i] ){
                    ans += 1;
                }
                else{
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

a,b,k = map(int,input().split())
r = gcd(a,b)
e = []
for i in range(1,r+1):
    if r%i == 0:
        e.append(i)
print(e[len(e)-k])

Measured memory_bytes: 9120
#include<stdio.h>
int main(void)
{
	int n,p[100],i,j,cnt,max;
	scanf("%d",&n);
	max=0;
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
	}
	for(i=1;i<=n;i++){
		for(j=0;j<n;j++){
			if(i<=p[j]){
				cnt++;
			}
		}
		if(i<=cnt && i>max){
			max=i;
		}
		cnt=0;
	}
	printf("%d\n",max);
	return 0;
}


Measured memory_bytes: 2132
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    cout << x+y/2 << endl;

    return 0;
}


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


void solve(long long N, long long A, long long B){
  if(abs(A-B)%2 == 0) {
    cout << (abs(A-B)/2) << endl;
  }
  else if((min(A, B) - 1) < (N - max(A, B))) {
    cout << (min(A, B) - 1) + (abs((A-1) - B) / 2) << endl;
  }
  else {
    cout << (N - max(A, B)) + (abs(A - (B+1)) / 2) << 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 N;
  scanf("%lld",&N);
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


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

using namespace std;

int main()
{
    string s, t;    cin >> s >> t;
    int a, b;       cin >> a >> b;
    string u;       cin >> u;

    if (s == u) {
        cout << a - 1 << ' ' << b << '\n';
    } else if (t == u) cout << a << ' ' << b - 1 << '\n';
    else cout << a << ' ' << b << '\n';


    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

struct name
{
	int x;
	int y;
	int z;
}list[100005];
int time1[100005];
int s[100005];
int cmp(name a,name b)
{
	return a.x<b.x;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%d%d%d",&list[i].x,&list[i].y,&list[i].z);
	}
		sort(list,list+n,cmp);
	int anc=1;
	time1[0]=list[0].y;
	s[0]=list[0].z;
	int lose=1;
	for(int i=1;i<n;i++)
	{
		int j;
		lose=1;
		for(j=0;j<anc;j++)
			{
				if(time1[j]<list[i].x||(time1[j]==list[i].x&&list[i].z==s[j]))
				{
					time1[j]=list[i].y;
					lose=0;
					break;
				}
				
			}
			
		if(lose)
		{	
			time1[anc]=list[i].y;
			s[anc]=list[i].z;
			anc++;
		}
	}
	
	
	printf("%d\n",anc);
	
	
	
	
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>Data(n);
  for(int i=0;i<n;i++){
    cin>>Data[i];
  }
  for(int i=n-1;i>0;i--){
    if(Data[i-1]>Data[i]){
      if(Data[i-1]-Data[i]>=2){
        cout<<"No"<<endl;
        //cout<<Data[i-1]<<" "<<Data[i]<<endl;
        return 0;
      }
      Data[i-1]--;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3716
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000000000000000LL

using namespace std;
typedef long long int ll;
typedef pair<int, ll> P;

int c[100000];
vector<P> G[100000];
int x0;
bool e0;
vector<int> cp;
ll num[100000];
bool muri;

void dfs(int x){
	for(int i=0; i<G[x].size(); i++){
		int y=G[x][i].first;
		if(c[y]==0){
			c[y]=-c[x];
			dfs(y);
			if(e0==1 && cp.back()==y){
				cp.push_back(x);
			}
			if(e0==1 && x0==x){
				e0=0;
			}
		}else if(c[y]!=-c[x]){
			if(cp.empty()){
				e0=1, x0=y;
				cp.push_back(x);
			}
		}
	}
	return;
}

void dfs2(int x){
	for(int i=0; i<G[x].size(); i++){
		int y=G[x][i].first;
		if(num[y]==INF){
			num[y]=G[x][i].second-num[x];
			dfs2(y);
		}else{
			if((num[x]+num[y])!=(G[x][i].second)){
				muri=1;
			}
		}
	}
	return;
}
		
int main()
{
	x0=100000000;
	int n, m;
	scanf("%d %d", &n, &m);
	int u[100000], v[100000];
	ll s[100000];
	for(int i=0; i<m; i++){
		scanf("%d %d %lld", &u[i], &v[i], &s[i]);
		u[i]--;
		v[i]--;
		G[u[i]].push_back(P(v[i], s[i]));
		G[v[i]].push_back(P(u[i], s[i]));
	}
	c[0]=1;
	dfs(0);
	int st;
	fill(num, num+n, INF);
	if(!cp.empty()){
		ll s0=0;
		for(int i=0; i<cp.size(); i++){
			int x=cp[i], y;
			if(i==cp.size()-1){
				y=cp[0];
			}else{
				y=cp[i+1];
			}
			for(int j=0; j<G[x].size(); j++){
				if(y==G[x][j].first){
					if(i%2==0){
						s0+=(G[x][j].second);
					}else{
						s0-=(G[x][j].second);
					}
					break;
				}
			}
		}
		if(s0%2ll!=0){
			cout<<0<<endl;
			return 0;
		}
		s0/=2ll;
		num[cp[0]]=s0;
		st=cp[0];
	}else{
		st=0;
		num[0]=0;
	}
	dfs2(st);
	if(muri){
		cout<<0<<endl;
		return 0;
	}
	ll m1=INF, m2=INF;
	for(int i=0; i<n; i++){
		if(c[i]==1){
			if(m1>num[i]) m1=num[i];
		}else{
			if(m2>num[i]) m2=num[i];
		}
	}
	if(!cp.empty()){
		if(m1>0 && m2>0){
			cout<<1<<endl;
		}else{
			cout<<0<<endl;
		}
		return 0;
	}
	if(m1+m2<2){
		cout<<0<<endl;
    }else{
		cout<<m1+m2-1<<endl;
    }
	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    ll n,k;
    cin >> n >> k;
    if (k*2 > n+1) {
        cout << -1 << endl;
        return 0;
    }
    set<ll> st;
    for (int i = 0;i < n;++i) st.insert(n+k+i);
    for (int i = 0;i < (n+1)/2;++i) {
        ll a = 2*i+k,c = 2*n+k+i;
        auto it = st.upper_bound(c-a);
        it--;
        cout << a << " " << *it << " " << c << "\n";
        st.erase(it);
    }
    for (int i = 0;i < n-(n+1)/2;++i) {
        ll a = 2*i+k+1,c = 2*n+k+(n+1)/2+i;
        auto it = st.upper_bound(c-a);
        it--;
        cout << a << " " << *it << " " << c << "\n";
        st.erase(it);
    }
}

Measured memory_bytes: 6912
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define ll long long

int main(void){
  int N, Q;
  cin >> N >> Q;
  fenwick_tree<ll> bit(N);
  for (int i = 0; i < N; ++i){
    int ai; cin >> ai;
    bit.add(i, ai);
  }
  while (Q--){
    int q; cin >> q;
    if (q == 0){ // add query
      int p, x; cin >> p >> x;
      bit.add(p, x);
    }
    else{ // get sum query
      int l, r; cin >> l >> r;
      cout << (bit.sum(l, r)) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 8216
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<char>> a(h, vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a.at(i).at(j);
    }
  }
  int count=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a.at(i).at(j)=='#'){
        count++;
      }
    }
  }
  if(count==h+w-1){
    cout<<"Possible";
  }
  else{
    cout<<"Impossible";
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int X = scan.nextInt();

		//演算
		String result = "No";

		if (X >= 30) {
			result = "Yes";
		}
		//結果出力
		System.out.println(result);
	}
}


Measured memory_bytes: 35688
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int box[10001];
	int flg;
	int cnt;
	int i;
	while(1){
		cin>>n;
		if(n==0)	break;
		cnt=n;
		flg=0;
		for(i=0;i<n;i++){
			cin>>box[i];
			if(box[i]>=2)	flg=1;
			if(box[i]==0)	cnt--;
		}
		if(flg==1)	cout<<cnt+1<<endl;
		else	cout<<"NA"<<endl;
	}
	return 0;
}
			
		


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c,d;
  cin >> a >> b >> c>>d;
  cout << (a-c)*(b-d) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int mn = 1000000000,mnp;
  for(int i = 0; n > i; i++){
    int tmp;cin>>tmp;
  }
  cout << ((n-1)%(k-1) == 0 ? (n-1)/(k-1) : (n-1)/(k-1)+1) << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1<<18;
#define mp make_pair
struct wjmzbmr
{
    pair<int,int> a,b;
    void update(pair<int,int> x)
    {
        if(x.second==a.second||x.second==b.second) return;
        if(x.first>=a.first) b=a,a=x;
        else
            if(x.first>b.first) b=x;
    }
}a[maxn+5];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<(1<<n);++i)
    {
        int x;
        scanf("%d",&x);
        a[i]={mp(x,i),mp(0,-1)};
    }
    for(int s=1;s<(1<<n);++s)
        for(int i=0;i<n;++i)
            if((1<<i)&s) a[s].update(a[s^(1<<i)].a),a[s].update(a[s^(1<<i)].b);
    int last=0;
    for(int i=1;i<(1<<n);++i)
    {
        last=max(last,a[i].a.first+a[i].b.first);
        printf("%d\n",last);
    }
    return 0;
}


Measured memory_bytes: 7168
#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,a,b; cin>>n>>a>>b;
	int cnta=0, cntb=0, cntc=0;
	rep(i,n){
		int p; cin>>p;
		if(p<=a) cnta++;
		else if(p>a&&p<=b) cntb++;
		else cntc++;
	}
	cout<<min(cnta,min(cntb,cntc))<<endl;
}

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

int main() {
 vector<string> c(3);
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin >> c[i][j];
  
   for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      if(i == j){
  		cout << c[i][j];
        }
	 cout << endl;
}

Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


r,c,k = readints()
a = [[0]*(c+1) for i in range(r+1)]

for i in range(k):
    R,C,V = readints()
    a[R][C] = V

dp = [0]*(r+1)*(c+1)*4

for x in range((r+1)*(c+1)*4):
    i = x//((c+1)*4)
    l = x%((c+1)*4)
    j = l//4
    l %= 4
    if i==0 or j==0:
        continue
    if l==0:
        dp[x] = max(dp[i*(c+1)*4 + (j-1)*4], dp[(i-1)*(c+1)*4 + j*4 + 3])
    else:
        dp[x] = max(dp[i*(c+1)*4 + (j-1)*4 + l], dp[(i-1)*(c+1)*4 + j*4 + 3]+a[i][j], dp[i*(c+1)*4 + (j-1)*4 + l-1]+a[i][j])

print(dp[-1])

Measured memory_bytes: 496420
s_arr = input().replace('><', '> <').split()
ans = 0

for s in s_arr:
  left = s.count('<')
  right = len(s) - left
  if left < right:
    left -= 1
    ans += left * (left + 1) // 2 + right * (right + 1) // 2
  else:
    right -= 1
    ans += left * (left + 1) // 2 + right * (right + 1) // 2

print(ans)



Measured memory_bytes: 12464
n = int(input())
s = [list(input()) for i in range(n)]
while len(s) > 1:
    a = s.pop(0)
    b = s.pop(0)
    l = []
    for i in a:
        if i in b:
            l.append(i)
            b.remove(i)
    s.insert(0,l)
ans = s.pop(0)
ans.sort()
for i in ans:
    print(i, end = "")

Measured memory_bytes: 39280
n = int(input())
mark = ['S','H','C','D']
l = {'S':[],'H':[],'C':[],'D':[]}
for i in range(n):
    m, num = input().split()
    num = int(num)
    l[m].append(num)
for m in mark:
    for i in range(13):
        if l[m].count(i + 1) == 0:
            print(m,i + 1)


Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){

	int w[10],k[10];
	int W,K;
	
	for(int i=0;i<10;i++)
		cin>>w[i];
	for(int i=0;i<10;i++)
		cin>>k[i];
	
	sort(w,w+10);
	sort(k,k+10);
	
	W=w[7]+w[8]+w[9];
	K=k[7]+k[8]+k[9];
	
	cout<<W<<" "<<K<<endl;
	
}

Measured memory_bytes: 1180
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=k;i<n;i++){
    if(a[i]>a[i-k]){
      cout <<"Yes\n";
    }else{
      cout <<"No\n";
    }
  }
}


Measured memory_bytes: 4784
void main()
{
    long n, m;
    rdVals(n, m);
    Edge[][] edge = new Edge[][](n);
    foreach (i; 0 .. m)
    {
        long l, r, d;
        rdVals(l, r, d);
        --l, --r;
        edge[l] ~= Edge(r, d), edge[r] ~= Edge(l, -d);
    }

    bool[] seen = new bool[n];
    long[] dist = new long[n];
    bool ok = true;

    void dfs(long idx)
    {
        if (seen[idx]) return;
        seen[idx] = true;
        foreach (e; edge[idx])
        {
            if (seen[e.to])
            {
                if (dist[e.to] != dist[idx] + e.dist) ok = false;
            }
            else
            {
                dist[e.to] = dist[idx] + e.dist;
                dfs(e.to);
            }
        }
    }

    foreach (i; 0 .. n)
    {
        dfs(i);
    }

    writeln(ok ? "Yes" : "No");
}

struct Edge
{
    long to, dist;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 34940
#include<stdio.h>
int main(void)
{
    double a[101],n,sum = 0;
    double m;
    int count = 0,i;
    scanf("%lf %lf",&n,&m);
    for(i = 1 ; i <= n ; i++)
    {
        scanf("%lf",&a[i]);
        sum+= a[i];
    }
    for(i = 1 ; i <= n ; i++)
    {
        if((a[i] / sum) >= 1 / (4 * m) )
        {
            count++;
        }
    }
    if(count >= m)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    
    return 0 ;
}

Measured memory_bytes: 1732
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

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

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
int amari[1000001];
int main() {
int x,y;
	while (cin>>x>>y,x){
		fill_n(amari, 1000001, -1);
		int ansa=0,ansb=0;
		int count=1;
		amari[x]=0;
		while (1){
			x *= 10;
				if (amari[x%y] == -1){
					amari[x%y] = count;
					if (x%y == 0){
						ansa=count;
						break;
					}
					x%=y;
				}
				else{
					ansa = amari[x%y];
					ansb = count - amari[x%y];
					break;
				}
				
			count++;
			
		}
		cout << ansa << " "<<ansb<<endl;
	}
}

Measured memory_bytes: 5064
#include <iostream>

using namespace std;

int main(){
	int n; cin >> n;
	int k[1000];
	int p[1000];
	for(int i = 0; i < n; i++){
		cin >> k[i];
		cin >> p[i];
	}

	for (int i = 0; i < n; i++){
		if(k[i] % p[i] != 0){
			cout << k[i] % p[i] << endl;
		}else{
			cout << p[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1168
/*
AizuOnline A0058
Title Orthogonal 
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
#include <float.h>
#include <math.h>
#define EPS 1e-08
//#include <limits.h>
//Global data section
double xa,ya,xb,yb,xc,yc,xd,yd;
//
int is_orthogonal(double xa,double ya,double xb,double yb,
                  double xc,double yc,double xd,double yd)
{

        if(fabs((ya-yb)*(yc-yd)+(xa-xb)*(xc-xd))<EPS)
                return(-1);
        else
                return(0);
}
main()
{
        int ret;

        while(EOF!=scanf("%lf %lf %lf %lf %lf %lf %lf %lf ",
                         &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd))

        {
                ret=is_orthogonal(xa,ya,xb,yb,xc,yc,xd,yd); 
                printf("%s\n",ret?"YES":"NO");
        }

return(0);
}

Measured memory_bytes: 616
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

const int MXN = 2e5, IINF = 1e9 + 10, INF = 1e18 + IINF + 10, MOD = 1000000007;
const ld PI = 4.0 * atanl(1.0), PREC = .000001;
const char nl = '\n';

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define ins insert

int n, m, t, a[MXN];

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

int main() {
  fast();
  cin >> n;
  FOR(i, 0, n) cin >> a[i];
  vi dp(n + 1, INF);
  dp[0] = 0;
  FOR(i, 1, n) {
    dp[i] = min(dp[i], dp[i - 1] + abs(a[i] - a[i - 1]));
    if (i - 2 >= 0) dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
  }
  cout << dp[n - 1];
  return 0;
}


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

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

    vector<int> h(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    vector<int> dp(n, 1000000000);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= min(i, k); j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n - 1] << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

int d[10] = {INTINF, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[pow10(4)];

void solve()
{
    int N, M;
    cin >> N >> M;

    vector<int> A(M);
    REP0 (i, M)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end(), [](int a, int b) { return a > b; });

    REP1 (i, N)
    {
        bool isng = true;
        REP0 (j, M)
        {
            if (i - d[A[j]] < 0)
                continue;
            dp[i] = max(dp[i], dp[i - d[A[j]]] + 1);
            isng = false;
        }
        if (isng)
            dp[i] = -INTINF;
    }

    int match = N;
    while (match)
    {
        REP0 (j, M)
        {
            if (match - d[A[j]] >= 0 and dp[match - d[A[j]]] == dp[match] - 1)
            {
                cout << A[j];
                match -= d[A[j]];
                break;
            }
        }
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n]={0};
  for(int i=0;i<k;i++)
  {
    int d;
    cin>>d;
    for(int j=0;j<d;j++)
    {
      int x;
      cin>>x;
      a[x-1]++;
    }
  }
  int count=0;
  for(int i=0;i<n;i++)
  {
    if(a[i]==0)
      count++;
  }
  cout<<count;
  return 0;
}
    

Measured memory_bytes: 3592
#2次元配列を表示
def print_arr2(arr):
    for i in range(len(arr)):
        for j in range(len(arr[i])):
            print(arr[i][j],end="")
        print()
    print()

import copy

def dfs(node,edge):
    ok = True
    narr = [0 for _ in range(node)]
    M = len(edge)
    stack = []
    stack.append([0,-1])
    narr[0] = 1
    while(stack != []):
        start = stack.pop(-1)
        for i in range(M):
            if edge[start[0]][i] == 1 and narr[i] != 1:
                narr[i] = 1
                stack.append([i,start[0]])
    for i in range(node):
        if narr[i] != 1:
            ok = False
    return ok
        
N,M = map(int,input().split())
edge = [[0]*N for _ in range(N)]
tedge = [[0]*N for _ in range(N)]
count = 0
for i in range(M):
    go, to = map(int,input().split())
    edge[go-1][to-1] = 1
    edge[to-1][go-1] = 1

for go in range(N):
    for to in range(go,N):
        if edge[go][to] == 1:
            tedge = copy.deepcopy(edge)
            tedge[go][to] = 0
            tedge[to][go] = 0
            if dfs(N,tedge) == False:
                count += 1

print(count)

Measured memory_bytes: 3568
s=int(input())
if s==1:
    print(0)
    exit()
mod=10**9+7
dp=[0]*(s+1)
dp[1]=0
dp[2]=0

for i in range(3,s+1):
    for j in range(3,i+1):
        dp[i]+=(dp[i-j])%mod
    dp[i]+=1

print(dp[s]%mod)

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';              

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

bool comp(pll x,pll y){
	return x.ss > y.ss;
}

int main(){

	ll n,m;
	cin >> n >> m;

	ll a[n];
	ll i,j,k;
	pll f[m];
	ll ans = 0;
	forn(0,n,i){
		cin >> a[i];
	}

	sort(a,a + n);

	forn(0,m,i){
		cin >> f[i].ff >> f[i].ss;
	}

	sort(f,f + m,comp);

	j = 0;

	forn(0,n,i){
		if(j >= m){
			ans += a[i];
		}else{
			if(f[j].ff){
				if(f[j].ss > a[i]){
					ans += f[j].ss;
					f[j].ff--;
				}
				else{
					ans += a[i];
				}
			}else{
				if(j + 1 < m and f[j + 1].ss > a[i]){
					j++;
					ans += f[j].ss;
					f[j].ff--;
				}else{
					ans += a[i];
				}				
			}
		}
	}
	cout << ans << '\n';
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

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

    cout << ((n % 500) <= a ? "Yes" : "No") << endl;
    return (0);
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,ans=1;
    cin >> n;
    string s[n];
    for (ll i=0;i<n;i++){
        cin >> s[i];
    }
    sort(s,s+n);
    string flag=s[0];
    for (ll i=1;i<n;i++){
        if (flag!=s[i]){
            ans++;
        }
        flag=s[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9860
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????????
"""
inputstr = input().strip()
cmdnum = int(input().strip())

for i in range(cmdnum) :
    cmd = input().strip().split()

    if cmd[0] == "print":
        start = int(cmd[1])
        end = int(cmd[2]) + 1
        print(inputstr[start:end])

    if cmd[0] == "reverse":
        start = int(cmd[1])
        end = int(cmd[2]) + 1
        prev = inputstr[:start]
        revr = inputstr[start:end]
        next = inputstr[end:]
        inputstr = prev + revr[::-1] + next

    if cmd[0] == "replace":
        start = int(cmd[1])
        end = int(cmd[2]) + 1
        inputstr = inputstr[:start] + cmd[3] + inputstr[end:]

Measured memory_bytes: 7720
n, k = map(int, input().split())

d = [[], []]
for _ in range(k):
    l, r = map(int, input().split())
    d[0].append(l-1)
    d[1].append(r-1)

dp = [0]*n
dp[0] = 1
a = [0]*(n+1)
a[1] = dp[0]
for i in range(1, n):
    for j in range(k):
        r = i - d[0][j]
        l = i - d[1][j]
        if l < 1:
            l = 1
        if r < 0:
            continue
        dp[i] += a[r] - a[l-1]
        dp[i] %= 998244353
    a[i+1] = (a[i] + dp[i]) % 998244353
print(dp[-1])


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef long long ll;
typedef vector<int> vi;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
//typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const int maxN = 1e5 + 5;

int n, a, b;
int ans[maxN], parent[maxN];
bool used[maxN];
vector<pii> graph[maxN];

void DFS(int root) {
	int col = 1;
	if (root != 1 && ans[parent[root]] == col) col++;
	used[root] = true;
	for (auto x: graph[root]) {
		if (!used[x.st]) {
			ans[x.nd] = col++;
			if (root != 1 && ans[parent[root]] == col) col++;
			parent[x.st] = x.nd;
			DFS(x.st);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	REP(i, n - 1) {
		cin >> a >> b;
		graph[a].pb({b, i});
		graph[b].pb({a, i});
	}
	parent[1] = -1;
	DFS(1);
	int maxim = 0;
	REP(i, n - 1) {
		maxim = max(maxim, ans[i]);
	}
	cout << maxim << endl;
	REP(i, n - 1) cout << ans[i] << endl;
	
	return 0;
}


Measured memory_bytes: 7808
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			System.out.println(IntStream.rangeClosed(1, n).filter(i -> {
				int digitSum = digitSum(i);
				return (digitSum >= a) && (digitSum <= b);
			}).sum());
		}
	}

	/**
	 * @param number
	 * @return numberの10進数の各桁の合計
	 */
	private static int digitSum(int number) {
		int result = 0;
		while (number > 0) {
			result += number % 10;
			number /= 10;
		}
		return result;
	}
}


Measured memory_bytes: 28244
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

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

    ll h,w;cin>>h>>w;
    if(h%3==0 || w%3==0){
        cout<<0<<endl;
        return 0;
    }
    ll res=min(w,h);
    for(int i=1;i<h;i++){
        vector<ll> v(3);
        v[0]=i*w,v[1]=(h-i)*(w/2),v[2]=(h-i)*w-v[1];
        sort(v.begin(),v.end());
        res=min(res,v[2]-v[0]);
    }
    for(int i=1;i<w;i++){
        vector<ll> v(3);
        v[0]=i*h,v[1]=(w-i)*(h/2),v[2]=(w-i)*h-v[1];
        sort(v.begin(),v.end());
        res=min(res,v[2]-v[0]);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b>c+d){
        printf("Left");
    }
    else if(a+b==c+d){
        printf("Balanced");
    }
    else{
        printf("Right");
    }
    return 0;
}

Measured memory_bytes: 128
function main(input) {
    const s = input.split(' ');
    const a = parseInt(s[0], 10);
    const b = parseInt(s[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
struct node{
    int a;
    int b;
    int c;
};
int main(){
    int n;
    cin>>n;
    node arr[n];
     
    for(int i=0;i<n;i++){
        cin>>arr[i].a>>arr[i].b>>arr[i].c;
    } 

    node dp[n];
    memset(dp,0,sizeof(dp));

    dp[0].a=max(arr[0].b,arr[0].c);
    dp[0].b=max(arr[0].a,arr[0].c);
    dp[0].c=max(arr[0].a,arr[0].b);

    for(int i=1;i<n;i++){
        dp[i].a=arr[i].a+max(dp[i-1].b,dp[i-1].c);
        dp[i].b=arr[i].b+max(dp[i-1].a,dp[i-1].c);
        dp[i].c=arr[i].c+max(dp[i-1].b,dp[i-1].a);
    }
    int ans=max(dp[n-1].a,max(dp[n-1].b,dp[n-1].c));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<bits/stdc++.h>
 using namespace std;
 int main(){
    int n;
    cin>>n;
cin.ignore();
    int ac=0, wa=0, tle=0, re=0;
    string s;
    for (int i = 0; i < n; ++i)
    {
        
        getline(cin, s);
        if(s == "AC"){
            ac++;
        }
        else if(s == "WA"){
            wa++;
        }
        else if(s== "TLE"){
            tle++;

        }
        else{
            re++;
        }
    }
// AC x 3
// WA x 1
// TLE x 2
// RE x 0
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;

    return 0;
 }

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

int main() {
    
    long long a;
    cin >> a;
    if(a%1000==0) cout << "0" << endl;
    
    else{
        int res = (a/1000)+1;
        cout << 1000*res - a << endl;
    }
    
    
    
    
    
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll dp[1000001]={0},coin[101]={0};
int main()
{
    fast;
    ll n,k;
    cin>>n;cin>>k;
    ll h[100001]={0},s=INT_MAX,i,j;
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(j=1;j<=k;j++)
        {
            if((i-j)>=0)
            {
                s=abs(h[i]-h[i-j]);
                dp[i]=min(dp[i],dp[i-j]+s);
            }
        }
        //cout<<dp[i]<<endl;
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    string s;
    cin >> s;
    cout << s[0] << "" << sz(s) - 2 << "" << s[sz(s) - 1] << '\n';
    return 0;
}   

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


ll n, k;
vector<bitset<64>> b;
bitset<64> kb;
vector<int> kflag;
vector<ll> ones;

ll solve(int d, int ki) {
  ll det = 0;
  while(d > kflag[ki]) {
    det += (1LL<<d) * (kb[d] ? n - ones[d] : ones[d]);
    d--;
  }
  if(d < 0) return det;

  // 0
  ll res = 0;
  res = (1LL<<d) * ones[d];
  rep(i,d) res += (1LL<<i) * max(ones[i], n - ones[i]);
  return det + max(res, solve(d, ki+1));
}

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

  b = vector<bitset<64>>(n);
  kb = bitset<64>(k);
  for(int i = 63; i > 0; i--) if(kb[i]) kflag.push_back(i);
  kflag.push_back(-1);

  rep(i,n) {
    ll a;
    cin >> a;
    b[i] = bitset<64>(a);
  }

  ll ans = 0;
  ones = vector<ll>(64, 0);
  rep(i,64) {
    rep(j,n) {
      if(b[j][i]) ones[i]++;
    }
  }

  cout << solve(63, 0) << endl;

  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  lvector A(n);rep(i,n) cin>>A[i];
  rep(i,n-2) {
    lvector v{A[i],A[i+1],A[i+2]};
    sort(ALL(v));
    if(v[1]==A[i+1]) ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>

using namespace std;

int main(){
  for(int N;cin>>N,N;){
    string s[1234];
    for(int i=0;i<N;i++){
      cin>>s[i];
    }
    bool f=false;
    int lt=1e9+9,ht=-1e9-9;
    for(int i=0;i<N-1;i++){
      if(s[i][0]=='x'){
	if(s[i+1][0]=='x'){
	  f=true;
	}else{
	  if(i%2==0){
	    lt=min(lt,stoi(s[i+1]));
	  }else{
	    ht=max(ht,stoi(s[i+1]));
	  }
	}
      }else{
	if(s[i+1][0]=='x'){
	  if((i+1)%2==0){
	    lt=min(lt,stoi(s[i]));
	  }else{
	    ht=max(ht,stoi(s[i]));
	  }
	}else{	      
	  if(i%2==0){
	    f|=stoi(s[i])>=stoi(s[i+1]);
	  }else{
	    f|=stoi(s[i])<=stoi(s[i+1]);
	  }
	}
      }
    }
    if(f||lt-ht<2){
      cout<<"none"<<endl;
    }else if(lt-ht>2){
      cout<<"ambiguous"<<endl;
    }else{
      cout<<lt-1<<endl;
    }
  }
}

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

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	int l=a+b,r=c+d;
	
	if(l>r) cout<<"Left"<<endl;
	else if(l==r) cout<<"Balanced"<<endl;
	else cout<<"Right"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n[100],m,max=0;
  for(int i=0;i<100;i++){
    n[i] = 0;
  }
  while(cin>>m){
    n[m-1]++;
    if(max<n[m-1]){
      max++;
    }
  }
  for(int i=0;i<100;i++){
    if(n[i] == max)
      cout<<i+1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 0
// author -> LetsGoAc
#include "bits/stdc++.h"
using    namespace std;
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) c out<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  gi  greater<int> 
#define  gpi greater<pii>  
#define  sp(n) fixed<<setprecision(n)
const int mod = (int)(1e9+7);
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int pct(int x)
{   return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " <<sp(5)<< 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ---------------------- 1.cpp --------------------------------- */
const int maxn = 5e5+5;
int Bit[maxn] , N;
int color[maxn];
int last[maxn];
void update(int index , int val)
{
    while(index<=N)
    {
        Bit[index] += val;
        index += (index&-index);
    }
}
int sum_bit(int index)
{
    int s = 0;
    while(index)
    {
        s += Bit[index];
        index -= index&-index;
    }
    return s;
}
void solve(int tc)
{
    // cout<<"Case #"<<tc<<": ";
    int n,i,j,k,m,q,l,r;
    cin>>N>>q;
    repv(i,1,N)
        cin>>color[i];
    vector<pair<int,pii>> queri(q);
    rep(i,q)
    {
        cin>>queri[i].S.F>>queri[i].F;
        queri[i].S.S = i;
    }
    sort(all(queri));
    j = 0;
    int ans[q];
    repv(i,1,N)
    {
        if(last[color[i]])
            update(last[color[i]] , -1);
        last[color[i]] = i;
        update(i , 1);
        while(j<q && queri[j].F == i)
        {
            ans[queri[j].S.S] = sum_bit(i) - sum_bit(queri[j].S.F-1);
            ++j;
        }
        if(j==q)
            break;
    }
    rep(i,q)
        cout<<ans[i]<<endl;
}  
signed main()
{
    // 1.cpp
    RAGE;
    //	db();    
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
    // 	timeit();
    return 0;
}
/*
    1. To find 2's complement , reverse all the bits after 1st set bit. (right - >left.)
*/

Measured memory_bytes: 31056
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<bool> a(n+1,0);
    vector<bool> b(n+1,0);
    int tmp;
    REP(i, n+1){
        cin >> tmp;
        a[i+1] = (tmp==1?true:false);
    }
    for(int i = ceil((n+1.0)/2); i <= n; i++){
    //    cout << i << endl;
        b[i] = a[i];
    }
    
    int cnt = 0;
    for(int i = n/2; i >0; i--){
        //cout << i << endl;
        cnt = 0;
        for(int j = 2; j*i <= n; j++){
            //cout << j * i << endl;
            cnt += b[j*i];
        }
        b[i] = ((cnt+a[i])%2);
    }
    cnt = 0;
    for(int i = 1; i <=n ; i++){
        if(b[i]){
            cnt++;
        }
    }
//    for(int i = 1; i <=n ; i++){
//        cout << b[i] << " ";
//    }
//    cout << endl;
    cout << cnt << endl;
    bool first = true;
    for(int i = 1; i <=n ; i++){
        if(b[i]){
            if(!first){
                cout << " ";
            }
            cout << i;
            first = false;
        }
    }
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;


inline ll power(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) {
      res *= a;
    }
    a *= a;
    b >>= 1;
  }
  return res;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll h;
  cin >> h;
  int c = 0;
  while(h) h >>= 1, c++;
  cout << power(2, c) - 1 << endl;
}


Measured memory_bytes: 256
/*		Author : Kaustubh Gangwar
		||S||A||M||R||A||T||
*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ld long double
#define pb push_back
#define gcd __gcd
#define vii vector<int>
#define vll vector<long long>
#define all(x) x.begin(),x.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
typedef long long  ll;
typedef pair<int,int> pii;

ll bpow(ll a, ll b) {
	a=a; ll res = 1;
    while(b){
        if (b & 1)
        res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	ll test=1;
//	cin>>test;
	while(test--)
	{
		ll n; cin>>n;
		ll a[n]; 
		f(i,0,n) cin>>a[i];
		sort(a,a+n,greater<ll>());
		ll ans=0;
		ans+=a[0];
		int j=1;
		for(int i=2;i<n;i+=2)
		{	
			ans+=a[j];
			if(i+1<n)
			ans+=a[j];
			
			j++;
		}
		cout<<ans<<nl;
		
	}
return 0;
}


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

using namespace std;

struct grid {
	int x,y;
};


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

	int h,w,d,q;
	grid a[90005];
	int cost[90005];
	int nt,now;
	int l,r;


	cin >> h >> w >> d;

	int n;
	for (int i = 0;i < h;i++){
		for (int j = 0;j < w;j++){
			cin >> n;
			a[n].x = j;
			a[n].y = i;
		}
	}


	for (int i = 1;i <= d;i++){
		cost[i] = 0;
		now = i;
		nt = i+d;
		while (nt <= h*w) {
			cost[nt] = cost[now] + abs(a[now].x-a[nt].x) + abs(a[now].y-a[nt].y);
			now += d;
			nt += d;
		}

	}

	cin >> q;

	for (int i = 0;i < q;i++){
		cin >> l >> r;
		cout << cost[r] - cost[l] << endl;
	}

	return 0;

}


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

int main()
{
    int n, x, y;
    char s[500];
    cin >> s;
    n = strlen(s);
    x = n;
    while(1)
    {
        x = x - 2;
        y = strncmp((s), (s+(x/2)), (x/2));
        if(y==0)
        {
            cout << x << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3644
n,k = map(int, input().split())
h_list = []
for i in range(n):
    h = int(input())
    h_list.append(h)
h_list.sort()
ans = 10000000000000000
for i in range(n-k+1):
    if ans > h_list[i+k-1] - h_list[i]:
        ans = h_list[i+k-1] - h_list[i]  
print(ans)  

Measured memory_bytes: 7384
"""def power(x, y): 
    res = 1
    x=x
    while (y > 0): 
        if ((y & 1) == 1) : 
            res = (res * x) 
        y = y >> 1
        x = (x * x)
    return res""" 
"""def fact(n):
    if(n==0):
        return 1
    if(n==1):
        return 1
    return fact(n-1)+fact(n-2)"""

import math
#import combinations


t=int(input())
d={}
count=0
for _ in range(t):
    #n=int(input())
    s=input()
    #arr=list(map(int,input().split()))
    #b=list(map(int,input().split()))
    #d={}
    #flag=0
    #a,b,c,d=map(int,input().split())
    #count=0
    if s not in d:
        count+=1
        d[s]=1
    else:
        d[s]+=1
print(count)


Measured memory_bytes: 35232