akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

int n,k;
vector<vec> G;
int cnt(int x,int p,int t){
    // cout<<x<<" "<<p<<" "<<t<<endl;
    int res=0;
    if(t>k/2) res++;
    for(auto e:G[x]){
        if(e==p)continue;
        res+=cnt(e,x,t+1);
    }
    return res;
}


main(){
    // int n,k;
    cin>>n>>k;
    vector<pii> que;
    G.resize(n+1);
    rep(i,n-1){
        int a,b;cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
        que.pb({a,b});
    }
    int ans=INF;
    if(k%2){
        for(auto p:que){
            int tmpsum=cnt(p.first,p.second,0)+cnt(p.second,p.first,0);
            ans=min(ans,tmpsum);
        }
    }
    else{
        rep2(i,1,n){
            ans=min(ans,cnt(i,0,0));
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 512
require 'pp'

w, h, n = *gets.chomp.split(" ").map(&:to_i)

data = [[0, 0, :left], [w, 0, :right], [0, 0, :bottom], [0, h, :top]]
n.times do
  x, y, mode = *gets.chomp.split(" ").map(&:to_i)
  mode2 = nil
  
  case mode
  when 1
    mode2 = :left
  when 2
    mode2 = :right
  when 3
    mode2 = :bottom
  when 4
    mode2 = :top
  end
  
  data << [x, y, mode2]
end

# puts w, h, n
# pp data

left = data.select{|v| v[2] == :left}.map{|v| v[0]}.max
right = data.select{|v| v[2] == :right}.map{|v| v[0]}.min
bottom = data.select{|v| v[2] == :bottom}.map{|v| v[1]}.max
top = data.select{|v| v[2] == :top}.map{|v| v[1]}.min

# puts [left, right, bottom, top]

width = [0, right - left].max
height = [0, top - bottom].max

puts width * height



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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> otable(H,vector<char>(W));
  vector<bool> ha(H, false), wa(W, false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++){
      cin >> otable.at(i).at(j);
        if (otable.at(i).at(j) == '#'){
          ha.at(i) = true;
          wa.at(j) = true;
      }
    }
  }
// # があれば Trueにする。  

  for (int i = 0; i < H ; i++){
    if (!ha.at(i)){
      continue;
    }
    for (int j = 0 ; j < W ; j++){
      if(wa.at(j)){
        cout << otable.at(i).at(j);  
      }
      if (j == W - 1 ) {
        cout << endl; // 末尾なら改行
      }
    }
  }                                                   
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<sstream>
using namespace std;
string toString(int n)
{
  stringstream ss;
  ss << n;
  return ss.str();
}
int main(void)
{
  string s1, s2;
  int n, r;
  char a;

  while(cin >> n, n){
    cin >> s1;
    for(int i = 0;i < n; i++){
      r = 1, a = s1[0];
      s2.clear();
      for(int j = 1;j < s1.size(); j++){
	if(s1[j] != s1[j - 1]){
	  s2 += toString(r) + a;
	  r = 1, a = s1[j];
	}
	else
	  r++;
      }
      s2 += toString(r) + a;
      s1 = s2;
    }
    cout << s1 << endl;
  }
}


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

using namespace std;

int main(void) {
  int a, b, c;
  while (cin >> a >> b >> c, a) {
    int n;
    cin >> n;

    vector<int> x(n), y(n), z(n), r(n);
    vector<int> flg(a + b + c + 1, 2);
    for (int i = 0; i < n; i++) {
      cin >> x[i] >> y[i] >> z[i] >> r[i];
      if (!r[i]) continue;
      flg[x[i]] = flg[y[i]] = flg[z[i]] = 1;
    }
    for (int i = 0; i < n; i++) {
      if (r[i]) continue;
      if (flg[y[i]] == 1 && flg[z[i]] == 1) {
        flg[x[i]] = 0;
      } else if (flg[z[i]] == 1 && flg[x[i]] == 1) {
        flg[y[i]] = 0;
      } else if (flg[x[i]] == 1 && flg[y[i]] == 1) {
        flg[z[i]] = 0;
      }
    }

    for (int i = 1; i <= a + b + c; i++) {
      cout << flg[i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3012
#include <algorithm>
#include <tuple>
#include <utility>
#include <iostream>
#include <vector>
using namespace std;

int main(){
  int N, Q;
  cin >> N >> Q;
  vector<int> C(N);
  for(int i = 0; i < N; ++i)
    cin >> C[i], --C[i];
  const int b = 1000;
  vector<vector<tuple<int,int,int>>> query(b);
  for(int i = 0; i < Q; ++i){
    int l, r;
    cin >> l >> r;
    --l;
    query[l/b].emplace_back(r,l,i);
  }
  for(auto& q : query)
    sort(q.begin(), q.end());
  vector<int> ans(Q);
  for(const auto& q : query){
    if(q.empty()) continue;
    vector<int> cnt(N);
    int m = 0;
    int ll = get<1>(q[0]), rr = ll;
    for(auto [r, l, i] : q){
      while(rr < r){
        ++cnt[C[rr]];
        if(cnt[C[rr]] == 1)
          ++m;
        ++rr;
      }
      while(ll < l){
        --cnt[C[ll]];
        if(!cnt[C[ll]])
          --m;
        ++ll;
      }
      while(ll > l){
        --ll;
        ++cnt[C[ll]];
        if(cnt[C[ll]] == 1)
          ++m;
      }
      ans[i] = m;
    }
  }
  for(auto e : ans)
    cout << e << '\n';
}


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

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++)
    cin>>h.at(i);
  int m=0;
  int mm=0;
  for(int i=1;i<n;i++){
    if(h.at(i-1)>=h.at(i)){
      m++;
      mm=max(mm,m);
    }else
      m=0;
  }
  cout<<mm<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if( N%1000 == 111 || N%1000 == 222 || N%1000 == 333 || N%1000 == 444 || N%1000 == 555 || N%1000 == 666 || N%1000 == 777 || N%1000 == 888 || N%1000 == 999 || N%1000 == 0){
    cout << "Yes" << endl;
  }
  else if( N%1110 < 10 || N%2220 < 10 || N%3330 < 10 || N%4440 < 10 || N%5550 < 10 || N%6660 < 10 || N%7770 < 10 || N%8880 < 10 || N%9990 < 10 || N < 10){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




void smain() {

    int n;
    cin>>n;
    cout<<(n/500)*1000+(n%500/5)*5;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb emplace_back
typedef pair<int,int> pi;

ll n, ans, one, two;
map<ll,ll,greater<ll> > cnt;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		ll x; cin >> x;
		++cnt[x];
	}
	for (auto i: cnt) {
		if (i.second >= 4) {
			one = max(one, i.first);
			two = max(two, i.first);
		} else if (i.second >= 2) {
			if (one >= two) {
				two = max(two, i.first);
			} else {
				one = max(one, i.first);
			}
		}
	}	
	cout << one * two;
	return 0;
}


Measured memory_bytes: 9900
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int X;
  cin >> X;
  int ans = 8-(X-400)/200;
  cout << ans << endl;
  return 0;
}

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

struct Node {
	int s, e, m;
	//covers s,e;
	int maxi;
	Node *l, *r;
	
	Node(int a, int b) {
		s = a;
		e = b;
		maxi = 0;
		if (s != e) {
			m = (s+e)/2;
			l = new Node(s,m);
			r = new Node(m+1,e);
		}
		else {
			l = NULL;
			r = NULL;
		}
	}

	void add(int i, int x) {
		if (s == e) {
            maxi = x;
			return;
		}
		if (i <= m) {
			l->add(i,x);
		}
		else if (i > m) {
			r->add(i,x);
		}
		else assert(false);
		maxi = max(l->maxi,r->maxi);
	}

	int getmaxi(int st, int en) {
		if (st <= s && e <= en) {
			return maxi;
		}
		int ret = 0;
		if (st <= m) {
			ret = max(ret,l->getmaxi(st,en));
		}
		if (en > m) {
			ret = max(ret,r->getmaxi(st,en));
		}
		return ret;
	}	
};

const int maxn = 2e5+5;
int n, a[maxn];
vector<int> adj[maxn];

int ans[maxn];
Node *root;

void dfs(int i, int p) {
    int prev = root->getmaxi(a[i],a[i]);
    root->add(a[i],root->getmaxi(0,a[i]-1)+1);
    ans[i] = root->getmaxi(0,n);
    for (int j: adj[i]) if (j != p) {
        dfs(j,i);
    }
    root->add(a[i],prev);
}

int main() 
{
    cin >> n;
    set<int> s;
    map<int,int> mp;
    int pt = 1;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s.insert(a[i]);
    }
    for (int i: s) {
        mp[i] = pt++;
    }
    for (int i = 1; i <= n; i++) a[i] = mp[a[i]];
    for (int i = 0; i < n-1; i++) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    root = new Node(0,n); 
    dfs(1,1);
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << '\n';
    }
}


Measured memory_bytes: 66788
n, m = map(int, input().split())
h = list(map(int, input().split()))
comp = [] 
for x in h:
    comp.append([x, [0]])
# print(comp)
for j in range(m):
    a, b = map(int, input().split())
    comp[a-1][1].append(comp[b-1][0])
    comp[b-1][1].append(comp[a-1][0])
# print(comp)
count = 0
for y in comp:
    if y[0] > max(y[1]):
        count += 1
print(count)

Measured memory_bytes: 33884
using System;
using System.Collections.Generic;

namespace _1_2_A {
    class Program {
        static void Main(string[] args) {
            var input = Console.ReadLine();
            var list = new List<int>();
            foreach (var str in input.Split(' ')) {
                list.Add(int.Parse(str));
            }
            var array = list.ToArray();
            var a = array[0];
            var b = array[1];
            if (a > b) {
                Console.WriteLine("a > b");
                return;
            }
            if (a < b) {
                Console.WriteLine("a < b");
                return;
            }
            if (a == b) {
                Console.WriteLine("a == b");
                return;
            }
        }
    }
}



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

int main(){
    int n,k;
    cin >> n >> k;
    if(n%k==0) cout << 0 <<endl;
    else cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
public class Main{
  public static void main(String[] args){
    System.out.println("1x1=1");
    System.out.println("1x2=2");
    System.out.println("1x3=3");
    System.out.println("1x4=4");
    System.out.println("1x5=5");
    System.out.println("1x6=6");
    System.out.println("1x7=7");
    System.out.println("1x8=8");
    System.out.println("1x9=9");
    System.out.println("2x1=2");
    System.out.println("2x2=4");
    System.out.println("2x3=6");
    System.out.println("2x4=8");
    System.out.println("2x5=10");
    System.out.println("2x6=12");
    System.out.println("2x7=14");
    System.out.println("2x8=16");
    System.out.println("2x9=18");
    System.out.println("3x1=3");
    System.out.println("3x2=6");
    System.out.println("3x3=9");
    System.out.println("3x4=12");
    System.out.println("3x5=15");
    System.out.println("3x6=18");
    System.out.println("3x7=21");
    System.out.println("3x8=24");
    System.out.println("3x9=27");
    System.out.println("4x1=4");
    System.out.println("4x2=8");
    System.out.println("4x3=12");
    System.out.println("4x4=16");
    System.out.println("4x5=20");
    System.out.println("4x6=24");
    System.out.println("4x7=28");
    System.out.println("4x8=32");
    System.out.println("4x9=36");
    System.out.println("5x1=5");
    System.out.println("5x2=10");
    System.out.println("5x3=15");
    System.out.println("5x4=20");
    System.out.println("5x5=25");
    System.out.println("5x6=30");
    System.out.println("5x7=35");
    System.out.println("5x8=40");
    System.out.println("5x9=45");
    System.out.println("6x1=6");
    System.out.println("6x2=12");
    System.out.println("6x3=18");
    System.out.println("6x4=24");
    System.out.println("6x5=30");
    System.out.println("6x6=36");
    System.out.println("6x7=42");
    System.out.println("6x8=48");
    System.out.println("6x9=54");
    System.out.println("7x1=7");
    System.out.println("7x2=14");
    System.out.println("7x3=21");
    System.out.println("7x4=28");
    System.out.println("7x5=35");
    System.out.println("7x6=42");
    System.out.println("7x7=49");
    System.out.println("7x8=56");
    System.out.println("7x9=63");
    System.out.println("8x1=8");
    System.out.println("8x2=16");
    System.out.println("8x3=24");
    System.out.println("8x4=32");
    System.out.println("8x5=40");
    System.out.println("8x6=48");
    System.out.println("8x7=56");
    System.out.println("8x8=64");
    System.out.println("8x9=72");
    System.out.println("9x1=9");
    System.out.println("9x2=18");
    System.out.println("9x3=27");
    System.out.println("9x4=36");
    System.out.println("9x5=45");
    System.out.println("9x6=54");
    System.out.println("9x7=63");
    System.out.println("9x8=72");
    System.out.println("9x9=81");
  }
}

Measured memory_bytes: 24076
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
count = 0
_sum  = 0
for a in A:
    for y,z in zip(a,B):
        _sum += y * z
    if _sum + C > 0:
        count += 1
    _sum = 0
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
using namespace std;

const int MX = 1000001;
bool sieve[MX];

int main() {
    memset(sieve, 0, sizeof sieve);
    sieve[0] = sieve[1] = true;
    for (int i=2; i*i<MX; ++i) {
        if (sieve[i]) continue;
        for (int j=i*i; j<MX; j+=i) {
            sieve[j] = true;
        }
    }
    int n;
    while (cin >> n, n) {
        int cnt = 0;
        for (int i=0; 2*i<=n; ++i) {
            if ( ! sieve[i] && ! sieve[n-i]) {
                ++ cnt;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 2148
#include<iostream> 
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    double a, b;
    cin >> a >> b;
    double ave;
    ave = ceil((a+b)/2);
    cout << (int)ave << endl;
}

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

int main(){
    string S;
    cin >> S;
    int len = S.size();
    int K = len;

    for(int i=0;i<S.size()-1;i++){
        if(S[i] != S[i+1]){
            K = min(K, max(i+1, len - (i+1)));
        }
    }

    cout << K << endl;

}

Measured memory_bytes: 512
#include<stdio.h>
 
#define MAX 10000
#define NIL -1
 
typedef struct{
  int p,l,r;
}Node;


Node T[MAX];
int n;

void preParse(int u){
  if(u == NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}
 
void inParse(int u){
  if(u  == NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}
 
void postParse(int u){ 
  if(u == NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}



int main(){
  int i,v,l,r,root;
 
  scanf("%d",&n);

  for(i=0;i<n;i++)
    T[i].p = NIL;
 
  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }
 
  for(i=0;i<n;i++)
    if(T[i].p == NIL)root = i;
 
  printf("Preorder\n");
  preParse(root);
 
  printf("\nInorder\n");
  inParse(root);
 
  printf("\nPostorder\n");
  postParse(root);


  printf("\n");
  return 0;
}
 

Measured memory_bytes: 620
N = int(input())
Sp = []
for i in range(N):
    s, p = input().split()
    Sp.append((s, int(p), i))

Sp.sort(key = lambda x: x[1], reverse=True)
Sp.sort(key = lambda x: x[0])

for sp in Sp:
    print(sp[2]+1)

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

int main() {
    int A, B;
    cin >> A >> B;
    int counter = 0;
    for (int i=A; i<=B; i++) {
        string s, t;
        s = t = to_string(i);
        reverse(t.begin(), t.end());
        if (s == t) counter++;
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    string Sa, Sb, Sc;
    cin >> Sa >> Sb >> Sc;
    char nxt = 'a';
    while(1){
        if(nxt == 'a'){
            if(Sa.empty()){
                cout << 'A' << endl;
                return 0;
            }
            else{
                nxt = Sa.at(0);
                erc(Sa,0);
            }
        }
        else if(nxt == 'b'){
            if(Sb.empty()){
                cout << 'B' << endl;
                return 0;
            }
            else{
                nxt = Sb.at(0);
                erc(Sb,0);
            }
        }

        else if(nxt == 'c'){
            if(Sc.empty()){
               cout << 'C' << endl;
               return 0;
            }
            else{
                nxt = Sc.at(0);
                erc(Sc,0);
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x;
    cin >> x;
    bool dp[101000] = {};
    dp[0] = true;
    rep(i, 0, 100000) {
        rep(j, 0, 6) {
            if (dp[i]) dp[i + 100 + j] = true;
        }
    }
    if (dp[x]) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


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



int main() {
    int X;
    cin>>X;
    int a=X/500;
    X%=500;
    X/=5;
    cout<<1000*a+5*X<<endl;
}

Measured memory_bytes: 256
//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123; 
const int mod=1e9+7;
using namespace std;
int n;
ll L;
int sz = 0;    
struct trie{
	int nx[2];	
	ll h;
	trie(){
		nx[1] = nx[0] = -1;
		h = 0;
	}
	trie(ll x){
		nx[0] = nx[1] = -1;
		h = x;
	}
};
ll ans = 0;
vector<trie> t;
void add(string s){
	int x = 0, pos = 0;
	while(pos < s.len()){
		int ch = s[pos] - '0';
		if(t[x].nx[ch] == -1){
			t[x].nx[ch] = ++ sz;
			trie y;
			t.pb(y);
		}
		t[t[x].nx[ch]].h = t[x].h + 1;
		pos ++;
		x = t[x].nx[ch];
	}
}
ll get(ll x){
	ll res = 1;
	while(x % 2 == 0){
		res *= 2;
		x /= 2;
	}
	return res;
}
void out(int v){
	int cnt = 0;
	for(int i = 0; i < 2; i ++){
		if(t[v].nx[i] > -1){	
			cnt ++;
			out(t[v].nx[i]);
		}
	}
	if(cnt == 1){
		ans = (ans ^ get(L - t[v].h));
	}
}
string s[100011];
int main(){
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  	srand(FOR);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	t.pb(trie());
	cin >> n >> L;
	for(int i = 1; i <= n; i ++){
		cin >> s[i];
		add(s[i]);
	}
	out(0);
	if(ans == 0)
		cout << "Bob";
	else
		cout << "Alice";
	return 0;
}

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

using namespace std;

int main(){
 
  int h, w;
  string a[100];
  
  cin >> h >> w;
  
  for(int i = 0; i < h; i++){
    cin >> a[i];
  }
  
  for(int i = 0; i < w + 2; i++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0; i < h; i++){
    cout << "#" << a[i] << "#" << endl;
  }
  for(int i = 0; i < w + 2; i++){
    cout << "#";
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k <= a) cout << k << endl;
  else if (k <= a + b) cout << a << endl;
  else cout << a - (k - a - b) << endl;
}


Measured memory_bytes: 3596
<?php
$n = fgets(STDIN);
for($i = 0; $i < $n; $i++){
    $clock[] = fgets(STDIN);
}
$clock = array_map("intval", $clock);

function gcd($m, $n){
    if($n > $m) list($m, $n) = [$n, $m];
    while($n != 0){
        $tmp = $n;
        $n = $m % $n;
        $m = $tmp;
    }
    return  $m;
}

while(count($clock) > 1){
    $m = array_pop($clock);
    $n = array_pop($clock);
    $clock[] = $m / gcd($m, $n) * $n;
}

print $clock[0];

Measured memory_bytes: 4728
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb push_back
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e6+5;
char s[N];int n,k;
inline void print(R char *s){s[n]='\0',printf("%s\n",s);}
void solve(R int p){
	R int i=1;
	while(p--){
		R int op=(i<=n?((i-1)&1):((n-1)&1));
//		printf("%d %d %c\n",i,op,s[i]);
		if((s[i]=='A')^op){s[i]=(s[i]=='A'?'B':'A');continue;}
		s[i+n]='A',++i;
	}
	R int op=(i<=n?((i-1)&1):((n-1)&1));
//		printf("%d %d %c\n",i,op,s[i]);
	fp(k,i,i+n-2){
		if(op)s[k]=(s[k]=='A'?'B':'A');
		if(k+1>n)op^=1;
	}
	s[i+n-1]='A';
	print(s+i);
}
void ss(R int p){
	R int i=1;
	while(p--){
		R int op=(i<=n?((i-1)&1):((n-1)&1));
//		printf("%d %d %c\n",i,op,s[i]);
		if((s[i]=='A')^op){s[i]=(s[i]=='A'?'B':'A');continue;}
		s[i+n]='A',++i;
	}
	if(n&1^1){
		fp(i,1,n)s[i]=((i&1)?'B':'A');
		print(s+1);
		return;
	}
	R int op=(i<=n?((i-1)&1):((n-1)&1));
	if(!((s[i]=='A')^op))--k;
	s[n]=(k&1?'B':'A');
	fp(i,1,n-1)s[i]=((i&1)?'A':'B');
	reverse(s+1,s+1+n);
	print(s+1);
}
int main(){
	scanf("%d%d%s",&n,&k,s+1);
	if(k<=1e6)return solve(k),0;
//	assert(false);
	ss(1e6);
	return 0;
}

Measured memory_bytes: 1536
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define PI acos(-1)
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie (0);
    double m=0,n=0;//t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    m=2*PI*n;
    cout<<setprecision(20)<<fixed<<m<<endl;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(),a.end());
    deque<ll> d,e;
    int ix=1,iy=n-1;
    d.push_front(0);
    if(n%2){
        for(int i=0; i<n/2; i++){
            if(i%2==0){
                d.push_front(iy);
                iy--;
                d.push_back(iy);
                iy--;
            }else{
                d.push_front(ix);
                ix++;
                d.push_back(ix);
                ix++;
            }
        }
    }else{
        for(int i=1; i<n/2; i++){
            if(i%2){
                d.push_front(iy);
                iy--;
                d.push_back(iy);
                iy--;
            }else{
                d.push_front(ix);
                ix++;
                d.push_back(ix);
                ix++;
            }
        }
        d.push_front(n/2);
    }
    ix=0,iy=n-2;
    e.push_front(n-1);
    if(n%2){
        for(int i=0; i<n/2; i++){
            if(i%2){
                e.push_front(iy);
                iy--;
                e.push_back(iy);
                iy--;
            }else{
                e.push_front(ix);
                ix++;
                e.push_back(ix);
                ix++;
            }
        }
    }else{
        for(int i=1; i<n/2; i++){
            if(i%2==0){
                e.push_front(iy);
                iy--;
                e.push_back(iy);
                iy--;
            }else{
                e.push_front(ix);
                ix++;
                e.push_back(ix);
                ix++;
            }
        }
        e.push_front(n/2);
    }
    vector<ll> b(n),c(n);
    for(int i=0; i<n; i++){
        b[i]=a[d.front()];
        d.pop_front();
        c[i]=a[e.front()];
        e.pop_front();
    }
    //cout<<endl;
    ll ans=0,ans2=0;
    for(int i=0; i<n-1; i++){
        ans+=abs(b[i]-b[i+1]);
        ans2+=abs(c[i]-c[i+1]);
    }
    cout<<max(ans,ans2)<<endl;
}

Measured memory_bytes: 4224
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        r: f64
    }
    println!("{}", 2.0 * r * 3.14159);
}


Measured memory_bytes: 2204
import itertools

N = int(input())
xyh = [list(map(int, i)) for i in [input().split() for _ in range(N)]]


for i in range(N):
    x, y, h = xyh[i]
    if h > 0:
        x_t, y_t, h_t = x, y, h
        break

for c_x, c_y in itertools.product(range(0, 100+1), repeat=2):
    H = h_t + abs(x_t - c_x) + abs(y_t - c_y)
    for i in range(N):
        x_i, y_i, h_i = xyh[i]
        if h_i != max(H - abs(x_i - c_x) - abs(y_i - c_y), 0):
            break
    else:
        print(c_x, c_y, H)
        exit()

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

using namespace std;

int main()
{
    long long fsecond=0;
    cin >> fsecond;
    int hour=0;
    int minute=0;
    int second=0;
    while(fsecond>=3600)
    {
        fsecond-=3600;
        hour++;
    }
    while(fsecond>=60)
    {
        fsecond-=60;
        second++;
    }
    cout<< hour << ":" << second << ":" << fsecond << endl;
    return (0);
}


Measured memory_bytes: 3088
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int x;
	cin >> x;
	int ans = 1;

	for (int b = 2; b <= x; b++) {
		int power = b * b;
		for (int p = 2;; p++) {
			if (power > x)break;
			ans = max(ans, power);
			power *= b;
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INT(a) scanf("%d",&a)
#define STR(a) scanf("%s",a)
#define DBL(a) scanf("%lf",&a)
#define LNG(a) scanf("%lld",&a)
#define PI acos(-1)

int num[10];
int val[]={0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
vector< pair< int, int > > vc;
int memo[15][10005];
int dp(int i, int n){
	//cout<<n<<" "<<i<<endl;
	if(i==vc.size() && n==0) return 0;
	else if(i==vc.size()) return -INT_MAX;
	if(memo[i][n]!=-1) return memo[i][n];
	int mx=-INT_MAX;
	if(n-vc[i].second>=0) mx = max(mx, 1+dp(i, n-vc[i].second));
	mx = max(mx, dp(i+1, n));
	return memo[i][n]=mx;
}

void dp2(int i, int n){
	if(i==vc.size()) return;
	int mx = memo[i][n];
	if(n-vc[i].second>=0 && 1+dp(i, n-vc[i].second)==mx){
		cout<<vc[i].first;
		dp2(i, n-vc[i].second);
	} else{
		dp2(i+1, n);
	}
}


int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>num[i];
		vc.push_back({num[i], val[num[i]]});
	}

	sort(vc.rbegin(), vc.rend());
	
	// for(auto i:vc) cout<<i.first<<" "<<i.second<<endl;

	memset(memo, -1, sizeof memo);
	dp(0, n);
	dp2(0, n);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 896
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {0, 1}, {0, -1}, {1, 0}, {-1, 0} };
ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }


template<typename T, T MOD = 1000000007>
struct Mint {
	T v;

	Mint() : v(0) {}
	Mint(signed v) : v(v) {}
	Mint(ll t) { v = t % MOD; if (v < 0) v += MOD; }

	Mint pow(ll k) {
		Mint res(1), tmp(v);

		while (k) {

			if (k & 1) res *= tmp;

			tmp *= tmp;
			k >>= 1;
		}



		return res;
	}

	Mint inv() { return pow(MOD - 2); }

	Mint& operator=(Mint a) { if (a.v >= MOD) a.v %= MOD; v = a.v; return *this; }
	Mint& operator+=(Mint a) { v += a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator-=(Mint a) { v += MOD - a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator*=(Mint a) { v = 1LL * v * a.v % MOD; return *this; }
	Mint& operator/=(Mint a) { return (*this) *= a.inv(); }
	Mint operator+(Mint a) const { return Mint(v) += a; }
	Mint operator-(Mint a) const { return Mint(v) -= a; }
	Mint operator*(Mint a) const { return Mint(v) *= a; }
	Mint operator/(Mint a) const { return Mint(v) /= a; }

	Mint operator-() { return v ? MOD - v : v; }
	bool operator==(const Mint a) const { return v == a.v; }
	bool operator!=(const Mint a) const { return v != a.v; }
	bool operator < (const Mint a) const { return a < a.v; }


};

using M = Mint<ll>;

M Fact[2 * 100005];


int main() {
	
	ll n, m, k;
	cin >> n >> m >> k;
	Fact[0] = 1;
	rep(i, n*m+1) {
		Fact[i + 1] = Fact[i] * (i+1);
	}


	auto comb = [](ll a, ll b) { return Fact[a] / (Fact[b] * Fact[a - b]); };
	
	M ret = 0;
	rep(i, n) {
		ret += M(i) * M((n - i)) * M(m) * M(m);
	}
	rep(i, m) {
		ret += M(i) * M((m - i)) * M(n) * M(n);
	}

	cout <<  (comb(m*n - 2, k - 2) * ret).v << endl;

	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using piii = pair<int, pii>;
#define x first
#define y second

const int N = 1005;
const ll M = ll(1e9) + 7;

int n, m, b, c;
ll x, y, r;
vector<int> v;
vector<pii> e[N];
vector<piii> el;

ll p(ll x, int y){
    if(!y) return 1;
    return p(x * x % M, y / 2) * ((y & 1) ? x : 1) % M;
}

int g(int x, int y, int z){
    if(x == z) return 0;
    for(pii i : e[x]) if(i.x != y){
        int t = g(i.x, x, z);
        if(t >= 0) return max(t, i.y);
    }
    return -1;
}

int main(){
    scanf("%d%d%lld", &n, &m, &x);
    for(int i = 0, x, y, z; i < m; i++){
        scanf("%d%d%d", &x, &y, &z);
        el.emplace_back(z, pii(x, y));
    }
    sort(el.begin(), el.end());
    for(piii i : el){
        int t = g(i.y.x, 0, i.y.y);
        if(t < 0){
            e[i.y.x].emplace_back(i.y.y, i.x);
            e[i.y.y].emplace_back(i.y.x, i.x);
            y += i.x;
        }
        else v.push_back(i.x - t);
    }
    if(y > x){ puts("0"); return 0; }
    if(y == x) r += p(2, m - n + 1) * (p(2, n - 1) + M - 2) % M;
    for(int i : v){
        if(i == x - y) b++;
        if(i > x - y) c++;
    }
    r = (r + p(2, c + 1) * (p(2, b) + M - 1)) % M;
    printf("%lld\n", r);
}

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

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	char judge='a';
	int numa=a.size();
	int numb=b.size();
	int numc=c.size();
	bool fin=true;
	while(fin){
		if(judge=='a'){
			if(numa==0){
				fin=false;
			}
			if(numa>0){
				judge=a.at(a.size()-numa);
				numa--;
			}
		}
		if(judge=='b'){
			if(numb==0) fin=false;
			if(numb>0){
				judge=b.at(b.size()-numb);
				numb--;
			}
		}
		if(judge=='c'){
			if(numc==0) fin=false;
			if(numc>0){
				judge=c.at(c.size()-numc);
				numc--;
			}
		}
	}
	if(judge=='a') cout << "A" << endl;
	if(judge=='b') cout << "B" << endl;
	if(judge=='c') cout << "C" << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define endl "\n"
#define ll long long
#define N ((int)(3e5 + 5))
#define MOD ((int)(1e9 + 7))


using namespace std;


/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/

int arr[5][5];


int main()
{
    fastio;
    for(int i = 1 ; i<=3 ; i++){
        for(int j = 1 ; j<=3 ; j++) cin>>arr[i][j];
    }
    for(int i = 2 ; i<=3 ; i++){
        for(int j = 2 ; j<4 ; j++){
            if(arr[i][j] - arr[1][j] != arr[i][1] - arr[1][1]){
                cout<<"No\n";
                return 0;
            }
        }
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
  int N,X,T;
  cin >>N>>X>>T;
  int kaisuu=N/X;
  if(N%X != 0)
  {
    kaisuu++;
  }
  
  cout<< kaisuu*T <<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
int main(){
  int i, j, x, ans=0;
  cin >> x;
  for(i=1; i<=x; i++){
    ans+=i;
    if(ans>=x){
      cout << i;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 200005
#define X first
#define Y second
#define MOD 998244353
#define inf 1e18
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
ll n,i,j,t;

int main()
{
    fastio;
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left, bisect_right
from functools import lru_cache, reduce
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n = int(input())
    n, k = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    g = reduce(gcd, a)

    m = max(a)
    if k <= m and k % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
1
4
-1 1 1 -1

"""


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

/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/


using namespace std;

typedef pair<int , int > pii;
typedef pair<long , long> pll;
typedef pair<pii , int > piii;
typedef pair<pll , long > plll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector <pii> vii;
typedef vector<pll> vll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long int lli;
typedef double d;
typedef float f;
typedef string s;
typedef char ch;
typedef pair<int,ll> pill;

#define loop(n) for(int i = 0; i < (n); i++)
#define lp(x , s , e) for(int x = (s); x < (e); x++)
#define lpe(x , s , e) for(int x = (s); x <= (e); x++)
#define readline(s) getline(cin,s)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;
#define MP make_pair
#define PB push_back
#define all(a) a.begin(),a.end()
#define clr(x , val) memset((x) , (val) , sizeof(x))
#define endl '\n'

ll power(ll a, ll b)
{
    ll res = 1;
    for(int i = 0; i<b; i++)
       res *= a;

    return res;
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int x[n];
	loop(n)
		cin >> x[i];
	int mncost = INT_MAX;
	for (int i = -100; i <= 100; i++)
	{
		int cost = 0;
		for(int j = 0; j < n; j++)
		{
			cost += ((x[j] - i) * (x[j] - i));
		}
		mncost = min(mncost , cost);
	}
	cout << mncost << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > ed;
int n;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            if(n%2==0)
            {
                if(i+j!=n+1)
                {
                    ed.push_back({i, j});
                }
            }
            else
            {
                if(i+j!=n)
                {
                    ed.push_back({i, j});
                }
            }
        }
    }
    cout<<ed.size()<<endl;
    for(int i=0; i<ed.size(); i++)
    {
        cout<<ed[i].first<<" "<<ed[i].second<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [a, b]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const aY = Math.ceil(a / 0.08);
    const bY = Math.ceil(b / 0.1);
    const aU = Math.ceil((a + 1) / 0.08) - 1;
    const bU = Math.ceil((b + 1) / 0.1) - 1;
    return `${bU < aY || aU < bY ? -1 : Math.max(aY, bY)}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 11468
#参照　https://atcoder.jp/contests/abc117/submissions/7661660

import sys
input = lambda: sys.stdin.readline().rstrip()

N, K = map(int, input().split())

A = list(map(int, input().split()))

# dp[桁数][0 or 1] 
# 0: Kより小さいことが未確定
# 1: Kより小さいことが確定
dp = [[-1 for _ in range(2)] for _ in range(55)]
dp[0][0] = 0

for d in range(50):
    mask = 1 << (50 - d - 1)

    # A で元々d桁目にビットが立っている個数
    num = 0
    for i in range(N):
        if A[i] & mask:
            num += 1

    # Xのd桁目をに0した時の増加分
    add0 = mask * num
    # Xのd桁目をに1した時の増加分
    add1 = mask * (N - num)

    # 1 => 1への遷移
    if dp[d][1] != -1:
        dp[d+1][1] = max(dp[d+1][1], dp[d][1] + max(add0, add1))

    # 0 => 1への遷移
    # Kのd桁目が1の時、Xのd桁目を0にする場合    
    if dp[d][0] != -1:
        if K & mask:
            dp[d+1][1] = max(dp[d+1][1], dp[d][0] + add0)

    # 0 => 0への遷移
    # Kのd桁目が1の時、Xのd桁目を1
    # Kのd桁目が0の時、Xのd桁目を0にする場合
    if dp[d][0] != -1:
        if K & mask:
            dp[d+1][0] = max(dp[d+1][0], dp[d][0] + add1)
        else:
            dp[d+1][0] = max(dp[d+1][0], dp[d][0] + add0)

print(max(dp[50][0], dp[50][1]))

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N), q(N);
  for (int i = 0; i < N; i++) cin >> p.at(i);
  for (int i = 0; i < N; i++) cin >> q.at(i);

  vector<int> a(N);
  for (int i = 0; i < N; i++) a.at(i) = i + 1;

  map<vector<int>, int> mp;
  do {
    mp[a] = mp.size();
  } while (next_permutation(a.begin(), a.end()));

  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
}

Measured memory_bytes: 5248