akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,q,cnt[100010] = {},sum = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		cnt[a]++;
		sum += a;
	}
	cin >> q;
	for(int i = 0;i < q;i++){
		int b,c;
		cin >> b >> c;
		sum -= cnt[b] * (b - c);
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sum << endl;
	}
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
// URL: https://atcoder.jp/contests/abc134/tasks/abc134_e

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int n; io.getV(n);
  int[] a; io.getC(n, a);

  auto rbt = redBlackTree!(true, int)([]);
  foreach_reverse (ai; a) {
    auto r = rbt.upperBound(ai);
    if (!r.empty)
      rbt.removeKey(r.front);
    rbt.insert(ai);
  }

  io.put(rbt.length);
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.meta, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, ref T v)
  if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


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

using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
typedef long long ll;

const int MX = (1 << 15) + 100;

bool prime[MX];

int main() {
	reep(i, 2, MX) {
		prime[i] = true;
	}
	for(ll i = 2; i * i <= MX; i++) {
		if(prime[i]) {
			for(ll j = i * i; j < MX; j += i) {
				prime[j] = false;
			}
		}
	}
	vector<int> v;
	rep(i, MX) {
		if(prime[i]) v.push_back(i);
	}
	int n;
	while(cin >> n, n) {
		int l = 0;
		int r = v.size() - 1;
		int ans = 0;
		while(l <= r) {
			if(v[l] > n) break;
			while(r >= 0 && v[r] > n - v[l]) {
				r--;
			}
			if(r < l) break;
			if(v[l] + v[r] == n) ans++;
			l++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3096
//
// Created by sark2 on 14-07-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cases int t;cin>>t;while(t--)
typedef long double ld;

int main() {
    IOS
    int n;
    cin>>n;
    int h[n+1];
    for(int i = 1 ; i <= n; i++)cin>>h[i];

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


}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int n,x,t;

int main()
{
    iosks;
    cin>>n>>x>>t;
    cout<<(n+x-1)/x*t<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll x; cin>>x;
	ll res = INF;
	for(ll i = 1; i*i<=x; i++){
		if(x%i) continue;
		res = log10(x/i)+1;
	}
	cout<<res<<endl;
	return 0;
}


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

// ----------- define --------------
#define int long long
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
// ---------------------------------

#define pow abcdef

int pow(int a, int b) {
  if (b == 0) return 1;
  int t = pow(a, b / 2);
  t *= t;
  if (b % 2) return a * t;
  return t;
}

void MAIN() {
  int n; cin >> n;
  vector<int> d(n + 1, 2e9); d[0] = 0;
  for (auto &i : {6, 9}) {
    for (int j = 1; pow(i, j) <= n; j++) {
      int p = pow(i, j);
      for (int k = p; k <= n; k++) {
        d[k] = min(d[k], d[k - p] + 1);
      }
    }
  }
  int ans = 2e9;
  for (int i = 0; i <= n; i++) {
    ans = min(ans, d[i] + n - i);
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3940
#include <iostream> 
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	int n, m, sum = 0, h;
	cin >> n >> m;
	while (n--) {
		cin >> h;
		if (h >= m) sum++;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
import math

point = 0

r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
for i in range(n//r+1):
    for j in range(n//g+1):
        if n-r*i-g*j >= 0:
            if (n-r*i-g*j)%b == 0:
                point += 1

print(point)

Measured memory_bytes: 40940
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
string S[201010];
map<string, int> m;

int main()
{
    cin >> N;
    rep(i, 0, N)
    {
        cin >> S[i];
        m[S[i]]++;
    }

    int ans = 0;
    for (auto e : m)
    {
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 25508
import itertools

x = int(input())
n = 200
table = [pow(i, 5) for i in range(-n, n+1)]
# choices = list(itertools.product([i for i in range(len(table))], repeat=2))
choices = list(itertools.permutations([i for i in range(len(table))], 2))

for choice in choices:
    left = choice[0]
    right = choice[1]
    if table[left] - table[right] == x:
        if left == n:
            ans_left = 0
        elif left < n:
            ans_left = left - n
        else:
            ans_left = left % n
            
        if right == n:
            ans_right = 0
        elif right < n:
            ans_right = right - n
        else:
            ans_right = right % n
        break

print(ans_left, ans_right)

Measured memory_bytes: 78356
using System;
   class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            if (a<b && b<c) 
            {
                Console.WriteLine("Yes");
            }
            else 
            {
                Console.WriteLine("No");
            }
        }
    }




Measured memory_bytes: 15948
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

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

int main() {
  IN(int, N);
  int count = 0;
  if (N < 105) {
    cout << "0" << endl;
    return 0;
  } else {
    REP(i, 105, (N + 1)) {
      int tmp_count = 0;
      REP(j, 1, i + 1) {
        if (i % j == 0) tmp_count++;
      }
      if (tmp_count == 8) count++;
      i++;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long MOD = 1000000007;

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

	int n;
	cin >> n;
	pair<double, double>* p;
	p = new pair<double, double>[n];

	rep(i, n) {
		cin >> p[i].first >> p[i].second;
	}

	double sum = 0;
	rep(i, n) {
		REP(j, i + 1, n) {
			sum += sqrt(pow((p[i].first - p[j].first), 2) + pow((p[i].second - p[j].second), 2));
		}
	}

	cout << fixed << setprecision(10) <<  2 * sum / double(n) << "\n";

	return 0;
}


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

public class Main {
    static final int SIZE = 3;

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

        int[][] c = new int[SIZE][SIZE];
        for (int i = 0; i < SIZE; ++i) {
            for (int j = 0; j < SIZE; ++j) {
                c[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve(c) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(int[][] c) {
        return IntStream.range(0, SIZE).map(i -> c[i][1] - c[i][0]).distinct().count() == 1
                && IntStream.range(0, SIZE).map(i -> c[i][2] - c[i][1]).distinct().count() == 1
                && IntStream.range(0, SIZE).map(j -> c[1][j] - c[0][j]).distinct().count() == 1
                && IntStream.range(0, SIZE).map(j -> c[2][j] - c[1][j]).distinct().count() == 1;
    }
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    string N;
    cin >> N;
    if ((N[0] == N[1] and N[1] == N[2]) or (N[1] == N[2] and N[2] == N[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

template< typename Monoid >
struct SegmentTree
{
	using F = function< Monoid(Monoid, Monoid) >;

	int sz;
	vector< Monoid > seg;

	const F f;
	const Monoid M1;

	SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
	{
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x)
	{
		seg[k + sz] = x;
	}

	void build()
	{
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x)
	{
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b)
	{
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid operator[](const int &k) const
	{
		return seg[k + sz];
	}
};
//min
//SegmentTree< int > seg(N, [](int a, int b){ return min(a, b); }, INT_MAX);

//max
//SegmentTree< int > seg(N, [](int a, int b){ return a + b; }, 0);

int main() {
	int n, q;
	cin >> n >> q;
	SegmentTree<int> seg(n, [](int a, int b) {return a + b;}, 0);
	for (int i = 0; i < q; i++) {
		int c, a, b;
		cin >> c >> a >> b;
		if (!c) {
			seg.update(a, seg[a] + b);
		} else {
			cout << seg.query(a, b + 1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3892
import java.io.*;
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int n=Integer.parseInt(scan.next());
    int hanakoPoint=0;
    int tarouPoint=0;
    for(int i=0;i<n;i++){
      String hanakoCard=scan.next();
      String tarouCard=scan.next();
      int judge=hanakoCard.compareTo(tarouCard);
      if(judge<0){
        hanakoPoint+=3;
      }else if(judge>0){
        tarouPoint+=3;
      }else{
        hanakoPoint++;
        tarouPoint++;
      }
    }

    System.out.println(tarouPoint+" "+hanakoPoint);
  }
}


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

int main () {
	int x, y;
	for (int i = 0; ; i++) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;

		if (x < y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
	}
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<signed, null_type, less_equal<signed>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//find_by_order();
//order_of_key();
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;
const double PI = 3.141592653589793238;


//MODULAR ARITHMATIC
const int mmod = 1000000007;

int add(int a, int b, int m=mmod) {
	return (a%m + b%m)%m;
}

int sub(int a, int b, int m=mmod) {
    return (a%m - b%m + m)%m;
}

int mul(int a, int b, int m=mmod) {
	return ((a%m) * (b%m) % m);
}

int pow(int a, int b, int m=mmod) {
    a %= m;
    int r = 1;
    while (b) {
		if (b&1) r = r*a%m;
		b >>= 1;
		a = a*a%m;
    }
    return r;
}

int inv(int a, int m=mmod) {
	return pow(a, m-2, m);
}

ii norm(int a, int b) {
	int g = __gcd(a, b);
	a /= g, b /= g;
	if (a == 0) b = 1;
	if (b == 0) a = 1;
	if (a < 0) a = -a, b = -b;
	return {a, b};
}

ii inv(ii p) {
	return norm(-p.second, p.first);
}

int pw[200010];

int32_t main() {
	FAST_IO;
	pw[0] = 1;
	for(int i = 1; i < 2e5 + 7; i++)
		pw[i] = pw[i - 1] * 2 % mmod;
		
	int n;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	
	int ans = 0;
	map<ii, int> cnt, vis;
	
	for (int i = 0; i < n; i++) {
		if (a[i] == 0 && b[i] == 0) ans++;
		else {
			ii p = norm(a[i], b[i]);
			cnt[p]++;
		}
	}
	int tt = 1;
	for (auto pp: cnt) {
		ii p = pp.first, q = inv(p);
		if (vis[p]) continue;
		tt = mul(tt, sub(add(pw[cnt[p]], pw[cnt[q]]), 1));
		vis[p] = vis[q] = 1;
	}
	ans = add(ans, tt);
	ans = sub(ans, 1);
	cout << ans << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 58292
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int n;
int a[200010];
vector<int> vt;
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		vt.push_back(a[i]);
	}
	sort(vt.begin(), vt.end());
	int ch = vt[(n+1) / 2];
	for (int i = 0; i < n; i++)
	{
		if (a[i] < ch)
		{
			printf("%d\n", vt[(n+1) / 2]);
		}
		else
			printf("%d\n", vt[(n-1) / 2]);
	}
}

Measured memory_bytes: 3828
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++) cin >> a[i];
    int cnt=0;

    for(int i=0;i<N-1;i++){
        int minj = i;
        for(int j=i;j<N;j++){
            if(a[j] < a[minj]) minj = j;
        }
        swap(a[i], a[minj]);
        if(i != minj) cnt++;
    }
    

    for(int i=0;i<N-1;i++) cout << a[i] << ' ';
    cout << a[N-1] << endl;
    cout << cnt << endl;
}


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

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int count=0;
  if(A<=C&&C<=B){
    count++;
  }
  if(count==1){
    cout<<"Yes"<<endl;
  }
  else if(count==0){
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

string ans="keyence",S,t;

int main(){
    cin>>S;
    rep(i,S.length()){
        rep(j,S.length()){
            t=S;
            t.erase(i,j);
            if(t==ans){
                out("YES");
                return 0;
            }
        }
    }
    out("NO");

}


Measured memory_bytes: 256
object Main {
  def binarySearch(arr: Array[Int], value: Int): Int = {
    var i = 0
    var j = arr.length
    var half = (i+j)/2
    if (arr.isEmpty) return 0
    while (i < j) {
      if (arr(half) >= value) {
        j = half
      } else {
        i = half+1
      }
      half = (i+j)/2
    }
    i
  }

  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val A = new Array[Int](N)
    val B = new Array[Int](N)
    for (i <- 0 until N) A(i) = sc.nextInt
    for (i <- 0 until N) B(i) = sc.nextInt

    var res = 0
    for (i <- (0 to 29).reverse) {
      val (higher, lower) = (1<<(i+1), 1<<i)
      for (j <- 0 until N) {
        A(j) = A(j) % higher
        B(j) = B(j) % higher
      }
      java.util.Arrays.sort(B)
      var loc_sum = 0
      for (k <- 0 until N) {
        if (lower-A(k) >= 0) {
          loc_sum += binarySearch(B, higher-A(k)) 
          loc_sum -= binarySearch(B, lower-A(k))
        } else {
          loc_sum += binarySearch(B, higher-A(k))
          loc_sum += binarySearch(B, higher)
          loc_sum -= binarySearch(B, higher + lower - A(k))
        }
      }
      res += lower*(loc_sum&1)
    }
    println(res)
  }
}


Measured memory_bytes: 114084
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int d=sc.nextInt();
    int ans=b/d-a/d;
    if(a%d==0)
      ans++;
    System.out.println(ans);
  }
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    string s;
    cin >> s;
    int len = SZ(s) % 2;
    puts(len ^ (s[0] == s.back()) ? "First" : "Second");
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long n,x;
long long gcd(long long a,long long b){
	if(!b)return a;
	return gcd(b,a%b);
}
int main(){
	cin>>n>>x;
	cout<<3*(n-gcd(n,x));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++)
#define ll long long 

int main() {
    ll a, b, k;
    cin >> a >> b >> k;

    if(a == b && a+b <= k) {
        cout << 0 << " " << 0 << endl;
    }
    else {
        if(k <= a) {
            cout << a-k << " " << b << endl;
        }
        else if((k-a) <= b){
            cout << 0 << " " << b-(k-a) << endl;
        }
        else {
            cout << 0 << " " << 0 << endl;
        }
    }

    return 0;


}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  


int main(){
    int h, w, m;
    cin >> h >> w >> m;
    
    vector<int> a(h + 1);
    vector<int> b(w + 1);
    map<ii, int> t;
    int mx1 = 0, mx2 = 0;
    for(int i = 0; i < m; i++){
        int mh, mw;
        cin >> mh >> mw;
        t[make_pair(mh, mw)] = 1;
        a[mh]++;
        b[mw]++;
        mx1 = max(mx1, a[mh]);
        mx2 = max(mx2, b[mw]);
    }

    vector<int> sol1, sol2;
    for(int i = 0; i <= h; i++)
        if(a[i] == mx1) sol1.push_back(i);
    for(int i = 0; i <= w; i++)
        if(b[i] == mx2) sol2.push_back(i);

    bool check = true;
    for(int x : sol1){
        for(int y : sol2){
            if(t[make_pair(x, y)] != 1){
                check = false;
                break;
            }
        }
    }
    cout << mx1 + mx2 - check;
}


Measured memory_bytes: 45516
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>



int main(void){
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    for(;;){
        if(abs(a-b)==1){printf("Borys\n");return 0;}
        a++;
        if(abs(a-b)==1){printf("Alice\n");return 0;}
        b--;
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define tc(t)  int t; cin>>t; while(t--) 
#define f(n)    for(int i=0;i<n;i++)

#define endl   "\n" 


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



int minimum_cost(int *arr,int n,int k)
{
  int dp[n+1];

  dp[0]=0;
  dp[1]=0;

  for(int i=2;i<=n;i++)
  {
             dp[i]=INT_MAX;
         for(int j=1;j<=k;j++)
         {
            
               if(i-j>0)
               {
                   int ans=abs(arr[i-1]-arr[i-j-1])+dp[i-j];
                   dp[i]=min(dp[i],ans);
               }

                    



         }






  }

 
  return dp[n];






}




int32_t main()
{
 // i_o_f();
  int n,k;
  cin>>n>>k;
  int *arr=new int[n];

  for(int i=0;i<n;i++) cin>>arr[i];
   cout<<minimum_cost(arr,n,k)<<endl;





}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

template<typename T>
void p(T elem) {cout << elem << endl;}
template<typename T>
void ps(vector<T>& arr) { for(T e: arr) p(e); }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

int main(void) {
    string str, sub;
    cin >> str;
    cin >> sub;
    vector<vector<int>> pos(26);
    for(int i = 0; i < str.size(); i++) {
        char ch = str[i] - 'a';
        pos[ch].push_back(i);
        pos[ch].push_back(i+str.size());
    }

    for(int i = 0; i < 26; i++) {
        sort(pos[i].begin(), pos[i].end());
    }

    int round = 0;
    int idx = -1;
    for(int i = 0; i < sub.size(); i++) {
        char ch = sub[i] - 'a';
        debug("%c: size: %d\n", sub[i], pos[ch].size());
        if(pos[ch].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        // greater than or equal to pos
        auto nidx = upper_bound(pos[ch].begin(), pos[ch].end(), idx);
        idx = *(nidx);
        if(idx >= str.size()) {
            idx -= str.size();
            round++;
        }
    }
    int64_t ans = ((int64_t)round*str.size()) + idx;
    // 1-indexed
    ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4600
#python3
INF = 10**9

def main():
    w, h, n = map(int, input().split())
    x_max = -1
    x_min = INF
    y_max = -1
    y_min = INF
    for i in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            x_max = max(x_max, x)
        if a == 2:
            x_min = min(x_min, x)     
        if a == 3:
            y_max = max(y_max, y)
        if a == 4:
            y_min = min(y_min, y)

    if x_max == -1:
        x_max = 0 
    if x_min == INF:
        x_min = w
    if y_max == -1:
        y_max = 0
    if y_min == INF:
        y_min = h

    dx_max = x_max
    dx_min = w - x_min
    dy_max = y_max
    dy_min = h - y_min 

    x = w - (dx_max+dx_min)
    y = h - (dy_max+dy_min)

    if (x<=0) | (y<=0):
        print(0)
    else:
        print(x*y)
    
main()


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	s+='0';
	int ans=1;
	char c=s[0];
	for(int i=1; i<n; i++){
		if(c!=s[i]){
			c=s[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a[400005];
ll b[400005];
ll N,M;
int main(){
  cin>>N>>M;vector<ll>A(N);
  for(ll i=0;i<N;i++){
  ll x;cin>>x;
    a[x+N]++;A[i]=x+N;
  }for(ll i=1;i<=N;i++){
  ll j=a[i+N];
    b[i-j+N+1]++;b[i+1+N]--;
  }for(ll i=1;i<=400004;i++)
    b[i]+=b[i-1];
  for(ll i=0;i<=N;i++)
    b[i]++;
  ll ans=0;
  for(ll i=0;i<=2*N;i++)
    ans+=abs(1-b[i]);
  ans/=2;
  for(ll i=0;i<M;i++){
  ll x,y;cin>>x>>y;x--;y+=N;
    ll X=A[x];A[x]=y;
    if(X==y)
      cout<<ans<<endl;
    else{
    ll c=0;
    b[X-a[X]+1]--;
    
    if(b[X-a[X]+1]!=0)
      c--;else c++;
    b[y-a[y]]++;
    if(b[y-a[y]]!=1)
      c++;
    else
      c--;
    c/=2;a[X]--;a[y]++;ans+=c;
    cout<<ans<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 9580
#include <bits/stdc++.h>
#define pb push_back
#define sz(V) ((int)(V).size())
#define befv(V) ((V)[(sz(V)-2)])
#define clv(V) (V).clear()
#define upmax(a,b) (a)=max((a),(b))
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define MAXN (300005)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
ll operator * (pll a, pll b) { return a.first*b.second - b.first*a.second; }
ll ccw(pll a, pll b, pll c) { return a*b + b*c + c*a; }
struct CHT {
	vector<pll> V;
	void init() { clv(V); }
	void push(ll a, ll b) { // a must be smaller
		for(; 1 < sz(V) && ccw(befv(V), V.back(), {a, b}) <= 0; V.pop_back());
		V.pb({a, b});
	}
	ll f(ll x, int idx) { return V[idx].first*x + V[idx].second; }
	ll f(ll x) {
		if(V.empty()) return -INFLL;
		int s = 0, e = sz(V)-1; for(int m; s < e;) {
			m = (s+e)/2;
			ll l = f(x, m), r = f(x, m+1);
			if(l < r) s = m+1; else e = m;
		}
		return f(x, s);
	}
};

CHT cht;
ll L[MAXN], R[MAXN], P[MAXN];
ll S[MAXN];
ll T[MAXN];
int N, M;

void f(ll d[]) {
	for(int i = 1; i <= N; i++) S[i] = S[i-1] + T[i];
	cht.init(); cht.push(0, 0);
	for(int i = 1; i <= N; i++) {
		d[i] = max(d[i-1], cht.f(i) + ((ll)i*i + i) / 2 - S[i]);
		cht.push(-i, d[i] + S[i] + ((ll)i*i - i) / 2);
	}
}
void f(ll d[], int s, int e) {
	if(s > e) return;
	if(s == e) {
		upmax(d[s], L[s-1] + R[s+1] + 1 - T[s]);
		return;
	}
	int m = (s+e)/2; ll x = -INFLL;
	cht.init();
	for(int j = m+1; j <= e; j++)
		cht.push(-j, R[j+1] - S[j] + ((ll)j*j + 3*j) / 2);
	for(int i = s; i <= m; i++) {
		ll t = cht.f(i) + L[i-1] + S[i-1] + ((ll)i*i - 3*i + 2) / 2;
		upmax(x, t); upmax(d[i], x);
	}
	cht.init(); x = -INFLL;
	for(int i = s; i <= m; i++)
		cht.push(-i, L[i-1] + S[i-1] + ((ll)i*i - 3*i) / 2);
	for(int j = e; m < j; j--) {
		ll t = cht.f(j) + R[j+1] - S[j] + ((ll)j*j + 3*j + 2) / 2;
		upmax(x, t); upmax(d[j], x);
	}
	f(d, s, m); f(d, m+1, e);
}
int main() {
	scanf("%d", &N);
	for(int i = 1; i <= N; i++) scanf("%lld", &T[i]);
	f(L); reverse(T+1, T+N+1); f(R); reverse(R+1, R+N+1); reverse(T+1, T+N+1);
	for(int i = 1; i <= N; i++) S[i] = S[i-1] + T[i];
	fill(P+1, P+N+1, -INFLL); f(P, 1, N);
	for(scanf("%d", &M); M--;) {
		int p; ll x; scanf("%d%lld", &p, &x);
		printf("%lld\n", max({L[p-1] + R[p+1], P[p] + T[p] - x, 0ll}));
	}
	return 0;
}

Measured memory_bytes: 14336
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		ArrayList<Integer> array = new ArrayList<Integer>();
		for(int i = 1;i<=a;i++){
			int b = sc.nextInt();
			array.add(b);
		}
		int ans = 1;

		boolean undefined = true;
		boolean upper = true;




		int former,latter;

		for(int i = 0;i<=a-2;i++){
			former = array.get(i);
			latter = array.get(i+1);
			if(undefined){
				if(latter - former > 0){
					upper = true;
					undefined = false;
				}else if(latter - former < 0){
					upper = false;
					undefined = false;
				}
			}else{
				if(upper){
					if(latter - former < 0){
						ans++;
						undefined = true;
					}
				}else{
					if(latter - former > 0){
						ans++;
						undefined = true;
					}
				}
			}

		}




		// 出力
		System.out.println(ans);
	}
}

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

//少数を考えるときはdouble!!!intだけ使うと引っかかるぞ！！
//愚かなことにcin > a[n]としていて全然進まなかった、、、

int main(){
  long n;
  int a[100100];
  int b[100100]={};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]==0){//すべてa[i]=0の時はX=0とすれば事足りる
      b[0]++;
      b[1]++;
    }else{
      b[a[i]-1]++;
      b[a[i]]++;
      b[a[i]+1]++;
    }
  }
  sort(b,b+100010,greater<int>());
  cout << b[0] <<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin>>n>>m;
  vector<double> vec(n, 0);
  long double d = 0;
  for(int i = 0; i < n; ++i){cin>>vec[i];d+=vec[i];}
  int u = 0;
  double x = (double)(d / (4 * m));
  for(int i = 0; i < n; ++i)if(vec[i]>=x)u++;
  if(u >= m)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define MAX_NUM 100001
#include <iomanip>
#include <string>
using namespace std;
int main()
{
    string S,T;
    cin>>S>>T;
    int N=S.size();
    int count=0;
    char temp;

    for(int i=0;i<N;i++)
    {
        temp=S[0];
        for(int j=0;j<N-1;j++)
        {
            S[j]=S[j+1];
        }
        S[N-1]=temp;
        if(S==T)
        {
            count=1;
            break;
        }
    }
    if(count)
        cout<<"Yes";
    else
        cout<<"No";

}

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

typedef long long ll;

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

int h, w;
string t[402];

ll ans;
int white, black;
bool used[402][402];

void solve(int x, int y) {
  used[y][x] = true;
  if (t[y][x] == '.') {
    white++;
  } else {
    black++;
  }

  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (0 <= nx && nx < w && 0 <= ny && ny < h && !used[ny][nx] &&
        t[ny][nx] != t[y][x]) {
      solve(nx, ny);
    }
  }
}

int main() {
  while (cin >> h >> w) {
    for (int i = 0; i < h; i++) {
      cin >> t[i];
    }
    memset(used, 0, sizeof(used));
    ans = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (t[i][j] != '#' || used[i][j]) {
          continue;
        }

        white = 0;
        black = 0;
        solve(j, i);

        ans += (ll)black * white;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 15616
def gcd(x,y):
	tx, ty = max(x,y), min(x,y)
	if ty%tx == 0:
		return tx
	else:
		return gcd(tx%ty, ty)

def main():
	x,y = map(int,input().split())
	print(gcd(x,y))
	return

main()	


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
  int m, c, N;
  cin >> N;
  m=9999999;
  for(int i=0;i<N;i++)
  {
    int a;
    cin >> a;
    c=0;
    while(a%2==0)
    {
      a /= 2;
      c++;
    }
    if(c<m)
    {
      m=c;
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long mbk(long long a,long long n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
long long inv(long long a,int m){return mbk((long long)a,m-2,m);}
long long i,n,m,ans=0,M=1e9+7,v[4000010],p[400010]={1,1};
long long aCb(long long a,long long b){return p[a]*v[b]%M*v[a-b]%M;}
int main(){
  for(i=2;i<400010;i++)p[i]=(p[i-1]*i)%M;
  for(i=0;i<400010;i++)v[i]=inv(p[i],M);
  scanf("%lld %lld",&n,&m);
  if(n<m)printf("%lld\n",p[n*2-1]*v[n]%M*v[n-1]%M);
  else{
    for(i=0;i<=m;i++)ans=(ans+(aCb(n,i)*aCb(n-1,i)%M))%M;
    printf("%lld\n",ans);
  }
  return 0;
}


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

char s[100][102];
pair<int,int> p[102];
const int inf=(~0u)>>2;
vector<pair<int,int> > s1,s2,s3;
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
bool cmp(pair<int,int> a,pair<int,int> b)
{
	return a.FI-a.SE<b.FI-b.SE;
}
bool check()
{
	int n,len;
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	{
		scanf("%s",s[i]);
		len=strlen(s[i]);
		int minv=inf,val=0;
		for(int j=0;j<len;++j)
		{
			if(s[i][j]=='(')++val;
			else --val;
			minv=min(minv,val);
		}
		p[i]=MP(minv,val);
		//cout <<minv<<" "<<val<<endl;
		if(minv>=0)s1.PB(p[i]);
		else if(val>=0)s2.PB(p[i]);
		else s3.PB(p[i]);
	}
	//for(auto i:s1)cout <<i.FI<<" "<<i.SE<<endl;
	//for(auto i:s2)cout <<i.FI<<" "<<i.SE<<endl;
	int sum=0;
	for(int i=0;i<s1.size();++i)
		sum+=s1[i].SE;
	//cout <<"s2 begin:"<<sum<<endl;
	sort(s2.begin(),s2.end());
	reverse(s2.begin(),s2.end());
	for(int i=0;i<s2.size();++i)
	{
		if(s2[i].FI+sum<0)return false;
		sum+=s2[i].SE;
	}
	//cout <<"s3 begin:"<<sum<<endl;
	sort(s3.begin(),s3.end(),cmp);
	//for(auto i:s3)cout <<i.FI<<" "<<i.SE<<endl;
	for(int i=0;i<s3.size();++i)
	{
		if(s3[i].FI+sum<0)return false;
		sum+=s3[i].SE;
		if(sum<0)return false;
	}
	//cout <<sum<<endl;
	return sum==0;
}
int main()
{
	if(check())puts("Yes");		
	else puts("No");
	return 0;
}

Measured memory_bytes: 3132
N = map(int, input().split())
A = map(int, input().split())

res = [0]
for a in A:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            res.append(0)
        else:
            res.append(1)

if sum(res) > 0:
    print("DENIED")    
else:
    print("APPROVED")



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

using namespace std;

int main(){

   // freopen ("input.txt", "r", stdin);

    string str;

    cin >> str;

    if(str[0] == '7' || str[1] =='7' || str[2] == '7'){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < 20; i++) {
		if (n == 1 << i) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes\n";
	for (int i = 2; i < n; i += 2) {
		cout << "1 " << i << '\n';
		cout << i << ' ' << i + 1 << '\n';
		cout << "1 " << i + 1 + n << '\n';
		cout << i + 1 + n << ' ' << i + n << '\n';
	}
	cout << 2 + n << ' ' << 1 + n << endl;
	if (n & 1) return 0;
	int a = 1;
	while (a + a < n) a += a;
	cout << n << ' ' << n - a << '\n';
	cout << n + n << ' ' << a + 1 + n << endl;
	return 0;
}


Measured memory_bytes: 2304
# coding: utf-8
n=int(input())
data=[]
for i in range(n):
    x,l=map(int,input().split())
    data.append((x-l,x+l))
data=sorted(data,key=lambda x:x[1])
p=-10**9-1
ans=0
for i in range(n):
    if data[i][0]>=p:
        ans+=1
        p=data[i][1]
print(ans)

Measured memory_bytes: 59096
# Some Sums
# input
N, A, B = map(int, input().split())

# solution
res = sum([n for n, y in zip(range(1, N+1), [sum([int(e) for e in str(x)]) for x in range(1, N+1)]) if y >= A and y <= B])

# output
print(res)

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int n, s;
int count = 0;

void DFS(int sum, int pre, int depth)
{
	if(depth > n || sum > s)
	{
		return;
	}
	else if(sum == s && depth == n)
	{
		++count;
		return;
	}
	for(int i = pre + 1; i < 10; ++i)
	{
		DFS(sum + i, i, depth + 1);
	}
}

void solve()
{
	while(cin >> n >> s, n || s)
	{
		count = 0;
		for(int i = 0; i < 10; ++i)
		{
			DFS(i, i, 1);
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <numeric>
#include <functional>
#include <algorithm>
using namespace std;

int N, K;
vector<int> L;

int main(void) {
	cin >> N >> K;

	L.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> L[i];
	sort(L.begin(), L.end(), greater<int>());
	int ans = accumulate(L.begin(), L.begin() + K, 0);

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
'use strict'

var mod = 1e9 + 7

function solve(N, mask, A, M, dp) {
  if (dp[N][mask] !== -1) {
    return dp[N][mask]
  } 
  if ((N === 0  && mask === 0) || (N === 0 && mask === (Math.pow(2, M) - 1))) {
    return 1
  }
  if (N === 0) {
    return 0
  }
  var res = 0 

  for (var i = 0; i < M; i++) {
    if (A[N-1][i] && !(mask & (1 << i))) {
      res = (res + solve(N-1, mask | (1 << i), A, M, dp)) % mod
    }
  }
  dp[N][mask] = res
  return res
}

function main(input) {
  var lines = input.split("\n")
  var N = parseInt(lines[0])
  var A = lines.slice(1).map(l => l.split(' ').map(e => parseInt(e)))
  var dp = new Array(N+1).fill(0).map(e => new Array(Math.pow(2,N)).fill(-1))
  dp[0][0] = 1
  dp[0][(1 << N) - 1] = 1
  var ans = solve(N, 0, A, N, dp)
  console.log(ans)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

// 6

// 0 1 1
// 1 0 1
// 1 1 1

// dp[0][111] = 1
// dp[3][000] = sum(dp[2][001] + dp[2][010] + dp[2][100])
// dp[2][001] = sum(dp[1][011] + dp[1][101])
// dp[2][010] = sum(dp[1][110] + dp[1][011])
// dp[2][100] = sum(dp[1][110] + dp[1][101])
// dp[1][011] = sum(dp[0][111])

//   0 1 2 3 4 5 6 7
// 0 1 0 0 0 0 0 0 1
// 1 0 0 0 1 0 1 0 0
// 2 0 1 1 0 1 0 0 0
// 3 3


Measured memory_bytes: 368660
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	int n; cin>>n;
	n%=1000;
	if(n==0) puts("0");
	else cout<<1000-n<<endl;
	return 0;
}

Measured memory_bytes: 3596
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) { 
    int cellsInfo;
    cin >> cellsInfo;
    
    int hasBallInFirstPlace  = cellsInfo / 100;
    int hasBallInSecondPlace = (cellsInfo - (hasBallInFirstPlace * 100)) / 10;
    int hasBallInThirdPlace  = (cellsInfo - hasBallInFirstPlace * 100 - hasBallInSecondPlace * 10);
    int result = hasBallInFirstPlace + hasBallInSecondPlace + hasBallInThirdPlace;
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 5010
ll dp[N][N];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n; string s;
    cin>>n>>s;
    for(int i=0;i<N;i++)for(int j=0;j<N;j++)dp[i][j]=0;
    dp[0][0]=1;
    for(int i=0;i<n;i++)for(int j=0;j<N-1;j++){
	mad(dp[i+1][max(0,j-1)],dp[i][j]);
	mad(dp[i+1][j+1],dp[i][j]*2);
    }
    ll ans=dp[n][s.size()];
    for(int i=0;i<s.size();i++){
	ans=ans*500000004%mod;
    }
    cout<<ans<<endl;
}




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

int main() {
  int N,f,a;
  cin >> N;
  f=0;
  a=1;

  for (int i=0; i<8; i++){
    f+=N/a%10;
    if (i==7){
      if (N%f==0)
        cout << "Yes" << endl;
      else
        cout << "No" << endl;
    }
    a*=10;
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static void main(String[] a)
        {
            int[] mt = new int[10];
            int i;
            Scanner scan = new Scanner(System.in);
            for (i = 0; i < 10; i++) {
                mt[i] = scan.nextInt();
            }
            Arrays.sort(mt);
            for (i = 9; i > 6; i--) {
                System.out.println(mt[i]);
            }
        }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

bool isFall(string &s, vector<pair<char, char>> &cmd, ll pos, char goal){
    bool ret = false;
    ll cmdSize = cmd.size();
    rep(i, cmdSize){
        // 現在位置が呪文の対象の場合
        if(cmd[i].first == s[pos]){
            cmd[i].second == 'R' ? pos++ : pos--;
            if(pos < 0 || pos > s.size()-1) break;
        }
    }
    if((pos < 0 && goal == 'L') || (pos > s.size()-1 && goal == 'R')) ret = true;
    return ret;
}

int main(){
    Init();
    ll n, q; string s;
    cin >> n >> q >> s;
    vector<pair<char, char>> cmd(q);
    rep(i, q) cin >> cmd[i].first >> cmd[i].second;

    // 左方向に落ちるゴーレムの中で最も右側にあるものを求める
    ll l = -1, r = n;
    while(r-l > 1){
        ll mid = (r+l)/2;
        (isFall(s, cmd, mid, 'L') ? l : r) = mid;
    }

    // 右方向に落ちるゴーレムの中で最も左側にあるものを求める
    ll ans = n-(l != -1 ? (l+1) : 0);
    l = -1, r = n;
    while(r-l > 1){
        ll mid = (r+l)/2;
        (isFall(s, cmd, mid, 'R') ? r : l) = mid;
    }
    cout << max(0LL, ans-(r != n ? (n-r) : 0))  << endl;
}

Measured memory_bytes: 3968
def main():
    n = int(input())
    if n % 10 == 3:
        print('bon')
    elif n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8:
        print('pon')
    else:
        print('hon')


if __name__ == "__main__":
    main()

Measured memory_bytes: 9108