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

int n;
int dice[6] = {1, 2, 3, 4, 5, 6};

void N() {
  int s[4] = {0, 1, 5, 4};
  for (int i = 1; i < 4; ++i) {
    swap(dice[s[i]], dice[s[i - 1]]);
  }
}

void E() {
  int s[4] = {0, 3, 5, 2};
  for (int i = 1; i < 4; ++i) {
    swap(dice[s[i]], dice[s[i - 1]]);
  }
}

void R() {
  int s[4] = {1, 2, 4, 3};
  for (int i = 1; i < 4; ++i) {
    swap(dice[s[i]], dice[s[i - 1]]);
  }
}

void S() {
  for (int i = 0; i < 3; ++i) {
    N();
  }
}

void W() {
  for (int i = 0; i < 3; ++i) {
    E();
  }
}

void L() {
  for (int i = 0; i< 3; ++i) {
    R();
  }
}

int main() {
  while (cin >> n, n) {
    for (int i = 0; i < 6; ++i) dice[i] = i + 1;
    int ans = 1;

    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;

      if (s[0] == 'N') N();
      if (s[0] == 'S') S();
      if (s[0] == 'E') E();
      if (s[0] == 'W') W();
      if (s[0] == 'R') R();
      if (s[0] == 'L') L();

      ans += dice[0];
    }

    cout << ans << endl;
  }
}

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

#define inf 2000000009
#define ff first 
#define ss second 
#define ll long long
#define M (1000*1000*1000+7)
#define vi vector<int>
#define vll vector<ll>
#define boost ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pq priority_queue<int> 
#define vpii vector< pair<int,int> >
#define pb push_back
#define pii pair<int,int> 
#define mp make_pair


char g[1001][1001]; 
char c[1001][1001]; 
int x[]={0,0,-1,-1,-1,1,1,1};
int y[]={1,-1,0,1,-1,0,1,-1}; 

void solve(){
  int n,m; cin>>n>>m; 
  int ans=1; 
  for(int i=1;i*i<=m;i++){
    if(m%i==0){
      int d=m/i; 
      ll p=(ll)i*n; 
      ll p2=(ll)d*n; 
      if(p<=m && (m-p)%i==0){
        ans=max(ans,i); 
      }
      if(p2<=m && (m-p2)%d==0){
        ans=max(ans,d); 
      }
    }
  }
  cout<<ans; 
  
}

int main(){
  boost; 
  clock_t beg=clock();
  int t=1; 
  while(t--){
    solve(); 
  }
  clock_t end=clock(); 
  fprintf(stderr, "%lf sec\n", (double)(end-beg)/(CLOCKS_PER_SEC));

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const string chars = "mcxi";
const int units[] = { 1000, 100, 10, 1 };

int parse( string str )
{
	REP( i, 0, str.size() )
	{
		if ( isalpha( str[i] ) && ( !i || isalpha( str[ i - 1 ] ) ) )
		{
			str.insert( i, "1" );
		}
	}

	int res = 0;
	for ( int i = 0; i < str.size(); i += 2 )
	{
		res += ( str[i] - '0' ) * units[ find( ALL( chars ), str[ i + 1 ] ) - chars.begin() ];
	}
	return res;
}

string enc( int n )
{
	string res;
	REP( i, 0, 4 )
	{
		int tmp = n / units[i];
		if ( tmp == 0 )
		{
			continue;
		}
		if ( tmp != 1 )
		{
			res += tmp + '0';
		}
		res += chars[i];
		n %= units[i];
	}
	return res;
}

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

	int n;
	cin >> n;

	REP( i, 0, n )
	{
		string s, t;
		cin >> s >> t;

		cout << enc( parse( s ) + parse( t ) ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;
typedef int64_t i64;

i64 calc_inversion (i64 *a, i32 n) {
  static i64 *tmp = NULL;
  if (tmp == NULL) {
    tmp = (i64 *) calloc (n, sizeof (i64));
  }
  if (n <= 1) return 0;
  i32 m = n / 2;
  i64 ans = calc_inversion (a, m) + calc_inversion (a + m, n - m);
  i32 i = 0;
  i32 j = m;
  i32 k = 0;
  while (i < m && j < n) {
    if (a[i] <= a[j]) {
      tmp[k++] = a[i++];
    } else {
      ans += m - i;
      tmp[k++] = a[j++];
    }
  }
  while (i < m) tmp[k++] = a[i++];
  memcpy (a, tmp, sizeof (i64) * k);
  return ans;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i64 *sum = (i64 *) calloc (n + 1, sizeof (i64));
  for (i32 i = 1; i <= n; ++i) {
    i32 a;
    scanf ("%" SCNi32, &a);
    sum[i] = sum[i - 1] + a - k;
  }
  i64 ans = (i64) (n + 1) * n / 2 - calc_inversion (sum, n + 1);
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


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

int main() {
  int64_t N, K;
  cin >> N >> K;

  int64_t answer = N;
  
  // Kは1以上
  
  int64_t a = 0;
  int64_t b = 0;

  if ( N >= K ){
    a = N % K;
    b = K - (N % K);
    answer = min(a,b);
    cout << answer << endl;
  }
  
  else {
    if ( N == 0 ) {
      answer = 0;
      cout << answer << endl;
    }
    else if ( N < ( K - N ) ) {
      answer = N;
      cout << answer << endl;
    }
    else {
      answer = ( K - N );
      cout << answer << endl;
    }
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
//NIL is NULL
#define NIL NULL
//Node structure
struct Node{
  int key;
  struct Node *parent;
  struct Node *leftc;
  struct Node *rightc;
};
//define Nodepointer
typedef struct Node * Nodepointer;

//root         
Nodepointer root;

//function insert
void insert(int k){
  Nodepointer x,y,z;
  y=NIL;
  x=root;
  //make memory
  z=new struct Node();

  z->key=k;
  z->leftc=NIL;
  z->rightc=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->leftc;
    else x=x->rightc;
  }

  z->parent=y;

  if(y==NIL) root=z;

  else if(z->key<y->key) y->leftc=z;

  else y->rightc=z;


}

//function search
Nodepointer find(Nodepointer now,int data){
  if(now==NIL||data==now->key) return now;
  if(data<now->key) return find(now->leftc,data);
  else return find(now->rightc,data);
}

//function treeminimum
Nodepointer treeminimum(Nodepointer x){
  while(x->leftc!=NIL){
    x=x->leftc;
  }
  return x;
}
//function treesuccerssor
Nodepointer treesuccessor(Nodepointer x){
  Nodepointer y;
  if(x->rightc!=NIL) return treeminimum(x->rightc);
  y=x->parent;
  while(y!=NIL && x==x->rightc){
    x=y;
    y=y->parent;
  }
  return y;
}
//function treedelete
void treedelete(Nodepointer z){
  Nodepointer x,y;
  if(z->leftc==NIL ||z->rightc==NIL)y=z;
  else y=treesuccessor(z);

  if(y->leftc!=NIL)x=y->leftc;
  else x=y->rightc;
 
  if(x!=NIL)x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else if(y==y->parent->leftc) y->parent->leftc=x;
  else y->parent->rightc=x;
  if(y!=z) z->key=y->key;
}

//print
void inorderprint(Nodepointer now){
  if(now!=NIL){
    inorderprint(now->leftc);
    printf(" %d",now->key);
    inorderprint(now->rightc);
  }
}

void preorderprint(Nodepointer now){
  if(now!=NIL){
    printf(" %d",now->key);
    preorderprint(now->leftc);
    preorderprint(now->rightc);
  }
}


int main(){

  int n,i,j,data;
  Nodepointer del;
  char str[10];
  //load n
  scanf("%d",&n);
  //load commnad and key
  for(i=0;i<n;i++){
    scanf("%s",str);
    //insert
    if(strcmp(str,"insert")==0) {
      scanf("%d",&data);
      insert(data);
    }
    //find
    else if(strcmp(str,"find")==0){
      scanf("%d",&data);
      if(find(root,data)!=NIL) printf("yes\n");
      else printf("no\n");
    }
    //delete
    else if(strcmp(str,"delete")==0){
      scanf("%d",&data);
      del=find(root,data);
      treedelete(del);
    }
    //print
    else if(strcmp(str,"print")==0){
      inorderprint(root);
      cout <<endl;
      preorderprint(root);
      cout <<endl;
    }
  }

  return 0;
}

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

vector<int> x[20];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,d;cin>>n>>d;
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      int t;cin>>t;
      x[i].push_back(t);
    }
  }
  int res=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double dist = 0;
      for(int k=0;k<d;k++){
        dist += pow(x[i][k]-x[j][k], 2);
      }
      int s = sqrt(dist);
      if(s*s==dist){
        res++;
      }
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
   char s[100];
   int c=0;
   while(gets(s))
   {
       c=0;
       for(int i=0;i<4;i++)
       {
           if(s[i]=='+')
            c++;
           else
            c--;
       }
       printf("%d\n",c);
   }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll d;cin >> d;
	vector<ll> c(26);REP(i, 26)cin >> c[i];
	vector<vector<ll>> s(d, vector<ll>(26));
	REP(i, d)REP(j, 26)cin >> s[i][j];
	vector<ll> now(26);

	ll score = 0;
	REP(i, d){
		ll a;cin >> a;a--;
		score += s[i][a];
		REP(j, 26)now[j]++;
		now[a] = 0;
		REP(j, 26)score -= c[j] * now[j];
		cout << score << endl;
	}

	return 0;
}


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
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; }

int n, a[100010], b[100010];
ll c[100010];
ll dist[100010];
bool visited[100010];
vector<vector<pil>> tree;

void dfs(int i) {
    visited[i] = true;
    for (pil &e: tree[i]) {
        int j = e.first;
        ll w = e.second;
        if (!visited[j]) {
            dist[j] = dist[i] + w;
            dfs(j);
        }
    }
}

int main() {
    cin >> n;
    tree.resize(n);
    rep(i, n-1) {
        int u, v; ll w;
        cin >> u >> v >> w;
        u--; v--;
        tree[u].pb(make_pair(v, w));
        tree[v].pb(make_pair(u, w));
    }
    int q, k;
    cin >> q >> k;
    k--;
    dfs(k);
    rep(i, q) {
        int x, y; cin >> x >> y;
        x--; y--;
        cout << dist[x] + dist[y] << endl;
    }
}


Measured memory_bytes: 12800
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  get(N);
  int ans = 0;
  int t = 10;
  while (t <= N) {
    ans += t * 9 / 10;
    t *= 100;
  }
  if (N >= t / 10)
    ans += N - t / 10 + 1;
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int n;
    std::cin >> n;
    if (n <= 111) {
        std::cout << 111 << std::endl;
        return 0;
    }
    if (n <= 222) {
        std::cout << 222 << std::endl;
        return 0;
    }
    if (n <= 333) {
        std::cout << 333 << std::endl;
        return 0;
    }
    if (n <= 444) {
        std::cout << 444 << std::endl;
        return 0;
    }
    if (n <= 555) {
        std::cout << 555 << std::endl;
        return 0;
    }
    if (n <= 666) {
        std::cout << 666 << std::endl;
        return 0;
    }
    if (n <= 777) {
        std::cout << 777 << std::endl;
        return 0;
    }
    if (n <= 888) {
        std::cout << 888 << std::endl;
        return 0;
    }
    if (n <= 999) {
        std::cout << 999 << std::endl;
        return 0;
    }
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N;
ll x[212345], y[212345];

int main() {
	cin >> N;
	REP(i, N) {
		scanf("%lld %lld", x + i, y + i);
		if (x[i] > y[i]) swap(x[i], y[i]);
	}
	
	ll ans;
	
	if (N == 1) ans = 0;
	else {
		// Rmax=最大値, Bmin=最小値
		ans = (*max_element(x, x + N) - *min_element(x, x + N)) * (*max_element(y, y + N) - *min_element(y, y + N));
		
		// Rmax=最大値, Rmin=最小値
		ll diff = *max_element(y, y + N) - *min_element(x, x + N);
		
		set<pii> ss;
		REP(i, N) ss.insert(pii(x[i], i));
		ss.insert(pii(y[ss.begin()->se], -1));
		ss.erase(ss.begin());
		
		while (ss.begin()->se >= 0) {
			chmin(ans, diff * (ss.rbegin()->fi - ss.begin()->fi) );
			pii tmp = pii(y[ss.begin()->se], -1);
			ss.erase(ss.begin());
			ss.insert(tmp);
		}
		chmin(ans, diff * (ss.rbegin()->fi - ss.begin()->fi) );
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 12928
#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;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	string s;
	cin >> s;
	int n = s.length();
	string s1 = s.substr(0, n / 2);
	string s2 = s.substr((n + 1) / 2, n / 2);
	string t1 = s1, t2 = s2, t = s;
	reverse(all(t));
	reverse(all(t1));
	reverse(all(t2));
	if(s == t && s1 == t1 && s2 == t2) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [inp - 1 for inp in map(int, input().split())]
B = [inp for inp in map(int, input().split())]
C = [inp for inp in map(int, input().split())]

ret = 0
cursor = -10
for a in A:
  ret += B[a]
  if cursor == a - 1:
  	ret += C[cursor]
  cursor = a
  
print(ret)

Measured memory_bytes: 3064
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N,K = LI()
amari = N%K
print(min(amari,abs(amari-K)))


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

struct Operation{
  bool op;
  double interest;
  int charge;
};

int main(){
  int m;
  cin >> m;
  while(m--){
    int value, y, n;
    vector<Operation> ope;
    
    cin >> value >> y >> n;
    
    Operation tmp;
    
    for(int i = 0 ; i < n ; i++){
      cin >> tmp.op >> tmp.interest >> tmp.charge;
      ope.push_back(tmp);
    }
    
    int ans = -1;
    
    for(int i = 0 ; i < n ; i++){
      int t = value;
      if(ope[i].op == 0){
	int v = 0;
	for(int j = 0 ; j < y ; j++){
	  v += t*ope[i].interest;
	  t -= ope[i].charge;
	}
	ans = max(ans, v+t);
      }
      else{
	for(int j = 0 ; j < y ; j++){
	  t += t*ope[i].interest;
	  t -= ope[i].charge;
	}
	ans = max(ans, t);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    ll ans = 0;
    reps(i,1,N+1){
        if(i*i > N) break;
        ans = i*i;
    }
    cout<<ans<<endl;
}

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

int main(){
	int N,K;
	cin>>N>>K;
	long h[N];
	for(int i=0;i<N;++i){
		cin>>h[i];
	}
	long dp[N];
	dp[0]=0;
	for(int i=1;i<N;++i){
		if(i<K){
			//cout<<i<<endl;
			dp[i]=1000000000;
			for(int j=0;j<i;++j){
				//cout<<j<<" ";
				dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
			}
			//cout<<endl;
		}
		else{
			//cout<<i<<endl;
			dp[i]=1000000000;
			for(int j=i-K;j<i;++j){
				//cout<<j<<" ";
				dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
			}
			//cout<<endl;
		}
	}
	/*
	for(int i=0;i<N;++i){
		cout<<dp[i]<<" ";
	}
	cout<<endl;
	*/
	cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1792
n=int(input())
a=[]
a.append([0,0,0])
stop=0
for i in range(n):
    a.append(list(map(int,input().split())))
for i in range(n):
    if stop==0:   
        t=a[i][0]-a[i+1][0]
        x=a[i][1]-a[i+1][1]
        y=a[i][2]-a[i+1][2]
        if abs(x)+abs(y) > abs(t) or (abs(t)-abs(x)-abs(y))%2 == 1: #absは絶対値
            stop=1
            print("No")
if stop==0:
    print("Yes")


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

using namespace std;
using ll = long long;

int main(){

ll N;

cin >> N;

vector<string> S(N);

for(ll i = 0;i < N;++i)    cin >> S[i];

sort(S.begin(), S.end());
S.erase(unique(S.begin(), S.end()), S.end());

ll ans = S.size();

cout << ans << endl;

return 0;

}

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

int main() {
  int N, a, b, c, d;
  cin >> N; 
  
  a = N / 1000; 
  b = (N - a * 1000) / 100; 
  c = (N - a * 1000 - b * 100) / 10; 
  d = N - a * 1000 - b * 100 - c * 10; 
  
  if (a == b && b == c){
    cout << "Yes" << endl;
  }
  
  else if (b == c && c == d){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl; 
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  LL N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<pair<string, string>> v;
  REP(i,Q){
    string t, d;
    cin >> t >> d;
    v.push_back(make_pair(t, d));
  }

  vector<LL> l;
  LL nowl = 0;

  REP(i,Q){
    if(nowl>=N){
      break;
    }
    LL q_idx = Q - i - 1;
    if (v[q_idx].first[0] == s[nowl])
    {
      if(v[q_idx].second[0]=='L'){
        nowl++;
      }
    }
    if(nowl!=0){
      if (v[q_idx].first[0] == s[nowl-1])
      {
        if(v[q_idx].second[0]=='R'){
          nowl--;
        }
      }
    }
  }
  l.push_back(nowl);

  LL maxl = 0;

  REP(i, l.size())
  {
    if(l[i]>maxl){
      maxl = l[i];
    }
  }

  LL maxr = 0;
  LL nowr = 0;
  vector<LL> r;

  REP(i,Q){
    if(nowr>=N){
      break;
    }
    LL q_idx = Q - i - 1;
    if(v[q_idx].first[0]==s[N-nowr-1]){
      if(v[q_idx].second[0]=='R'){
        nowr++;
      }
    }
    if(nowr!=0){
      if (v[q_idx].first[0] == s[N-nowr])
      {
        if(v[q_idx].second[0]=='L'){
          nowr--;
        }
      }
    }
  }
  r.push_back(nowr);
  REP(i, r.size())
  {
    if(r[i]>maxr){
      maxr = r[i];
    }
  }

  LL score = min(N, maxr + maxl);
  cout << N - score << endl;
}


Measured memory_bytes: 23228
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		
		int[][] list = new int[n][d];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < d; j++) {
				list[i][j] = sc.nextInt();
			}
		}
		
//		int cnt = 0;
//		for (int i = 0; i < n - 1; i++) {
//			int sum = 0;
//			for (int j = 0; j < d; j++) {
//				int temp = (int) Math.pow(list[i][j] - list[i + 1][j], 2);
//				sum += temp;
//			}
//			int temp2 = (int) Math.sqrt(sum);
//			if (Math.pow(temp2, 2) == sum) {
//				cnt++;
//			}
//			
//		}
		
		// n3 d4
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				int sum = 0;
				for (int k = 0; k < d; k++) {
					int temp = (int) Math.pow(list[i][k] - list[j][k], 2);
					sum += temp;
				}
				int temp2 = (int) Math.sqrt(sum);
				if (Math.pow(temp2, 2) == sum) cnt++;
			}
		}
		
		System.out.println(cnt);
				
	}
}

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

int main(){
    int n;  cin >> n;
    vector<ll>a(n);
    rep(i, n)   cin >> a[i];
    ll ans = 0;
    for(int i = 1; i < n; i++){
        if(a[i] < a[i-1]){
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4756
#include "bits/stdc++.h"
using namespace std;
int func(int n){
    if(n%2) return 3*n+1;
    else return n/2;
}
int main(){
    map<int,int> mp;
    int a,i=1;
    cin >> a;
    mp[a]++;
    while(true){
        i++;
        a = func(a);
        if(mp[a]) break;
        mp[a]++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; t=1; while(t--)
typedef long long int ll;
int main() {
    FIO;
    test{
        ll n,x;
        cin>>n;
        ll a[n+1];
        for(ll i=0;i<=n;i++){
            a[i]=0;
        }
        for(ll i=0;i<n-1;i++){
            cin>>x;
            a[x]++;
        }
        for(ll i=1;i<=n;i++){
            cout<<a[i]<<" ";
        }
    }
	return 0;
}


Measured memory_bytes: 5168
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)

path, ans = [[0]], 0
while len(path) > 0:
    p = path.pop()
    for g in G[p[-1]]:
        if not g in p:
            if len(p) == N - 1:
                ans += 1
            else:
                path.append(p + [g])

print(ans)


Measured memory_bytes: 3064
const input = require('fs').readFileSync('/dev/stdin','utf8')
                           .split("\n")
                           .map(i => Number(i))
const N = input[0]
const A = input.slice(1,input.length-1)
const sort = A.slice(0,A.length).sort((a,b) => a-b)
const max = sort[sort.length-1]
const maxsecond = sort[sort.length-2]

for(var i = 0;i<N;i++) {
    if(max === A[i]) {
        console.log(maxsecond)
    }else{
        console.log(max)
    }
}

Measured memory_bytes: 39868
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;



signed main(){
	int A[10],K;
	REP(i,5){
		cin>>A[i];
	}
	cin>>K;
	if(A[4]-A[0]>K){
		cout<<":("<<endl;
	}
	else{
		cout<<"Yay!"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;


ll H,W,h,w;

int main(void) {

	cin >> H>>W>>h>>w;
	ct(H*W - h*W - w*H + h*w);



	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
int maze[2002][2002];
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
int sx,sy,gx,gy;


int main(){
  cin >> sx >> sy >> gx >> gy;
  int yoko=gx-sx;
  int tate=gy-sy;
  string ans="";
  rep(i,tate) ans+="U"; 
  rep(i,yoko) ans+="R";
  rep(i,tate) ans+="D";
  rep(i,yoko) ans+="L";
  ans+="L";
  rep(i,tate+1) ans+="U";
  rep(i,yoko+1) ans+="R";
  ans+="D";
  ans+="R";
  rep(i,tate+1) ans+="D";
  rep(i,yoko+1) ans+="L";
  ans+="U";
  cout << ans << endl;
  //cout << ans.size() << endl;
   return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int MAX = 1000000;
		boolean[] prime = new boolean[MAX + 1];
		for (int i = 2; i <= MAX; i++) {
			if (!prime[i]) {
				for (int j = i * 2; j <= MAX; j += i) {
					prime[j] = true;
				}
			}
		}
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			int[] a = new int[n];
			int min = Integer.MAX_VALUE;
			boolean[] f = new boolean[m + 1];
			f[0] = true;
			for (int i = 0; i < n; i++) {
				int s = scanner.nextInt();
				min = Math.min(s, min);
				a[i] = s;
				for (int j = s; j <= m; j += s) {
					f[j] = true;
				}
			}
			int max = 0;
			for (int i = min; i <= m; i++) {
				if (!f[i])
					for (int j = 0; j < n; j++) {
						if (i - a[j] >= 0 && f[i - a[j]]) {
							f[i] = true;
							break;
						}
					}
				if (f[i] && !prime[i])
					max = i;
			}
			System.out.println(max == 0 ? "NA" : max);

		}

	}
}

Measured memory_bytes: 59444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


struct Edge {
    ll to;
    ll weight;
    Edge(ll t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;


typedef vector<vector<int> > Matrix;

const int INF = 100000000;
Matrix d;

void warshall_floyd(int n) { // nは頂点数
    for (int i = 0; i < n; i++)      // 経由する頂点
        for (int j = 0; j < n; j++)    // 開始頂点
            for (int k = 0; k < n; k++)  // 終端
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

ll modnum = 1e9+7;

int main() {
    char x,y; cin >> x >> y;
    if(x == y) {
        cout << "=" << endl;
    } else if(x > y) {
        cout << ">" << endl;
    } else {
        cout << "<" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x = 0;
 int i = 1;
  while (i < 5) {
    cin >> x;
    if(x==0){
        cout << i << endl;
      return 0;
    }
    i++;
  }
 
  cout << i << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 10000000000000;

int main() {
  int k,x;
  cin>>k>>x;
  rep(i,-k+1,k){
    int a=i+x;
    if(!(a>1000000||a<-1000000))cout<<a<<" ";
  }
}

Measured memory_bytes: 256
S = input()
a = abs(753-(int(S[0])*100+int(S[1])*10+int(S[2])))
for i in range(len(S)-2):
  if a >= abs(753-(int(S[i])*100+int(S[i+1])*10+int(S[i+2]))):
    a = abs(753-(int(S[i])*100+int(S[i+1])*10+int(S[i+2])))
print(a)

Measured memory_bytes: 3064
pub mod contest {
    pub mod input {
        use std::io;
        use std::str::FromStr;
        use std::fmt::Debug;

        pub fn read_line<F>() -> F
        where F: FromStr, <F as FromStr>::Err: Debug {
            let mut input = String::new();
            io::stdin().read_line(&mut input).unwrap();
            input.trim().parse().unwrap()
        }

        pub fn read_words<F>() -> Vec<F>
        where F: FromStr, <F as FromStr>::Err: Debug {
            let mut input = String::new();
            io::stdin().read_line(&mut input).unwrap();
            input
                .split_whitespace()
                .map(|i| i.parse().unwrap())
                .collect()
        }

        pub fn read_matrix<F>(num_lines: usize) -> Vec<Vec<F>>
        where F: FromStr, <F as FromStr>::Err: Debug {
            (0..num_lines).map(|_| read_words()).collect()
        }

        // 所有権的な問題で SplitWhitespace を直接持てないので妥協
        // まあ、一行のデータの数なんてそんなに多くないだろうし
        pub struct WordsReader {
            words: Vec<String>,
            cur: usize,
        }

        impl WordsReader {
            pub fn new() -> Self {
                let mut input = String::new();
                io::stdin().read_line(&mut input).unwrap();
                WordsReader {
                    words: input.split_whitespace().map(|i| i.to_owned()).collect(),
                    cur: 0,
                }
            }

            pub fn next<F>(&mut self) -> F
            where F: FromStr, <F as FromStr>::Err: Debug {
                let v: F = self.words[self.cur].parse().unwrap();
                self.cur += 1;
                v
            }
        }
    }
}

fn main() {
    let n: usize = contest::input::read_line::<usize>();
    let mut d: Vec<i32> = contest::input::read_words();
    d.sort();
    let ans = d[(n / 2)] - d[(n / 2) - 1];
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;
    cin >> s;
    if (s == "Sunny")
        t = "Cloudy";
    if (s == "Cloudy")
        t = "Rainy";
    if (s == "Rainy")
        t = "Sunny";
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
def func(n):
    x = []
    for i in range(1,n+1):
        num = i
        if i % 3 == 0:
            x.append(i)
        else:
            while num:
                if int(num % 10) == 3:
                    x.append(i)
                    break
                num = int(num / 10)
    return x

if __name__ == '__main__':
    N = int(input())
    rlt = func(N)
    print(" ", end='')
    for i in range(len(rlt)):
        if rlt[i] == rlt[-1]:
            print(rlt[i], end='')
        else:
            print(rlt[i], end=' ')
print()

Measured memory_bytes: 8228
/* C++標準ヘッダファイル */
/* 文字列ライブラリ */
#include <string>

/* コンテナライブラリ */
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>

/* アルゴリズムライブラリ */
#include <algorithm>

/* 数値演算ライブラリ */
#include <cmath>

/* 入出力ライブラリ */
#include <iostream>

/* std使用<-namespace */
using namespace std;

/* define, typedef */
#define rpt(i, n) for(ll i = 0; i < (n); i++)  // リピート
typedef long long ll;


/* main関数 */
int main(void) {
	int n;
	cin >> n;
	vector<int> d;
	d.reserve(n);
	rpt(i, n) {
		int num;
		cin >> num;
		d.push_back(num);
	}

	int sum = 0;
	for (int i = 0; i < d.size() - 1; i++) {
		for (int j = i + 1; j < d.size(); j++) {
			sum += (d[i] * d[j]);
		}
	}

	cout << sum;

	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    A = in_nl()

    def sad(x):
        s = 0
        for i in range(N):
            s += abs(A[i] - (x + i + 1))
        return s

    def binary_search(min_n, max_n):

        while max_n - min_n != 1:
            tn = (min_n + max_n) // 2
            if sad(tn) < sad(tn + 1):
                max_n = tn
            else:
                min_n = tn

        return max_n

    b = binary_search(min(A) - 10**9, max(A) + 10**9)
    print(sad(b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 99984
/*
 * atcoder/dp_3rd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX_N = 110;
const int MAX_W = 100100;
ll N, CAP;
ll W[MAX_N], V[MAX_N];
ll dp[MAX_N][MAX_W];

void input() {
  cin >> N >> CAP;
  loop(n,0,N) {
    cin >> W[n] >> V[n];
  }
}

void solve() {
  memset(dp, 0, sizeof(dp));
  for (int n=0; n<N; n++) {
    int w=W[n], v=V[n];
    for (int cap=0; cap<=CAP; cap++) {
      if (n == 0) {
        if (cap>=w) dp[0][cap] = v;
        continue;
      }
      chmax(dp[n][cap], dp[n-1][cap]);
      if (cap-w >= 0) chmax(dp[n][cap], dp[n-1][cap-w] + v);
    }
  }
  cout << dp[N-1][CAP] << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 86272
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll res=0;
    vi v;
    while(n!=1){
        v.pb(n/2);
        
        n=n/2;
    }
    // for(auto k:v)
    // cout<<k<<" ";
    ll mul=2;
    for(int i=0;i<v.size();i++){
        res+=mul;;
        mul=2*mul;
    }
    cout<<res+1<<endl;
}

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

using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  int r = 0;
  int m = 0;
  REP(i, n - 1){
    int j = n - 2 - i;
    if(a[j] >= a[j + 1]){
      ++r;
    }else{
      r = 0;
    }
    m = max(m, r);
  }
  cout << m << endl;
  return 0;
}

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

public class Main {
    int a, b, c;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        solve();
    }

    void solve() {
        if (c >= a && c <= b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
import sys
readline = sys.stdin.readline

N = readline().rstrip()
N = list(map(int, N))
L = len(N)

total = 0

a = [0] * L

for i in range(L - 1, -1, -1):
    k = N[i]
    if k <= 4:
        a[i] = 0 # none
        total += k
    elif k >= 6:
        a[i] = 1 # age
        total += 10 - k
        if i == 0:
            total += 1
        else:
            N[i - 1] += 1
    else:
        if i == 0:
            a[i] = 0
            total += k
        else:
            if N[i - 1] <= 4:
                a[i] = 0
                total += k
            else:
                a[i] = 1
                total += 10 - k
                N[i - 1] += 1

print(total)




Measured memory_bytes: 123176
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
import heapq
import numpy as np

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	N, K = MAP()
	A = LIST()
	F = LIST()

	A.sort(reverse=True)
	F.sort()

	A = np.array(A)
	F = np.array(F)
	time = A*F
	# print(F)
	# print(time)
	sum_A = A.sum()

	def is_ok(x):  # 時間をx以下にできるか？
		return sum_A - np.minimum(A,x//F).sum() <= K

	min_ = -1
	max_ = 10**18
	while min_ + 1 != max_:
		search = (min_+max_)//2
		# print(min_, max_, search)
		if is_ok(search):
			max_ = search
		else:
			min_ = search

	print(max_)


if __name__ == "__main__":
	main()


Measured memory_bytes: 42928
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int n, m, x;
vector<int> a;

int main(){
    scanf("%d%d%d", &n, &m, &x);

    REP(i, m){
        int tmp;
        scanf("%d", &tmp);
        a.push_back(tmp);
    }

    sort(a.begin(), a.end());

    auto itr = lower_bound(a.begin(), a.end(), x);
    int p = distance(a.begin(), itr);
    int q = m - p;

    printf("%d\n", min(p, q));

	return 0;
}

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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);


void solve() {
    ll n, x, y;
    cin >> n >> x >> y;
    map<int, int> mp;
    for(int i = 1; i<=n-1; i++) {
        for(int j = i+1; j<=n; j++) {
            int  curr = 0;
            if(i < x) {
                if(j <= x) {
                    curr = j-i;
                }
                else {
                    int now = x-i + 1 + abs(y-j);
                    curr = min(now, j-i);
                }
            }
            else if(i >= x && i <= y) {
                int now = i-x + 1 + abs(j-y);
                curr = min(now, j-i);
            }
            else {
                curr = j-i;
            }
            mp[curr] ++;
        }
    }
    for(int i = 1; i<=n-1; i++) {
        cout << mp[i] << '\n';
    }
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
  
typedef long long ll;
typedef pair<int, int> ii;
 
int main() {
     
    int n, m;
    while(cin >> n >> m, n ,m){
        vector<int> table(n);
        vector<int> way(n, 1);
        rep(i, 3){
            int num;
            cin >> num;
            rep(j, num){
                int tmp;
                cin >> tmp;
                table[tmp-1] = i;
            }
        }
         
        vector<int> now(n, 0);
         
        int ans = 0;
        bool nn = false;//moved n-1th privious step
        while(1){
            bool flag = true;
            rep(i, n){
                if(table[i] != now[i]) flag = false;
            }
            if(flag) break;
             
            int num = IINF;
            if(!nn){
                num = n-1;
            }
            else{
                vector<int> maxi(3, -1);
                rep(i, n){
                    maxi[now[i]] = i;
                }
                rep(i, 3){
                    if(num > maxi[i] && maxi[i] > maxi[i+way[maxi[i]]]) num = maxi[i];
                }
            }   
            now[num] += way[num];
            if(now[num] != 1) way[num] *= -1;
            nn = (num == n-1);
            ans++;
        }
         
        int tans = min(ans, (int)pow(3, n) - 1 - ans);
        if(tans > m) cout << -1 << endl;
        else cout << tans << endl;
         
    }
     
 
    return 0;
}

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

int main(){
	int n;
	string str;
	cin >> n;
	getline(cin, str);
	for(int i = 0;i < n;i++){
		getline(cin, str);
		while(str.find("Hoshino") != -1){
			int locate = str.find("Hoshino");
			str[locate + 6] = 'a';
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 3148
from sys import stdin
N = int(stdin.readline().rstrip())
r = N-1
l = 0
print(0)
s = input()
cnt = 0
mid = (r+l)//2
if s == "Male":
    for _ in range(25):
        print(mid)
        s = input()
        if s == "Male" and mid % 2 == 0:
            l += max((r-l)//2,1)
        elif s == "Female" and mid % 2 != 0:
            l += max((r-l)//2,1)
        elif s == "Vacant":
            break
        else:
            r -= max((r-l)//2,1)
        mid = (r+l)//2
        
elif s == "Female":
    for _ in range(25):
        print(mid)
        s = input()
        if s == "Female" and mid % 2 == 0:
            l += max((r-l)//2,1)
        elif s == "Male" and mid % 2 != 0:
            l += max((r-l)//2,1)
        elif s == "Vacant":
            break
        else:
            r -= max((r-l)//2,1)
        mid = (r+l)//2

Measured memory_bytes: 3660
#include <stdio.h>

int main()
{
    int i, j;
    
    for (i = 1; i < 10; i++) {
        for (j = 1; j < 10; j++) {
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
    return 0;
}    


Measured memory_bytes: 2056
import collections

N = int(input())
rates = list(map(int, input().split()))

colors = [min(8, i // 400) for i in rates]
CTR_colors = collections.Counter(colors)

ans = len(CTR_colors)

if (CTR_colors[8] > 0):
    ans -= 1

    if (ans == 0):
        mini_ans = ans + 1
    else:
        mini_ans = ans
    
    max_ans = min(100, ans + CTR_colors[8])

else:
    mini_ans, max_ans = ans, ans

print(mini_ans, max_ans)


Measured memory_bytes: 9228