akhauriyash/Code-Regression huggingface dataset:
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

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

    int ans = 0;
    rep(i, 3) ans += s[i] == 'o';
    cout << 700 + ans*100 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	rep(i,n){
		ans = min(2*ans, ans+k);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int w;
    cin >> w;
    for(int i=0;i<s.size();i++){
        if(i%w==0) cout << s[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int a[1050];
    while(cin>>n,n){
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int mn=1000000;
        for(int i=1;i<n;i++){
            mn=min(mn,a[i]-a[i-1]);
        }
        cout<<mn<<endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ll long long
int main()
{
    ll n;
    ll count = 0;
    ll ans;
    std::vector<char> C;
    std::cin >> n;
    for (ll i = 0; i < n; ++i) {
        char temp;
        std::cin >> temp;
        if (temp == 'R') {
            ++count;
        }
        C.push_back(temp);
    }
    ans = count;
    for (ll i = 0; i < count; ++i) {
        if (C[i] == 'R') {
            --ans;
        }
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 3708
// https://atcoder.jp/contests/abc119/tasks/abc119_c
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int N, A, B, C;
vector<int> v;
int dfs(int cur, int a, int b, int c) {
    if (cur == N) {
        if (min({a, b, c}) > 0) {
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        } else {
            return INF;
        }
    }
    int ret0 = dfs(cur + 1, a, b, c);
    int ret1 = dfs(cur + 1, a + v[cur], b, c) + 10;
    int ret2 = dfs(cur + 1, a, b + v[cur], c) + 10;
    int ret3 = dfs(cur + 1, a, b, c + v[cur]) + 10;
    return min({ret0, ret1, ret2, ret3});
}
int main() {
    cin >> N >> A >> B >> C;
    v.resize(N);
    REP(i, N) { cin >> v[i]; }
    cout << dfs(0, 0, 0, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;





int main(void) {
    
    
    string s;
    cin>>s;
    ll ans=0;
    vll csum(s.size(),0);
  if(s[0]=='B')csum[0]++;
    for(int i=1;i<s.size();i++){
        if(s[i]=='B'){
            csum[i]=csum[i-1]+1;
        } else {
            csum[i]=csum[i-1];
        }
    }
    rep(i,s.size()){
        if(s[i]=='W'){
            ans+=csum[i];
        }
    }

    fin(ans);
}


Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}
//f(L) = 全部の丸太を長さL以下にするときの最小切断回数
//二分探索でf(L) <= k となる最小のLを見つける
//O(Nlog(max(a_i)))
int main(){
    ll n, k;
    cin >> n >> k;
    ll amax = -1;
    ll a[n+1];
    rep1(i, n){
        cin >> a[i];
        amax = max(amax, a[i]);
    }
    ll l = 1;
    ll r = amax;
    while(l < r){
        ll tmp = (ll)floor((r-l)/2.0) + l;
        ll num = 0;
        rep1(i, n){
            num += max((ll)ceil((a[i]-tmp)/(double)tmp), (ll)0);
        }
        if(num < k) r = tmp;
        else if(num == k) r = tmp;
        else l = tmp + 1;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 4708
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
#define PI acos(-1)
#define deb(x) cout<<#x<<" "<<x<<endl;
#define rotate_left(vec,amt) rotate(vec.begin(),vec.begin()+amt,vec.end());
#define rotate_right(vec,amt) rotate(vec.begin(),vec.begin()+vec.size()-amt,vec.end());


int main() {
    fio;
    ll t=1; 
   // cin>>t;
    while(t--)
    {
		ll r; cin>>r;
		double ans= 2 * PI *r;
		cout<<ans<<"\n";
    }

    
    return 0;
        
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define ii pair<int,int>
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define int long long int
#define modulo 1000000007
using namespace std;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    if(a>9||b>9)cout<<-1;
    else cout<<a*b;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-9;
using vi = vector <int>;
using vvi = vector <vi>;

int combination(int n, int k)
{
  if(k < 0 || n < k) return (0);
  int ret = 1;
  for(int i = 1; i <= k; ++i) {
    ret *= n--;
    ret /= i;
  }
  return (ret);
}

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	int v[n];
	map <int, int> mp;
	rep(i, n) {
		cin >> v[i];
		mp[v[i]]++;
	}

	sort(v, v + n);
	reverse(v, v + n);

	long double ans = 0;
	int combi = 0;
	for (int i = a; i <= b; i++) {
		long double sum = 0;
		int cnt = 1;
		for(int j = 0; j < i; j++) {
			sum += v[j];
			if(j != 0 && v[j - 1] == v[j]) {
				cnt++;
			} else {
				cnt = 1;
			}
		}
		if(ans <= 1.0L * sum / i) {
			if(ans != 1.0L * sum / i) {
				combi = 0;
			}
			ans = 1.0L * sum / i;
			combi += combination(mp[v[i - 1]], cnt);
		}
	}
	printf("%.10Lf\n%lld\n", ans, combi);
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
    val d = Array.fill[Int](N)(sc.nextInt)

    val sorted = d.sorted
    val res = if (N % 2 == 0) {
      sorted(N / 2) - sorted(N / 2 - 1)
    } else {
      0
    }

    println(res)
  }
}

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

int main() {
    int N;
    cin >> N;
    int cnt = 0;
    int guuki = 100;
    for(int i = 0; i < N; i++) {
        int s;
        cin >> s;
        cnt+=s;
        if(s%2 == 1) {
            guuki = min(guuki,s);
        }
    }
    if(cnt%10 != 0) {
        cout << cnt << endl;
    }
    else if(guuki != 100) {
        cout << cnt-guuki << endl;
    }
    else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int r=sc.nextInt();
    int c=sc.nextInt();
    int sumr[];
    int sumc[];
    int a[][];
    int sum=0;
    sumr=new int[r];
    sumc=new int[c];
    a=new int[r][c];
    for(int i=0;i<r;i++) sumr[i]=0;
    for(int j=0;j<c;j++) sumc[j]=0;
    for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
        a[i][j]=sc.nextInt();
        sumr[i]+=a[i][j];
        sumc[j]+=a[i][j];
        sum+=a[i][j];
      }
    }
    for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
        System.out.print(a[i][j]+" ");
      }
      System.out.println(sumr[i]);
    }
    for(int j=0;j<c;j++){
      System.out.print(sumc[j]+" ");
    }
    System.out.println(sum);
  }
}



Measured memory_bytes: 42384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
    for(int i=0; i<N; i++) {
      cin >> a.at(i);
    }
 
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int A=0,B=0;
  
  for(int i=0;i<N;i++){
    if(i%2 == 0){
      A+=a.at(i);
    }
    else{
      B+=a.at(i);
    }
  }
  
  cout << A - B <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] pos = new int[n];
        for (int i = 0; i < n; ++i) {
            pos[sc.nextInt() - 1] = i;
        }

        int max = 1;
        int first = 0;
        for (int i = 1; i < pos.length; ++i) {
            if (pos[i] > pos[i - 1]) {
                max = Math.max(max, i - first + 1);
            } else {
                first = i;
            }
        }

        System.out.println(n - max);
    }
}


Measured memory_bytes: 78984
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
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(false);
	int N, M; cin >> N >> M;
	vector<int> a(N), b(N); rep(i, 0, N) { cin >> a[i] >> b[i]; }
	vector<int> c(M), d(M); rep(i, 0, M) { cin >> c[i] >> d[i]; }
	rep(i, 0, N) {
		int ans = -1, e = INF;
		rep(j, 0, M) {
			int D = abs(c[j] - a[i]) + abs(d[j] - b[i]);
			if (chmin(e, D)) {
				ans = j;
			}
		}
		cout << ans + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php
// Your code here!
    $count = fgets(STDIN);
    $height_array = explode(" ",fgets(STDIN));

    $adjustment = 0;
    $base = $height_array[0];
    for($i=0;$i<$count;$i++){
        if($height_array[$i]<$base){
            $adjustment += $base - $height_array[$i];
        }else{
            $base = $height_array[$i];
        }
    }
    
    echo $adjustment;
    
?>

Measured memory_bytes: 31844
#include <algorithm>
#include <cstdio>

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

using namespace std;

int main(){
	int n,c[499],s[499],f[499];
	scanf("%d",&n);
	rep(i,n-1) scanf("%d%d%d",c+i,s+i,f+i);

	rep(i,n){
		int t=0;
		for(int j=i;j<n-1;j++){
			t=max(t,s[j]);
			t=(t+f[j]-1)/f[j]*f[j];
			t+=c[j];
		}
		printf("%d\n",t);
	}

	return 0;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a,b,c,x;cin>>a>>b>>c>>x;
  int ans=0,hoge;
  for (int i = 0; i < a+1; ++i){
  	for (int j = 0; j < b+1; ++j){
  		hoge=x-i*500-j*100;
  		//cout<<hoge<<endl;
  		if (hoge>=0 && hoge<=50*c){
  			ans++;
  		}
  	}
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int n, m; cin >> n >> m;
    int wa = 0;
    int ac = 0;
    map<int, int> mp;

    vector<bool> f(n+1, false);

    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        if (f[p]) continue;
        if (s == "WA") {
            auto it = mp.find(p);
            if (it != mp.end()) mp[p] += 1;
            else mp[p] = 1;
        }
        else {
            f[p] = true;
            ++ac;
            wa += mp[p];
        }
    }

    cout << ac << " " << wa << endl;

    return 0;
}


Measured memory_bytes: 4992
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}

//......................................@uthor_Alx..............................................
 static List<Character> l;
 static void rec(long n,String s){
 	if(n<=0l) return;
 	if(n>0)n--;
 	long k=n/26l;int r=(int)(n%26l);
 	
 	 l.add(s.charAt(r));
 	rec(k,s);
 }
   public static void main(String[] args) throws  IOException{
	        		  assign();
	        		  	long n=long_v(read());
	        		  	l=new ArrayList<>();
	        		  	String s="abcdefghijklmnopqrstuvwxyz";
	        		  	rec(n,s);
	        		  	for(int i=l.size()-1;i>=0;i--){
	        		  		out.write(l.get(i));
	        		  	}
	        		  	
	        		  	//out.write(res+"");
                      	out.flush();
	        		 
	}
}
	       


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    int n;
    cin >>n;
    vi d(n);
    rep(i,n) cin>>d[i];

    sort(beginend(d));

    int ans=1;
    int cnt=1;
    for(int i=1;i<n;++i){
        if(d[i]>d[i-1]) {
            cnt++;
        }else if(d[i]==d[i-1]) {
            continue;
        }else{
            ans=max(ans,cnt);
            cnt=1;
        }
    }
    ans=max(ans,cnt);
    out(ans);
}


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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

ll res = 0;

int main()
{
    ll n;
    string s;
    cin >> n >> s;

    ll x = 0;
    for (char c: s)
    {
        if (c == 'I')
        {
            x++;
        }
        else
        {
            x--;
        }
        res = max(res, x);
    }

    println(res);
}


Measured memory_bytes: 3640
#include <vector>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cassert>


template <typename T> struct BIT {
  std::vector<T> tree;
  long long int size;

  BIT(long long int n) : tree(n + 1, (T)0), size(n) {}

  T sum(long long k) {
    T s = 0;
    assert(0 <= k && k < size);

    for (long long int i = k + 1; i > 0; i -= i & -i) {
      s = s + tree[i];
    }
    return s;
  }

  T range(long long int start, long long int end) {
    return sum(end) - sum(start - 1);
  }

  void add(long long int k, T v) {
    assert(0 <= k && k < size);
    for (long long int i = k + 1; i <= size; i += i & -i) {
      tree[i] = tree[i] + v;
    }
  }

  void debug() {
    for (long long int i = 0; i <= size; i++) {
      std::cout << tree[i] << " ";
    }
    std::cout << std::endl;
  }
};

using namespace std;
using ll = long long int;

ll N;
vector<ll> A;


bool check(ll mid) {
  //二分探索の目標値。 #{ m[i] | x <= m[i]} = objective となる最大の x を探す
  const ll comb = (N + 1) * N / 2;
  const ll objective = (comb + 1) / 2;

  vector<ll> s(N + 1);
  s[0] = 0;

  for (int i = 0; i < N; i++) {
    ll inc = A[i] < mid ? -1 : 1;
    s[i + 1] = s[i] + inc;
  }

  BIT<ll> bit(2 * N + 3);

  ll invs = 0;
  for (int i = 0; i <= N; i++) {
    ll idx = s[i] + N + 1;
    invs += bit.sum(idx);
    bit.add(idx, 1);
  }

  return invs >= objective;
}


int main() {
  cin >> N;
  for (int i = 0; i < N; i++)  {
    ll tmp; cin >> tmp; A.push_back(tmp);
  }

  ll left = 1;
  ll right = (ll)1e9 + 10;

  while (right - left > 1) {
    ll mid = (left + right) / 2;

    if (check(mid)) { // satisfies
      left = mid;
    } else {
      right = mid;
    }
  }

  assert(check(left + 1) == false);
  assert(find(A.begin(), A.end(), left) != A.end());

  cout << left << endl;
  return 0;
}


Measured memory_bytes: 3444
// AOJ 2400

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

#define score first.first
#define pena first.second
#define id second

int main(void)
{
	int t, p, r;
	while (cin >> t >> p >> r, r){
		int wrong[t][p];
		vector < pair < pair <int, int>, int> > team(t);
		for (int i = 0; i < t; i++){
			team[i].score = team[i].pena = 0;
			team[i].id = i + 1;
			fill (wrong[i], wrong[i] + p, 0);
		}
		int ti, pi, time;
		string mes;
		for (int i = 0; i < r; i++){
			cin >> ti >> pi >> time >> mes;
			ti--; pi--;
			if (mes == "WRONG"){
				wrong[ti][pi]++;
			}
			if (mes == "CORRECT"){
				team[ti].score++;
				team[ti].pena += (time + (1200 * wrong[ti][pi]));
			}
		}
		// cout << "check" << endl;
		
		int ret[t];
		for (int i = 0; i < team.size(); i++){
			int cnt = t-1;
			//　cout << "check" << endl;
			for (int j = 0; j < team.size(); j++){
				if (team[j].score < team[i].score) cnt--;
				if (team[j].score == team[i].score && team[i].pena < team[j].pena) cnt--;
				if (team[j].score == team[i].score && team[i].pena == team[j].pena && team[i].id < team[j].id) cnt--;
			}
			ret[cnt] = i;
		}
		for (int i = 0; i < t; i++){
			int rank = ret[i];
			cout << team[rank].id << " " << team[rank].score << " " << team[rank].pena << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1220
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e3 + 5;
const double eps = 1e-9;
char str[MAXN];
ll dp[MAXN][MAXN], a[MAXN][MAXN];

int main()
{
    int h, w;
    ni(h), ni(w);
    for (int i = 0; i < h; i++) {
        scanf("%s", str);
        for (int j = 0; j < w; j++)
            if (str[j] != '#')
                a[i][j] = 1;
    }
    dp[0][0] = 1;
    for (int i = 1; i < w; i++)
        dp[0][i] = dp[0][i - 1] * a[0][i];
    for (int i = 1; i < h; i++)
        dp[i][0] = dp[i - 1][0] * a[i][0];
    for (int i = 1; i < h; i++) {
        for (int j = 1; j < w; j++) {
            dp[i][j] = (dp[i - 1][j] * a[i][j] + dp[i][j - 1] * a[i][j]) % MOD;
        }
    }
    prl(dp[h - 1][w - 1]);
    return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  string s,t;
  cin>>s>>t;
  int ans = INT_MAX;
  for(int i=0;i<(int)s.size();i++){
    int best = 0;
    if(i + (int)t.size() > s.size())
      break;
    for(int j=i;j < i +(int)t.size(); j++){
      if(s[j] != t[j-i]) best++;
    }
    min_self(ans,best);
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 3664
k = int(input())
import math
ans = 0
for i in range(1,k+1):
         for j in range(i,k+1):
                  for l in range(j,k+1):
                           tmp = math.gcd(i,j)
                           tmp = math.gcd(tmp,l)
                           if i == j == l:
                                    ans += tmp
                           elif i == j or j == l or l == i:
                                    ans += 3 * tmp
                           else:
                                    ans += 6 * tmp
print(ans)

Measured memory_bytes: 9200
#define _GLIBCXX_DEBUG
#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;
const double pi=acos(-1);

ll keta(ll n)
{
  ll k=0;
  while(n!=0)
  {
    n/=10;
    k++;
  }
  return k;
}  

ll pla(ll n,ll i)
{
  ll x = pow(10,i + 1),y = pow(10,i);
  return n % x / y;
}

int main() 
{
  ll N,M; cin>>N>>M;
  //cout<<N<<M<<endl;
  vector<ll> s(M);
  vector<ll> c(M);
  rep(i,M)
  {
    ll S,C; cin>>S>>C;
    S=N-S;
    s.at(i)=S;
    c.at(i)=C;
  }  
  for(ll i=0;i<1000;i++)
  {
    if(!(keta(i)==N||(i==0&&N==1))) {continue;}
    rep(j,M)
    {
      if(pla(i,s.at(j))!=c.at(j)) {goto OUT;}
    }
    cout<<i<<endl;
    return 0;
    OUT:;
  }
  cout<<-1<<endl;
  return 0;
}


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

template<int MOD>
class mod_int {
	unsigned x;
public:
	mod_int() : x(0) { }
	mod_int(int sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	mod_int(long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	mod_int &operator+=(mod_int that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator-=(mod_int that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator*=(mod_int that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	mod_int &operator/=(mod_int that) { return *this *= that.inverse(); }

	mod_int operator+(mod_int that) const { return mod_int(*this) += that; }
	mod_int operator-(mod_int that) const { return mod_int(*this) -= that; }
	mod_int operator*(mod_int that) const { return mod_int(*this) *= that; }
	mod_int operator/(mod_int that) const { return mod_int(*this) /= that; }

	bool operator==(const mod_int& that) const { return x == that.x; }

	mod_int inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		return mod_int(u);
	}
};

template<int MOD>
istream& operator >> (istream& is, mod_int<MOD>& val) {
	long long x;
	is >> x; val = x;
	return is;
}

template<int MOD>
ostream& operator << (ostream& os, const mod_int<MOD>& val) {
	os << val.get();
	return os;
}

const int mod = 1e9 + 7;
using mint = mod_int<mod>;

const int MAX = 2e6;

bool inited = false;
mint fac[MAX + 1];
mint rfac[MAX + 1];

void init() {
	inited = true;
	fac[0] = 1;
	for (int i = 1; i <= MAX; i++) {
		fac[i] = fac[i - 1] * i;
	}
	rfac[MAX] = fac[MAX].inverse();
	for (int i = MAX; i >= 1; i--) {
		rfac[i - 1] = rfac[i] * i;
	}
}

mint nPr(int n, int r) {
	if (!inited) init();
	return r < 0 || n < r ? 0 : fac[n] * rfac[n - r];
}

mint nCr(int n, int r) {
	if (!inited) init();
	return r < 0 || n < r ? 0 : fac[n] * rfac[n - r] * rfac[r];
}

mint nHr(int n, int r) {
	if (!inited) init();
	return r == 0 ? 1 : nCr(n + r - 1, r);
}

mint power(mint a, int n) {
	mint res = 1;
	while (n) {
		if (n & 1) res *= a;
		n >>= 1;
		a *= a;
	}
	return res;
}

int main()
{
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	mint a = mint(A) / (A + B), b = mint(B) / (A + B);
	mint one = mint(100) / mint(100 - C);
	if (A == 0 || B == 0) {
		cout << one * N << endl;
		return 0;
	}
	mint res = 0;
	for (int i = 0; i < N; i++) {
		res += mint(N + i) * nCr(N - 1 + i, i) * power(a, N) * power(b, i);
	}
	for (int i = 0; i < N; i++) {
		res += mint(N + i) * nCr(N - 1 + i, i) * power(a, i) * power(b, N);
	}
	cout << res * one << endl;
	return 0;
}


Measured memory_bytes: 15872
l,r = map(int, input().split())
waruL = l // 2019
waruR = r // 2019
if waruL < waruR :
    modMin = 0
else:
    modMin = 2018
    modL = l%2019
    modR = r%2019

    for i in range(modL,modR):
        for j in range(i+1,modR+1):
            modIJ = (i*j)%2019

            if modIJ < modMin:
                modMin = modIJ
print(modMin)

Measured memory_bytes: 3060
import itertools

n, d = map(int, input().split())
points = []
for _ in range(n):
  point = list(map(int, input().split()))
  points.append(point)

combinations = list(itertools.combinations(points, 2))
dist_lists = []
ans = 0
for comb in combinations:
  A = comb[0]
  B = comb[1]

  tmp = 0
  for j in range(len(A)):
    tmp += (B[j] - A[j])**2
  
  distance = tmp**(0.5)

  if distance.is_integer():
    ans += 1
print(ans)

Measured memory_bytes: 9480
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

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

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}

int main(void)
{
 ll x;
 cin >> x;
 for(ll i = -1000;i<=1000;i++){
  for(ll j=-1000;j<=1000;j++){
    if(pow(i,5)-pow(j,5)==x){
      cout << i << " " << j;
      return 0;
    }
  }
 }

 
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  ll tmp = accumulate(a, a + M, 0);
  cout << (tmp > N ? -1 : N - tmp) << endl;
  return 0;
}

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

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

  int result = (b - 1) / (a - 1) + ((b - 1) % (a - 1) == 0 ? 0 : 1);

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        switch (S){
            case "SUN":
                System.out.println(7);
                break;
            case "MON":
                System.out.println(6);
                break;
            case "TUE":
                System.out.println(5);
                break;
            case "WED":
                System.out.println(4);
                break;
            case "THU":
                System.out.println(3);
                break;
            case "FRI":
                System.out.println(2);
                break;
            case "SAT":
                System.out.println(1);
                break;
        }

    }
}


Measured memory_bytes: 21844
h, w, d = map(int, input().split())
cell = {}
for i in range(h):
  row = list(map(int, input().split()))
  for j, a in enumerate(row):
    cell[a] = (i, j)

max_point = h * w
req_mp = [0 for i in range(max_point)]
for i in range(max_point):
  if i < d:
    req_mp[i] = 0
  else:
    temp = req_mp[i-d]
    temp += abs(cell[i-d+1][0] - cell[i+1][0])
    temp += abs(cell[i-d+1][1] - cell[i+1][1])
    req_mp[i] = temp

q = int(input())
for _ in range(q):
  l, r = map(int, input().split())
  print(req_mp[r-1] - req_mp[l-1])


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

ll dp[110][110][310];  // dp[i+1][j][k] : i番目の品物まででj個選んで重さの総和k以下のときの価値の総和の最大値
 
int main() {
    ll n, W;
    cin >> n >> W;

    vl w(n), v(n);
    rep(i, n) {
        cin >> w[i] >> v[i];
    }

    ll w0 = w[0];
    rep(i, n) {
        w[i] -= w0;
    }

    rep(i, n) {
        exrep(j, 0, n) {
            exrep(k, 0, 300) {
                chmax(dp[i+1][j][k], dp[i][j][k]);
                chmax(dp[i+1][j+1][k+w[i]], dp[i][j][k] + v[i]);
            }
        }
    }

    ll ans = 0;
    exrep(j, 1, n) {
        exrep(k, 0, 300) {
            if(j*w0 + k <= W) {
                chmax(ans, dp[n][j][k]);
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 28544
#include <stdio.h>
#include <string.h>
int main() {
    int i, j, len, index = 0;
    char *keyence = "keyence", S[100], tmp[100] = {'\0'};
    scanf("%s", S);
    len = strlen(S);
    for (i = 0; i < strlen(keyence); i++) {
        if (S[i] != keyence[i]) break;
    }
    for (j = i; j < strlen(keyence); j++) {
        tmp[index++] = keyence[j];
    }
    index = i;
    for (j = strlen(keyence) - i; j >= 1; j--) {
        if (S[len - j] != keyence[index++]) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 128
/*
https://atcoder.jp/contests/dp/tasks/dp_h
*/
#include<bits/stdc++.h>
#include<vector>
#define mod 1000000007
using namespace std;

int main(){

    int n,m;  cin>>n>>m;
    int dp[n][m];
    char arr[n][m];

    memset(dp,0,sizeof(dp));

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        cin>>arr[i][j];
      }
    }

    for(int i=0;i<n;i++){
        if(arr[0][i] == '.'){
            dp[0][i] = 1;
        }
        else{
            break;
        }
    }

    for(int i=0;i<m;i++){
        if(arr[i][0] == '.'){
            dp[i][0] = 1;
        }
        else{
            break;
        }
    }

    for(int i=1;i<n;i++){
      for(int j=1;j<m;j++){
        if(arr[i][j] == '#'){
            dp[i][j] = 0;
        }
        else{
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
        }
      }
    }

    cout<<dp[n-1][m-1]<<"\n";

return 0;
}



Measured memory_bytes: 5120
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t N;
	uint64_t capacity = 26, pc = 0, delta = 1;
	int gotiusanokokoa[1024];
	int sumipe = 0;
	int i;
	int count = 0;
	if (scanf("%" SCNu64, &N) != 1) return 1;
	if (N > 26) {
		int num;
		while (capacity < N) {
			pc = capacity;
			delta *= 26;
			capacity += delta * 26;
			count++;
		}
		num = (int)((N - pc - 1) / delta);
		putchar('a' + num);
		N -= pc + delta * num;
	}
	N--;
	do {
		gotiusanokokoa[sumipe++] = (int)(N % 26);
		N /= 26;
	} while (N > 0 || sumipe < count);
	for (i = sumipe - 1; i >= 0; i--) putchar('a' + gotiusanokokoa[i]);
	putchar('\n');
}


Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
  int n,x,t;
  int g;
  vector<int> dx;
  cin >> n >> x;
  dx.push_back(x);
  for(int i=0;i<n;i++){
    cin >> t;
    dx.push_back(t);
  }
  sort(dx.begin(),dx.end());
  g = dx[1]-dx[0];
  for(int i=1;i<n+1;i++){
    g = gcd(g,dx[i]-dx[0]);
  }
  cout << g << endl;
}



Measured memory_bytes: 892
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    int a;
    REP(i, 3){
        a*=10;
        int d;
        cin >> d;
        a+=d;
    }
    cout << (a%4?"NO":"YES") << endl;
}



Measured memory_bytes: 4992
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, c, d = LI()
ans = b - a + 1
lcm = c * d // math.gcd(c, d)
ans -= b // c - ((a-1) // c + 1) + 1
ans -= b // d - ((a-1) // d + 1) + 1
ans += b // lcm - ((a-1) // lcm + 1) + 1
print(ans)

Measured memory_bytes: 65648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	int n;
	int[] a = new int[1000];

	Scanner scan = new Scanner(System.in);
	n = scan.nextInt();

	for(int i = 0; i < n; i ++) {
	    a[i] = scan.nextInt();
	}

	for(int i = n-1; i > 0; i--) {
	    System.out.print(a[i]+ " ");
	}
	System.out.println(a[0]);
    }
}



Measured memory_bytes: 26224
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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






















struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;
    vector<bool> lazyFlag;
 
public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);
 
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
 
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = min(node[k], lazy[k]);
            if(r - l > 1) {
                lazy[k*2+1] = min(lazy[k*2+1], lazy[k]);
                lazy[k*2+2] = min(lazy[k*2+2], lazy[k]);
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }
 
    void update(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = min(lazy[k], x);
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }
 
    ll query(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[k];
        ll vl = query(a, b, 2*k+1, l, (l+r)/2);
        ll vr = query(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main(){
    ll n, q;
    cin >> n >> q;
    vector<ll> s(n), t(n), x(n);
    REP(i, n){
        cin >> s[i] >> t[i] >> x[i];
    }
    vector<ll> d(q);
    REP(i, q){
        cin >> d[i];
    }
    
    LazySegmentTree tree(vector<ll>(q, INF));
    REP(i, n){
        ll itr1 = lower_bound(d.begin(), d.end(), s[i] - x[i]) - d.begin();
        ll itr2 = lower_bound(d.begin(), d.end(), t[i] - x[i]) - d.begin();
        cerr << itr1 << " " << itr2 << " " << x[i] << " " << endl;
        tree.update(itr1, itr2, x[i]);
    }
    
    REP(i, q){
        ll val = tree.query(i, i + 1);
        cout << ((val != INF)? val : -1) << endl;
    }
}

Measured memory_bytes: 16384
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int, int> P;
int p[250005];
int dis[505][505], cst[505][505];
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };

signed main() {
	int n; cin >> n;
	rep(i, n*n) {
		cin >> p[i]; p[i]--;
	}
	rep(i, n) {
		rep(j, n) {
			dis[i][j] = min(min(i, n - i - 1), min(j, n - j - 1));
			cst[i][j] = 1;
		}
	}

	int ans = 0;

	rep(i, n*n) {
		int ni = p[i] / n, nj = p[i] % n;
		ans += dis[ni][nj]; cst[ni][nj] = 0;
		queue<P>Q; Q.push(P(ni, nj));
		while (Q.size()) {
			P p = Q.front(); Q.pop();
			rep(j, 4) {
				int mi = p.first + dx[j], mj = p.second + dy[j];
				if (0 <= mi && mi < n && 0 <= mj && mj<n&&dis[mi][mj]>dis[p.first][p.second] + cst[p.first][p.second]) {
					dis[mi][mj] = dis[p.first][p.second] + cst[p.first][p.second];
					Q.push(P(mi, mj));
				}
			}
		}
	}
	cout << ans << endl;
}

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


int foo(int a){
  int b= 0, i = 1;
  while(1){
    if(a%i == 0){
      b++;
    }
    if(i == a) break;
    i++;
  }

  return b;
}


int main(){
  int a, b = 0, i = 1;
  
  cin>>a;

  while(1){
    if(foo(i) == a) break;
    i++;
  }
  cout<<i<<endl;
  
  return 0;
}



Measured memory_bytes: 3084
s = input()
k = int(input())

words = set()

l = k+1 if len(s) > k else len(s) + 1

for i in range(1,l):
    for j in range(len(s)):

        words.add(s[j:i+j])

sort_word = sorted(words)

print(sort_word[k-1])

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

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

    vector<int> C(N - 1), S(N - 1), F(N - 1), ans(N - 1);
    rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];

    rep(i, N - 1) {
        int time = S[i] + C[i];
        repd(j, i + 1, N - 1) {
            if (time < S[j] + F[j]) {
                time = S[j] + C[j];
            }
            else {
                int tmp = time - S[j];
                if (tmp % F[j] == 0) {
                    time = C[j] + S[j] + (F[j] * (tmp / F[j]));
                }
                else {
                    time = C[j] + S[j] + (F[j] * ((tmp / F[j]) + 1));
                }
            }
        }
        ans[i] = time;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int m,n;
int main(){
    while(scanf("%d%d", &m, &n) && m && n){
        for(int i = 1; i <= m; ++i){
            for(int j = 1; j <= n; ++j){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3240
var
    n,h,i,w_max,t_damage,c_index,count: Longint;
    a,b,c:array[1..100000] of Longint;

procedure kp(l,r:longint);
var
i,j,mid:longint;
begin
    if l>=r then exit;
    i:=l;j:=r;mid:=c[(l+r) div 2];
    repeat
         while c[i]<mid do inc(i);
         while c[j]>mid do dec(j);
         if i<=j then
         begin
             c[0]:=c[i];c[i]:=c[j];c[j]:=c[0];
             inc(i);dec(j);
         end;
    until i>j;
    kp(l,j);
    kp(i,r)
end;

begin
    read(n,h);
    for i := 1 to n do
    begin
        read(a[i],b[i]);
        if (w_max<a[i]) then
        begin
            w_max:=a[i];
        end
    end;
    for i := 1 to n do
    begin
        if (b[i]>w_max) then
        begin
            c_index:=c_index+1;
            c[c_index]:=b[i];
        end
    end;
    kp(1,c_index);
    for i := c_index downto 1 do
    begin
        inc(count);
        dec(h,c[i]);
        if h<1 then
        begin
            writeln(count);
            exit;
        end
    end;
    count:=count+h div w_max;
    if (h mod w_max > 0) then
    begin
        inc(count);
    end;
    writeln(count);
end.

Measured memory_bytes: 1280