akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

template <class T>
bool set_min(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

struct State {
    ll a, b, c;
};

int main() {
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    bool ok = true;
    string ans;
    vector<string> SS(N);
    cin >> SS;
    rep(i, N) {
        string S = SS[i];

        if (S == "AB") {
            if (A > B) {
                A--;
                B++;
                ans.push_back('B');
            } else if (i + 1 < N and A == B) {
                if (SS[i + 1] == "AC") {
                    A++;
                    B--;
                    ans.push_back('A');
                } else {
                    A--;
                    B++;
                    ans.push_back('B');
                }
            } else {
                A++;
                B--;
                ans.push_back('A');
            }
        } else if (S == "AC") {
            if (A > C) {
                A--;
                C++;
                ans.push_back('C');
            } else if (i + 1 < N and A == C) {
                if (SS[i + 1] == "AB") {
                    A++;
                    C--;
                    ans.push_back('A');
                } else {
                    A--;
                    C++;
                    ans.push_back('C');
                }
            } else {
                A++;
                C--;
                ans.push_back('A');
            }
        } else if (S == "BC") {
            if (B > C) {
                B--;
                C++;
                ans.push_back('C');
            } else if (i + 1 < N and B == C) {
                if (SS[i + 1] == "AB") {
                    B++;
                    C--;
                    ans.push_back('B');
                } else {
                    B--;
                    C++;
                    ans.push_back('C');
                }
            } else {
                B++;
                C--;
                ans.push_back('B');
            }
        } else
            assert(0);
        ok &= A >= 0 and B >= 0 and C >= 0;
    }
    if (ok) {
        cout << "Yes" << endl;
        rep(i, N) cout << ans[i] << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 6688
S = int(input())
x1, y1 = 0, 0
y2 = 1
y3 = 10**9
if S % 10**9 == 0:
    x2 = S//10**9
    x3 = 0
else:
    x2 = S//10**9+1
    x3 = 10**9-(S%10**9)
print(x1,y1,x2,y2,x3,y3)

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 805;
const int INF = 1e+9;

int h,w,k;
char s[N][N];
int sx,sy;
int dis[N][N],vis[N][N],tim;
int fx[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
struct point{
	int x,y;
	point (const int x_=0,const int y_=0){x=x_;y=y_;}
}que[N*N];

int main(){
	h=get();w=get();k=get();
	fo(i,1,h){
		scanf("%s",s[i]+1);
		fo(j,1,w)
		if (s[i][j]=='S')sx=i,sy=j;
	}
	fo(i,1,h)fo(j,1,w)dis[i][j]=INF;
	dis[sx][sy]=0;
	int he=0,ta=1;
	que[1]=point(sx,sy);
	while(he<ta){
		point u=que[++he];
		fo(i,0,3){
			int x=u.x+fx[i][0],y=u.y+fx[i][1];
			if (!x||x>h||!y||y>w||s[x][y]=='#'||dis[x][y]<INF)continue;
			dis[x][y]=dis[u.x][u.y]+1;
			que[++ta]=point(x,y);
		}
	}
	int ans=INF;
	fo(i,1,h)
		fo(j,1,w)
		if (s[i][j]!='#'&&dis[i][j]<=k){
			int tmp=min(min(i-1,h-i),min(j-1,w-j));
			if (tmp)tmp=(tmp-1)/k+1;
			ans=min(ans,tmp+1);
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11136
import java.util.Scanner;
 public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int r = scanner.nextInt();
      
      int a =r*r;
      
      if(r>=1){
      System.out.println(a);
      }
      else{
       System.out.println();
      }
    }
 }

Measured memory_bytes: 21716
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))
      
n,q=map(int,input().split())
dsu=DSU(n)
for i in range(q):
  t,u,v=map(int,input().split())
  if(t==0):
    dsu.merge(u,v)
  else:
    if(dsu.same(u,v)):
      print(1)
    else:
      print(0)

Measured memory_bytes: 12520
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll N_MAX=2e5+5;
int main(){
  ll n;
  cin >>n;
  
  vector<ll> a(n),count(n,0),ans(n);
  rep(i,n) {
    ll a0;
    cin>>a0;
    a[i]=a0-1;
    count[a[i]]++;
  }
  
  ll tot=0;
  rep(i,n){//i番目のボールを使う場合
    if(count[a[i]]>1){
      ans[i]=count[a[i]]-1;
    }
    
    if(count[i]>1){
      tot+=(count[i]-1)*count[i]/2;
    }
    
  }
  
  rep(i,n){
    cout<<tot-ans[i]<<endl;
    
  }
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll a;
    cin>>a;
    ll ans = a + a*a + a*a*a;
    cout<<ans;
}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>

using ui = unsigned int;

int main() {
	ui n;
	std::cin >> n;

	std::vector<int> v( 2*n );

	for (auto&e : v)
		std::cin >> e;

	std::sort(std::begin(v), std::end(v));
	
	/*
	for (auto&e : v)
		std::cout << e <<" ";
	std::cout << "\n";
	*/

	int sum_{};
	for (ui i{ 0 }; i < 2*n; ++++i)// {
//		std::cout << v[i] << "\n";
		sum_ += v[i];
//	}

	std::cout << sum_ << "\n";

	return 0;
}

Measured memory_bytes: 384
#include <cstdio>

int main()
{
  int result,N, K;
  
  scanf("%d", &N);
  scanf("%d", &K);
  
  result = K;
  
  for(int i = 1; i < N; i++)
  {result *= (K - 1);}
  
  printf("%d", result);
}

Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Scanner;


public class Main{
	

	
	
	public static void main(String[] args) {

		
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		
		HashMap<Integer,Integer> h = new HashMap<>();
		for(int i=1;i<n;i++) {
			int c = s.nextInt();
			if(h.containsKey(c)) {
				h.put(c, h.get(c)+1);
			}
			else {
				h.put(c, 1);
			}
		}
		for(int i=1;i<=n;i++) {
			if(h.containsKey(i))
				System.out.println(h.get(i));
			else {
				System.out.println(0);
			}
		}
		
	}
}

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

signed main(){
  int H,W,K;
  cin>>H>>W>>K;
  vector<string> A(H);
  rep(i,H)cin>>A[i];
  int ans=0;
  rep(ii,1<<H){
    rep(jj,1<<W){
      int count=0;
      rep(i,H){
        rep(j,W){
          if(ii>>i&1)continue;
          if(jj>>j&1)continue;
          if(A[i][j]=='#')count+=1;
        }
      }
      if(count==K)ans+=1;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main() {
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  while (a>0 || c>0) {
    //cout<<a<<" "<<c<<endl;
    a -= d;
    c -= b;
  }
  a += d;
  c += b;
  //cout<<"a"<<a<<" c"<<c<<endl;
  if (c<=0 && a<=0) {
    cout<<"Yes"<<endl;
  } else if (a<=0) {
    cout<<"No"<<endl;
  } else {
    cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3620
///*.......................Shadman Sakib Utshob............................*///

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

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

#define Boost           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define pb              push_back
#define inf             1e9+8
#define mp              make_pair
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define ll              long long
#define pii             pair<ll,ll >
#define MOD             1000000007
#define fileout         freopen("output.txt","w",stdout)
#define mem(x,i)        memset(x,i,sizeof x)
#define Ones(x)         __builtin_popcount(x);
#define PI              acos(-1.0)
#define ff              first
#define ss              second
#define T               int t;cin>>t;while(t--)
#define ok              cout<<"ok"<<endl;
#define all(x)          (x).begin(),(x).end()
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define nln	            cout<<endl;

int main()
{
    Boost;

    ll i,j,n;

    cin>>n;
    ll h[n+10],dp[n+10];
    rep1(i,n)
    {
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[1]-h[2]);
    if(n==2)
    {
            cout<<dp[2]<<endl;
            return 0;
    }
    //see(dp[2])
    for(i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]));
        //see(dp[i])
    }
    cout<<dp[n]<<endl;

}


Measured memory_bytes: 5192
#include <stdio.h>

int main(void){

        int n,m,q;
        scanf("%d%d%d",&n,&m,&q);
        int a[q],b[q],c[q],d[q];
        int ans = 0;
        int sum = 0;
        int A[51];
        
for(int i=1;i<=q;i++){
                scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
        }       
        
        for(int i_1=1;i_1<=m;i_1++){
                A[1] = i_1;
                for(int i_2=i_1;i_2<=m;i_2++){
                        A[2] = i_2;
                        for(int i_3=i_2;i_3<=m;i_3++){
                                A[3] = i_3;
                                for(int i_4=i_3;i_4<=m;i_4++){
                                        A[4] = i_4;
                                        for(int i_5=i_4;i_5<=m;i_5++){
                                                A[5] = i_5;
                                                for(int i_6=i_5;i_6<=m;i_6++){
                                                        A[6] = i_6;
                                                        for(int i_7=i_6;i_7<=m;i_7++){
                                                                A[7] = i_7;
        for(int i_8=i_7;i_8<=m;i_8++){                          
                A[8] = i_8;
                for(int i_9=i_8;i_9<=m;i_9++){
                        A[9] = i_9;
                        for(int i_10=i_9;i_10<=m;i_10++){
                                A[10] = i_10;   //ここまでで数列Aが決定
                                
                                for(int i=1;i<=q;i++){
                                        if(A[b[i]]-A[a[i]]==c[i]){
                                                sum += d[i];
                                        }       
                                }               //ここまででその数列の時の合計が決定
                                
                                        if(sum>ans){
                                                ans = sum;
                                        }       
                                sum = 0;        //数列Aが変わるから合計を初期化
                                }
                        }       
                }       
        }       
}}}}}}  
printf("%d",ans);
return 0;
}

Measured memory_bytes: 1696
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int p10[18];
int n;
int dp[18][2];

//num…あと何桁？
int dfs(int num, int flag) {
	if (num == 0) return 0;
	if (flag) return dfs(num - 1, 1) + 9;
	if (dp[num][flag] != -1) return dp[num][flag];
	
	int jyo = (n / p10[num - 1]) % 10;
	int ret = 0;
	for (int i = 0; i <= jyo; i++) {
		int res;
		if (i == jyo) {
			res = i + dfs(num - 1, 0);
		}
		else {
			res = i + dfs(num - 1, 1);
		}
		ret = max(ret, res);
	}
	//cout << num << " " << flag << " " << ret << endl;
	return dp[num][flag] = ret;
}

signed main() {
	int i, j;
	
	p10[0] = 1;
	for (i = 1; i < 18; i++) p10[i] = p10[i - 1] * 10;
	cin >> n;
	
	for (i = 0; i < 18; i++) {
		dp[i][0] = -1;
		dp[i][1] = -1;
	}
	cout << dfs(17, 0) << endl;
	return 0;
}

Measured memory_bytes: 256
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;


signed main() {
	int n,a,b;
	cin >> n >> a >> b;
	int x[n];
	REP (i,n) cin >> x[i];
	int ans = 0;
	FOR (i,1,n) {
		int X = x[i] - x[i-1];
		if (X * a < b) ans += X * a;
		else ans += b;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int main() {

  int n, old1, old2, cold1, cold2, high, cost, first;
  cin >> n >> first;
  old1 = old2 = first;
  cold1 = cold2 = 0;
  for(int i = 1;i < n;i++){
    cin >> high;
    cost = min(cold1 + abs(high - old1), cold2 + abs(high - old2));
    cold2 = cold1;
    cold1 = cost;
    old2 = old1;
    old1 = high;
  }
  cout << cost;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> a >> b >> c;
	x = 4*a*b;
	y = c-a-b;
	if (y<0) {
		cout << "No" << endl;
		return 0;
	}
	y = y*y;
	if (x < y) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	//vector<ll>	aa(n);
	//for(i=0;i<n;i++) cin >> aa[i];
	//vector<ll>	dp(n+1,INFL);
	//vector<vector<ll>>	dp2(x , vector<ll>(y,INFL));

//	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right, bisect_left
N, Q = map(int, input().split())
S = input()
ac = []
for i in range(N-1):
  if S[i:i+2] == "AC":
    ac.append(i)
for i in range(Q):
  l, r = map(int, input().split())
  l -= 1
  r -= 1
  print(bisect_right(ac, r-1) - bisect_left(ac, l))
  

Measured memory_bytes: 5852
while 1:
    n = int(input())
    if n == 0:
        break

    mat = [[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        mat[i] = list(map(int, input().split()))

    for i in range(n):
        tmp = 0
        for j in range(n):
            tmp += mat[i][j]
        mat[i].append(tmp)

    col = [0] * n
    for i in range(n):
        tmp = 0
        for j in range(n):
            tmp += mat[j][i]
        col[i] = tmp

    ans = sum(col)
    col.append(ans)

    for i in range(n):
        print(''.join(str(ans).rjust(5) for ans in mat[i]))

    print(''.join(str(ans).rjust(5) for ans in col))



Measured memory_bytes: 5604
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanFloat() float64 {
	sc.Scan()
	a, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func scanTextSlice(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = scanText()
	}
	return a
}

func scanSlice(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanFloatSlice(n int) []float64 {
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = scanFloat()
	}
	return a
}

// var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	s := scanText()

	t := "ABC"
	ans := 0
	for i := 0; i < n-2; i++ {
		tmp := s[i : i+3]
		if t == tmp {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
n=int(input())
D={"M":0 , "A":0, "R":0 , "C":0 , "H":0}
for i in range(n):
    s=input()
    if s[0] in ["M","A","R","C","H"]:
        D[s[0]]+=1

from itertools import combinations as com 
ans=0
A=list(D.values()) ; # print(A)
for l in com(list(range(5)), 3):
    ans+= A[l[0]]* A[l[1]] * A[l[2]]
print(ans)


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

int main() {
  ll a,b;
  cin >> a >> b;
  ll n = b-a;
  ll acc = 0;
  rep(i,n) acc+=i;
  cout << acc-a << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, q;
    cin >> n >> q;

    vector<pair<ll, pair<ll, ll>>> p(n);
    rep(i, n) {
        ll s, t, x;
        cin >> s >> t >> x;
        s -= x;  t -= x;
        p[i] = make_pair(x, make_pair(s, t));
    }
    sort(all(p));

    set<pair<ll, ll>> st;
    rep(i, q) {
        ll d;
        cin >> d;
        st.insert(make_pair(d, i));
    }

    vl ans(q, -1);
    rep(i, n) {
        ll x = p[i].first;
        ll l = p[i].second.first;
        ll r = p[i].second.second;
        auto it = st.lower_bound(make_pair(l, -1));
        while(it != st.end()) {
            if(it->first >= r) {
                break;
            }
            ans[it->second] = x;
            st.erase(it++);
        }
    }

    rep(i, q) {
        out(ans[i]);
    }

    re0;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
vector<long long> factors;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()






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

	int a,b,c;

	cin >> a >> b >> c;
	if(c <= a + b)
		cout << b + c;
	else
		cout << a + b + b + (c - b - a >0?1 : 0);

	return 0;
}/*


 */

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int Q;
  cin >> Q;
  while (Q--) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    //a<=b

    int ok = a, ng = b + 1;
    for (int i = 0; i < 100; i++) {
      int k = (ok + ng) / 2;
      int m = (k + a) / 2;

      if (k == a) m--; //m=aとなるため。

      if (m * (a + k - m) < a * b) {
        ok = k;
      } else {
        ng = k;
      }
    }
    cout << a + ok - 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,temp;
  scanf("%d",&n);
  temp = n%10;
  if(temp == 0 || temp == 1 || temp == 6 
     || temp == 8)
    printf("pon");
  else if (temp == 3)
    printf("bon");
  else
    printf("hon");
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#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()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, K, L; cin >> N >> K >> L;
  Graph road(N), train(N);
  rep(i,K) {
    int p, q; cin >> p >> q; --p; --q;
    road[p].push_back(q);
    road[q].push_back(p);
  }
  rep(i,L) {
    int r, s; cin >> r >> s; --r; --s;
    train[r].push_back(s);
    train[s].push_back(r);
  }

  vector<bool> seen(N, false);
  vi parent_road(N);
  map<int, set<int>> connect_road;

  rep(i,N) {
    if (seen[i]) continue;
    seen[i] = true;
    queue<int> q;
    connect_road[i].insert(i);
    q.push(i);
    
    while (!q.empty()) {
      int v = q.front(); q.pop();
      for (auto nv : road[v]) {
        if (seen[nv]) continue;
        seen[nv] = true;
        connect_road[i].insert(nv);
        q.push(nv);
      }
    }
    
    for (auto v : connect_road[i]) {
      parent_road[v] = i;
    }
  }

  seen.assign(N, false);
  vi parent_train(N);
  map<int, set<int>> connect_train;

  rep(i,N) {
    if (seen[i]) continue;
    seen[i] = true;
    queue<int> q;
    connect_train[i].insert(i);
    q.push(i);
    
    while (!q.empty()) {
      int v = q.front(); q.pop();
      for (auto nv : train[v]) {
        if (seen[nv]) continue;
        seen[nv] = true;
        connect_train[i].insert(nv);
        q.push(nv);
      }
    }
    
    for (auto v : connect_train[i]) {
      parent_train[v] = i;
    }
  }

  seen.assign(N, false);
  vi ans(N);
  rep(i,N) {
    if (seen[i]) continue;
    int a = parent_road[i];
    int b = parent_train[i];
    vi connect;
    
    if (connect_road[a].size() < connect_train[b].size()) {
      for (auto v : connect_road[a]) {
        if (parent_train[i] == parent_train[v]) {
          connect.push_back(v);
          seen[v] = true;
        }
      }
    } else {
      for (auto v : connect_train[b]) {
        if (parent_road[i] == parent_road[v]) {
          connect.push_back(v);
          seen[v] = true;
        }
      }
    }

    for (auto v : connect) {
      ans[v] = connect.size();
    }
  }

  rep(i,N-1) cout << ans[i] << ' ';
  cout << ans[N-1] << endl;
  return 0;
}


Measured memory_bytes: 66560
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <limits>
#include <stdexcept>
#include <vector>

// lib/safe_sum.hpp
#ifndef SAFE_SUM_HPP
#define SAFE_SUM_HPP


namespace tools {
  template <typename T>
  T safe_sum(const T& lhs, const T& rhs) {
    if (lhs == ::std::numeric_limits<T>::min() && rhs == ::std::numeric_limits<T>::max()) throw std::runtime_error("Indefinite.");
    if (lhs == ::std::numeric_limits<T>::max() && rhs == ::std::numeric_limits<T>::min()) throw std::runtime_error("Indefinite.");
    if (lhs == ::std::numeric_limits<T>::min() || rhs == ::std::numeric_limits<T>::min()) return ::std::numeric_limits<T>::min();
    if (lhs == ::std::numeric_limits<T>::max() || rhs == ::std::numeric_limits<T>::max()) return ::std::numeric_limits<T>::max();
    return lhs + rhs;
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 R, C, K;
  std::cin >> R >> C >> K;
  std::vector<std::vector<i64>> items(R, std::vector<i64>(C, 0));
  for (i64 i = 0; i < K; ++i) {
    i64 r_i, c_i, v_i;
    std::cin >> r_i >> c_i >> v_i;
    items[r_i - 1][c_i - 1] = v_i;
  }

  std::vector<std::vector<std::array<i64, 4>>> dp(R, std::vector<std::array<i64, 4>>(C));
  for (i64 y = 0; y < R; ++y) {
    for (i64 x = 0; x < C; ++x) {
      std::fill(dp[y][x].begin(), dp[y][x].end(), std::numeric_limits<i64>::min());
    }
  }
  dp[0][0][0] = 0;

  for (i64 y = 0; y < R; ++y) {
    for (i64 x = 0; x < C; ++x) {
      for (i64 k = 0; k <= 3; ++k) {
        if (x + 1 < C) {
          dp[y][x + 1][k] = std::max(dp[y][x + 1][k], dp[y][x][k]);
        }
        if (x + 1 < C && k + 1 <= 3) {
          dp[y][x + 1][k + 1] = std::max(dp[y][x + 1][k + 1], tools::safe_sum(dp[y][x][k], items[y][x]));
        }
        if (y + 1 < R) {
          dp[y + 1][x][0] = std::max(dp[y + 1][x][0], tools::safe_sum(dp[y][x][k], k < 3 ? items[y][x] : 0));
        }
      }
    }
  }

  std::cout << std::max({
    tools::safe_sum(dp[R - 1][C - 1][0], items[R - 1][C - 1]),
    tools::safe_sum(dp[R - 1][C - 1][1], items[R - 1][C - 1]),
    tools::safe_sum(dp[R - 1][C - 1][2], items[R - 1][C - 1]),
    dp[R - 1][C - 1][3]
  }) << std::endl;
  return 0;
}

Measured memory_bytes: 355136
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion

/************************************************************************/

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
 
	int n;
	cin >> n;
	vi a(n);
	map<LL, LL>m, o;
	f(i, 0, n) {
		cin >> a[i];
		m[a[i]]++;
		o[a[i]] = a[i];
	}
	sort(all(a));
	LL ans = 0;
	if (size(o) == 1) {
		cout << n;
	}
	else if(size(o)==2&&n==2){
		if (abs(a[0] - a[1]) == 1) {
			cout << 2;
		}
		else {
			cout << 1;
		}
	}
	else {
		f(i, 1, n - 1) {
			LL tmp;
			tmp = m[o[i - 1]] + m[o[i]] + m[o[i + 1]];
			ans = max(ans, tmp);
		}
		cout << ans;
	}
	return 0;
}

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

int main(){
    int N;
    int array[110] = {0};
    cin >> N;

    for(int i = 0; i < N; i++){
        cin >> array[i];
    }
    int count = 0;
    int buf = 1000;
    sort(array,array + N,greater<int>());
    for(int i = 0; i < N; i++){
        if(buf != array[i]){
            count++;
            buf = array[i];
        } 
    }

    cout << count << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

/*
 
 8/11/2018
 
 16:40-16:50 analysis
 16:51-16:57 implement and
 
 */

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
const int MAX_N=1e2+1;
const int MAX_M=1e3+1;
int N,M;
int mx[MAX_N][MAX_N];
int A[MAX_M],B[MAX_M],W[MAX_M];
const int Inf=1e7;
void solve() {
  ZERO(mx);
  REP(i,N)REP(j,N)if(i!=j)mx[i][j]=Inf;
  REP(i,M)mx[A[i]][B[i]]=mx[B[i]][A[i]]=W[i];
  REP(k,N)REP(i,N)REP(j,N)SMIN(mx[i][j],mx[i][k]+mx[k][j]);
  int res=0;
  REP(i,M){
    int x=A[i],y=B[i],w=W[i];
    bool ok=false;
    REP(u,N)REP(v,N) {
      if(mx[u][v]==mx[u][x]+w+mx[y][v]) ok|=true;
    }
    if(!ok) ++res;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N>>M;
  REP(i,M) {
    cin>>A[i]>>B[i]>>W[i];
    A[i]--,B[i]--;
  }
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  string s;
  cin>>s;
  if(s=="AAA"||s=="BBB"){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<math.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define maax(a,b,c) max((a), max((b), (c)))
int n, a[111111][3], b[111111][3];

int solve(int i, int j){
    if(j!=-1 && b[i][j] >= 0) return b[i][j];
    if(i >= n) return 0;
    return b[i][j] = maax((j!=0)*(a[i][0]+solve(i+1, 0)), (j!=1)*(a[i][1]+solve(i+1, 1)), (j!=2)*(a[i][2]+solve(i+1,2)));
}

int main(){
    scanf("%d", &n);
    for(int i  = 0; i < n; i++){
        scanf("%d%d%d", &a[i][0], &a[i][1], &a[i][2]);
    }
    for(int i=0; i < 111111; i++){
        b[i][0] = -1;b[i][1] = -1;b[i][2] = -1;
    }
    printf("%d\n", solve(0, -1));
}

Measured memory_bytes: 12032
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
typedef long long ll;
char str[11111];
int mark[30];
int main()
{
	cin>>str;
	int f=1;
	for(int i=0;i<strlen(str);i++){
		if(mark[str[i]-'a'])f=0;
		mark[str[i]-'a']=1;
	}
	if(f)puts("yes");
	else puts("no");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

void solve(int a, int b, int d) {
    if (a == b) {
        cout << a << ' ';
        return;
    }

    int x = ((a^b)&(-(a^b))); // least significant bit
    d ^= x;
    int y = d&(-d);
    solve(a, a^y, d), solve(a^x^y, b, d);
}

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int N, A, B; cin >> N >> A >> B;
    if (__builtin_popcount(A^B) & 1) {
        cout << "YES\n";
        solve(A, B, (1<<N)-1);
    }
    else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 3660
H, W = map(int, input().split())
result = 0
if H==1 or W==1:
    result = 1
elif W%2==0:
    result = (W/2)*H
else:
    if H%2==0:
        result=W*(H/2)
    else :
        result=W*(H-1)/2+(W+1)/2
print(str(round(result)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
main(){
  int n,k,d[10]={},tmp;
  vector <int> dl;
  for(cin>>n>>k;cin>>tmp;dl.push_back(tmp));
  for(;;n++){
    for(int a=n;a;a/=10) for(int i=0;i<dl.size();i++) if(dl[i]==a%10) goto end;
    cout<<n<<endl;
    return 0;
  end:;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		double[] h = sc.nextDoubleArray(n);
		for(int i = 0; i < n; i++) {
			h[i] *= 0.006;
			h[i] = t - h[i];
			h[i] = Math.abs(a - h[i]);
		}
		int min = 0;
		for(int i = 0; i < n; i++)
			if(h[i] < h[min])
				min = i;
		
		System.out.println(min+1);
		
		
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 23636
#include <stdio.h>
#include <stdlib.h>
#define NIL -1

typedef struct node{
  int left;
  int right;
  int parent;
}node;

int getSibling(int);
int getDegree(int);
int getDepth(int);
int getHeight(int);
void printTree(void);

node *tree;
int n;

int main(){
  int id,left,right,i;
  
  scanf("%d",&n);
  tree = (node *)malloc(sizeof(node)*n);
  for(i=0;i<n;i++){
    tree[i].parent = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    
    tree[id].left = left;
    
    tree[id].right = right;
    
    tree[tree[id].left].parent = id;
    
    tree[tree[id].right].parent = id;
  }

  printTree();

  return 0;
}

int getSibling(int c){
  int left,right;
  if(tree[c].parent!=-1){
    left = tree[tree[c].parent].left;
    right = tree[tree[c].parent].right;

    if(left!=-1&&c!=left) return left;
    else if(right!=-1&&c!=right) return right;
  }
  return -1;
}

int getDegree(int c){
  int d=0;
  if(tree[c].left!=-1) d++;
  if(tree[c].right!=-1) d++;
 
  return d;
}

int getDepth(int c){
  int d=0;
  while(tree[c].parent!=-1){
    c=tree[c].parent;
    d++;
  }
  return d;
}

int getHeight(int c){
  int d=0;
  if(tree[c].left==-1&&tree[c].right==-1) return 0;
  if(tree[c].left==-1) return getHeight(tree[c].right)+1;
  if(tree[c].right==-1) return getHeight(tree[c].left)+1;
  if(getHeight(tree[c].left)<getHeight(tree[c].right))
    return getHeight(tree[c].right)+1;
  else return getHeight(tree[c].left)+1;
  return d;
}

void printTree(){
  int i,deep,h;
  for(i=0;i<n;i++){
    deep=getDepth(i);
    h=getHeight(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,getSibling(i),getDegree(i),deep,h);
    if(deep==0) printf("root\n");
    else if(h==0) printf("leaf\n");
    else printf("internal node\n");
  }

  return;
}

Measured memory_bytes: 2684
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000
#define EPS 1e-8
#define EQ(x,y) fabs((x)-(y))<EPS

double x[50];
double y[50];

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

  vector<P> points(n);
  rep(i,n){
    scanf("%lf %lf", &x[i], &y[i]);
  }

  if(n%2==1){
    cout<<"NA"<<endl;
    return 0;
  }

  double cx, cy; //candidate x,y
  cx = (x[0]+x[n/2])/2.0;
  cy = (y[0]+y[n/2])/2.0;

  repl(i,1,n/2){
    if(EQ((x[i]+x[n/2+i])/2.0, cx) &&
       EQ((y[i]+y[n/2+i])/2.0, cy)){
      continue;
    } else {
      cout<<"NA"<<endl;
      return 0;
    }
  }

  printf("%.5f %.5f\n", cx, cy);
  

  return 0;
}

Measured memory_bytes: 1280
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var w,h,n int
    fmt.Scan(&w,&h,&n)
    xmax := w
    xmin := 0
    ymax := h
    ymin := 0
    for i:=0;i<n;i++{
        var x,y,a int
        fmt.Scan(&x,&y,&a)
        switch{
            case a==1:
                xmin = max32(xmin,x)
            case a==2:
                xmax = min32(xmax,x)
            case a==3:
                ymin = max32(ymin,y)
            case a==4:
                ymax = min32(ymax,y)
        }
    }
    if xmax<=xmin || ymax<=ymin{
        fmt.Println(0)
    } else {
        fmt.Println((xmax-xmin)*(ymax-ymin))
    }
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,s;
  cin>>n>>k>>s;
  for(int i=0;i<n;i++)
  {
    if(i<k)cout<<s<<' ';
    else if(s!=1)cout<<s-1<<' ';
    else cout<<s+1<<' ';
  }
  return 0;
}

Measured memory_bytes: 1280