akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


class UnionFind:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes

        # self.parents[x] < 0 の時，xが根である．
        # また，xが根の時，(-1) * (同一グループの要素数) が格納されるようになる.
        self.parents = [-1] * n_nodes

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # 常にxの方が要素数が多くなるように，スワップする
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        # 要素数の少ない方のグループを，要素数が多い方の木に貼る．
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def get_size(self, x):
        return -self.parents[self.find(x)]

    def check(self, x, y):
        return self.find(x) == self.find(y)

    def get_members(self, x):
        parent = self.find(x)
        return [i for i in range(self.n_nodes) if self.find(i) == parent]

    def get_parent_list(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def get_n_groups(self):
        return len(self.get_parent_list())

    def get_members_dict(self):
        return {par: self.get_members(par) for par in self.get_parent_list()}


def main():
    N, M = map(int, input().split())
    base_tree = UnionFind(N)
    edges = []
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        base_tree.union(a, b)
        edges.append((a, b))

    n_groups = base_tree.get_n_groups()
    ans = 0
    for i in range(M):
        tmp_tree = UnionFind(N)
        for j, (a, b) in enumerate(edges):
            if i == j:
                continue

            tmp_tree.union(a, b)

        tmp = tmp_tree.get_n_groups()
        if n_groups != tmp:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################

const int mod = 998244353;
void add(int &a,int b){
    a = (a+b)%mod;
    a = (a%mod + mod)%mod;
}
signed main(){
    int n,k;cin >> n >> k;
    vector<int> l(k),r(k);
    rep(i,k)cin >> l[i] >> r[i];
    vector<int> dp(n+3);
    dp[1] = 1;
    add(dp[2],-1);
    int sum = 0;
    for(int i = 1;i <= n;i++){
        add(sum,dp[i]);
        rep(j,k){
            if(r[j]+1+i <n+3)add(dp[r[j]+1+i],-sum);
            if(l[j]+i < n+3)add(dp[l[j]+i],sum);
        }
        // trace(i,sum,dp);
    }
    for(int i = 1;i <= n;i++)add(dp[i+1],dp[i]);
    
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

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

	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'o')	cnt++;
	}

	if (15 - s.size() +cnt >= 8) cout << "YES" << endl;
	else cout << "NO" << endl;
}



Measured memory_bytes: 256
#include<cstdio>
const int inf=0x7f7f7f7f;
int n,m,S,T,ans,cnt,tot=1,hd,tl,a[110],b[210],head[210],cur[210],to[20010],nxt[20010],val[20010],pre[20010],dep[210],q[210],num[210];
inline int abs(int x){
	return x>0?x:-x;
}
inline int min(int a,int b){
	return a<b?a:b;
}
inline void add_edge(int u,int v,int w){
	nxt[++tot]=head[u];
	to[tot]=v;
	val[tot]=w;
	head[u]=tot;
	return;
}
inline void Add_edge(int u,int v,int w){
	add_edge(u,v,w);
	add_edge(v,u,0);
	return;
}
void bfs(){
    for(int i=0;i<T;i++)
	    dep[i]=T+1;
    dep[T]=0;
    hd=tl=0;
    q[tl++]=T;
    while(hd<tl){
	    int u=q[hd++];
	    for(register int i=head[u];i;i=nxt[i]){
		    int v=to[i];
		    if(dep[v]==T+1&&val[i^1]){
			    dep[v]=dep[u]+1;
			    q[tl++]=v;
			}
		}
	}
    return;
}
inline int get_flow(){
    int flw=inf;
    for(int u=T;u!=S;u=to[pre[u]^1])
	    flw=min(flw,val[pre[u]]);
    for(int u=T;u!=S;u=to[pre[u]^1]){
	    val[pre[u]]-=flw;
	    val[pre[u]^1]+=flw;
	}
    return flw;
}
void ISAP(){
    int u=S;
    bfs();
    for(int i=0;i<=T;i++){
	    num[dep[i]]++;
	    cur[i]=head[i];
	}
    while(dep[S]<T){
	    if(u==T){
		    ans+=get_flow();
		    u=S;
		}
	    bool ck=0;
	    for(int i=cur[u];i;i=nxt[i])
		    if(dep[to[i]]+1==dep[u]&&val[i]){
			    ck=1;
			    cur[u]=i;
			    pre[u=to[i]]=i;
			    break;
			}
	    if(!ck){
		    int mini=T-1;
		    for(int i=head[u];i;i=nxt[i])
			    if(val[i])
				    mini=min(mini,dep[to[i]]);
		    if(!(--num[dep[u]]))
			    break;
		    num[dep[u]=(mini+1)]++;
		    cur[u]=head[u];
		    if(u!=S)
			    u=to[pre[u]^1];
		}
	}
    return;
}
inline bool check(int x){
	if(x<=2)
		return 0;
	for(register int i=2;i*i<=x;i++){
		if(!(x%i))
			return 0;
	}
	return 1;
}
int main(){
	cnt=0;
	scanf("%d%d",&n,a+1);
	b[++cnt]=a[1];
	for(int i=2;i<=n;i++){
		scanf("%d",a+i);
		if(a[i]-a[i-1]>1&&i>1){
			b[++cnt]=a[i-1]+1;
			b[++cnt]=a[i];
		}
	}
	b[++cnt]=a[n]+1;
	S=0,T=cnt+1;
	for(int i=1;i<=cnt;i++){
		if(b[i]&1){
			m++;
			Add_edge(S,i,1);
			for(int j=1;j<=cnt;j++)
				if(!(b[j]&1)&&check(abs(b[i]-b[j])))
					Add_edge(i,j,1);
		}
		else Add_edge(i,T,1);
	}
	ISAP();
	printf("%d",cnt-ans+((m-ans)&1));
	return 0;
}
/*
3
1 3 5
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 2050
#define pii  pair<int, int>
#define ss second
#define ff first
 
using ll = long long;
using namespace std;
const int mod = 1e9 + 7;


int main(){
    int n;

    cin >> n;

    vector<int> v(n);

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

    bool impossible = false;

    for (int i=n-1; i>=1 ; i--){
        if (v[i] < v[i-1]){
            v[i-1]--;
        }
    }

    for (int i=1; i<n; i++){
        if (v[i] < v[i-1]) impossible = true;
    }

    if (impossible) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int mcnt = -1;
    int cnt = 0;
    for (int i=0; i<s.length(); i++) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
            cnt++;
        else
            cnt = 0;
        mcnt = max(mcnt, cnt);
    }
    cout << mcnt << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] x=new int[n];
        for (int i=0;i<=n-1;i++){
            x[i]=sc.nextInt();
        }
        int ans=10000000;
        for(int c=1;c<=100;c++){
            int total=0;
            for(int i=0;i<=n-1;i++){
                total+=(x[i]-c)*(x[i]-c);
            }
            if(total<ans){
                ans=total;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 22732
n=int(input())
d=dict()
for i in range(n):
  s = input()
  if s in d.keys():
    d[s] = d[s] + 1
  else:
    d[s] = 1
    
m=int(input())
for i in range(m):
  s = input()
  if s in d.keys():
    d[s] = d[s] - 1
print(max(0,max(d.values())))

Measured memory_bytes: 3060
process.stdin.resume();
process.stdin.setEncoding('utf8');

var input_lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  input_lines.push(line);
});

reader.on('close', () => {
  //console.log(input_lines);
  var line_one = input_lines[0];
  var line_two = input_lines[1];

  var one_split = line_one.split('');
  var two_split = line_two.split('');

  var correct_times = 0;

  //console.log(line_one);
  //console.log(line_two);
  //console.log(one_split);
  //console.log(two_split);

  for(var i = 0; i < one_split.length; i ++){
    if(one_split[i] != two_split[i]){
      correct_times ++;
    }
  }

  console.log(correct_times);

});


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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n, bef, curr, cnt = 0, ans = 0;
    cin >> n;
    cin >> bef;
    for(int i = 1 ; i < n ; i++){
    	cin >> curr;
    	if(bef >= curr){
    		cnt++;
    	} else {
    		cnt = 0;
    	}
    	ans = max(cnt, ans);
    	bef = curr;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=1e5+5;
const int INF=1<<30;
int N,X[MAXN],Ans,MIN;

int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d",&X[i]);
	}
	MIN=INF;
	for(int i=0;i<=100;i++){
		Ans=0;
		for(int j=1;j<=N;j++){
			Ans=Ans+(X[j]-i)*(X[j]-i);
		}
		MIN=min(MIN,Ans);
	}
	printf("%d\n",MIN);
	return 0;
}

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

typedef pair<int,int> ii;

const int N = 100009;

int n, k, q;
long long dist[N]={};
vector<ii> adj[N];

void dfs(int u, long long length){
    dist[u] = length;
    for(int i = 0; i < adj[u].size(); i++){
        int v = adj[u][i].first,
            dv = adj[u][i].second;
        if(!~dist[v]) dfs(v, length + dv);
    }
}

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n-1; i++){
        int x, y, v; scanf("%d %d %d", &x, &y, &v);
        adj[x].push_back({y,v});
        adj[y].push_back({x,v});
    }

    memset(dist, -1, sizeof dist);

    scanf("%d %d", &q, &k);
    dfs(k,0);

    for(int i = 0; i < q; i++){
        int x, y; scanf("%d %d", &x, &y);
        printf("%lld\n", dist[x] + dist[y]);
    }
    return 0;
}


Measured memory_bytes: 12800
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
int a[1005];
int b[1005];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    printf("%d\n",(n*3+m)/2);

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

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

	char first = S[0];
	int cnt = 0;
	int kind = 1;
	rep(j, 4) {
		cnt = 0;
		rep(i, 4) {
			if(S[j]==S[i]) cnt++;
		}
		if(cnt!=2) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
  return 0;
}

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

ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
  
   
// Function to return LCM of two numbers  
  ll lcm(ll a, ll b)  
 {  
    return (a*b)/gcd(a, b);  
 }  
int main(){
		ll a,b;
		cin>>a>>b;
		cout<<lcm(a,b)<<endl;
		
		
		
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

vector<PII> A, B;

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    int a;
    scanf("%d", &a);
    A.PB(MP(0, a));
  }
  for (int i = 0; i < N; i++) {
    int b;
    scanf("%d", &b);
    B.PB(MP(0, b));
  }
  int ans = 0;
  for (int t = 0; t <= 28; t++) {
    int num = 1 << t;
    int mask = num - 1;
    for (int i = 0; i < N; i++)
      A[i].F = A[i].S & mask;
    sort(ALL(A));
    for (int i = 0; i < N; i++)
      B[i].F = B[i].S & mask;
    sort(ALL(B));
    int total = 0;
    for (int i = 0; i < N; i++)
      if (B[i].S & num)
        total++;
    int cnt = total;
    int pt = N - 1;
    int res = 0;
    for (int i = 0; i < N; i++) {
      while (pt >= 0 && A[i].F + B[pt].F >= num) {
        if (B[pt].S & num)
          cnt--;
        pt--;
      }
      int sum_1 = cnt + (N - 1 - pt - (total - cnt));
      debug("%d %d - %d (%d %d %d)\n", t, i, sum_1, total, cnt, pt);
      if (A[i].S & num)
        res ^= (N - sum_1) % 2;
      else
        res ^= sum_1 % 2;
    }
    if (res)
      ans |= num;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000007)
#define PI 3.14159265358979323846

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

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

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

i64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

int main() {
  cout << setprecision(18);
  i64 N;
  cin >> N;
  vector<i64> a(N);
  ArrayInput(a);

  i64 res = MAX_NUM;

  for (i32 num = -100; num <= 100; ++num) {
    i64 tmp = 0;
    for (u32 i = 0; i < N; ++i) {
      tmp += (a[i] - num) * (a[i] - num);
    }
    if (tmp < res) res = tmp;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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; }

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

int main(){
    string s;
    cin >> s;
    bool ok = false;
    int ans = 0;
    int num = 0;
    rep(i,s.size()){
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            ok = true;
        }else{
            ok = false;
        }
        if (ok){
            num++;
            ans = max(ans, num);
        }else{
            num = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
h, w, k = gets.split.map(&:to_i)
cs = []
h.times do
  cs << gets.chomp
end

patterns = []
(0...2**(h+w)).each do |x|
  patterns << x.to_s(2).rjust(h+w, "0")
end

ans = 0
patterns.each do |pattern|
  count = 0
  (0..h-1).each do |j|
    (0..w-1).each do |i|
      next if pattern[j] == '1' || pattern[i+h] == '1'

      if cs[j][i] == "#"
        count += 1
      end
    end
  end
  if count == k
    ans += 1
  end
end
puts ans

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

#define FOR(a, n, i) for(ll i = a; i < n; i++)
#define FORR(a, n, i) for(ll i = n - 1; i >= a; i--)
#define FORIT(a, n, it) for (auto it = a; it != n; it++)
#define FORE(e, container) for (auto e : container)
#define FORIN(n, v) vll v(n); FOR(0, n, i) cin >> v[i];
#define FORINP(n, v) vpl v(n); FOR(0, n, i) cin >> v[i].ff >> v[i].ss;
#define WHT(t) int t; cin >> t; while(t--)
#define REP(n, i) FOR(0, n, i)

#define bb begin()
#define ee end()
#define sz size()
#define ff first
#define ss second
#define pb push_back
#define in insert
#define ct count

#define MODF(x) (((x) % MOD) + MOD) % MOD
#define MP(a, b) make_pair(a, b)
#define ALL(container) container.bb, container.ee

using namespace std;

typedef long long ll;
typedef double dd;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvl; 
typedef vector<pll> vpl;
typedef set<ll> sll;
typedef set<pll> spl;
typedef map<ll, ll> mll;
typedef map<pll, ll> mpl;


const ll inf = numeric_limits<ll>::max(), 
         MAX = 4e4, 
         MOD = 1e9 + 7;

///////////////////////////////////////////////////////////
////////////////////    AUXILARY    ///////////////////////
///////////////////////////////////////////////////////////

vll primes;
bool is_composite[MAX + 1];

void compute_primes() {
    FOR(2, MAX + 1, i) {
        if (!is_composite[i])  {
            primes.pb(i);
        }
        FORE(p, primes) {
            ll j = i * p;
            if (j > MAX) break;
            is_composite[j] = true;
            if (i % p == 0) break;
        }
    }
}

///////////////////////////////////////////////////////////
//////////////////////    MAIN    /////////////////////////
///////////////////////////////////////////////////////////

sll factors(ll n) {
    sll facts; facts.in(1);
    FORE(p, primes) {
        if (p * p > n) break;
        while (n % p == 0) {
            sll _facts;
            FORE(f, facts) 
                _facts.in(f * p);
            facts.in(ALL(_facts));
            n /= p;
        }
    }
    if (n != 1) {
        sll _facts;
        FORE(f, facts) 
            _facts.in(f * n);
        facts.in(ALL(_facts));
    }
    return facts;
}

int main() {
    compute_primes();
    ll n, m; cin >> n >> m;
    sll f = factors(m);
    cout << m/(*f.lower_bound(n)) << endl;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

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

    static class DPartition {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int res = 1;
            List<Integer> factors = new ArrayList<>();
            for (int i = 1; i <= Math.sqrt(m); i++) {
                if (m % i == 0) {
                    factors.add(i);
                    factors.add(m / i);
                }
            }
            for (int i : factors) {
                if (i >= n) {
                    res = Math.max(res, m / i);
                }
            }
            out.println(res);
        }

    }

    static class Scanner {
        private StringTokenizer st;
        private BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22612
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_M = 100000;

int dp[5005][5005];




int main(int argc, char *args[]) {
	int N;
	cin >> N;
	string s;
	cin >> s;
	stack<int> st;
	st.push(s[0]);
	for (int i = 1; i < N; i++) {
		if (st.top() == s[i]) {

		}
		else {
			st.push(s[i]);
		}
	}
	cout << st.size() << endl;

}

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

int main(){
	int N, D;
	cin>>N>>D;
	for(int j=1; j<=N; j++){
		if(j*(2*D+1)>=N){
			cout<<j;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

const int MAX_N = 50;
const int MAX_M = 50;
int N, M;
char A[MAX_N][MAX_N + 1];
char B[MAX_M][MAX_M + 1];

void _main() {
  cin >> N >> M;
  rep(i, 0, N) cin >> A[i];
  rep(i, 0, M) cin >> B[i];

  rep(ai, 0, N-M+1) rep(aj, 0, N-M+1) {
    bool ok = true;
    rep(bi, 0, M) rep(bj, 0, M) {
      if (A[ai+bi][aj+bj] != B[bi][bj]) ok = false;
    }
    if (ok) {
      cout << "Yes" << "\n";
      return;
    }
  }
  cout << "No" << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();

		int i = 0;
		String ans = "";

		while (true) {

			if (n <= 26){
				ans = (char) (96 + n) + ans;
				break;
			}

			long mod = n % 26;
			n = n / 26;

			if (mod == 0){
				mod = 26;
				n--;
			}

			char c = (char) (96 + mod);
			ans = c + ans;

			i++;

		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 39352
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()

if n == 0:
    print(0)
else:
    ans = ""
    while n != 0:
        if n & 1:
            n -= 1
            ans = '1' + ans
        else:
            ans = '0' + ans
        n //= -2
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 100100
//#define NIL -1

vector<vector<int>> ab(MAX);
vector<vector<LL>> c(MAX);
vector<LL> d(MAX);
vector<bool> is_visit(MAX, false);

void dfs(int s){
    if(ab[s].size()==0){
        return;
    }

    for(int i=0; i<ab[s].size(); i++){
        if(is_visit[ab[s][i]]==true){
            continue;
        }
        d[ab[s][i]]=d[s]+c[s][i];
        is_visit[ab[s][i]]=true;
        dfs(ab[s][i]);
    }

    return;
}

int main(){
    int n;
    int q;
    int k;
    int tmp_a;
    int tmp_b;
    LL tmp_c;
    cin >> n;
    for(int i=0; i<n-1; i++){
        cin >> tmp_a >> tmp_b >> tmp_c;
        tmp_a--;
        tmp_b--;
        ab[tmp_a].push_back(tmp_b);
        ab[tmp_b].push_back(tmp_a);
        c[tmp_a].push_back(tmp_c);
        c[tmp_b].push_back(tmp_c);
    }

    cin >> q >> k;
    k--;
    vector<int> x;
    vector<int> y;
    int tmp_x;
    int tmp_y;

    for(int i=0; i<q; i++){
        cin >> tmp_x >> tmp_y;
        tmp_x--;
        tmp_y--;
        x.push_back(tmp_x);
        y.push_back(tmp_y);
    }

    is_visit[k]=true;
    d[k]=0;
    dfs(k);

    for(int i=0; i<q; i++){
        cout << d[x[i]]+d[y[i]] << endl;
    }

    return 0;
}


Measured memory_bytes: 19188
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define MAX 1005
const ll MOD=1e9+7;
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);
  rep(i,N){
    cin >> a[i];
  }
  sort(All(a));
  ll tmp=a[0],count=1,sum=0;
  for(ll i=1;i<N;i++){
    if(tmp==a[i]){
      count++;
    }else{
      sum += (count%2==1) ? 1 : 0;
      count=1;
      tmp=a[i];
    }
  }
  sum += (count%2==1) ? 1 : 0;
  cout << sum << endl;
}

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

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

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

int main(){
  string S,T;
  cin>>S>>T;
  int n = S.length();
  char tmp;
  int ans = 0;
  for(int j=0;j<n;++j){
  tmp = S[n-1];
  for(int i=0;i<n-1;++i){
    S[n-i-1]=S[n-i-2];
  }
  S[0]=tmp;
  if(S==T) {
    ans += 1;
    break;
  }
  }
  if(ans>0) {cout<<"Yes"<<endl;}
  else {cout << "No"<<endl;}
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF=1<<30;


int main(void) {

    char a,b,c; cin>>a>>b>>c;
    set<char> st;
    st.insert(a);st.insert(b);st.insert(c);

    if(st.size()==1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

ll K;
ll A[100001];

// l以上r以下の最大のaの倍数
ll maxnum(ll l, ll r,ll a) {
	//まずr以下の最大のaの倍数を求める
	ll res = (r / a)*a;
	if (res >= l) return res;
	else return -1;
}

ll minnum(ll l, ll r, ll a) {
	if (l%a == 0) return l;
	else {
		ll res = (l / a + 1)*a;
		if (res <= r) return res;
		else return -1;
	}
}

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

	cin >> K;
	for (int i = 0; i < K; i++) cin >> A[i];

	ll left = 2;
	ll right = 2;

	for (int i = K-1; i >= 0; i--) {
		ll up = maxnum(left, right, A[i]);
		ll down = minnum(left, right, A[i]);
		if (up == -1 || down == -1) {
			cout << -1 << endl;
			return 0;
		}
		else {
			left = down;
			right = up + A[i] - 1;
		}
	}

	cout << left << " " << right << endl;

	return 0;
}

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

using ll = long long;

const int MAXN = 44;
int N;
bool A[MAXN*2][MAXN*2];

ll dp[MAXN][MAXN][MAXN];
// inclusive range, with b chosen as special
ll go(int a, int b, int c) {
	if (dp[a][b][c] != -1) {
		return dp[a][b][c];
	}
	if (a == b && c == b) {
		return dp[a][b][c] = 1;
	} else if (a == b || c == b) {
		return dp[a][b][c] = 0;
	}

	ll ans = 0;
	for (int p1 = a; p1 <= b-1; p1++) {
		for (int p2 = b+1; p2 <= c; p2++) {
			for (int q1 = p1; q1 <= b-1; q1++) {
				for (int q2 = p2; q2 >= b+1; q2--) {
					ans += A[p1][p2] * go(a, p1, q1) * go(q1+1, b, q2-1) * go(q2, p2, c);
				}
			}
		}
	}
	return dp[a][b][c] = ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N; N *= 2;
	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		for (int j = 0; j < N; j++) {
			A[i][j] = bool(s[j] - '0');
		}
	}
	memset(dp, -1, sizeof(dp));
	ll ans = 0;
	for (int i = 1; i < N; i++) {
		if (A[0][i]) {
			ans += go(1, i, N-1);
		}
	}
	cout << ans << '\n';

	return 0;
}


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

using namespace std;

typedef long long ll;
//const ll MOD = 1000000007;

int main() {
  int N,K;
  cin>>N>>K;
  vector<ll> v1(N),v2(N);
  for (int i = 0; i < N; i++) cin>>v2[i];
  v1 = v2;
  reverse(v2.begin(),v2.end());
  vector<ll> ans(200, - 1e15);
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= (N - i); j++) {
      for (int k = 0; k <= min(i + j, K - (i + j)); k++) {
        ll sum = 0;
        multiset<ll> st;
        for (int l = 1; l <= i; l++) sum += v1[l-1], st.insert(v1[l-1]);
        for (int l = 1; l <= j; l++) sum += v2[l-1], st.insert(v2[l-1]);
        auto itr = st.begin();
        for (int l = 1; l <= k; l++)  {
          sum -= *itr;
          ++itr;
        }
        ans[i + j + k] = max(ans[i + j + k], sum);
      }
    }
  }
  ll max_val = -1e15;
  for (int i = 0; i <= K; i++) max_val = max(max_val,ans[i]);
  cout<<max_val<<endl;
  return 0;
}

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

const int INF = 1000000007;
const int MX = 200010;
int dp[MX][3];

int main(){
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    rep(i, MX) rep(j, 3) dp[i][j] = 0;

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    rep(i, n){
        dp[i + 1][0] = max(dp[i][1] + a[i + 1], dp[i][2] + a[i + 1]);
        dp[i + 1][1] = max(dp[i][2] + b[i + 1], dp[i][0] + b[i + 1]);
        dp[i + 1][2] = max(dp[i][0] + c[i + 1], dp[i][1] + c[i + 1]);
    }

    cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>

struct Node {
    int key;
    Node *parent, *left, *right;
};
Node *nil, *root;

void Insert(int key)
{
    Node *x = root;
    Node *y = nil;
    Node *z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->left = nil;
    z->right = nil;
    while (x != nil) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;

    if (y == nil) {
        root = z;
    } else if (z->key < y->key) {
        y->left = z;
    } else {
        y->right = z;
    }
}

Node *Find(int key)
{
    if (root == nil) {
        return nil;
    }
    Node *x = root;
    while (x != nil) {
        if (x->key == key) {
            return x;
        }
        if (x->key < key) {
            x = x->right;
        } else {
            x = x->left;
        }
    }
    return nil;
}

Node *GetMinimum(Node *x)
{
    while (x->left != nil) {
        x = x->left;
    }
    return x;
}

Node *GetSuccessor(Node *x)
{
    if (x->right != nil) {
        return GetMinimum(x->right);
    }
    Node *y = x->parent;
    while (y != nil && x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void Delete(int key)
{
    Node *z = Find(key);
    Node *x, *y;
    if (z->left == nil || z->right == nil) {
        y = z;
    } else {
        y = GetSuccessor(z);
    }

    if (y->left != nil) {
        x = y->left;
    } else {
        x = y->right;
    }

    if (x != nil) {
        x->parent = y->parent;
    }

    if (y->parent == nil) {
        root = x;
    } else if (y == y->parent->left) {
        y->parent->left = x;
    } else {
        y->parent->right = x;
    }

    if (y != z) {
        z->key = y->key;
    }

    free(y);
}

void PrintPreorder(Node *node)
{
    if (node != nil) {
        fprintf(stdout, " %d", node->key);
        PrintPreorder(node->left);
        PrintPreorder(node->right);
    }
}

void PrintInorder(Node *node)
{
    if (node != nil) {
        PrintInorder(node->left);
        fprintf(stdout, " %d", node->key);
        PrintInorder(node->right);
    }
}

int main(int argc, char *argv[])
{
    int n, key;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        char inst[32];
        scanf("%s", inst);

        if (inst[0] == 'i') {
            scanf("%d", &key);
            Insert(key);
        } else if (inst[0] == 'p') {
            PrintInorder(root);
            fprintf(stdout, "\n");
            PrintPreorder(root);
            fprintf(stdout, "\n");
        } else if (inst[0] == 'f') {
            scanf("%d", &key);
            if (Find(key)) {
                fprintf(stdout, "yes\n");
            } else {
                fprintf(stdout, "no\n");
            }
        } else if (inst[0] == 'd') {
            scanf("%d", &key);
            Delete(key);
        }
    }

    return 0;
}


Measured memory_bytes: 21508
from collections import deque
 
n = int(input())
lst = [deque(map(int, input().split())) for _ in range(n)]
 
current = []
for i in range(n):
    current.append(lst[i].popleft())

count = 0
players = set(range(1, n+1))
while True:
    index_lst = []
    for i in players:
        candidate = current[i-1]
        if candidate in index_lst:
            continue
        if current[candidate-1] == i:
            index_lst += [i, candidate]   
    if len(index_lst) == 0:
        if sum(current) == 0:
            print(count)
            break
        else:
            print(-1)
            break
    for i in index_lst:
        if len(lst[i-1]) == 0:
            current[i-1] = 0
        else:
            current[i-1] = lst[i-1].popleft()
    players = set(index_lst)
    count += 1

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

using namespace std;

int main()
{
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n > k)
		cout << k * x + (n - k) * y << endl;
	else
		cout << n * x << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    string s;
    cin >> s;
    int a = 0;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'x') a++;
    }
    cout << (a >= 8 ? "NO" : "YES") << endl;
    return 0;
}

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

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))




int main(void)
{
	//変数の宣言
	int q;
	llong int a[110];
	llong int b[110];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	llong int ans=0;
	int count=0;
	int sum=0;
	long int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d",&q);
	
	for(i=0;i<q;i++){
		scanf("%lld %lld",&a[i],&b[i]);
	}
	
//	for(i=0;i<q;i++){
//		printf("%lld %lld\n",a[i],b[i]);
//	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	for(i=0;i<q;i++){
//		printf("i=%d q=%d\n",i,q);
		if(a[i]==b[i]){
			printf("%lld\n",2*a[i]-2);
		}else if(abs(a[i]-b[i])==1){
			printf("%lld\n",a[i]+b[i]-3);
		}else{
			temp=(long int)sqrt(a[i]*b[i]);
			if(temp*(temp+1)<a[i]*b[i]){
				printf("%ld\n",temp*2-1);
			}else if(temp*(temp+1)==a[i]*b[i]){
				printf("%ld\n",temp*2-2);
			}else if(temp*temp==a[i]*b[i]){
				printf("%ld\n",temp*2-3);
			}else{
				printf("%ld\n",temp*2-2);
			}
		}
	}
//	printf("計算部分終了\n");
	//出力
	
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



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

int main() {
	int A;	// 正整数.
	int B;	// 正整数.
	int C;	// 正整数.
	int D;	// 正整数.
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	if ((A + B) > (C + D)) {
		cout << "Left" << endl;
	}
	else if ((A + B) == (C + D)) {
		cout << "Balanced" << endl;
	}
	else {
		cout << "Right" << endl;
	}
}

Measured memory_bytes: 256
N,K = list(map(int,input().split()))
H = list(map(int,input().split()))

H.sort(reverse=True)

H=H[K:]

H_cumsum=[0]
H_sum_=0
for n in range(len(H)):
    H_sum_=H_sum_+H[n]
    H_cumsum.append(H_sum_)
print(H_sum_)

Measured memory_bytes: 101452
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
#define MAX 10000003
const int mod = 1000000007;
int prime[MAX];
unordered_map<int, int> max_map;
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
void sieve()
{
    prime[0] = prime[1] = 1;
    for (int i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}
ll fun1(ll ar[], int n)
{
    for (int i = 0; i < n; i++) {
        int num = ar[i];
        unordered_map<int, int> temp;
        while (num > 1) {
            int factor = prime[num];

            temp[factor]++;
            num /= factor;
        }

        for (auto it : temp) {
            max_map[it.first] = max(max_map[it.first], it.second);
        }
    }

    ll ans = 1;

    for (auto it : max_map) {
        ans = (ans * fast_expo(it.ff, it.ss)) % mod;
    }

    return ans;
}
int main()
{
    sieve();
    int n,i;
    cin>>n;
    ll a[n];
    ll ans1,ans=0,f=1;

    for(i=0;i<n;i++)
        {cin>>a[i];
        }
        f=fun1(a,n);
        for(i=0;i<n;i++)
        {
            ans=(ans+fast_expo(a[i],MOD-2))%MOD;
            ans%=MOD;
        }
        ans%=MOD;
        ans1=(f*ans)%MOD;
        cout<<ans1<<e;
}


Measured memory_bytes: 39808
#include <stdio.h>
#include <stdlib.h>

//int isEmpty(void);
//int isFull(void);
void push(int);
int pop(void);

int stack[1000];
int top=0;

int main(){

  int a,b;
  char c[100];
  while(scanf("%s",c)!=EOF){

    if(c[0]>=48 && c[0]<=57)push(atoi(c));
    
    else if(c[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
      //   printf("aaaaaaa:%d,%d\n",a,b);
    }
    else if(c[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
      //  printf("aaaaaaa:%d,%d\n",a,b);
    }
    else if(c[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
      //   printf("aaaaaaa:%d,%d\n",a,b);
    }
 
  }


  printf("%d\n",pop());
  return 0;
}

void push(int x){

  top++;
  stack[top]=x;

}

int pop(void){

  top--;
  return stack[top+1];
}



Measured memory_bytes: 2104
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int a[1005][1005],n,l[1005],f[1005];
int read(){
	int X=0;bool flag=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')flag=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){X=(X<<1)+(X<<3)+ch-'0';ch=getchar();}
	if(flag)return X;
	return ~(X-1);
}
V<int> v,t;
int main(){
    n=read();
    FOR(i,1,n){
    	FOR(j,1,n-1)a[i][j]=read();
    	l[i]=1;v.PB(i);
    }
    int ans=0;
    while(1){
    	bool anf=0;
    	for(int i=0;i<v.size();i++){
    		if(l[v[i]]<n){
    			anf=1;break;
    		}
    	}
    	if(!anf)break;
		ans++;
		anf=0;t.clear();
    	for(int j=0;j<v.size();j++){
    		int i=v[j];
    		if(l[i]>=n||l[a[i][l[i]]]>=n)continue;
    		if(f[i]||f[a[i][l[i]]])continue;
    		if(a[a[i][l[i]]][l[a[i][l[i]]]]==i){
    			anf=1;
    			t.PB(i);t.PB(a[i][l[i]]);f[i]=1;f[a[i][l[i]]]=1;
    			l[a[i][l[i]]]++;l[i]++;
    		}
    	}
    	for(int j=0;j<t.size();j++)f[t[j]]=0;
    	v=t;
    	if(!anf){
    		puts("-1");return 0;
		}
//    	FOR(i,1,n)cout<<l[i]<<' ';
//    	cout<<'\n';
    }
    printf("%d",ans);
	RE 0;
}


Measured memory_bytes: 4224
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


fn main() {
    let n: i32 = read();

    let c: i32 = (n as f64 / 2.).ceil() as i32;

    println!("{}", c);
}

Measured memory_bytes: 4352
import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.List (sort)

main :: IO ()
main = do
  [n, m] <- map read <$> words <$> getLine
  solve n <$> replicateM m (read <$> head <$> words <$> getLine) >>= print

solve :: Int -> [Int] -> Int
solve n = sum . map f . tail . sort
  where f x = max 0 (n - x)



Measured memory_bytes: 4836
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  vector<ll>a(n+1);
  vector<ll>b(n);
  for(int i=0;i<n+1;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  ll ans=0;
  for(int i=0;i<n;i++){
    if(b[i]<=a[i])ans+=b[i];
    else if(b[i]<=a[i]+a[i+1]){
      a[i+1]-=b[i]-a[i];
      ans+=b[i];
    }
    else {
      ans+=a[i]+a[i+1];
      a[i]=0;
      a[i+1]=0;
    }
  }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
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;
}
int main()
{
    COMinit();
    ll N, K, ans1 = 0, ans2 = 0;
    cin >> N >> K;
    vll A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    sort(all(A), greater<int>());
    for (int i = 0; i <= N - K; i++) //N-1-K>=i
    {
        ans1 = (ans1 + ((A[i] % MOD) * (COM(N - 1 - i, K - 1) % MOD)) % MOD) % MOD;
        ans2 = (ans2 + ((A[N - 1 - i] % MOD) * (COM(N - 1 - i, K - 1) % MOD)) % MOD) % MOD;
    }
    cout << ((ans1 - ans2) % MOD+MOD)%MOD;
    return 0;
}

Measured memory_bytes: 13056
import queue
N,M=map(int,input().split())
s=[[]for i in range(N)]
for i in range(M):
    L,R,D=map(int,input().split())
    s[L-1].append((R-1,D))
    s[R-1].append((L-1,-D))

q=queue.Queue()
dist=[None]*N

for i in range(N):
    if dist[i]==None:
        dist[i]=0
        q.put(i)
    while not q.empty():
        From=q.get()
        for l in s[From]:
            To,w=l
            if dist[To]==None:
                dist[To]=dist[From]+w
                q.put(To)
            else:
                if dist[To]!=dist[From]+w:
                    print("No")
                    exit()
print("Yes")

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

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

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

  cout << N*(N-1)/2 + M*(M-1)/2;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h> 
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#define max(a,b) (a>b ? a : b)
#define min(a,b) (a<b ? a : b)
using namespace std;
typedef long long int lli;
lli mod=1000000007;
vector < lli> primes;

void Sieve(lli n) 
{ 
    bool prime[n+1];
	for(lli i=0;i<n+1;++i)
		prime[i]=true;
    for (lli p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (lli i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(lli p=2; p<=n; p++) 
       if (prime[p]) 
		primes.push_back(p);  
}
lli gcd(lli a,lli b)  
 {
    if(b>a)
        swap(a,b);
    if (a%b==0)  
        return b;  
    else 
        return gcd(a%b,b);  
 }
lli lcm(lli a,lli b)
{
    return (a*b)/gcd(a,b);    
}
lli power(lli x,lli y,lli m)   
{ 
    lli res = 1; 
    x=x%m;   
    while (y > 0) 
    {  
        if (y%2==1) 
            res =(res*x)%m;  
        y=y/2; 
        x=(x*x)%m; 
    } 
    return res; 
}
bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) 
{ 
	return v1[0] < v2[0]; 
}
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	string s;
	cin>>s;
	char last;
	lli child[s.length()]={0};
	lli dp[s.length()][2];
	dp[s.length()-1][0]=s.length()-1;
	dp[s.length()-1][1]=-1;
	dp[0][1]=0;
	for(lli i=s.length()-2;i>=0;--i)
	{
		if(s[i]=='L')
			dp[i][0]=i;
		else
			dp[i][0]=dp[i+1][0];
	}
	for(lli i=1;i<s.length();++i)
	{
	    if(s[i]=='R')
	        dp[i][1]=i;
	    else
	        dp[i][1]=dp[i-1][1];
	}
	for(lli i=0;i<s.length();++i)
	{
	    //cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
		if(s[i]=='R')
		{
			lli end=dp[i][0];
			lli steps=end-i;
			if(steps%2==0)
			{
				child[end]++;
			}
			else
				child[end-1]++;
		}
		else
		{
			lli end=dp[i][1];
			lli steps=i-end;
			if(steps%2==0)
			{
				child[end]++;
			}
			else
				child[end+1]++;
		}
		
	}
	for(lli i=0;i<s.length();++i)
		cout<<child[i]<<" ";
	
	
}

Measured memory_bytes: 3024