akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int N;
vector < string > S;

bool check(int A, int B) {
	REP(i,N) REP(j,N) {
		int px = (A + i) % N;
		int py = (B + j) % N;
		int nx = (py - A + N) % N;
		int ny = (px - B + N) % N;
		char a = S[i][j];
		char b = S[nx][ny];
		if (a != b) return false;
	}
	return true;
}

int main() {

    cin >> N;
    S.resize(N);
    REP(i,N) cin >> S[i];

    int ans = 0;
    REP(i,N) {
    	if (check(i, 0)) ans += N;
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long int ll;


ll sumOfDigit(ll n){
    ll res = 0;
    while (n > 0){
        res += n % 10;
        n /= 10;
    }
    return res;
}

double fraction(ll n){
    return (double)(n) / sumOfDigit(n);
}

vector<ll>res;

void precal(){
    ll base = 1;
    map<ll,bool>check;
    for(int i=0;i<15;i++){
        for(int j=1;j<150;j++){
            ll snuke = (base*(j+1))-1;
            if(check.count(snuke)==0){
                res.push_back(snuke);
                check[snuke]=true;
            }
        }
        base*=10;
    }

    for(int i=0;i<res.size();i++){
        for(int j=i+1;j<res.size();j++){
            if (fraction(res[i]) > fraction(res[j])){
                res.erase(res.begin() + i--);
                break;
            }
        }
    }
}

int main(){
    precal();
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) printf("%lld\n",res[i]);
    return 0;
}


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

typedef long l;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1e9 + 7
#define INF 999999999
#define F first
#define S second
#define pb push_back
#define mp make_pair

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int field[100][100];

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

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

  int k = 0;
  REP(i, h) {
    REP (j, w) {
      if (a[k] == 0) {
        k++;
      }
      field[i][j] = k + 1;
      a[k]--;
    }
    i++;
    for (int j = w - 1; -1 < j; j--) {
      if (a[k] == 0) {
        k++;
      }
      field[i][j] = k + 1;
      a[k]--;
    }
  }

  REP(i, h) {
    REP(j, w) {
      if (j != 0) cout << " ";
      cout << field[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 384
//***Faithless is he that says farewell when the road darkens***

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
   ll a,b;
   cin>>a>>b;
   if((a+b)%2!=0)
      cout<<"IMPOSSIBLE";
   else cout<<(a+b)/2;
}

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

int main(){
  int N;
  cin>>N;
  set<int> t;
  for(int i=0;i<N;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--,c--;
    if(a>b)swap(a,b);
    if(b>c)swap(b,c);
    if(a>b)swap(a,b);
    t.insert( a*1000000+b*1000+c );
  }
  cout<<N-t.size()<<endl;
}

Measured memory_bytes: 3132
n = int(input())
a = list(input().split())
evena = [s for s in a if int(s) % 2 == 0]
divide3or5 = [s for s in evena if (int(s) % 3 == 0) | (int(s) % 5 == 0)]
if len(evena) == len(divide3or5):
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
X = int(input())

def solve(X):
    # a > 0 and b > 0
    for a in range(10000):

        k = a**5 - X
        if k > 0:
            b = round(k**(1/5))
            if a**5 - b**5 == X:
                return a,b
        elif k < 0:
            b = (-k)**(1/5)
            b = round(b)
            if a**5 + b**5 == X:
                return a,-b
    return None

a,b = solve(X)
print(a,b)


Measured memory_bytes: 9452
#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)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int S;
    cin >> S;
    ll f[2001];
    rep1(i,2000) f[i] = 0;

    f[3] = 1;
    f[4] = 1;
    f[5] = 1;
    f[6] = 2;
    f[7] = 3;

    if (S <= 7){
        cout << f[S] << endl;
        return 0;
    }

    for(int i = 8; i <= S; i++){
        f[i] = 1;
        for(int j = 3; j <= i-3; j++){
            f[i] = (f[i] + (1 * f[i-j]) ) % MOD;
            while (f[i] < 0){
                f[i] += MOD;
            }
        }
    }

    cout << f[S] << endl;

    return 0;
}

Measured memory_bytes: 3644
a,b,c = map(int,input().split())

L = [[0] for _ in range(a)] + [[1] for _ in range(b)] + [[2] for _ in range(c)]
while len(L) > 1:
  L[0] += L.pop()
  L.sort()
print(''.join(('a','b','c')[i] for i in L[0]))

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, D, X[10][10];
    cin >> N >> D;
    REP(i, N) {
        REP(j, D) {
            cin >> X[i][j];
        }
    }
    int res = 0;
    REP(i, N - 1) {
        FOR(j, i + 1, N, 1) {
            int sum = 0;
            REP(k, D) {
                int d = X[i][k] - X[j][k];
                sum += d * d;
            }
            int sq = sqrt(sum);
            for (int x = 0; x < sq + 1; x++) {
                if (x * x == sum) {
                    res++;
                    break;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    string S;
    cin >> S;

    int sum;
    for (int i = 0; i < S.length(); ++i) {
        if(S.at(i) == '+') sum++;
        else sum--;
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  for (int n = 0; n < 10000; ++n) {
    int za = n*8/100;
    int zb = n*10/100;
    if (a == za && b == zb) {
      cout << n << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    int A,B,C;
    cin >> A >> B >> C;

    map<int,int> mp;
    mp[A]++;
    mp[B]++;
    mp[C]++;
    if (mp[5] == 2 && mp[7] == 1) {
        cout << "YES" << endl;
        return;
    }
    cout << "NO" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <utility>

using namespace std;


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


#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

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


int main(){
	int r,D,x2000;cin >> r>>D>>x2000;
	
	REP(i,10){
		x2000 = r*x2000 - D;
		cout << x2000 << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(a==x){
        cout<<"YES\n";
        return 0;
    }
    if(a+b>=x && a<=x){
        cout<<"YES\n";
    }
    else if(a>x){
        cout<<"NO\n";
        return 0;
    }
    else {
        cout<<"NO\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int Q = sc.nextInt();

    //List<Tree> list = new ArrayList<>();
    Map<Integer, Tree> map = new HashMap<>();
    map.put(1 ,new Tree(0));

    /* treeを作成 */
    for(int i = 0; i < N - 1; i++){
        int a = sc.nextInt();
        int b = sc.nextInt();

        Tree newTree = new Tree(a);
        map.put(b, newTree);
    }

    for(int i = 0; i < Q; i++){
      int p = sc.nextInt();
      int x = sc.nextInt();
      map.get(p).addScore(x);
    }

    System.out.print(map.get(1).getScore() + " ");

    for(int i = 2; i < N + 1; i++){
      Tree t = map.get(i);
      t.addScore(map.get(t.getParendNodeNumber()).getScore());
      System.out.print(t.getScore() + " ");
    }
    System.out.println();
  }

  public static class Tree  {
    /* 子要素 */
    private int parendNodeNumber;
    private int score;

    public Tree(int parendNodeNumber){
      this.parendNodeNumber = parendNodeNumber;
    }

    public int getParendNodeNumber(){
      return this.parendNodeNumber;
    }

    public void addScore(int point){
      this.score += point;
    }

    public int getScore(){
      return this.score;
    }
    public void print(){
      System.out.print(this.score + " ");
    }
  }
}


Measured memory_bytes: 185688
import math
A, B, H, M = map(int, input().split())

l = 6 * M

s =(H * 60 + M) * 360 / (12 * 60)

abs = abs(l - s)
pi = math.radians(abs)
ans = (A*A + B*B) - (2 * A * B) * math.cos(pi)
print(math.sqrt(ans))


Measured memory_bytes: 9488
package main

// Solution for https://atcoder.jp/contests/abc179/tasks/abc179_a

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var s string
	con.Scan(&s)
	if s[len(s)-1] == 's' {
		s += "es"
	} else {
		s += "s"
	}
	con.Println(s)
	return nil
}


Measured memory_bytes: 1860
package main
import (
	"bufio"
	"fmt"
	"io"
	"os"
	"regexp"
	"runtime/debug"
)
var in = NewScanner(os.Stdin, 0)
func main(){
	debug.SetGCPercent(-1)
	s := in.String()
	re := regexp.MustCompile(`^A?KIHA?BA?RA?$`)
	if re.Match([]byte(s)){
		Pln("YES")
	} else{
		Pln("NO")
	}
}
const M7 = 1000000007
type Scanner struct{
	*bufio.Scanner
}
func NewScanner(r io.Reader, x int) *Scanner{
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if x <= 0{
		x = 1048576
	}
	s.Buffer([]byte{}, x)
	return &Scanner{s}
}
func (s *Scanner) String() string{
	s.Scan()
	return s.Text()
}
func isSpace(b byte) bool{
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(d []byte, e bool) (int, []byte, error){
	s := 0
	for s < len(d) && isSpace(d[s]){
		s++
	}
	for i := s; i < len(d); i++{
		if isSpace(d[i]){
			return i + 1, d[s:i], nil
		}
	}
	if e && len(d) > s{
		return len(d), d[s:], nil
	}
	return s, nil, nil
}
func Pln(s ...interface{}){
	fmt.Println(s...)
}
type ByteSlice []byte
type IntSlice []int


Measured memory_bytes: 768
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int cnt[100005];
void solve(){  
	int n,k,q;
	cin>>n>>k>>q;
	rep(i,0,q){
		int x;
		cin>>x;
		--x;
		cnt[x]++;
	}
	rep(i,0,n){
		if(q-cnt[i]>=k){
			cout<<"No"<<endl;
		}
		else cout<<"Yes"<<endl;
	}
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1408
from sys import stdin
s = stdin.readline().rstrip()
A, B, C, D = int(s[0]), int(s[1]), int(s[2]), int(s[3])
if A + B + C + D == 7:
    print('{}+{}+{}+{}=7'.format(A, B, C, D))
    exit()
elif A + B + C - D == 7:
    print('{}+{}+{}-{}=7'.format(A, B, C, D))
    exit()
elif A + B - C + D == 7:
    print('{}+{}-{}+{}=7'.format(A, B, C, D))
    exit()
elif A + B - C - D == 7:
    print('{}+{}-{}-{}=7'.format(A, B, C, D))
    exit()
elif A - B - C + D == 7:
    print('{}-{}-{}+{}=7'.format(A, B, C, D))
    exit()
elif A - B - C - D == 7:
    print('{}-{}-{}-{}=7'.format(A, B, C, D))
    exit()
elif A - B + C + D == 7:
    print('{}-{}+{}+{}=7'.format(A, B, C, D))
    exit()
elif A - B + C - D == 7:
    print('{}-{}+{}-{}=7'.format(A, B, C, D))
    exit()

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#define MOD 1000000007
using namespace std;
typedef long long LL;
string s,t;
int n,tmp;
LL ans;
int main(){
	scanf("%d",&n);
	cin>>s>>t;
	int i;
	if(s[0]==t[0]){
		ans=3;
		i=1;
	}
	else{
		ans=6;
		i=2;
		tmp=1;
	}
	while(i<n){
		if(s[i]==t[i]){
			if(!tmp)ans=ans*2%MOD;
			i++;
			tmp=0;
		}
		else{
			if(tmp)ans=ans*3%MOD;
			else ans=ans*2%MOD;
			i+=2;
			tmp=1;
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
 
using namespace std;
 
int main(){
 int A;
 int B;
 int C;
 cin >> A >> B >> C;
 if(A+B+C>21)cout << "bust" << endl;
  else cout << "win" << endl;
 return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const ll mod = 1e9+7;

vector<ll> v;
ll a,b;

bool can(ll t){
  ll cnt = 0;
  rep(i,v.size()){
    ll tmp = v[i];
    tmp-= b*t;
    if (tmp > 0) {
      cnt += (tmp+(a-b)-1)/(a-b);
    }
  }
  if (cnt <= t) return true;
  else return false;
}
 
int main(){
  int n;
  cin >> n >> a >> b;
  v.resize(n);
  rep(i,n) cin >> v[i];
  ll l = 0LL,r = 1e9+1;
  while(r-l > 1){
    int mid = (r+l)/2;
    //printf("(l,r,mid) = (%d,%d,%d)\n",l,r,mid);
    if (can(mid)){
      //cout << "yes" << endl;
      r = mid;
    }
    else {
      //cout << "No" << endl;
      l = mid;
    }
  }
  //if (can(62500000)) cout << "Yes" << endl;
  cout << r << endl;
  return 0; 
}



Measured memory_bytes: 1024
while line = gets do
	n = line.to_i
	count = 0
	if n > 36 then
		puts 0
	else
		if n > 18 then
			n = 36-n
		end
		[9,n].min.downto(0) do |a|
			if a <= n then
				# puts "n:#{n-a}, a:#{a}"
				[a,n-a].min.downto(0) do |b|
					if b <= n then
						# puts "n:#{n-a-b}, a:#{a}, b:#{b}"
						[b,n-a-b].min.downto(0) do |c|
							if c <= n then
								# puts "n:#{n-a-b-c}, a:#{a}, b:#{b}, c:#{c}"
								[c,n-a-b-c].min.downto(0) do |d|
									if d == n-a-b-c then
										# puts "a:#{a}, b:#{b}, c:#{c}, d:#{d}"
										if a == b and b == c and c == d then
											count += 1
										elsif (a == b and b == c) or (b == c and c == d) then
											count += 4
										elsif a == b and c == d then
											count += 6
										elsif a == b or b == c or c == d then
											count += 12
										else
											count += 24
										end
									end
								end
							end
						end
					end
				end
			end
		end
		p count
	end
end

Measured memory_bytes: 8788
#include <stdio.h>

int main()
{
  int kk, aa, bb;
  scanf("%d", &kk);
  scanf("%d %d", &aa, &bb);
  for(int ii = aa;ii <= bb;ii++)
  {
    if(ii % kk == 0)
    {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  return 0;
}

Measured memory_bytes: 1624
#include <iostream>
#include <string>
using namespace std;
 
int main(void) {
	string S;
	cin >> S;
 
	if (S[1] == 'B')
		S[1] = 'R';
	else
		S[1] = 'B';
 
	cout << S << '\n';
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}

ll tree[1200001];
ll a[300001];
void update(ll mini ,ll maxi, ll treeindex , ll index, ll val){
    if(mini==maxi){tree[treeindex] = val; return ;}
    ll mid=(mini+maxi)/2;
    if(mid>=index){update(mini, mid , 2*treeindex , index , val); }
    else update(mid+1 , maxi , 2*treeindex+1 , index , val);
    tree[treeindex]= max(tree[treeindex*2] , tree[2*treeindex +1]);
}

ll maxval(ll mini, ll maxi,  ll l ,ll r , ll index){
    if(l > r)return 0;
    if(l==mini && r== maxi){return tree[index];  }
    ll mid= (mini+maxi)/2;
    return max( maxval(mini, mid , l ,min(r,mid) , 2*index) , maxval(mid+1 , maxi , max(l,mid+1), r, 2*index+1) );
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n;
        cin>>k;
        fo(i,n)cin>>a[i];
        //fo(i,300001)node[i]=0;
        fo(i,1200001)tree[i]=0;
        ll ans;
        fo(i,n){
            ll val= maxval(0,300000, max(0,a[i]-k),min(300000,a[i]+k),1) + 1;
            update (0,300000, 1, a[i], val);
        }
        cout<<tree[1];



        





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

int main(){
    string w,t;
    cin>>w;
    int count=0;
    for(int i=0;i<w.size();i++){
        if(w[i]>='A'&&w[i]<='Z') w[i]+='a'-'A';
    }
    cin>>t;
    while(t!="END_OF_TEXT"){
        for(int i=0;i<t.size();i++){
        if(t[i]>='A'&&t[i]<='Z') t[i]+='a'-'A';
        }
        if(w==t) count++;
        cin>>t;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 3228
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int W,H;
int visited[51][51] = {};
char A[51][51];

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

bool in(int x,int y){
    return 1<=x && x<=H && 1<=y && y<=W;
}

void init(){
    for(int i=1;i<=H;i++) for(int j=1;j<=W;j++) visited[i][j] = 0;
}

int main(){
    while(cin >> W >> H && W>0){
        for(int i=1;i<=H;i++) for(int j=1;j<=W;j++) cin >> A[i][j];
        int black = 0,white = 0;
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                if(A[i][j]!='.') continue;
                init();
                visited[i][j] = 1;
                queue<P> Q;
                Q.push({i,j});
                bool b = false,w = false;
                while(!Q.empty()){
                    int x = Q.front().first,y = Q.front().second;
                    Q.pop();
                    for(int i=0;i<4;i++){
                        int nx = x+dx[i],ny = y+dy[i];
                        if(!in(nx,ny)) continue;
                        if(visited[nx][ny]==1) continue;
                        if(A[nx][ny]=='W') w = true;
                        if(A[nx][ny]=='B') b = true;
                        if(A[nx][ny]=='.'){
                            visited[nx][ny] = 1;
                            Q.push({nx,ny});
                        }
                    }
                }
                if(b&&!w) black++;
                if(!b&&w) white++;
            }
        }
        cout << black << " " << white << endl;
    }
}


Measured memory_bytes: 3012
#include<iostream>

using namespace std;

int main(){

    ios::sync_with_stdio(false);

    int a,b;

    cin>>a>>b;

    if(a>=13)cout<<b<<endl;
    else if(a>=6&&a<13)cout<<b/2<<endl;
    else cout<<"0\n";

    return 0;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;

int main(){
	
	int a,b;
	
	while(cin >> a >> b){
		
int n = a+b;
int ans = 1;
int s = 10;
while(n >= s){
s *= 10;
ans++;
}
	cout << ans <<endl;
	}
	}


Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.cup2", "r", stdin);
	string str = "";
	int a[] = {1, 0, 0 };

	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		while (str.find(',') != string::npos ){
			str = str.replace(str.find(','), 1, " ");
		} // end while
		stringstream ss(str);
		char P0, P1;
		ss >> P0 >> P1;
		int p0 = P0 - 'A';
		int p1 = P1 - 'A';
		swap (a[p0], a[p1] );
//		cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
	} // end loop

	int i;
	char res = 0;
	for (i = 0; i < 3; ++i){
		if (a[i] == 1){
			res = 'A' + i;
			break;
		} // end if
	} // end for

	cout << res << endl;
		
	return 0;
}

Measured memory_bytes: 0
/************************************/
/* NoobM							*/
/* File Name : ata.cpp				*/
/* Date : 20.06.2020 19:27:06 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
	ll x;
	cin >> x;
	
	for(int i = 1; ; i++) {
		if((360 * i) % x == 0) {
			cout << (360 * i) / x<< endl;
			break;
		}
	}
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	
	int t = 1;
	//cin >> t;
	
	while (t--) {
		solve();
	}
    return 0;
}


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

using namespace std;
typedef long long ll;

const int MAX = 26;
int H, W;
int A[MAX][MAX];

int count(int h, int w) {
  int ans = 0;
  for (int i=0; i<H; i++) {
    if (i==h) continue;
    for (int j=0; j<W; j++) {
      if (j==w) continue;
      int moyori = min(abs(i-h), abs(j-w));
      ans += (moyori * A[i][j]);
    }
  }
  return ans;
}

int main() {
  scanf("%d %d", &H, &W);
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      scanf("%d", &A[i][j]);
    }
  }

  int ans = INT_MAX;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      ans = min(ans, count(i, j)); 
    }
  }

  printf("%d\n", ans);
  
  return 0;
}



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

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  int answer = numeric_limits<int>::max();
  for (int i = 0; i <= S.length() - T.length(); i++) {
    int diff = 0;
    for (int j = 0; j < T.length(); j++) {
      if (S[i + j] != T[j]) diff++;
    }
    answer = min(answer, diff);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3628
sx, sy, tx, ty = map(int, input().split())
X, Y = tx - sx, ty - sy
for d, n in zip("RULDRULULDR", [X, Y, X, Y + 1, X + 1, Y + 1, 1, 1, X + 1, Y + 1, 1]):
    print(d * n, end="")
print()

Measured memory_bytes: 3060
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

ans = []
X.sort(key=lambda x: x[2])
for c_x in range(0, 101):
    for c_y in range(0, 101):
        height = X[-1][2] + abs(X[-1][0] - c_x) + abs(X[-1][1] - c_y)
        flag = True
        for x, y, h in X:
            flag &= h == max(height - abs(x - c_x) - abs(y - c_y), 0)

        if flag:
            print(c_x, c_y, height)
            exit()


Measured memory_bytes: 74364
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }

int ans[10000001];
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // ifstream fin(".in");
    // ofstream fout(".in");
    int n;

    cin>>n;
for(int i=1;i<=n;i++)
{
  for(int j=i;j<=n;j+=i)
  ans[j]++;
}
i64 sum=0;
for(int i=1;i<=n;i++)
{
  sum+=1LL*i*ans[i];
}
cout<<sum;



    return 0;
  }


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    lli n = stoll(s);
    lli sum = 0;
    each (c, s) {
      sum += c - '0';
    }
    cout << (n % sum == 0 ? "Yes" : "No") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())

cnt_AB = 0
xA = 0
Bx = 0
BA = 0
xx = 0
for i in range(N):
  s = input()
  cnt_AB += s.count('AB')
  if s[0] == 'B':
    if s[-1] == 'A':
      BA += 1
    else:
      Bx += 1
  else:
    if s[-1] == 'A':
      xA += 1
    else:
      xx += 1

A = xA + BA
B = Bx + BA
ans = cnt_AB

if A > B:
  ans += B
elif A < B:
  ans += A
elif A > 0:
  ans += A
  if xA == 0:
    ans -= 1

print(ans)

Measured memory_bytes: 21528
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int, int> a, pair<int, int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vint a(n + 1), b(n);
	rep(i, n + 1) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
	}
	llint ans = 0;
	rep(i, n) {
		if (a[i] < b[i]) {
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
			if (a[i + 1] < b[i]) {
				ans += a[i + 1];
				a[i + 1] = 0;
			}
			else {
				ans += b[i];
				a[i + 1] -= b[i];
			}
		}
		else {
			ans += b[i];
			a[i] -= b[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
N,M = map(int, input().strip().split(' '))
if M > 0:
  broken = set(int(line.strip()) for line in sys.stdin)
else:
  broken = set()
p = [0]*(N+2)
p[0] = 1
for i in range(N):
  # 今i段目にいる
  if i in broken:
    continue
  p[i+1] += p[i]
  p[i+2] += p[i]
print(p[N]%1000000007)


Measured memory_bytes: 462708
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        boolean check = false;
        int count = 1;
        while(!check){
            int x = scan.nextInt();
            if(x != 0){
                System.out.println("Case " + count + ": " + x);
                count++;
            }else if(x == 0){
                check = true;
            }
        }
    }
}


Measured memory_bytes: 42868
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>
#include<algorithm>

using namespace std;

#define DBL(d) ((d)*(d))
#define DIST(x,y,z,a,b,c) (DBL(x-a)+DBL(y-b)+DBL(z-c))

int main(){
  int n;
  double x[110], y[110], z[110], r[110];
  double d[110][110];
  while(cin>>n, n){
    vector<int> f(n);
    double ans = 0.0;
    for(int i=0; i<n; i++){
      cin>>x[i]>>y[i]>>z[i]>>r[i];
      f[i]=i;
    }

    for(int i=0; i<n; i++){
      for(int j=i+1; j<n; j++){
	double tmp = sqrt(DIST(x[i],y[i],z[i],x[j],y[j],z[j])) - r[j] - r[i];
	if(tmp < 0.0) tmp = 0.0;
	d[i][j]=d[j][i]=tmp;
      }
    }

    for(int i=1; i<n; i++){
      int jj=-1,kk=-1;
      double dmin = 1e20;
      for(int j=0; j<n; j++){
	for(int k=j+1; k<n; k++){
	  if(f[j]!=f[k] && dmin > d[j][k]){
	    jj=j; kk=k;
	    dmin = d[j][k];
	  }
	}
      }
      while(jj==-1);
      int cb = max(f[jj],f[kk]);
      int ca = min(f[jj],f[kk]);
      for(int j=0; j<n; j++)
	if(f[j] == cb) f[j]=ca;
      ans += dmin;
    }
    printf("%.3f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		int[] sets=new int[9];
		int[] core=new int[3];
		long res=0;
		int kaz=0;
		for(int i=0; i<262144; i++) {
			int tmp=i;
			res=0;
			core[0]=0;
			core[1]=0;
			core[2]=0;
			for(int j=0; j<9; j++) {
				sets[j]=tmp%4;
				if(tmp%4>0) {
					core[tmp%4-1]++;
				}
				tmp/=4;
			}
			int digit=0;
			int aaa=i;
			while(aaa>=4) {
				digit++;
				aaa/=4;
			}
			digit+=1;
			if(core[0]*core[1]*core[2]>0 && core[0]+core[1]+core[2]==digit) {
				long tmpp=1;
				for(int k=0; k<9; k++) {
					if(sets[k]>0) {
						res+=(sets[k]*2+1)*tmpp;
					}
					tmpp*=10;
				}
				if(res<=a) {
					kaz++;
				}
			}
		}

		System.out.println(kaz);
	}
}

Measured memory_bytes: 24148
/* kop Chy_Chy*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll , ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define si(x)   scanf("%d", &x)
#define sl(x)   scanf("%lld", &x)
#define pi(x)   printf("%d\n", x)
#define pl(x)   printf("%lld\n", x)
#define deb(x)  cout<< #x << " = " << x << endl // debugging kop 
#define mp      make_pair
#define pb      push_back
#define MOD     1000000007
#define PI      acos(-1)
#define ff      first
#define ss      second
#define newline printf("\n")
ll binpow(ll a, ll b); // binary exponentiation kop
void prime_factorization(ll n, vll &prime_factors); // prime factorization kop
ll gcd(ll a, ll b); // greatest common divisor kop. Use LONG LONG
void speedup() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}
void func(ll a[], ll n, ll k){
    ll mul = 1;
    for(ll i = 1; i <= k; i++){
        mul *= a[i];
    }
    double cmul = mul;
    double pmul = mul;
    for(int i = k+1; i <= n; i++){
        if(a[i] > a[i-k]) cout<< "Yes\n";
        else cout<< "No\n";
    
    }
}
int main(){
    speedup();
    int t = 1;
    // cin>> t;
    while(t--){
        // khela final Mamooo
        ll n , k; cin>> n >> k;
        ll a[n+1];
        for(int i = 1; i <= n; i++) cin>> a[i];
        func(a, n, k);
        
        
    }
    // kop kop return 
    return 0;
}


// kop kop functions:
ll binpow(ll a, ll b){
    a = a % MOD; ll res = 1;
    while(b > 0){
        if(b & 1) res *= a % MOD;
        a = a* a % MOD;b = b >> 1;}
    return res;
}
/*---------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
/*---------------------------------------------------------------------------------------------------------------*/
void prime_factorization(ll n, vll &prime_factors){
    // first two step taking care of composite number
    // taking care of 2
    while(n%2 == 0){
        prime_factors.pb(2);
        n = n / 2;
    }
    // now n must be odd. And the remaining prime divisors are odd. so we start from 3 and increamenting 2
    for(ll i = 3; i <= sqrt(n); i = i + 2){
        while(n%i == 0){
            prime_factors.pb(i);
            n = n / i;
        }
    }
    // now we are taking care of  n is prime number and greater than 2
    if(n > 2){
        prime_factors.pb(n);
    }
}
/*---------------------------------------------------------------------------------------------------------------*/














Measured memory_bytes: 5276
n,m=map(int,input().split())
ab=[[int(i) for i in input().split()] for j in range(m)]

li=[[] for i in range(n+1)]

for a,b in ab:
    li[a].append(b)

li2=[]
for i in li[1]:
    li2.append(i)

ans=False
for i in li2:
    if n in li[i]:
        ans=True
print('POSSIBLE' if ans else 'IMPOSSIBLE')

Measured memory_bytes: 58972
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        ddd: [[u8; 2]; n]
    };
    let zoros = ddd.iter().map(|dd| dd[0] == dd[1]).collect::<Vec<bool>>();
    for w in zoros.windows(3) {
        if w[0] && w[1] && w[2] {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2192
argA,argB,argC = list(map(int,input().split()))

if argA > argB:
  if argA > argC and argC > argB:
    print("Yes")
  else:
    print("No")
else:
  if argB > argC and argC > argA:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 2940
class Madowaku:
  def __init__(self, madowaku, curtain):
    self.madowaku = madowaku
    self.curtain = curtain
  
  def aki(self):
    ans = self.madowaku - self.curtain*2
    if ans >0:
      print(ans)
    else:
      print(0)
      
A, B = list(map(int, input().split(' ')))
solve = Madowaku(A,B)
solve.aki()      

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

int main(){
  long n,b = 0,w = 0;
  cin >> n;
  string s;
  cin >> s;
  bool ok = false;
  if(s.at(0) == 'B' && s.at(2*n-1) == 'B') ok = true;
  for(long i = 0;i < 2*n;i++){
    if(i % 2 == 0){
      if(s.at(i) == 'W'){
        s.at(i) = 'B';
      }
      else{
        s.at(i) = 'W';
      }
    }
    if(s.at(i) == 'B') b++;
    if(s.at(i) == 'W') w++;
  }
  //cout << s << endl;
  long left = 0,right = 0,ans = 1,inf = 1000000007;
  if(ok == true && b == w){
    for(long i = 0;i < 2*n;i++){
      if(s.at(i) == 'W'){
        left++;
      }
      else{
        //cout << left-right << endl;
        ans *= left-right;
        ans %= inf;
        right++;
      }
    }
  }
  else{
    ans = 0;
  }
  //cout << ans << endl;
  for(long i = 1;i <= n;i++){
    ans *= i;
    ans %= inf;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoderABC052B
{
    class Program
    {
        static void Main()
        {
            int S = int.Parse(Console.ReadLine());
            var list = new List<int>();
            var hashSet = new HashSet<int>();
            list.Add(S);
            hashSet.Add(S);
            int cnt = 1;
            while(true){
                if(list[list.Count()-1]%2 == 0){
                    cnt++;
                    int a = list[list.Count()-1]/2;
                    list.Add(a);
                    if(hashSet.Add(a)==false){
                        break;
                    }
                }else{
                    cnt++;
                    int a=3*list[list.Count()-1]+1;
                    list.Add(a);
                    if(hashSet.Add(a)==false){
                        break;
                    }
                }
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 11348
#include<stdio.h>

int main(){
  int a,b;
  scanf("%d%d",&a,&b);

  if(a<b){
    printf("a < b\n");
  } else if(a>b) {
    printf("a > b\n");
  } else {
    printf("a == b\n");
  }

  return 0;
}


Measured memory_bytes: 2040
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
# ABC162-C
# 3つ以上の数の最大公約数
# 制約 1 <= N <= 200
# 三つの最大公約数はgcd(gcd(a,b), c)
K = iin()
 
ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        # 三重ループをする前に、ここでa,bの最大公約数を求めておく
        # 三重ループでa,b,cの最大公約数を求めるとTLE
        ab = 1
        if a == 1 or b == 1:
            ab = 1
        elif a == b:
            ab = a
        else:
            ab = math.gcd(a, b)
        for c in range(1, K+1):
            if ab == 1 or c == 1:
                ans += 1
            elif ab == c:
                ans += c
            else:
                ans += math.gcd(ab, c)
print(ans)


Measured memory_bytes: 10620
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int m;
cin>>m;
ll sum=0,t=0;
for(int i=0;i<m;i++){
    ll d,c;//オーバーフロー()
    cin>>d>>c;
    t+=c;
    sum+=d*c;
}
//(桁の数分の操作)+(繰り上がりの回数)
ll ans=t-1+(sum-1)/9;
cout<<ans<<endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include <random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back(a)
#define print(x) cout<<x<<'\n'
#define pe(x) cout<<x<<" "
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
#define double long double

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
int MOD = 1e9+7;

const int MAX = 200060;
const double pi = acos(-1);
const double EPS = 1e-12;


void solve(){
	int N; cin >> N;
	bool ok = false;
	FOR(i, 1, 10) {
		if (N%i == 0) {
			if (N / i <= 9)ok = true;
		}
	}
	if (ok)print("Yes");
	else print("No");
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 256
def selectionSort(a, n)
  count = 0
  0.upto(n-1) do |i|
    minj = i
    for j in i..(n-1)
      minj = j if a[j] < a[minj]
    end
    if i != minj
      a[i], a[minj] = a[minj], a[i]
      count += 1
    end
  end
  puts a.join(' '), count
end

n = gets.to_i
a = gets.split(" ").map(&:to_i)
selectionSort(a, n)



Measured memory_bytes: 6864