akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int k;
	string s;
	cin >> k;
	vector<int> es(k, 0);
	vector<int> ws(k, 0);
	cin >> s;
	for (int i = 0; i < k; i++) {
		if (s[i] == 'W') {
			if (i == 0) ws[i] = 1;
			else ws[i] = ws[i - 1] + 1;
		}
		else {
			if (i == 0) ws[i] = 0;
			else ws[i] = ws[i - 1];
		}
	}
	for (int i = k - 1; i >= 0; i--) {
		if (s[i] == 'E') {
			if (i == k - 1) es[i] = 1;
			else es[i] = es[i + 1] + 1;
		}
		else {
			if (i == k - 1) es[i] = 0;
			else es[i] = es[i + 1];
		}
	}
	int ans = INT32_MAX;
	for (int i = 0; i < k; i++) {
		ans = min(ans, ws[i] - 1 + es[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3204
import math


def main():
    A, B, N = map(int, input().split())

    def target(x):
        # print(math.floor(A * x / B))
        # print(A * math.floor(x / B))
        return math.floor(A * x / B) - A * math.floor(x / B)

    print(target(min(N, B-1)))

    # B_A = 1.0 * B / A
    #
    # max_value = -1
    # for i in range(1, int(B / B_A) + 3):
    #     x = int(B_A * i)+1
    #     if x > N:
    #         break
    #     v = target(x)
    #     # print(f'x={i} f(x)={v}')
    #     if v > max_value:
    #         max_value = v
    #
    #     x_2 = int(B_A * i)
    #     if x_2 > N:
    #         break
    #     v = target(x_2)
    #     # print(f'x={i} f(x)={v}')
    #     if v > max_value:
    #         max_value = v
    #
    #     x_3 = int(B_A * i) -1
    #     if x_3 > N:
    #         break
    #     v = target(x_3)
    #     # print(f'x={i} f(x)={v}')
    #     if v > max_value:
    #         max_value = v
    #
    # print(max_value)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
	ll n;
	scanf("%lld", &n);
	ll dap = 0;
	for (ll i = 1; i<= n; i++) {
		if ((n - i) / i <= i)break;
		if ((n - i) % i == 0) {
			dap += (n - i)/i;
		}
	}
	printf("%lld\n", dap);
}

Measured memory_bytes: 256
from itertools import product

N=int(input())
S=input()
t=["0","1","2","3","4","5","6","7","8","9"]

u=product(t,repeat=3)
ans=0

for com in u:
  x_flag=False
  y_flag=False
  x=com[0]
  y=com[1]
  z=com[2]
    
  for i in range(N):
    if S[i]==x:
      x_flag=True
      break
  if x_flag:
    for j in range(i+1,N):
      if S[j]==y:
        y_flag=True
        break
  if y_flag:
    for k in range(j+1,N):
      if S[k]==z:
        ans+=1
        break
        
print(ans)


Measured memory_bytes: 43484
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
void call(int n);
using namespace std;
int main(){
	int n,nm;
	char l;
	int T[52];//0-12:S 13-25:H 26-38:C 39-51:D
	for(int i =0;i<52;i++){
		T[i]=0;
	}
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l>>nm;
		if(l=='S'){
			T[nm-1]=1;
		}else if(l=='H'){
			T[nm+12]=1;
		}else if(l=='C'){
			T[nm+25]=1;
		}else if(l=='D'){
			T[nm+38]=1;
		}
	}	
	
	for(int i=0;i<52;i++){
		if(T[i]==0){
			if(i<13){
				cout<<"S "<<i+1<<endl;
			}else if(i<26){
				cout<<"H "<<i+1-13<<endl;
			}else if(i<39){
				cout<<"C "<<i+1-26<<endl;
			}else if(i<52){
				cout<<"D "<<i+1-39<<endl;
			}
		}
		
	}
	
	
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.S = sc.next();
    }
    
    //解答処理
    private int solve() {
        int red = 0;
        int blue = 0;
        
        for (int i=0; i<S.length(); i++) {
        	if (S.charAt(i) == '0') {
        		red++;
        	} else {
        		blue++;
        	}
        }
        
        int count = 2 * (int)Math.min(red, blue);
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


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

using namespace std;

int main()
{
    char s[10];
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
s=[]
for i in range(m):
    s.append(list(map(int,input().split())))
p=list(map(int,input().split()))

onoff=[["0"],["1"]]

for i in range(n-1):
    tmp=[]
    for j in onoff:
        tmp.append(j+["0"])
        tmp.append(j+["1"])
    onoff=tmp

ans=0
for i in onoff:
    f=0
    for j in range(m):
        c=0
        for k in range(s[j][0]):
            if i[s[j][1+k]-1]=='1':
                c+=1
        if c%2!=p[j]:
            f+=1
    if f==0:
        ans+=1
print(ans)

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sign(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int a[110000];
vint G[110000];
int dfs(int x) {
    int ub = 0;
    vint v;
    for (int to:G[x]) { v.emplace_back(dfs(to)); }
    sort(all(v)), reverse(all(v));
    int ret = v.size();
    rep(i, v.size()) { chmax(ret, v[i] + i + 1); }
    return ret;
}
signed main() {
    cin >> N;
    reps(i, N - 1) {
        cin >> a[i], a[i]--;
        G[a[i]].push_back(i);
    }
    cout << dfs(0) << endl;
}

Measured memory_bytes: 17776
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

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

	vector<pair<ll, ll>> p(N + 1);
	repn(i, N) {
		cin >> p[i].first;
		p[i].second = i;
	}
	sort(++p.begin(), p.end());

	vll D(N + 1);
	repn(i, N) { D[i] = p[i].first; }
	
	vll sz(N + 1, 0);
	vll par(N + 1, 0);

	for (ll v = N; v > 1; v--) {
		ll x = D[v] - (N - 2 - sz[v] * 2);

		auto itr = lower_bound(++D.begin(), D.end(), x);
		ll w = distance(D.begin(), itr);
		
		if (w > N || D[w] != x) { cout << -1 << endl; return 0; }
		par[v] = w;
		sz[w] += sz[v] + 1;
		//cout << v << " " << w << endl;

	}

	vll subtr(N + 1, 0);
	vll sum(N + 1, 0);
	for (ll v = N; v > 1; v--) {
		subtr[par[v]] += subtr[v] + 1;
	}
	for (ll v = N; v > 1; v--) {
		sum[par[v]] += sum[v] + subtr[v] + 1;
	}

	//repn(v, N) cout << sum[v] << endl;

	if (sum[1] != D[1]) { cout << -1 << endl; return 0; }

	for (ll v = N; v > 1; v--) {
		cout << p[v].second << " " << p[par[v]].second << endl;
	}

}

Measured memory_bytes: 8808
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = ab[0];
        var b = ab[1];

        Console.WriteLine(Math.Max(0, a - b * 2));
    }
}


Measured memory_bytes: 13268
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int a[n],b[n];
    long long int a_sum = 0,b_sum = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        a_sum += a[i];
    }
    for(int i = 0;i < n;i++)
    {
        cin >> b[i];
        b_sum += b[i];
    }
    if(b_sum > a_sum)
    {
        cout << "-1\n";
    }
    else
    {
        vector<long long int> v;
        long long int sum = 0;
        int count = 0;
        for(int i = 0;i < n;i++)
        {
            if(a[i] - b[i] < 0)
            {
                sum += b[i] - a[i];
                count++;
            }
            else if(a[i] - b[i] > 0)
            {
                v.push_back(a[i] - b[i]);
            }
        }
        if(count == 0)
        {
            cout << "0\n";
        }
        else
        {
            sort(v.begin(),v.end(),greater<int>());
            long long int d = 0;
            int i = 0;
            while(d < sum)
            {
                d += v[i];
                i++;
            }
            cout << count + i << "\n";
        }
    }
    
    return 0;
}

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

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a>b){
        cout << "a > b" << endl;
    }
    else if(a<b){
        cout << "a < b" << endl;
    }
    else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
void kehsihba(){
	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*/
}
void solve(){
	ll n,k;
	cin>>n;
	map<int,int>m;
	ll arr[n];ll sum=0;
	for(int i=0;i<n;i++){
		cin>>arr[i];m[arr[i]]+=1;sum+=arr[i];
	}cin>>k;
	while(k--){
		ll a,b;cin>>a>>b;
		if(m[a]){
			ll x=m[a];
			//cout<<x;test;
			sum-=x*a;
			sum+=b*x;
			m[a]=0;m[b]+=x;
		}
		cout<<sum<<endl;
	}
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 10124
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
#include <iterator>
#include <list>
#include <unordered_map>
#include <deque>
#include <math.h>
#include <tgmath.h>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << "\n";}
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

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

ll aabs(ll a) {
    if (a < 0) return -a;
    return a;
}

//fast power
ll calc(ll a, ll b) {
    if (b == 0) return 1;
    else if (b % 2 == 0) {
        ll d = calc(a, b / 2);
        return (d * d) % MOD;
    }
    else return (a * calc(a, b - 1)) % MOD;
}

//fast combination
ll comb(ll n, ll a) {
    ll b = 1, c = 1;
    for (ll i = 1; i <= a; ++i) {
        b = b * i % MOD;
        c = c * (n - i + 1) % MOD;
    }

    return c * calc(b, MOD - 2) % MOD;
}

ll comb2(ll a) {
    ll b = a / 2;
    if (a % 2) {
        b = (a - 1) / 2;
        return (b * a);
    }
    return (b * (a - 1));
}

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> a >> b >> c;

    cout << c << ' ' << a << ' ' << b << endl;


    
    return 0;
}


Measured memory_bytes: 256
lake_length, num_of_house = map(int, input().split())
positions = list(map(int, input().split()))

max_interval = lake_length - positions[num_of_house - 1] + positions[0]

for i in range(1, num_of_house):
    max_interval = max(max_interval, positions[i] - positions[i - 1])

print(str(lake_length - max_interval))


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int sum = 1;
  for (int i = 0; i < N-1; i++) {
    if (S.at(i) != S.at(i+1)) {
      sum++;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10 , M = 5e5+10 ,  MOD = 1e9+7;
const int OO = 0x3f3f3f3f;
const double EPS = 1e-3;
#define M_PI 3.14159265358979323846
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define pb push_back
#define F first
#define S second
#define all(v) ((v).begin()) , ((v).end())
#define sz(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
 

int n, m;
char grid[105][105];
bool row[105] , col[105];



int main() {

    //ios_base::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
	

    scanf("%d %d",&n,&m);
    for(int i = 0 ; i < n ; ++i)
        scanf("%s", grid[i]);

   
    for(int i = 0 ; i < n ; ++i){
        for(int j = 0 ; j < m ; ++j)
            if(grid[i][j] == '#')
                row[i] = 1 , col[j] = 1;
    }
   
    bool f = 0;
    for(int i = 0 ; i < n ; ++i){
        if(row[i]){
            for(int j = 0 ; j < m ; ++j){
                if(col[j])
                    printf("%c",grid[i][j]);
            }
            puts("");
        }
    }



    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100004
#define ll long long
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    ll n,k,m;
    cin>>n>>k;
    m=k-2*n;
    if(m<=0){
        cout<<k/2<<endl;
        return 0;
    }
    cout<<n+m/4<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string O, E;
  cin>>O>>E;
  string ans;
  for(int i=0;i<O.size()+E.size();++i) {
    if(i%2==0) ans += O[i/2];
    else ans += E[(i-1)/2];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3544
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        Bridge solver = new Bridge();
        solver.solve(1, in, out);
        out.close();
    }

    static class Bridge {
        boolean[] visited;
        int[] lowest;
        int[] order;
        int[] parent;
        int timer;
        List<List<Integer>> g;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt() + 1;
            int m = in.nextInt();

            visited = new boolean[n];
            // lowlink
            lowest = new int[n];
            // nodeを訪れた順番
            order = new int[n];
            parent = new int[n];
            timer = 1;
            g = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                g.add(new ArrayList<>());
            }

            for (int i = 0; i < m; i++) {
                int a = in.nextInt();
                int b = in.nextInt();
                (g.get(a)).add(b);
                (g.get(b)).add(a);
            }
            long result = 0;
            dfs(1, 0);
            for (int i = 1; i < n; i++) {
                for (Integer v : g.get(i)) {
                    if (order[i] < lowest[v]) {
                        result++;
                    }
                }
            }

            out.println(result);

        }

        public void dfs(int current, int prev) {
            order[current] = timer;
            lowest[current] = timer;
            timer++;
            visited[current] = true;

            for (Integer next : g.get(current)) {
                if (!visited[next]) {
                    parent[next] = current;
                    dfs(next, current);
                    // 子の探索が終了
                    lowest[current] = Math.min(lowest[current], lowest[next]);
                } else if (next != prev) {
                    // Back edge の最小
                    lowest[current] = Math.min(lowest[current], order[next]);
                }
            }
        }

    }
}



Measured memory_bytes: 36264
#include<stdio.h>
#include<string.h>

int main(){
    int i,l;
    char s[131072]={0},t[131072]={0};
    scanf("%s",s);
    l = strlen(s);
    for(i = 0;i < l;i++){
        t[l-i-1]=s[i];
    }
    for(i = 0;i < l;i++){
        if(t[i] == 'b'){t[i]='d';}
        else if(t[i] == 'd'){t[i]='b';}
        else if(t[i] == 'p'){t[i]='q';}
        else if(t[i] == 'q'){t[i]='p';}
    }
    if(strcmp(s,t) == 0){printf("Yes\n");}else{printf("No\n");}
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };


int main() {
	int h, w;
	cin >> h >> w;
	whei(char) a(h + 2,hei(char)(w + 2,'.'));
	bool ans = true;
	rep(i, 1, h + 1) {
		rep(j, 1, w + 1) {
			cin >> a[i][j];
		}
	}
	int dy[] = { 1,0,-1,0 };
	int dx[] = { 0,1,0,-1 };
	rep(i, 1, h + 1) {
		rep(j, 1, w + 1) {
			if (a[i][j] == '#') {
				bool s = false;
				rep(k, 0, 4) {
					if (a[i][j] == a[i + dx[k]][j + dy[k]])s = true;
				}
				if (!s)ans = false;
			}
		}
	}
	Yes(ans)
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

string str(ll n){
  stringstream ss;
  ss << n;
  return ss.str();
}

int N;
bool snuke(ll n){
  if(n<=N && str(n)<=str(N))return true;
  if(n>N && str(n)>str(N))return true;
  return false;
}

int qcnt = 0;
bool query(ll n){
  if(n < 1 || n > 1000000000000000000ll){
    cout << "ERROR" << n << endl;
    exit(1);
  }
  qcnt++;
  if(false){
    return snuke(n);
  }else{
    cout << "? " << n << endl;
    string ans;
    cin >> ans;
    return ans == "Y";
  }
}

int main(){
  // FOR(i,1,1252){
  //   N = i;
  //   cout << (snuke(1)?"1":"0");
  //   cout << (snuke(9)?"1":"0");
  //   cout << " ";
  //   cout << (snuke(10)?"1":"0");
  //   cout << (snuke(99)?"1":"0");
  //   cout << " ";
  //   cout << (snuke(100)?"1":"0");
  //   cout << (snuke(999)?"1":"0");
  //   cout << " ";
  //   cout << (snuke(1000)?"1":"0");
  //   cout << (snuke(9999)?"1":"0");
  //   cout << " ";
  //   cout << (snuke(10000)?"1":"0");
  //   cout << (snuke(99999)?"1":"0");
  //   cout << endl;
  // }
  // N = 525;
  // // cout<<" "<<endl;
  // FOR(i,0,999){
  //   cout << (snuke(i)?"1":"0");
  //   if(i%10==9)cout<<endl;
  // }
  // cout << endl;
  const ll e9 = 1000000000ll;
  // cin>>N;
  // N = 123;
  // N = 1;
  // FOR(i,1,1000){
  //   if(i==1)cout<<" ";
  //   cout<<query(i);
  //   if(i%10==9)cout<<endl;
  // }
  // return 0;
  // decide
  ll ans = 0;
  ll bai = e9 * e9 / 10ll;
  REP(i,10){
    ans *= 10;
    int low = 0, high = 10;
    // if(i==0)low++;
    while(low+1<high){
      int x = (low+high)/2;
      ll q = ans + x;
      bool po = query(bai * (ans+x));
      if(po){
        high = x;
      }else{
        low = x;
      }
    }
    ans += low;
    if(ans>0)bai /= 10ll;
  }
  if(ans==0){
    ans = e9;
  }else{
    ans ++;
  }
  // cout << ans << endl;
  while(ans % 10 == 0){
    ll nxt = ans/10+1;
    if(str(nxt).size() == str(ans).size()){
      // 99999
      if(query(nxt)){
        break;
      }else{
        ans /= 10;
        break;
      }
    }
    if(query(ans/10+1)){
      ans /= 10;
    }else{
      break;
    }
  }
  // cout << qcnt << endl;
  cout << "! " << ans << endl;
  return 0;
}


Measured memory_bytes: 596
#累積GCDによるsolution : O(N)
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
B = [A[0]]+[0]*(N-1)
C = [0]*(N-1)+[A[-1]]
for i in range(N-1):
    B[i+1] = gcd(A[i+1],B[i])
for i in range(N):
    C[-i-1] = gcd(A[-i-1],C[-i])

ans = 0
for i in range(1,N-1):
    ans = max(gcd(B[i-1],C[i+1]),ans)
# in case of i=0,N-1
ans = max(ans,C[1])
ans = max(ans,B[-2])
print(ans)

Measured memory_bytes: 16572
def main(*, int=int, input=input):
    a, b = map(float, input().split())
    bi = round(b*100)
    ai = int(a)
    x = ai*bi
    x = x // 100
    print(x)

if __name__ == "__main__":
    import io, sys
    if "_INPUT" in locals():
        sys.stdin = io.StringIO(_INPUT)
    main()

Measured memory_bytes: 9048
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

signed main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, 0, n)
        cin >> v[i];
    int res = 0;
    rep(i, 0, k+1)
        rep(j, 0, k+1-i)
        {
            int z = k-i-j;
            if (i+j>n) continue;
            if (z<0) continue;
            priority_queue<int> q;
            rep(a, 0, i)
                q.push(-v[a]);
            rep(a, 0, j)
                q.push(-v[n-1-a]);
            int now = 0;
            while (now < z && !q.empty())
            {
                int t = q.top();
                if (t < 0)
                    break;
                q.pop();
                now++;
            }
            int tmp = 0;
            while (!q.empty())
            {
                int t = q.top();
                q.pop();
                tmp -= t;
            }
            res = max(tmp, res);
        }
    cout << res;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
long h[100005] = {0};
long g[100005] = { 0 };
int main()
{
    int n, m;
    cin >> n>> m;
    long p; string s;
    for (int i = 1; i <= m; i++) {
        cin >> p >> s;
        if (g[p] == 0 & s == "AC") {
            
            g[p] = 1;
        }
        else if (g[p] == 0) {
            h[p]++;
        }
    }
    long ans = 0;
    long ac = 0;
    for (int i = 1; i <= n; i++) {
        if (g[i] == 1) { ans += h[i]; ac++; }
    }
    cout <<ac<<" "<< ans << endl;

}

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

int main(){
    int H, W;
    cin >> H >> W;

    string data[H];
    for (int i = 0; i < H; i++) {
        cin >> data[i];
    }
    
    vector<int> row(H, 0);
    vector<int> col(W, 0);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (data[i][j] == '#') {
                row[i] = 1;
                col[j] = 1;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        if (row[i] == 1){
            for (int j = 0; j < W; j++) {
                if (col[j] == 1){
                    cout << data[i][j];
                }
            }
            cout << endl; // cout << '\n'; のほうが速い
        }
    }
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#define MAX_N 200000
using namespace std;

int N, T;
typedef long long ll;

int main(void){
	ll planned_finish_time = 0;
	ll actual_watering_time;
	ll push_time;
	ll total_time = 0;
	ll next_push_time;
	cin >> N >> T;
	cin >>  push_time;
	planned_finish_time = push_time + T;
	for(int i = 1; i <= N - 1; i++){
		cin >> next_push_time;
		if(planned_finish_time > next_push_time){
			actual_watering_time = next_push_time - push_time;
		}else{
			actual_watering_time = T;
		}
		//cout << push_time << " " << next_push_time << " " << actual_watering_time << endl;
		total_time += actual_watering_time;
		push_time = next_push_time;
		planned_finish_time = push_time + T;
	}
	total_time += T;
	cout << total_time << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main( void ) 
{
	int b[101];
	int a[101][101];
	int res;
	int n,m;
	int i,j;

	scanf( "%d%d", &n, &m );
	for( i=0; i<n; i++ ) {
		for( j=0; j<m; j++ ) {
			scanf( "%d", &a[i][j] );
		}
	}

	for( j=0; j<m; j++ ) {
		scanf( "%d", &b[j] );
	}

	for( i=0; i<n; i++ ) {
		res=0;
		for( j=0; j<m; j++ ) {
			res+=a[i][j]*b[j];
		}
		printf( "%d\n", res );
	}

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 998244353;

int main() {
    // your code goes here
    ll n,s,a[3005],dp[3005][3005]={0};
    cin >> n >> s;
    rep(i,1,n){
    	cin >> a[i];
    }
    dp[0][0]=1;
    rep(i,1,n){
    	rep(j,0,3000){
    		if(j<a[i]){
    			dp[i][j]=dp[i-1][j]*2%mod;
    		} else {
    			dp[i][j]=dp[i-1][j]*2%mod;
    			dp[i][j]=(dp[i][j]+dp[i-1][j-a[i]])%mod;
    		}
    	}
    }
    cout << dp[n][s] << endl;
    return 0;
}

Measured memory_bytes: 74204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N){
    cin>>A[i];
    if(i) A[i]+=A[i-1];
  }
  ll ans=abs(A[N-1]-2*A[0]);
  rep(i,N-2){
    ll t=abs(A[N-1]-2*A[i+1]);
    if(t<ans) ans=t;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import static java.util.Arrays.fill;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner fsc = new Scanner(System.in);
        int n = fsc.nextInt();
        int m = fsc.nextInt();
        int[] ans = new int[n];
        fill(ans, -1);
        for (int i = 0; i < m; i++) {
            int s = fsc.nextInt() - 1;
            int c = fsc.nextInt();
            if (s == 0 && c == 0 && n > 1) {
                System.out.println(-1);
                return;
            }
            if (ans[s] < 0) {
                ans[s] = c;
            } else if (ans[s] != c) {
                System.out.println(-1);
                return;
            }
        }
        for (int i = 0; i < n; i++) {
            if (i == 0) {
                if (ans[i] == 0) {
                    if (n > 1) {
                        System.out.println(-1);
                        return;
                    } else {
                        System.out.println(0);
                        return;
                    }
                } else if (ans[i] < 0) {
                    if (n > 1) {
                        System.out.print(1);
                    } else {
                        System.out.println(0);
                        return;
                    }
                } else {
                    System.out.print(ans[i]);
                }
            } else {
                System.out.print(ans[i] >= 0 ? ans[i] : 0);
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 21332
/* # */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/
int n, m, k;
vi A, B;

void Mx(ll& x, const ll& y) {
    if (x < y) x = y;
    else return;
}
void sol() {
    cin >> n >> m >> k;
    A.resize(n), B.resize(m);
    ll sum(0), cnt(n);

    for (int i = 0; i < n; i++) {
        cin >> A[i]; 
        sum += A[i];
    }
    for (int i = 0; i < m; i++)
        cin >> B[i];

    ll ans(0);
    int ai(n - 1), bi(0);
    if (sum <= k) Mx(ans, cnt);
    while (bi < m && sum + B[bi] <= k) {
        sum += B[bi]; bi++, cnt++;
        Mx(ans, cnt);
    }

    while (ai >= 0) {
        sum -= A[ai]; ai--, cnt--;
        while (bi < m && sum + B[bi] <= k) {
            sum += B[bi]; bi++, cnt++;
            Mx(ans, cnt);
        }
    }
    cout << ans << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    int T(1);
    while (T--)
        sol();


    return 0;
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
i_i dp[2000000];
int a[2000000];

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    int beki[25];
    beki[0] = 1;
    for(int i = 1; i <= n; i++){
        beki[i] = beki[i - 1] * 2;
    }
    //cout << beki[n] << endl;
    for(int i = 0; i < beki[n]; i++){
        cin >> a[i];
        dp[i] = {0, a[i]};
    }
    for(int i = 0; i < n; i++){
        //dp[beki[i]] = {0, a[beki[i]]};
    }
    dp[0] = {0, a[0]};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 1<<n; j++){
            if(!(j & (1<<i))) continue;
            vector<int> now;
            now.push_back(dp[j].first);
            now.push_back(dp[j].second);
            now.push_back(dp[j^(1<<i)].first);
            now.push_back(dp[j^(1<<i)].second);
            sort(now.begin(), now.end(), greater<int>());
            dp[j] = {now[0], now[1]};
        }
    }
    int ans = 0;
    //cout << n << " " << beki[n] << endl;
    for(int i = 1; i < beki[n]; i++){
        //cout << i << endl;
        /*int mini = 1;
        while(mini * 2 <= i){
            mini = mini * 2;
        }
        mini--;
        cout << i << " " << mini << endl;*/
        ans = max(ans, dp[i].first + dp[i].second);
        cout << ans << endl;
        //cout << max(dp[i].first + dp[i].second, dp[mini].first + dp[mini].second) << endl;
        //cout << i << " " << dp[i].first << " " << dp[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
using namespace std;
int main(){
	int a = 0, b = 0, c = 0, d = 0, e[500] = { 0 }, counto=0;
	bool sin = false;
	pair<char, int>n[10][10];
	vector<int> r;
	cin >> a;
	b = a;
	while (sin == false) {
		if (b % 2 == 0) {
			r.push_back(b / 2);
			b = b / 2;
		}
		else { r.push_back(b * 3 + 1); 
		b = b * 3 + 1;
		}
		//cout << b << endl;
		for (int i = 0; i < counto; i++) {
			if (r[i] == r[counto]) {
				sin = true;
			}
		}
		if (r[counto] == a) {
			sin = true;
		}
		counto++;
	}
	cout << counto+1 << endl;
	return 0;
}

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

ll n,k;
vector<ll> v_a;
vector<ll> v_f;

// index が条件を満たすかどうか
bool isOK(ll x) {
    ll c=0;
    for (int i = 0; i < n; i++)
    {
        //cout<<i<<" "<<x<<" "<<v_a[i]*v_f[i]<<" "<<c<<endl;
        if(v_a[i]*v_f[i]>x){
            c+=v_a[i]-x/v_f[i];
            //cout<<i<<" "<<x<<" "<<v_a[i]*v_f[i]<<" "<<c<<endl;
        }
        if(c>k){
            return false;
        }
    }
    if(c<=k){
        return true;
    }else{
        return false;
    }
}

int main() {
    cin>>n>>k;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin>>a;
        v_a.push_back(a);
    }
    for (int i = 0; i < n; i++)
    {
        int f;
        cin>>f;
        v_f.push_back(f);
    }
    sort(v_a.begin(),v_a.end());
    sort(v_f.begin(),v_f.end(),std::greater<int>());

    ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll right = 1e12+1; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        ll mid = left + (right - left) / 2;

        if (isOK(mid)) right = mid;
        else left = mid;
    }

    cout<<right;

    return 0;
}

Measured memory_bytes: 4848
#include <stdio.h>

int main() {
  int a[100], i, n;

  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", &a[i]);
  if (n>=1) printf("%d", a[n-1]);
  for(i=n-2;i>=0;i--) printf(" %d", a[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
int main() {
	ios::sync_with_stdio(false);

	string s; cin >> s;
	FOR(i,0,sz(s)) {
		if ((i+1)%2 == 0) {
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
				continue;
			} else {
				cout << "No" << endl;
				return 0;
			}
		} else {
			if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
				continue;
			} else {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int n, m, ans=0;
  cin >> n >> m;
  if(n%m==0)cout << m/n << endl;
  else{
    for(int i=m/n;i>=1;i--){
      int x=m-(n*i);
      if((x+i)%i==0){
        ans=i;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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




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


map<string,int>mp;

int n;
cin>>n;

for(int i=0;i<n;i++)
{
  string s;
  cin>>s;
  mp[s]++;
}
set<string>s;
int cnt=0;

for(auto i : mp)
{
  cnt=max(cnt,i.second);
}

for(auto i : mp)
{
  if(i.second==cnt)
  {
    s.insert(i.first);
  }
}

for(auto i : s)cout<<i<<"\n";

  
}



Measured memory_bytes: 33280
N, K = map(int, input().split())
S = list(input())

l = []
bef = ""
start = 0

for i, s in enumerate(S):
    if bef=="":
        start = i
    elif bef!=s:
        cnt = 0
        l.append(i-start)
        start = i
    bef = s
l.append(i-start+1)

size = len(l)
ans = 0
for i in range(min(2*K+1, size)):
    ans += l[i]
ans -= 1
for i in range(min(2*K+1, size), size):
    ans += l[i]-1
print(ans)


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

ll gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}

ll lcm(int a, int b)
{
    return (ll)a * b / gcd(a, b);
}

int main()
{
    int a,b;
    ll ans;
    cin >> a >> b;

    ans = lcm(a, b);
    std::cout << ans << endl;

    return 0;
}

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

int main()
{
    int N, min, max;
    cin >> N;
    vector<int> len(N);

    for (int i = 0; i < N; i++)
    {
        cin >> len.at(i);
    }
    max = *max_element(len.begin(), len.end());
    min = *min_element(len.begin(), len.end());
    cout << max-min << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<bitset>
#define INF 0x3f3f3f3f
#define LL long long
#define MOD1 998244353
#define MOD2 1000000007
#define MAXN 1000005
using namespace std;
// struct Edge{
// 	int to,nex;
// 	Edge(){}
// 	Edge(int a,int b){
// 		to=a,nex=b;
// 	}
// }e[MAXN<<1];
LL n,m;
LL rd(){
	LL x=0,tp=1;char c;
	c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*tp;
}
int main(){
	// freopen("nmsl.in","r",stdin); 
	// freopen("nmsl.out","w",stdout);
	n=rd(),m=rd();
	int x=1,ans=0;
	while(x<m){
		x+=n-1;
		ans++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i32 = input();
    let d: i32 = input();
    let m = 2 * d + 1;
    println!("{}", (n + m - 1) / m);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define loop for(int i = 0;i < prime.size();i++)
vector<int> prime,q;
bool D(int n){
  loop{
    if(n%prime[i] == 0)return 0;
  }
  return 1;
}

int main() {
  int ip = 6,n;
  while(ip <= 300000){
    if(D(ip))prime.push_back(ip);
    ip += 2;
    if(D(ip))prime.push_back(ip);
    ip += 5;
  }
  while(cin >> n){
    if(n == 1)break;
    else q.push_back(n);
  }
  for(int n = 0;n < q.size();n++){
    bool flag = 1;
    cout << q[n] << ":";
    loop{
      if(q[n]%prime[i] == 0){
        flag = 0;
        cout << " " << prime[i];
      }
    }
    if(flag)cout << " " << q[n];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  int cnt = 0;
  REP(i,N-1){
    if(A[i]==i+1){
      int x = A[i];
      A[i]=A[i+1];
      A[i+1]=x;
      cnt++;
    }
  }

  if(A[N-1]==N){
    cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	double q;
	while(cin >> q && q + 1)
	{
		double x = abs(q / 2);
		while(abs(x * x * x - q) >= 0.00001 * q)
			x = x - (x * x * x - q) / (3 * x * x);
		printf("%.6f\n", x);
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int n, A[50];

// 入力値のMから選んだ要素を引いていく再帰関数
int solve(int i, int m) {
    if(m==0) return 1;
    if(i>=n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(void) {
    int q, M, i;

    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    scanf("%d",&q);
    for(i=0;i<q;i++) {
        scanf("%d", &M);
        if(solve(0,M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2096