akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Ma = sc.nextInt();
        int Mb = sc.nextInt();
        int[] a = new int[N+1];
        int[] b = new int[N+1];
        int[] c = new int[N+1];
        for(int i=1;i<=N;i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        int[] sa = new int[N+1];
        int[] sb = new int[N+1];
        for(int i=1;i<=N;i++){
            sa[i] = sa[i-1]+a[i];
            sb[i] = sb[i-1]+b[i];
        }
        int sumA = sa[N];
        int sumB = sb[N];
        int[][][] dp = new int[sumA+1][sumB+1][N+1];
        for(int i=0;i<=sumA;i++){
            for(int j=0;j<=sumB;j++){
                for(int k=0;k<=N;k++) dp[i][j][k] = Integer.MAX_VALUE;
            }
        }
        dp[0][0][0] = 0;
        for(int end=1;end<=N;end++){
            for(int front=0;front<end;front++){
                for(int i=0;i<=sa[front];i++){
                    for(int j=0;j<=sb[front];j++){
                        if(dp[i][j][front]<Integer.MAX_VALUE){
                            dp[i][j][end]=Math.min(dp[i][j][end],dp[i][j][front]);
                            dp[i+a[end]][j+b[end]][end] = Math.min(dp[i+a[end]][j+b[end]][end],dp[i][j][front]+c[end]);
                        }
                    }
                }
            }
        }
        int ans = Integer.MAX_VALUE;
        for(int i=1;i<=sumA;i++){
            for(int j=1;j<=sumB;j++){
                if(i*Mb==j*Ma&&dp[i][j][N]<Integer.MAX_VALUE) ans = Math.min(ans,dp[i][j][N]);
            }
        }
        if(ans==Integer.MAX_VALUE) System.out.println(-1);
        else System.out.println(ans);
    }
}


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

int main() {
  int n;
  cin>>n;
  long long int a[n],b[2]={};
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==1)
      b[0]++;
    if(a[i]%4==0)
      b[1]++;
  }
  bool ad=false;
  if(b[0]==0)
    ad=true;
  else if(b[0]<=b[1])
    ad=true;
  else if(b[0]==b[1]+1 && n%2==1)
    ad=true;
  
  if(ad)
    cout<<"Yes";
  else cout<<"No";
  
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    //write code  here
    string K;
    int S;
    cin >> S;
    cin >> K;

    if (K.size() > S){
        string out = K.substr(0,S);
        cout << out << "..." << endl;
    }else {
        cout << K << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMitsui solver = new BMitsui();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMitsui {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a = 0;
            int res = -1;
            while (true) {
                int b = (int) (1.08 * (double) a);
                if (b == n) {
                    res = a;
                    break;
                }
                if (b > n) {
                    break;
                }
                a++;
            }
            if (res == -1) {
                out.println(":(");
            } else {
                out.println(res);
            }
        }

    }
}



Measured memory_bytes: 21716
#include<iostream>

using namespace std;

class UFT{
public:
  int P[10010];//その頂点の親を格納する

  //初めは全ての頂点はバラバラで違うグループに属する
  void init(int N){
    for(int i=0;i<N;i++) P[i]=i;
  }

  int root(int a){
    if(P[a]==a) return a;
    P[a]=root(P[a]);//aの親を辿っていく
    return P[a];
  }

  bool is_same_set(int a,int b){
    return root(a)==root(b);
  }

  void unite(int a,int b){
    //aのルートだったもののルートをbのルートにする
    P[root(a)]=root(b);
  }
};

int main(){
  int N,Q;cin >> N >> Q;
  int com,x,y;
  UFT P;P.init(N);
  for(int i=0;i<Q;i++){
    cin >> com >> x >> y;
    if(com==0){
      P.unite(x,y);
    }else{
      int t=(int)(P.is_same_set(x,y));
      cout << t << endl;
    }
  }
}




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

using namespace std;
#define ll long long
#define ld long double

set<int> s;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n;
    cin >> n;
    cout << (int)ceil(n/2.0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
const int N=200010;
int a[N],b[N],n;
int tmp1[N],tmp2[N];
inline int get(int x){
	int t=lower_bound(tmp2+1,tmp2+n+1,x)-tmp2;
	if (tmp2[t]>=x||t>n) --t;
	return t;
}
int main(){
	n=read();
	for (int i=1;i<=n;++i) a[i]=read();
	for (int i=1;i<=n;++i) b[i]=read();
	int ans=0,mod=0;
	for (int k=1;k<=29;++k){
		mod<<=1,mod|=1;
		for (int i=1;i<=n;++i) tmp1[i]=a[i]&mod,tmp2[i]=b[i]&mod;
		sort(tmp2+1,tmp2+n+1);
		int cnt=0;
		for (int i=1;i<=n;++i){
			int t=get((1<<k)-tmp1[i])-get((1<<(k-1))-tmp1[i])+n-get((1<<k)+(1<<(k-1))-tmp1[i]);
			cnt+=t;
		}
		ans|=(cnt&1)<<(k-1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
N, A, B = map(int, input().split())
X = [1<<20] * 4040
for _ in range(N):
    a, b, c = map(int, input().split())
    t = A*b-B*a
    X = [min(X[i], (0 if (i-t)%4040 == 0 else X[(i-t)%4040]) + c) for i in range(4040)]
print(-1 if X[0] > 1<<18 else X[0])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define deb(x) cout<<#x<<" "<<x
#define pi 3.1415926535
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   int n;
   cin>>n;
   int t;
   int arr[n+1]={0};
   for(int i=1;i<n;i++)
   {cin>>t;arr[t]++;}
   for(int i=1;i<=n;i++)
   cout<<arr[i]<<endl;
    return 0;
}
//make all values ll

Measured memory_bytes: 4404
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

int main()
{ 
    LL a,b,k;
    cin>>a>>b>>k;
    if(k<=a){a=a-k;}
    else{b=b+a-k;a=0;}
    if(b<0){b=0;}

    cout<<a<<' '<<b<<endl;
    return 0;
}

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

int main()
{
    int N,A,B,answer;
    std::cin >> N >> A >> B;
    for(int i = 1; i <= N; i++)
    {
        int n = i;
        int count = 0;
        while(n > 0)
        {
            count += n%10;
            n = (n - n % 10) / 10;
        }
        if(A <= count && count <= B) answer+=i;
    }
    std::cout << answer << std::endl;
    return 0;
}

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

using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define re return
#define fi first
#define mp make_pair
#define se second
#define sz(a) (int)a.size()
#define prev previ
#define tm tmmm
#define div divv
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int ma = 1024 * 1024;
const ll mod = int(1e9) + 7;

string s;
int main() {
	iostream::sync_with_stdio(0), cin.tie(0);
	cin >> s;
	forn (i, 8) s.pop_back();
	cout << s;
}

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


#define ll long long
#define mk make_pair
#define pb push_back


using namespace std;


int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   
   int a,b,c,d;cin>>a>>b>>c>>d;

   int t1 = (a+d-1)/d;
   int t2 = (c+b-1)/b;

   cout << (t1>=t2 ? "Yes" : "No");
   return 0;
}


Measured memory_bytes: 3624
def main():
    n = int(raw_input())
    s = raw_input().strip()
    e = [0] * (n + 1)
    for i, c in enumerate(s):
        e[i+1] = e[i] + (c == 'E')
    ans = n
    x = 0
    for i, c in enumerate(s):
        if ans > x + e[n] - e[i+1]:
            ans = x + e[n] - e[i+1]
        x += c == 'W'
    print ans
main()


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

int main() 
{
    int N;
    cin >> N;
    vector<uint64_t> A(N);
    for(int i=0; i<N; i++)
    {
        cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    if(A.at(0)>=4294967296)
    {
        cout << -1 <<endl;
        return 0;
    }
    if(A.at(0)==0)
    {
        cout << 0 << endl;
    }
    else
    {    
    uint64_t ans=1;
    for(int i=0; i<N; i++)
    {
        ans=ans*A.at(i);
        if(ans>1000000000000000000)
        {
            break;
        }
    }
    if(ans>1000000000000000000)
    {
        cout << -1 <<endl;
    }
    else
    {
        cout << ans << endl;
    }
    }
}

Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
#include<map>
using namespace std;
#define int long long
const int N = 2e5 + 10, inf = 1e9 + 10;
int a[N], ps[N], n, MOD;
map <int , vector <int>> cnt;
 
int32_t main()
{
    cin >> n >> MOD;
    cnt[0].push_back(0);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i], a[i]--;
        ps[i] = (ps[i - 1] + a[i]) % MOD;
        int x = upper_bound(cnt[ps[i]].begin(), cnt[ps[i]].end(), i - MOD) - cnt[ps[i]].begin();
        ans += (int)cnt[ps[i]].size() - x;
        cnt[ps[i]].push_back(i);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; 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;
  }
}

// 二項係数計算
long long 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;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  bool flag = true;
  for(int i=0;i<n/2;i++){
    if(s[i] != s[i+n/2]){
      flag = false;
      break;
    }
  }
  cout << (flag?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	string s;
	cin >> s;
	ll ans=0,num=0;
	ll c1=0,c2=0;
	for(ll i=0;i<s.length();i++)
	{
		if(s[i]=='<')
		{
			while(s[i]=='<' && (i<s.length()))
			{
				c1+=1;
				i++;
				num+=1;
			}
			ans+=(c1*(c1+1))/2;
		}
		// cout << ans << " ";
		c1=0;
		ll x;
		if(s[i]=='>')
		{
			x=i;
			while(s[i]=='>'&& (i<s.length()))
			{
				c2+=1;
				i++;
			}
			ans+=(c2*(c2+1))/2;
			if(c2>num)
				ans-=num;
			if(c2<=num)
				ans-=c2;
			num=0;
		}
		c2=0;
			i--;
	}
	cout << ans;
}


Measured memory_bytes: 900
s = input()
q = int(input())
#+---+---+---+---+---+---+
#| P | y | t | h | o | n |
#+---+---+---+---+---+---+
#0   1   2   3   4   5   6
#-6  -5  -4  -3  -2  -1
for i in range(0, q):
  l = list(input().split())
  a = int(l[1])
  b = int(l[2]) + 1
  if l[0] == "print":
    print(s[a: b])
  elif l[0] == "reverse":
    rev = s[a: b]
    rev = rev[::-1]
    s = s[:a] + rev + s[b:]
  else:
    s = s[:a] + l[3] + s[b:]



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, M; cin >> N >> M;
    vector<string> A(N);
    REP(i, N) cin >> A[i];
    vector<string> B(M);
    REP(i, M) cin >> B[i];

    REP(y, N) {
        if (y + M > N) break;
        REP(x, N) {
            if (x + M > N) break;
            bool ok = true;
            REP(i, M) {
                if (A[y + i].substr(x, M) != B[i]) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, h;
	cin >>n >>h;
	vector<pii> vp(n);
	rep(i, n) cin >>vp[i].second >>vp[i].first;
	
	sort(vp.rbegin(), vp.rend());
	int mxi = 0;
	rep(i, n) if(vp[mxi].second < vp[i].second) mxi = i;
	int qa = vp[mxi].second;

	int ans = 0;
	for(auto z: vp){
		if(z.first > qa){
			ans++;
			h -= z.first;
			if(h <= 0) break;
		}
	}
	if(h>0){
		ans += (h + qa -1)/ qa;
	}
	cout <<ans <<"\n";

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  int s[N], tot=0;
  rep(i,N) {
    cin >> s[i];
    tot += s[i];
  }
  if (tot%10!=0) cout << tot << endl;
  else {
    sort(s,s+N);
    bool found = false;
    rep(i,N) {
      if (s[i]%10!=0) {
        tot -= s[i];
        found = true;
        break;
      }
    }
    if (found) cout << tot << endl;
    else cout << 0 << endl;
  }

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define ff          first
#define ss          second
#define mem(a,val)  memset(a, val, sizeof(a))
#define md          1000000007
#define pi          acos(-1.0)

ll a[200010];
map<ll,ll>m;
vector<ll>v;
string s,q;

int main()
{
    ll t,n,i,j,k,l,mn=0, mx=0;
    sl(n);
    //n=100;
    ll cnt=0, cc=0;
    for(int i=1; i*i<=n; i++)
    {
        for(int j=i; j*i<=n; j++)
        {
            if(j*i!=n && j*i<n)
            {
                if(j==i) cc++;
                cnt++;
            }
        }
    }
    cout<<(cnt*2)-cc<<endl;
}




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

int main() {
  int N, K;
  cin >> N >> K;
  
  int count=0;
  vector<int> sunuke(N,0);
  for (int i=0; i<K; i++){
    int num;
    cin >> num;
    for (int j=0; j<num; j++){
      int who;
      cin >> who;
      sunuke.at(who-1)++;
    }
  }
  
  for (int i=0; i<N; i++){
    if(sunuke.at(i)==0){
      count++;
    }
  }  
  cout << count << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        sc.close();

        int cnt = 0;
        int ans = 0;

        for (int i = 1; i <= n; i += 2) {
            cnt = 0;
            for (int j = 1; j <= i; j += 2) {
                if (i % j == 0) {
                    cnt++;
                }
            }
            if (cnt == 8) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define PB push_back
#define MP make_pair
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

constexpr int INF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 100005;
constexpr int dx[] = { 0, 1, 0, -1 };
constexpr int dy[] = { 1, 0, -1, 0 };

int flg[MAX_N];

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

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        flg[t] = true;
    }

    int ans = 0;
    for (int i = 1; i < MAX_N; ++i) {
        if (flg[i]) ans++;
    }

    if (ans % 2) cout << ans << endl;
    else cout << ans - 1 << endl;
}

Measured memory_bytes: 1024
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> w(n);
  rep(i, n)cin >> w[i];
  int ld = 0, rd = inf;
  while(rd - ld > 1){
    int md = (ld + rd) / 2;
    ll curr = 0;
    int cnt = 1;
    for(int i = 0; i < n; i++){
      if(w[i] > md)cnt += k;
      if(curr + w[i] > md){
        curr = 0;
        cnt++;
      }
      curr += w[i];
    }
    if(cnt <= k)rd = md;
    else ld = md;
  }
  cout << rd << endl;
	return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

const int maxN = 100005;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};


class SegmentTree {
public:
	vector<int> maxi;

	SegmentTree(){
	}

	void prepare(int n){
		maxi.assign(4*n, 0);
	}

	void update(int b, int e, int index, int i, int val){
		if(b > i or e < i){
			return;
		}
		if(i <= b and e <= i){
			maxi[index] = val;
		}else{
			int mid = (b+e)/2, le = 2*index + 1, ri = le + 1;
			update(b, mid, le, i, val);
			update(mid+1, e, ri, i, val);
			maxi[index] = max(maxi[le], maxi[ri]);
		}
	}

	int query(int b, int e, int index, int i, int j){
		if(b > j or e < i){
			return 0;
		}
		if(i <= b and e <= j){
			return maxi[index];
		}
		int mid = (b+e)/2, le = 2*index + 1, ri = le + 1;
		int ans = query(b, mid, le, i, j);
		ans = max(ans, query(mid+1, e, ri, i, j));
		return ans;
	}

};

class TaskF {
private:
	Debugger debugger;
	vector<int> values;
	vector<pair<int,int>> uniques;
	int n;
	SegmentTree st;
	vector<vector<int>> graph;
	vector<int> ans;

	void dfs(int u, int parent = -1){
		int pos = lower_bound(uniques.begin(), uniques.end(), make_pair(values[u], -1) ) - uniques.begin();
		int maxi = (pos > 0 ? st.query(0, n-1, 0, 0, pos-1) : 0 );
		int realPos = lower_bound(uniques.begin(), uniques.end(), make_pair(values[u], u) ) - uniques.begin();
		st.update(0, n-1, 0, realPos, maxi + 1);
		ans[u] = st.maxi[0];

		for(int nxt : graph[u]){
			if(nxt == parent){
				continue;
			}
			dfs(nxt, u);
		}
		st.update(0, n-1, 0, realPos, 0);
	}

public:
	void solveOne(int it){
		cin >> n;
		values.assign(n, 0);
		for(int i = 0; i < n; i++){
			cin >> values[i];
			uniques.push_back({values[i], i});
		}
		sort(uniques.begin(), uniques.end());
		st.prepare(n);

		graph.assign(n, vector<int>());
		for(int i = 0; i < n-1; i++){
			int x , y;
			cin >> x >> y;
			x--; y--;
			graph[x].push_back(y);
			graph[y].push_back(x);
		}
		ans.assign(n, 0);
		dfs(0);
		for(int i = 0; i < n; i++){
			cout << ans[i] << endl;
		}
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskF solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 46096
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
  int a,b,c,k,ans;
  cin>>a>>b>>c>>k;
  if(k<=a)
    ans=k;
  else if(k<=(a+b))
    ans=a;
  else
    ans=a-(k-a-b);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<map>

using namespace std;

int i,j,k,N,ans,u;
char S[30001];

int memo[4][30001][1000]={0};



int main()
{
  cin >> N >> S;
  
  memo[0][0][0]=1;
  
  for(i=0;i<4;i++)
  {
    for(j=0;j<N;j++)
    {
      for(k=0;k<1000;k++)
      {
        if(memo[i][j][k]==1)
        {
          memo[i][j+1][k]=1;
          if(i<3)
          {
            u=S[j]-'0';
            memo[i+1][j+1][10*k+u]=1;  
          }
        }
        
      }
    }
  }
  
  ans=0;
  for(i=0;i<1000;i++)
  {
    ans+=memo[3][N][i];
  }
  
  cout <<ans;

    
  return 0;
}

Measured memory_bytes: 468992
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int R, B, G, N;

void solve() {
	cin >> R >> B >> G >> N;
	ll res = 0;
	rep(i, 0, N + 1) {
		rep(j, 0, N + 1) {
			int v = N - R * i - B * j;
			if(v < 0) continue;
			if(v % G == 0) res++;
		}
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)

ll H,W;
char grid[55][55];


int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>H>>W;

rep(i,H){
	rep(j,W){
		cin>>grid[i][j];
	}
}
rep(i,H){
	rep(j,W){
		if(grid[i][j]=='#'){
			ll ok1=1;
			ll ok2=1;
			ll ok3=1;
			ll ok4=1;
			if(i-1>=0) if(grid[i-1][j]=='#') ok1=0;
			if(j-1>=0) if(grid[i][j-1]=='#') ok2=0;
			if(j+1<W) if(grid[i][j+1]=='#') ok3=0;
			if(i+1<H) if(grid[i+1][j]=='#') ok4=0;
			if(ok1*ok2*ok3*ok4){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
}
cout<<"Yes"<<endl;

}
	


Measured memory_bytes: 256
# datas = list(map(int, input().split()))

# # min
# small = min(datas)

# # max
# large = max(datas)

# for data in datas:
#     if small == data:
#         continue
#     elif large == data:
#         continue
#     else:
#         mid = data

# print("{0} {1} {2}".format(small, mid, large))

datas = list(map(int, input().split()))
sorted_datas = sorted(datas)

print("{0} {1} {2}".format(sorted_datas[0], sorted_datas[1], sorted_datas[2]))



Measured memory_bytes: 5592
#include <iostream> 

using namespace std;

int main() {
	int N,L;
	cin >> N >> L;
	int ans = 0;
	if(L>=0){
		for(int i=1;i<N;i++){
			ans += L+i;
		}
		cout << ans;
	}
	else if(L+N <= 0){
		for(int i=0;i<N-1;i++){
			ans += L+i;
		}
		cout << ans;
	}
	else{
		for(int i=0;i<N;i++){
			ans += L+i;
		}
		cout <<ans;
	}
}

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

int main(){
  int a,b,c,cheapest ; cin >>a>>b>>c;
  cheapest = a+b;
  if (cheapest > b+c){
    cheapest = b+c;
  }
  if (cheapest > a+c){
    cheapest = a+c;
  }
  cout << cheapest <<endl;
}


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

const int N=2e5+20;

int n,q,t,u,v,c;

int main()
{
	scanf("%d%d",&n,&q);
	auto dsa=dsu(n);
	while(q--)
	{
		scanf("%d%d%d",&t,&u,&v);
		if(t==0) dsa.merge(u,v);
		else printf("%d\n",dsa.same(u,v));
	}
}

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

using i64 = int64_t;

int main(){
    i64 m;
    cin >> m;
    i64 sum = 0, digits = 0;
    for(int i=0;i<m;++i){
        i64 d, c;
        cin >> d >> c;
        digits += c;
        sum += d*c;
    }

    cout << (digits - 1) + (sum-1) / 9 << endl;

    return 0;
}


Measured memory_bytes: 256
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1),i=new(r(2))(n.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));r(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3);t.exports=class{constructor(t){this.inp=new n(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){var e=t.in(),r=new Array(e+1).fill(9999999999);r[e]=0;for(var n=1,i=[];6*n<=e;)n*=6,i.push(n);for(var o=1,s=[];9*o<=e;)o*=9,s.push(o);for(var u=i.length,c=s.length,a=e;a>0;a--){var f=r[a]+1;r[a-1]=Math.min(r[a-1],f);for(var l=0;l<u&&!(i[l]>a);l++)r[a-i[l]]=Math.min(r[a-i[l]],f);for(var p=0;p<c&&!(s[p]>a);p++)r[a-s[p]]=Math.min(r[a-s[p]],f)}console.log(r[0])}}]);

Measured memory_bytes: 9788
#include<stdio.h>
#include<stdlib.h>
#include<stdarg.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define reps(i,n,k) for((i)=0;(i)<(n);(i)+=(k))
#define MOD ((int)1e9+7)
#define INF INFINITY
typedef long long ll;
typedef unsigned long long ull;
typedef struct pair_{int x,y;}pair_t;
void swap(int *x, int *y){int t=*x;*x=*y;*y=t;}
void debug(char *f, ...){va_list a;va_start(a,f);vfprintf(stderr,f,a);va_end(a);}
int asc_cmp(const void *x, const void *y){int X=*((int*)x),Y=*((int*)y);if(X<Y)return -1;else if(X>Y)return 1;else return 0;}
int desc_cmp(const void *x, const void *y){int X=*((int*)x),Y=*((int*)y);if(X<Y)return 1;else if(X>Y)return -1;else return 0;}

int main(){
    int a,b,c,d;scanf("%d %d %d %d",&a,&b,&c,&d);
    while(1){
       
        c-=b;
        if(c<=0){
            printf("Yes\n");
            return 0;
        }
         a-=d;
        if(a<=0){
            printf("No\n");
            return 0;
        }
    }

}


Measured memory_bytes: 1644
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

constexpr int INF = 1e9;

struct pos {
    int dir;
    int y, x;
    bool operator<(pos const& p) const {
        return dir < p.dir;
    }
};

using P = pair<int, pos>;

int main() {
    int w, h;
    while(cin >> w >> h, w) {
        vector<vector<vector<int>>> d(4, vector<vector<int>>(h, vector<int>(w, INF)));
        vector<vector<int>> s(h, vector<int>(w));
        int c[4] = {};
        for(int i=0; i<h; ++i) {
            for(int j=0; j<w; ++j) {
                cin >> s[i][j];
            }
        }
        for(int i=0; i<4; ++i) {
            cin >> c[i];
        }
        d[0][0][0] = 0; // 0 -> east, 1 -> south, 2 -> west, 3 -> north 
        priority_queue<P, vector<P>, greater<P>> que;
        que.push(P{0, pos{0, 0, 0}});
        int dx[4] = {1, 0, -1, 0},
            dy[4] = {0, 1, 0, -1};
        while(!que.empty()) {
            P p = que.top(); que.pop();
            pos pp = p.second;
            if(d[pp.dir][pp.y][pp.x] < p.first) {
                continue;
            }
            // 0 -> straight, 1 -> right, 2 -> turn, 3 -> left
            for(int op=0; op<4; ++op) {
                int ndir = (pp.dir+op)%4;
                int ny = pp.y + dy[ndir], nx = pp.x + dx[ndir];
                if(ny < 0 || h <= ny || nx < 0 || w <= nx) {
                    continue;
                }
                if(s[pp.y][pp.x] == op) {
                    if(d[ndir][ny][nx] > p.first) {
                        d[ndir][ny][nx] = p.first;
                        que.push(P{p.first, pos{ndir, ny, nx}});
                    }
                } else {
                    if(d[ndir][ny][nx] > p.first + c[op]) {
                        d[ndir][ny][nx] = p.first + c[op];
                        que.push(P{p.first + c[op], pos{ndir, ny, nx}});
                    }
                }
            }
        }
        int res = INF;
        for(int i=0; i<4; ++i) {
            res = min(res, d[i][h-1][w-1]);
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll double
#define endl '\n'
#define pi 3.14159265
int n;
ll p[3001];
ll dp[3001][3001];
ll f(int i,int head)
{
   if(i==n)
    return 1;
    if(dp[i][head]!=3)
        return dp[i][head];
    ll odd=i-head;
    if(odd==n/2)
    {
        dp[i][head]=f(i+1,head+1)*p[i];
        return dp[i][head];
    }
    dp[i][head]=f(i+1,head)*(1-p[i])+f(i+1,head+1)*p[i];
    return dp[i][head];
}
int main()
{
    IOS;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>p[i];
    for(int i=0;i<=3000;i++)
        for(int j=0;j<=3000;j++)
            dp[i][j]=3;
    cout<<fixed<<setprecision(10);
    cout<<f(0,0);
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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(a > b) { a = b; return true; } return false; }

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll a, b, x; cin >> a >> b >> x;
    if(a == 0) cout << b/x + 1 << endl;
    else cout << b/x - (a-1)/x << endl;
}

Measured memory_bytes: 3652
num=[int(e) for e in input().split()]
A=str(num[0])
B = str(num[1])

if num[0]>=num[1]:
  for i in range(num[0]-1):
    B+=str(num[1])
  print(B)
else:
  for i in range(num[1]-1):
      A+=str(num[0])
  print(A)


Measured memory_bytes: 2940
# -*- coding:utf-8 -*-
import math
import sys

line = input().split(' ')
N = int(line[0])
A = int(line[1])
B = int(line[2])
hn = sorted([int(input()) for i in range(N)])

maxT = int(hn[-1] / B) + 1
minT = 0

def enough(T):
    count = sum([math.ceil((h - B*T) / (A-B)) if math.ceil((h - B*T) / (A-B)) >= 0 else 0 for h in hn])
    return True if count <= T else False

while True:
    med = int((maxT + minT) / 2)
    if enough(med):
        maxT = med
    else:
        minT = med
    if maxT - minT <= 1:
        break
print(maxT)


Measured memory_bytes: 10960
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

long long dp[100005][3],vet[100005][3],n;

long long rec (long long dia, long long usado){
    if(dp[dia][usado]>-1) return dp[dia][usado];
    if(usado>2) return -1000000007;
    if(dia>=n) return 0;
    return dp[dia][usado]=vet[dia][usado]+max(rec(dia+1,(usado+1)%3),rec(dia+1,(usado+2)%3));
}
 
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    long long m,p=0,i,j;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            cin>>vet[i][j];
        }
    }
    cout<<max(rec(0,0),max(rec(0,1),rec(0,2)))<<endl;
}

Measured memory_bytes: 14520
#include<iostream>
using namespace std;
int main() {
	int pay[6] = { 500,100,50,10,5,1 };
	while (true) {
		int a = 0, b = 0;
		cin >> a;
		if (a == 0) break;
		a = 1000 - a;
		for (int i = 0; i < 6; ++i) {
			b = b + a / pay[i];
			a = a%pay[i];
		}
		cout << b << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  string s;
  cin>>s;
  int n=s.size();
  int sum=0;
  for(char c:s) sum+=(c=='g'?1:-1);
  int mn=sum,re=0;
  rrep(i,n){
    sum-=(s[i]=='g'?1:-1);
    if(s[i]=='g' && mn>=2){
      //cout<<i<<endl;
      ++re;
      mn-=2;
    }
    MN(mn,sum);
  }
  cout<<re<<endl;
  return 0;
}


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

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

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    vector<VL> pref(n+2,VL(60,0));
    VL arr(n);
    fr(i,0,n)
    {
        cin>>arr[i];
        ll x=arr[i];
        fr(j,0,60)
        {
            if(x&(1LL<<j))
            {
                pref[i+1][j]=1;
            }
        }
    }
    fr(j,0,60)
    {
        frr(i,n+1,1)
        {
            pref[i][j]+=pref[i+1][j];
        }
    }
    ll ans=0;

    fr(i,0,n-1)
    {
        //cin>>arr[i];
        ll x=arr[i];
        ll rem=n-(i+1);
        fr(j,0,60)
        {
            if(x&(1LL<<j))
            {
                ans+=(powerm(2,j)*(rem-pref[i+2][j])%mod);
                //scout<<x<<' '<<j<<endl;
            }
            else
            {
                ans+=(powerm(2,j)*(pref[i+2][j])%mod);
            }
            ans%=mod;
        }
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 157908
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define int long long
#define MAX         2000000000000000000
#define re(i,x,n) for(i=x;i<=n;i++)
typedef long long ll;
using namespace std;
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vi graph[200001];
int vis[200001] = {0};
int cost[100001];
int parent = -1;
int costi ;
void dfs(int i)
{
	vis[i] = 1;
	costi = min(cost[i], costi);
	//cout << costi << endl;
	for (auto &it : graph[i])
	{
		if (vis[it] == 0) {

			dfs(it);

		}
	}

}
int pp[100001];
bool isPrime(int n)
{
	int i;
	for (i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
			return false;
	}
	return true;
}
//
int32_t main()
{
	//c_p_c();
	int x, y;
	cin >> x >> y;
	int i;
	string res = "No";
	for (i = 0; i < x + 1; i++)
	{
		int j = x - i;
		if (2 * i + 4 * j == y) {
			res = "Yes";
			break;
		}
	}
	cout << res;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
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() {
  ll N, K;
  cin >> N >> K;
  ll ans;
  if(K % 2 != 0){
    ll knpk = N / K;
    ans = knpk * knpk * knpk;
  }else{
    ll knpk = N / K;
    ll wsgh = (N + (K / 2)) / K;
    ans = knpk * knpk * knpk + wsgh * wsgh * wsgh;
  }

print(ans);
}


Measured memory_bytes: 256