akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] a) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> al = new ArrayList<String>();

		String str;
		// 1???????????\?????????????????????????????????
		while ((str = br.readLine()) != null) {
			if (str.length() == 0) {
				break;
			}
			al.add(str);
		}

		int[][] gcdLcm = new int[al.size()][2];
		int len = al.size();

		for (int i = 0; i < len; i++) {
			String[] buf = al.get(i).split(" ");
			int m = Integer.parseInt(buf[0]);
			int n = Integer.parseInt(buf[1]);
			gcdLcm[i][0] = gcd(m, n);
			gcdLcm[i][1] = lcm((long)m, (long)n, (long)gcdLcm[i][0]);
		}

		//??????
		for(int i=0;i<gcdLcm.length;i++){
			System.out.println(gcdLcm[i][0]+" "+gcdLcm[i][1]);
		}
	}

	// GCD????¨????
	private static int gcd(int m, int n) {
		return n == 0 ? m : gcd(n, m % n);
	}

	// LCM????¨????
	private static int lcm(long m, long n, long gcd) {
		return (int)(m * n / gcd);
	}
}

Measured memory_bytes: 24388
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int N; cin >> N;
  set<int> s;
  for(int i=0;i<N;i++){
    int x;cin >> x;
    s.insert(x);
  }

  int ans=s.size();
  if(ans%2==0) ans-=1;

  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string s, t;
	cin >> n >> s >> t;
	for(int i = 0; i <= n; ++i){
		bool accept = true;
		for(int j = i; j < n; ++j){
			if(s[j] != t[j - i]){ accept = false; }
		}
		if(accept){
			cout << n + i << endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 256
/* ex4_1
    riverstone*/

#include<stdio.h>
#include<math.h>  //math.h を include する。


int main(void){

    double apple,range;
    scanf("%lf  %lf",&apple,&range); //りんごの個数と監視の幅を入力

    //1人の監視員は(監視の幅)×2+１のりんごを監視できるので、りんごの数をそれで割り切り上げる
    int watchmen = ceil(apple / (range*2 + 1)); 
    printf("%d",watchmen); //監視員の人数を出力
    return 0;

}

Measured memory_bytes: 128
#pragma comment(linker, "/STACK:512000000")
#define _CRT_SECURE_NO_WARNINGS
//#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve();
void precalc();
clock_t start;
//int timer = 1;

int testNumber = 1;

bool todo = true;

int main() {
#ifdef AIM
    freopen("/home/alexandero/ClionProjects/ACM/input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
    cout.sync_with_stdio(0);
    cin.tie(0);
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cerr << testNum << endl;
        //cout << "Case #" << testNum++ << ": ";
        solve();
        ++testNumber;
        //++timer;
    }

#ifdef AIM
    cerr << "\n\n time: " << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n";
#endif

    return 0;
}

//BE CAREFUL: IS INT REALLY INT?

template<typename T>
T binpow(T q, T w, T mod) {
    if (!w)
        return 1 % mod;
    if (w & 1)
        return q * 1LL * binpow(q, w - 1, mod) % mod;
    return binpow(q * 1LL * q % mod, w / 2, mod);
}

template<typename T>
T gcd(T q, T w) {
    while (w) {
        q %= w;
        swap(q, w);
    }
    return q;
}
template<typename T>
T lcm(T q, T w) {
    return q / gcd(q, w) * w;
}

void precalc() {

}

//#define int li

//const int mod = 1000000007;

struct Point {
    ld x, y;
    Point() {}
    Point (ld x, ld y):x(x), y(y) {}
    Point operator - (const Point& ot) const {
        return Point(x - ot.x, y - ot.y);
    }
    ld dist() const {
        return sqrt(x * x + y * y);
    }
    ld operator % (const Point& ot) const {
        return x * ot.x + y * ot.y;
    }
    ld operator * (const Point& ot) const {
        return x * ot.y - y * ot.x;
    }
    ld get_cos(Point a, Point b) {
        a = (a - *this);
        b = (b - *this);
        return (a % b) / a.dist() / b.dist();
    }
    ld get_sin(Point a, Point b) {
        a = (a - *this);
        b = (b - *this);
        return fabs(a * b) / a.dist() / b.dist();
    }
    ld get_alpha(Point a, Point b) {
        ld co = get_cos(a, b), si = get_sin(a, b);
        ld res = atan2(si, co);
        if (res < 0) {
            res += acos(-1.0);
        }
        return res;
    }
};

void solve() {
    Point points[3];
    for (int i = 0; i < 3; ++i) {
        cin >> points[i].x >> points[i].y;
    }

    vector<ld> alphas(3), lens(3);
    for (int st = 0; st < 3; ++st) {
        Point a = points[(st + 1) % 3], b = points[(st + 2) % 3];
        lens[st] = (a - b).dist();
        alphas[st] = points[st].get_alpha(a, b) / 2;
    }

    ld res = 0;
    for (int st = 0; st < 3; ++st) {
        ld r = lens[st] / (2 + 1 / tan(alphas[(st + 1) % 3]) + 1 / tan(alphas[(st + 2) % 3]));
        //cout << st << ' ' << r << endl;
        //cout << lens[st] << ' ' << tan(alphas[(st + 1) % 3]) << " " << tan(alphas[(st + 2) % 3]) << endl;
        res = max(res, r);
    }

    cout << res << endl;

}

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

int main(){
  int N;
  cin >> N;
  int S[N];
  rep(i,N-1){
    int C,F;
    cin >> C >> S[i] >> F;
    rep(j,i){
      S[j]=max( S[i],(S[j]+F-1)/F*F );
    }
    rep(j,i+1){
      S[j]+=C;
    }
  }
  rep(i,N-1) cout << S[i] <<endl;
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
#T r→P点
#T s→R点
#T p→S点
r=0;s=1;p=2;m=3
#dp[r,s,p][range(N)]:
#dp[i][j]:j番目まで見たとき、最後がiのときのKおきの和のmax
dp=[[0 for j in range(N)] for i in range(4)]
for j in range(K):
    if T[j]=="r":
        dp[p][j]=P
    elif T[j]=="s":
        dp[r][j]=R
    else:
        dp[s][j]=S
    dp[m][j]=max(dp[r][j],dp[s][j],dp[p][j])
for j in range(K,N):
    for i in range(3):
        dp[i][j]=max(dp[(i+1)%3][j-K],dp[(i+2)%3][j-K])
    if T[j]=="r":
        dp[p][j]+=P
    elif T[j]=="s":
        dp[r][j]+=R
    else:
        dp[s][j]+=S
    dp[m][j]=max(dp[r][j],dp[s][j],dp[p][j])
ans=0
for i in range(K):
    ans+=dp[m][-i-1]
print(ans)


Measured memory_bytes: 64112
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;

int main() {
		ll a;double b;
	cin >> a >> b;
	b*=100;ll gg=round(b);
	gg*=a;gg/=100;
	cout << gg;

	return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<bool> a(10);
	rep(i,k){
		int b;cin >> b;
		a.at(b) = true;
	}
	for(int i = n; i <= n * 10; i++){
		int t = i;
		bool ok = true;
		while(t){
			if(a.at(t % 10)) ok = false;
			t /= 10;
		}
		if(ok){
			cout << i << endl;
			break;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	cout << ((n/10==9 || n%10 == 9)? "Yes": "No") << endl;
}

Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

int G[500][500];
int main() {
  int h, w; cin >> h >> w;
  loop(y,0,h) loop(x,0,w) {
    cin >> G[y][x];
  }
  
  vector<tuple<int, int, int, int> > A;
  loop(y,0,h) {
    loop(x,0,w) {
      if (G[y][x]%2!=0) {
        if (y+1<h and G[y+1][x]%2!=0) {
          G[y][x]--; G[y+1][x]++;
          A.emplace_back(x, y, x, y+1);
          continue;
        }
        
        if (x+1<w and G[y][x+1]%2!=0) {
          G[y][x]--; G[y][x+1]++;
          A.emplace_back(x, y, x+1, y);
          continue;
        }
        
        if (y+1<h) {
          G[y][x]--; G[y+1][x]++;
          A.emplace_back(x, y, x, y+1);
          continue;
        }
        
        if (x+1<w) {
          G[y][x]--; G[y][x+1]++;
          A.emplace_back(x, y, x+1, y);
          continue;
        }
      }
    }
  }
  cout << A.size() << endl;
  for (auto &&a: A) {
    int x, y, x1, y1;
    tie(x, y, x1, y1) = a;
    x++;y++;x1++;y1++;
    cout << y << " " << x << " " << y1 << " " << x1 << endl;
  }
  return 0;
}


Measured memory_bytes: 6324
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    int dis[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            if(i==j){
                dis[i][j]=0;
            }else{
                dis[i][j]=1100000000;
            }
        }
    }
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin>>dis[i][j];
        }
    } 
    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    ll ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;
            cin>>a;
            if(a!=-1){
            ans+=dis[a][1];
            }
        } 
    }
    cout<<ans<<endl;
}   





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

using namespace std;
const int mod = 1e9+7;

int solve(int n){
    int ans = 1;
    
    for (int i = 1; i <= n; i++){
        ans *= 2;
        ans %= mod;
    }
    
    return ans;
}

int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    vector<int> cnt(100002);
    
    for (int i = 0; i < n; i++) cnt[a[i]]++;
    
    bool check = true;
    
    if (n % 2 == 1){
        
        if (cnt[0] != 1) check = false;
        
        for (int i = 2; i < n; i+=2){
            if (cnt[i] != 2) check = false;
        }
        
        if (check){
            cout << solve((n-1)/2) << endl;
            return 0;
        }
        else{
            cout << 0 << endl;
            return 0;
        }
        
    }
    else if (n % 2 == 0){
        
        for (int i = 1; i < n; i+=2){
            if (cnt[i] != 2) check = false;
        }
        
        if (check){
            cout << solve(n/2) << endl;
            return 0;
        }
        else{
            cout << 0 << endl;
            return 0;
        }
    }
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>

int main()
{
    long N,K;
    std::cin >> N >> K;
    std::string S;
    std::cin >> S;
    long happy=0;
    for(long i=0; i<S.length();i++){
        if(S[i]=='R' && i!=S.length()-1){
            if(S[i+1]=='R'){
                happy++;
            }
        }
        if(S[i]=='L' && i!=0){
            if(S[i-1]=='L'){
                happy++;
            }
        }
    }
    happy=2*K+happy;
    if(happy>=S.length()){
        happy=S.length()-1;
    }
    std::cout << happy << std::endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  string s,t;
  int i,j;
  cin>>s>>t;
  int len=s.length();
  s=s+s;
  int len2=s.length();

  bool flag=false;
  bool flag2=true;
  for(i=0;i<len2;i++){
  
    if(s[i]==t[0]){
      flag2=true;
      for( j=0;j<len;j++){
	if(s[i+j]!=t[j]){
	  flag2=false;
	}	
      }
      if(flag2==true){
	flag=true;

      }
    }
  }
  if(flag==true)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

#define fstinpt     ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll          long long
#define sn          1010
#define bn          1000007
#define M           1000000007
#define iii(i)      cin>>i
#define ooo(i)      cout<<i
#define sss         cout<<" "
#define nnn         cout<<"\n"
//#define cin(i)      cin>>i
//#define cout(i)      cout<<i
//#define sss         cout<<" "
//#define nnn         cout<<"\n"




int main()
{
        string a,b; iii(a>>b);
        ll sz = a.size(),c = 0;
        for(ll i = 0; i < sz; i++)
        {
                if(a[i] != b[i]) c++;
        }
        ooo(c);
        return 0;
}



/*






*/






















/**/


Measured memory_bytes: 3916
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine.toInt

  val ans = {
    var dp = Array.ofDim[Long](n+1)
    dp(0) = 2L
    dp(1) = 1L
    for(i <- 2 to n){
      dp(i) = dp(i-1) + dp(i-2)
    }
    dp(n)
  }

  println(ans)
}

Measured memory_bytes: 27080
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    string result;
    rep(i, s.size())
    {
        result.push_back((s[i] - 'A' + n) % 26 + 'A');
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	
	int h,a;cin >> h >> a;
	cout << (ll)ceil(h/(ld)a);
	return 0;
}


Measured memory_bytes: 892
q, h, s, d = map(int, input().split())
n = int(input())
q1 = q / 0.25
h1 = h / 0.5
s1 = s / 1
d1 = d / 2
minx = min(q1, h1, s1, d1)
a = [[q1, 0.25], [h1, 0.5], [s1, 1], [d1, 2]]
a.sort()
if n % 2 != 0 and a[0][1] == 2:
    print(int((n - 1) // 2 * d) + int(a[1][0]))
else:
    if minx == d1:
        print(int(d * n // 2))
    else:
        print(int(minx * n))

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

int main(void){
    int a, b, c, x, i, j, k, re, result;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    
    re = 0;
    result = 0;
    
    for(i = 0; i < a + 1; i++){
        for(j = 0; j < b + 1; j++){
            for(k = 0; k < c + 1; k++){
                re = 500 * i + 100 * j + 50 * k;
                if(re - x == 0){
                    result++;
                }
            }
         }
    }
    printf("%d\n", result);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main() {
	int n;
	int even = 0, count = 0;
	int a[100000], b[100001] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		b[a[i]]++;
	}
	for (int i = 0;i <= 100000; i++) {
		if (b[i] != 0){
			count++;
				if (b[i] % 2 == 0) {
					even++;
			}
		}
	}
	if (even % 2 == 0) {
		cout << count << endl;
	}
	else {
		cout << count - 1 << endl;
	}
	return 0;

}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
#include<stack>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

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

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

int main(void){
  int n;
  while(cin>>n,n){
    
    vector<int> vec(n);
    rep(i,n)cin>>vec[i];
    int ans=1000000;
    vector<int> f,s;
    rep(j,1<<n){
      int a=0,b=0;
      rep(i,n){
	//cout<<j<<endl;
	if((j>>i)%2)a+=vec[i];
	else b+=vec[i];
      }
      ans= min(ans,abs(a-b));
      //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    
    

    
  }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
long long h, w, n, r, c, ans;
long long f[200005], rev[200005];
long long mod=1000000007;
long long fastpowering(long long a, long long b){
	long long solv=1;
	while (b){
		if (b&1){solv*=a; solv%=mod;}
		a*=a; a%=mod; b>>=1;
	}
	return solv;
}
void findfact(){
	f[0]=1;
	for (int i=1; i<=200003; i++)
		f[i]=(f[i-1]*i)%mod;
	for (int i=0; i<=200003; i++)
		rev[i]=fastpowering(f[i], mod-2);
}
long long perm(long long a, long long b){
	long long solv=f[a];
	solv = (solv*rev[b])%mod;
	solv = (solv*rev[a-b])%mod;
	return solv;
}
pair<long long, long long> xx[3005];
long long dp[3005];
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
	cin >> h >> w >> n; findfact();
	ans = perm(h+w-2, h-1); 
	for (int i=0; i<n; i++){
		cin >> r >> c;
		xx[i] = make_pair(r, c);
	} sort(xx, xx+n);
	for (int i=0; i<n; i++){
		r = xx[i].first; c = xx[i].second;
		dp[i] = perm(r+c-2, r-1);
		for (int j=0; j<i; j++){
			if (c>=xx[j].second){
				dp[i] -= dp[j]*perm(r+c-xx[j].first-xx[j].second, r-xx[j].first);
				dp[i]%=mod; if (dp[i]>0) dp[i]+=mod;
			}
		}
	}
	for (int i=0; i<n; i++){
		r = xx[i].first; c = xx[i].second;
		ans -= dp[i]*perm(h+w-r-c, h-r);
		ans%=mod; if (ans<0) ans+=mod;
	} 
	cout << ans;
return 0;
}


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

#define int long long  

using namespace std;

int N, W, dp[100005], ans, u[100005], s, w[105], c[105];

main(){
	cin >> N >> W;
	for(int i = 1; i <= N; i++){
		cin >> w[i] >> c[i];
		s += c[i];
	}
	for(int i = 1; i <= N; i++){
		u[0] = 1;
		for(int j = s; j >= 0; j--){
			if(u[j] == 1 && j + c[i] <= s){
				u[j + c[i]] = 1;
				if(dp[j + c[i]] == 0) dp[j + c[i]] = dp[j] + w[i];
				else dp[j + c[i]] = min(dp[j] + w[i] , dp[j + c[i]]);
				if(dp[j + c[i]] <= W)ans = max(ans, j + c[i]);
			}
		}            
	}
	cout << ans;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	/*
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
	}
	*/
	cout << int(ceil(double(n - 1) / double(k - 1))) << endl;
	return 0;
}



Measured memory_bytes: 256
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false
using namespace std;

ll bmm(ll a, ll b) {
	if (b == 0) return a;
	else return bmm(b, a%b);
}
ll kmm(ll a, ll b) {
	return(a*b) / bmm(a, b);
}


const ll mod = 1e9 + 7;
const ll MAXN = 3e5+5;

ss s;
bft;
int main() {
	isc;
	cin >> s;
	rep(i,0,s.size() && f){
		if(i%2==0){
			if(s[i]=='L')
				f=false;
		}
		else{
			if(s[i]=='R')
				f=false;
		}
	}
	if(f)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}



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

template<size_t max_N, size_t prime_size>
struct Prime{
    bool sieve[max_N];
    int_fast64_t prime[prime_size];
    size_t counter = 0;
    constexpr Prime() : sieve(), prime() {
        for(int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        sieve[0] = sieve[1] = false;
        for(int_fast64_t i = 2; i < max_N; ++i){
            if(sieve[i]){
                prime[counter] = i;
                ++counter;
                if(counter >= prime_size)break;
            }
            for(int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
    }
    constexpr int_fast64_t operator[](size_t i) const{
        return i < counter ? prime[i] : prime[counter - 1];
    }
};

constexpr Prime<8831, 1000> p = Prime<8831, 1000>();

constexpr int_fast64_t gcd(int_fast64_t a, int_fast64_t b){
    int_fast64_t t(0);
    while(b){
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

constexpr int_fast64_t lcm(int_fast64_t a, int_fast64_t b){
    return a / gcd(a, b) * b;
}

constexpr int_fast64_t lcm(int_fast64_t a, int_fast64_t b, int_fast64_t c, int_fast64_t d){
    return lcm(lcm(a, b), lcm(c, d));
}

struct Ans{
    int_fast64_t ans[502][502];
    constexpr size_t v(size_t i){
        return i & 1 ? i / 2 : 999 - i / 2;
    }
    constexpr Ans() : ans(){
        for(size_t i = 0; i < 501; ++i){
            ans[i][0] = 1;
            ans[501][i] = 1;
            ans[i + 1][501] = 1;
            ans[0][i + 1] = 1;
        }
        for(size_t i = 1; i <= 500; i += 2)
            for(size_t j = 1; j <= 500; j += 2){
                ans[i][j] = p[v((i + j - 2) / 2)] * p[v((1500 + i - j) / 2)];
                if(i < 500 && j < 500)ans[i + 1][j + 1] = p[v((i + j) / 2)] * p[v((1500 + i - j) / 2)];
            }
        for(size_t i = 1; i < 500; i += 2)
            for(size_t j = 1; j < 500; j += 2){
                ans[i + 1][j] = lcm(ans[i][j], ans[i + 2][j], ans[i + 1][j + 1], ans[i + 1][j - 1]) + 1;
                ans[i][j + 1] = lcm(ans[i][j], ans[i][j + 2], ans[i + 1][j + 1], ans[i - 1][j + 1]) + 1;
            }
    }
    constexpr int_fast64_t at(size_t i, size_t j)const{
        return ans[i + 1][j + 1];
    }
};

constexpr Ans a = Ans();
int_fast64_t N;

int main(){
    scanf("%lld", &N);
    for(size_t i = 0; i < N; ++i){
        for(size_t j = 0; j < N; ++j)printf("%lld ", a.at(i, j));
        puts("");
    }
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n;
    cin>>n;
    vi v;
    rep(i,0,n)
    {
        ll x;
        cin>>x;
        v.pb(x);
    }
    vi v1;
    rep(i,0,n)
    {
        ll x;
        cin>>x;
        v1.pb(x);
    }
    reverse(all(v1));
    ll x=0,c=0;
    vi p1;
    rep(i,0,n)
    {
        if(v[i]==v1[i])
        {
            x=v[i];
            p1.pb(i);
        }
    }
    vi p2;
    rep(i,0,n)
    {
        if(v[i]!=x&&v1[i]!=x)
        {
            p2.pb(i);
        }
    }
    if(p1.size()>p2.size())
    {
        cout<<"No"<<endl;
        return;
    }
    cout<<"Yes"<<endl;
    if(p1.size()==0)
    {
        for(auto u:v1)
            cout<<u<<" ";
        return;
    }
    rep(i,0,p1.size())
    {
        swap(v1[p1[i]],v1[p2[i]]);
    }
    for(auto u:v1)
        cout<<u<<" ";

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    time
    return 0;
}

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

int main() {
  int H, N;
  cin >> H >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int input;
    cin >> input;
    sum += input;
  }
  if (H > sum) {
    cout << "No";
  } else {
    cout << "Yes";
  }
}




Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	
	while (b <= a)
	{
		if (k > 0)
		{
			b *= 2;
			k--;
		}
		else
		{
			cout << "No";
			return 0;
		}
	}
	while (c <= b)
	{
		if (k > 0)
		{
			c *= 2;
			k--;
		}
		else
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3584
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;
const int MAX_DIGIT = 50;
ll dp[100][2];

int main(){
  int N; ll K; cin >> N >> K;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  
  memset(dp,-1,sizeof(dp));
  dp[0][0] = 0;
  for(int d = 0; d < MAX_DIGIT; d++){
    ll mask = 1LL << (MAX_DIGIT - d - 1);
    
    int num = 0;
    rep(i,N) if(A[i] & mask) num++;
    
    ll cost0 = mask * num;
    ll cost1 = mask * (N-num);
    
    if(dp[d][1] != -1){
      chmax(dp[d+1][1], dp[d][1] + max(cost0,cost1));
    }
    if(dp[d][0] != -1){
      if (K & mask){
        chmax(dp[d+1][1], dp[d][0] + cost0);    
      }
    }
    if(dp[d][0] != -1){
      if (K & mask){
        chmax(dp[d+1][0], dp[d][0] + cost1);
      }else chmax(dp[d+1][0], dp[d][0] + cost0);
    }
  }
  
  cout << max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]) << endl;
  
  return 0;
}

Measured memory_bytes: 1024
int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  int i, check[n], flg[n];
  for (i = 0; i < n; i++)
  {
    check[i] = 0;
    flg[i] = 0;
  }
  
  int p[m], clear = 0, sum = 0;
  char s[m][3];
  for (i = 0; i < m; i++)
  {
    scanf("%d %s", &p[i], &s[i]);
    
    if (strcmp(s[i], "AC") == 0 && flg[p[i] - 1] == 0)
    {
      sum += check[p[i] - 1];
      flg[p[i] - 1] = 1;
      clear++;
    }
    else if (strcmp(s[i], "WA") == 0)
    {
      check[p[i] - 1]++;
    }
  }
  
  printf("%d %d", clear, sum);
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int H, A;
	cin >> H >> A;
	int ans;
	ans = H / A;
	if (H % A != 0)
		ans++;
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int low_elements(int N, vector<int>& P) {
	int cnt = 0;
	vector<int> mn(N + 1);

	mn[0] = N + 1;
	for (int i = 1; i <= N; i++) {
		if (P[i - 1] <= mn[i - 1])
			cnt++;
		mn[i] = min(P[i - 1], mn[i - 1]);
	}

	return cnt;
}

int main() {
	int N;
	cin >> N;
	vector<int> P(N);
	for (int i = 0; i < N; i++)
		cin >> P[i];
	cout << low_elements(N, P);
	return 0;
}

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

char field[44][44];

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

struct NODE{
	int x,y,cost;
};
bool operator < (const NODE &a,const NODE &b){
	return a.cost > b.cost;
}
int main(){
	int W,H;
	cin >> H >> W;
	for(int i = 0 ; i < 50 ; i++)
		for(int j = 0 ; j < 50 ; j++)
			field[i][j] = '#';
	int sx,sy,gx,gy;
	for(int i = 5 ; i < H+5 ; i++){
		for(int j = 5 ; j < W+5 ; j++){
			char c;
			cin >>c;
			field[i][j] = c;
			if( c == 'S' ){
				c = '.';
				sx = j;
				sy = i;
			}else if( c == 'G' ){
				c = '.';
				gx = j;
				gy = i;
			}
		}
	}
	priority_queue<NODE> Q;
	Q.push({sx,sy});
	int done[44][44]={};
	while( Q.size() ){
		NODE q = Q.top(); Q.pop();
		if( done[q.y][q.x]++ ) continue;
		if( q.y == gy && q.x == gx ){
			cout << q.cost << endl;
			return 0;
		}
		for(int i = 0 ; i < 4 ; i++){
			int tx = dx[i] + q.x;
			int ty = dy[i] + q.y;
			if( field[ty][tx] == '#' ) continue;
			if( field[ty][tx] == 'x' ) continue;
			Q.push({tx,ty,q.cost+(field[ty][tx]=='o'?1:2)});
		}
		for(int i = 0 ; i < 4 ; i++){
			for(int k = 1 ; k <= 3 ; k++){
				int tx = dx[i] * k + q.x;
				int ty = dy[i] * k + q.y;
				if( field[ty][tx] == '#' ) break;
				Q.push({tx,ty,q.cost+k+2});
			}
		}
	}
	
}

Measured memory_bytes: 1240
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 100;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,a,b;
    cin >> x >> a >> b;
    if (b <= a) PRINT("delicious");
    else if (b <= a+x) PRINT("safe");
    else PRINT("dangerous");
}


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

const int MAX_N = 2 * 1e5 + 2;

int P[MAX_N], len[MAX_N];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) {
        len[P[i]] = len[P[i] - 1] + 1;
    }
    int max_len = 0;
    for (int i = 1; i <= N; i++) {
        max_len = max(max_len, len[i]);
    }
    cout << N - max_len << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define anuj ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define ll long long int
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%I64d",&x)
#define ss(s)	scanf("%s",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define endl '\n'
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;
const int N = 2e5;
const int LG = 20;
string a[N];

int main(){
	anuj;

	int n,m;
	cin >> n >> m;

	fo(i,n) cin >> a[i];

	ll dp[n][m];

	dp[0][0]=1;
	Fo(i,1,m){
		if(a[0][i]=='#')
			dp[0][i]=0;
		else dp[0][i]=dp[0][i-1];
	}

	Fo(i,1,n){
		if(a[i][0]=='#') dp[i][0]=0;
		else dp[i][0]=dp[i-1][0];
	}

	Fo(i,1,n)
		Fo(j,1,m){
			if(a[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];	
}


Measured memory_bytes: 10624
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    long long a, b;
    std::cin >> a >> b;

    auto xor_value = [](long long n) -> long long {
        switch (n % 4) {
        case 0:
            return n;
        case 1:
            return 1;
        case 2:
            return n + 1;
        case 3:
            return 0;
        }
    };

    std::cout << (xor_value(std::max(0LL, a - 1LL)) ^ xor_value(b)) << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h+2, vector<char>(w+2, '*'));
    rep(i, h)rep(j, w)cin >> s[i+1][j+1];
    int ans = true, now = false;
    REP(i, h){
        REP(j, w){
            if(s[i][j] == '.')continue;
            if(s[i+1][j] == '#') now = true;
            if(s[i-1][j] == '#') now = true;
            if(s[i][j+1] == '#') now = true;
            if(s[i][j-1] == '#') now = true;
            if(!now)ans=false;
            now = false;
        }
    }
    if(ans) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(min([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))

Measured memory_bytes: 31000
#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)
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;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  int N;
  cin >> N;
  ll K;
  cin >> K;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vvi pos(200010);
  rep(i,N) {
    pos[A[i]].push_back(i);
  }
  vl ps;
  ps.push_back(0);
  ll p = 0;
  while(!(p>0&&p%N==0)) {
    int lp = p%N;
    int t = A[lp];
    int k = (upper_bound(rng(pos[t]),lp) - pos[t].begin()) % sz(pos[t]);
    ll np = p;
    np += pos[t][k] - lp;
    if(pos[t][k]<=lp) {
      np += N;
    }
    p = np;
    p++;
    ps.push_back(p);
  }
  ll loop = p/N;
  K %= loop;
  if(K==0) {
    cout << endl;
    return 0;
  }
  int k = lower_bound(rng(ps),K*N) - ps.begin();
  k--;
  vi x;
  ll s = ps[k];
  while(s<K*N) {
    x.push_back(A[s%N]);
    s++;
  }
  map<int,vi> xp;
  
  rep(i,sz(x)) {
    xp[x[i]].push_back(i);
  }
  vi ans;
  rep(l,sz(x)) {
    int k = upper_bound(rng(xp[x[l]]),l) - xp[x[l]].begin();
    if(k==sz(xp[x[l]])) {
      ans.push_back(x[l]);
      continue;
    }
    l = xp[x[l]][k];
  }
  rep(i,sz(ans)) {
    cout << ans[i];
    if(i < sz(ans)-1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 39284
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

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

const int MAX_SIZE = 10000;
const int MAX_PRIME = 1000000;

ll prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
ll p;

const ll INF=10000000000LL;

void erats(){
	// primeXgðú»
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(ll i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i])
			prime[p++] = i;
		else
			continue;
		// Óé¢É©¯é
		for(ll j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
	}
}


void solve(){
	ll A,B;
	cin>>A>>B;
	erats();
	bool isFoxNumber[1000001];
	// ÅãÉÜÁ½wÌY¦
	ll exs[1000001];
	fill(isFoxNumber,isFoxNumber+1000001,true);
	fill(exs,exs+1000001,INF);
	// êÂ¸ÂÝÄ¢­
	ll start=-1;

	ll c2=2*B+1;
	for(ll i = A-B; i <= A+B; i++){
		if(i>=2){
			start=i-A+B;
			break;
		}
		else
			c2--;
	}
	for(ll i = 0; i < p; i++){
		ll pm=prime[i];
		if(pm*pm>A+B)
			break;
		ll ss=start+A-B;
		if(ss%pm!=0){
			ss=((ss+pm)/pm)*pm;
		}
		for(ll j = ss-A+B; j <= 2*B; j+=pm){
			ll n=j+A-B;
			if(!isFoxNumber[j]||n<=0)
				continue;
			if(n%pm!=0)
				continue;
			else{
				ll cnt=0;
				while(1){
					if(n%pm!=0)
						break;
					n/=pm;
					cnt++;
				}
				// ðð½¹È¢
				if(exs[j]<cnt){
					isFoxNumber[j]=false;
					c2--;
				}
				else
					exs[j]=cnt;
			}
		}
	}
	cout<<c2<<endl;
}

int main(){

	solve();

	return 0;
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int H,W;
    string S[52];
    int count=0;
    cin >> H >> W;
    REP(i,H){cin >> S[i];}
    REP(i,H){
        REP(j,W){
            count=0;
            if(S[i][j]=='#'){
                cout << '#';
            }else{
                if(i!=0){
                    if(j!=0){
                        count+=(S[i-1][j-1]=='#')?1:0;
                    }
                    count+=(S[i-1][j]=='#')?1:0;
                    if(j!=W-1){
                        count+=(S[i-1][j+1]=='#')?1:0;
                    }
                  
                }
                
                if(j!=0){
                    count+=(S[i][j-1]=='#')?1:0;
                }
                count+=(S[i][j]=='#')?1:0;
                if(j!=W-1){
                    count+=(S[i][j+1]=='#')?1:0;
                }
                
                if(i!=H-1){
                    if(j!=0){
                        count+=(S[i+1][j-1]=='#')?1:0;
                    }
                    count+=(S[i+1][j]=='#')?1:0;
                    if(j!=W-1){
                        count+=(S[i+1][j+1]=='#')?1:0;
                    }
                }
                cout << count ;
            }
        }
        cout << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int x;
    cin >> x;
    int g = gcd(x, 360);
    int ans = x * 360 / g;
    ans /= x;
    cout << ans << endl;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int aidx = s.size();
  int zidx = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] == 'A') aidx = min(aidx, i);
    if (s[i] == 'Z') zidx = max(zidx, i);
  }
  cout << zidx - aidx + 1 << endl;
  return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int h,w;
	scanf("%d %d",&h,&w);
	char s[55][55];
	int i,j;
	for(i=0;i<h;i++)
	  scanf("%s",s[i]);
	int x;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(s[i][j]=='#')
			  printf("#");
			else
			{
				x=0;
				if(i!=0 && j!=0)
				  if(s[i-1][j-1]=='#')x++;
				if(i!=0)
				  if(s[i-1][j]=='#')x++;
				if(i!=0 && j!=w-1)
				  if(s[i-1][j+1]=='#')x++;
				if(j!=0)
				  if(s[i][j-1]=='#')x++;
				if(j!=w-1)
				  if(s[i][j+1]=='#')x++;
				if(i!=h-1 && j!=0)
				  if(s[i+1][j-1]=='#')x++;
				if(i!=h-1)
				  if(s[i+1][j]=='#')x++;
				if(i!=h-1 && j!=w-1)
				  if(s[i+1][j+1]=='#')x++;
				printf("%d",x);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	s := newSegment(n)
	for i := 1; i < n+1; i++ {
		s.update(0, i, n/i, s.add)
		s.update(1, n%i+1, 1, s.add)
	}
	var ans int64
	for i := k; i < n; i++ {
		ans += int64(s.query(i, 0, s.add))
	}

	fmt.Fprintln(writer, ans)
}

type segment [][]int

func newSegment(n int) segment {
	seg := make(segment, 0)
	for n > 1 {
		seg = append(seg, make([]int, n))
		n = (n + 1) >> 1
	}
	seg = append(seg, make([]int, 1))
	return seg
}
func (seg segment) update(l, r int, v int, f func(int, int) int) {
	for h := 0; h < len(seg) && l < r; h++ {
		if l&1 == 1 {
			seg[h][l] = f(v, seg[h][l])
			l++
		}
		l >>= 1
		if r&1 == 1 {
			seg[h][r-1] = f(v, seg[h][r-1])
		}
		r >>= 1
	}
}
func (seg segment) query(i int, s int, f func(int, int) int) int {
	for h := 0; h < len(seg); h++ {
		s = f(s, seg[h][i>>uint(h)])
	}
	return s
}
func (seg segment) add(x, y int) int {
	return x + y
}


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

#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(s) s.begin(),s.end()
#define vll vector<ll>
#define vi vector<int>
#define vpii vector<pii>
#define vpll vector<pll>
#define vull vector<ull>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define fi first
#define se second
#define sz(x) x.size()
#define cinarr(n,a) for(int i = 0; i < n; i++) cin >> a[i];
#define coutarr(n,a) for(int i = 0; i < n; i++) cout << a[i] << (i+1==n?'\n':' ');
#define fori(i,a,b,x) for(int i = a; i <= b; i+=x)
#define ford(i,a,b,x) for(int i = a; i >= b; i-=x)
#define tc int tt; cin >> tt; for(int cs = 1; cs <= tt; cs++)
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define reset(x,y) memset(x,y,sizeof x);
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define debug(val) cerr << "The value of " << #val << " is = " << val << endl;
#define testing cerr << "--------------------------\n";
const int N=10000000;
ll sieve[N+5];
ll dp[N+5];
 
int main() {
	IOS
	for(ll i = 1; i <= N; i++) {
		for(ll j = 1; i*j <= N; j++) {
			sieve[i*j]++;
		}
	}
	ll n,res=1;
	cin>>n;
	for(ll i = 2; i <= n; i++) {
		res+=i*sieve[i];
	}
	cout<<res<<endl;
}


Measured memory_bytes: 81724