akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

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

	const int L = S.length();

	int ans = 0;

	string x = "";
	while (!S.empty()) {
		if (x.length() == 0 || x.length() == 2) {
			x = S.substr(0, 1);
			S.erase(0, 1);
			++ans;
		}
		else if (x.length() == 1) {
			if (x != S.substr(0, 1)) {
				x = S.substr(0, 1);
				S.erase(0, 1);
				++ans;
			}
			else if (S.length() >= 2) {
				x = S.substr(0, 2);
				S.erase(0, 2);
				++ans;
			} else {
				x += S.substr(0, 1);
				S.erase(0, 1);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>

using namespace std;
inline long long po(int n) {
	long long ans = 1;
	for (int i = 0;i < n;i++) {
		ans *= 2;
	}
	return ans;
}

inline long long bac(vector<bool> ju) {
	long long ans = 0;
	long long di = 1;
	for (int i = 0;i < ju.size();i++) {
		if (ju[i]) {
			ans += di;
		}
		di *= 2;
	}
	return ans;
}

inline void cha(long long n, vector<bool> &ju) {
	for (int i = 0;i < ju.size();i++) {
		ju[i] = n % 2;
		n /= 2;
	}
}

int main() {
	int n;
	cin >> n;
	vector<vector<int> > da(n, vector<int>(n));
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			cin >> da[i][j];
		}
	}
	vector<long long> mo(n);
	mo[0] = 1;
	for (int i = 0;i < n - 1;i++) {
		mo[i + 1] = mo[i] * 2;
	}
	int x = po(n);
	vector<long long> dp(x, 0);
	dp[0] = 1;
	for (long long i = 1;i < x;i++) {
		vector<bool> ju(n);
		cha(i, ju);
		int co = -1;
		long long me = 0, gg = 0;
		for (int j = 0;j < n;j++) {
			if (ju[j]) {
				gg += mo[j];
				co++;
			}
		}
		for (int j = 0;j < n;j++) {
			if (ju[j] & da[co][j]) {
				me += dp[gg-mo[j]];
			}
		}
		dp[i] = me % 1000000007;
	}
	printf("%lld",dp[x-1]);
}


Measured memory_bytes: 16640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N;

int main() {
	scanf("%d", &N);
	vector <pii> ans;
	int mat[110];
	if(N % 2 == 1) { mat[N] = N; for(int i=1;i<=N-1;i++) mat[i] = N-i; }
	else { for(int i=1;i<=N;i++) mat[i] = N+1-i; }
	for(int i=1;i<=N;i++) for(int j=i+1;j<=N;j++) if(mat[i] != j && mat[j] != i) {
		ans.pb(pii(i, j));
	}
	printf("%d\n", szz(ans));
	for(pii e : ans) printf("%d %d\n", e.Fi, e.Se);
	return 0;
}

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

typedef long long lint;
typedef long double louble;

const char lf = '\n';

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline lint ty()
	{
		lint a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

int main()
{
	lint n=ty(),a=ty(),b=ty();
	if(a>b)swap(a,b);
	lint ans=min(b-1,n-a);
	if((a&1)==(b&1))ans=min(ans,(b-a)/2);
	else
	{
		ans=min(ans,a+(b-a-1)/2);
		ans=min(ans,n-b+1+(b-a-1)/2);
	}
	cout<<ans<<lf;

	return 0;
}

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

typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for (int i=0;i<N;i++){
        int h;
        cin >> h;
        if (h >= K) ans++;
    }
    cout << ans << endl;

    return 0;
}

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

int D;
std::vector<int> c(26);
std::vector<std::vector<int>> s(365, std::vector<int>(26));
std::vector<int> last(26, 0);
std::vector<int> t(365);

void calc_greedy_score() {
    for (int i = 0; i < D; i++) {
        int max_idx = 0;
        int max_score = -365 * 100 * 26;
        for (int j = 0; j < 26; j++) {
            int tmp_score = 0;
            for (int k = 0; k < 26; k++) {
                if (j != k) {
                    tmp_score -= c[k] * (i + 1 - last[k]);
                }
            }
            tmp_score += s[i][j];
            if (tmp_score > max_score) {
                max_idx = j;
                max_score = tmp_score;
            }
        }
        last[max_idx] = i + 1;
        t[i] = max_idx + 1;
    }
}


void update_score(int day, int before_cont, int after_cont, int score) {
    int pre_day = day - 2;
    for (; pre_day >= 0; pre_day--) {
        if (t[pre_day] == before_cont) {
            break;
        }
    }
    int diff = day - pre_day - 1;

    int post_day = day;
    for (; post_day < D; post_day++) {
        if (t[post_day] - 1 == before_cont) {
            break;
        }
        score -= diff;
    }
}


int main() {
    std::cin >> D;

    for (int i = 0; i < 26; i++) {
        std::cin >> c[i];
    }

    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) {
            std::cin >> s[i][j];
        }
    }

    calc_greedy_score();

    for (auto val : t) {
        std::cout  << val << std::endl;
    }
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int num[n + 1];
    num[0] = 0;

    int number = 0;
    repd(i, 1, n + 1) {
        number = i;
        int temp = 0;
        while (true) {
            if (number % 2 == 0) {
                temp++;
                number /= 2;
            } else {
                break;
            }
        }

        num[i] = temp;
    }

    int ans = 1;
    int count = 0;
    rep(i, n + 1) {
        if (count < num[i]) {
            ans = i;
            count = num[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){
	int n, c[100001] = {};
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int a; scanf("%d", &a);
		c[a]++;
	}
	int res = 0, e = 0;
	for(int i = 1; i <= 100000; i++){
		if(c[i] == 0) continue;
		res += (c[i] - 1) / 2;
		if(c[i] % 2 == 0) e++;
	}
	res = n - 2 * res;
	if(e % 2 == 0) res -= e;
	else res -= e + 1;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
typedef struct{
  int parent, left, right;
}Node;
 
Node Tree[MAX];
int n, Depth[MAX];
 
int getDepth(int);
void print(int);
 
int child[MAX];
 
int main(void){
  int i, j;
  int degree, vertex;
 
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ) {
    Tree[i].parent = NIL;
    Tree[i].left = NIL;
    Tree[i].right = NIL;
  }
 
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &vertex, &degree);
    for ( j = 0; j < degree; j++ ){
      scanf("%d", &child[j]);
 
      Tree[child[j]].parent = vertex;
       
      //rightを決める基準となる。
      if(j == 0)
    Tree[vertex].left = child[0];
       
      else
    Tree[child[j - 1]].right = child[j];
    }
  }
   
  for ( i = 0; i < n; i++ )
    Depth[i] = getDepth(i);
   
  for ( i = 0; i < n; i++ )
    print(i);
   
  return 0;
}
 
int getDepth(int u){
  int d = 0;
 
  while(Tree[u].parent >= 0){
    u = Tree[u].parent;
    d++;
  }
 
  return d;
}
 
void print(int u){
 
  int i, cnt = 0;
 
  printf("node %d: parent = %d, depth = %d, ",u,Tree[u].parent,Depth[u]);
 
  if(Tree[u].parent == NIL)
    printf("root, [");
 
  else if(Tree[u].left == NIL)
    printf("leaf, [");
 
  else
    printf("internal node, [");
 
  u = Tree[u].left;
  while(u != NIL){
    if(cnt == 0)
      printf("%d",u); 
 
    else
      printf(", %d",u);
   
    u = Tree[u].right;
    cnt++;
 
     
  
 }
 
 
    printf("]\n");
 
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] num = Input.ScanIntArray();
          Console.WriteLine(Math.Max(0,num[0]-num[1]));
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main() {
    int N; cin >> N;
    vector<int> s(N); REP(i, N) cin >> s[i];

    sort(all(s));
    int ans = accumulate(all(s), 0);
    if(ans % 10 == 0) {
        REP(i, N) {
            int a = ans - s[i];
            if(a % 10 != 0) {
                ans = a;
                break;
            }

            if(i == N - 1) {
                ans = 0;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=605,mod=1000000007;
int v[N],f[N][N],g[N][N];
inline void add(int &a,int b){
	a=a+b>=mod?a+b-mod:a+b;
}
int main(){
	int n=read(),cnt=0;
	ll ans=1;
	for(int i=1;i<=n;i++){
		int x=read(),y=read();
		if(x!=-1&&y!=-1){v[x]=v[y]=-1; continue;}
		if(x!=-1)v[x]=1; if(y!=-1)v[y]=1;
		if(x==-1&&y==-1)ans=ans*++cnt%mod;
	}
	f[0][0]=1;
	for(int i=1;i<=2*n;i++)if(v[i]!=-1){
		if(v[i]){
			for(int j=0;j<=i;j++){
				for(int k=0;k+j<=i;k++)if(f[j][k]){
					add(g[j+1][k],f[j][k]);
					if(k)add(g[j][k-1],(ll)f[j][k]*k%mod);
					f[j][k]=0;
				}
			}
		}else{
			for(int j=0;j<=i;j++){
				for(int k=0;k+j<=i;k++)if(f[j][k]){
					add(g[j][k+1],f[j][k]);
					add(g[j+1][k],f[j][k]);
					if(j)add(g[j-1][k],f[j][k]);
					f[j][k]=0;
				}
			}
		}
		swap(f,g);
	}
	cout<<ans*f[0][0]%mod<<endl;
}

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

using namespace std;

int main()
{
  long long n, p;
  cin >> n >> p;
  unordered_map<long long, long long> m;
  long long now = 2;
  while (now * now <= p)
    if (p % now == 0)
    {
      m[now]++;
      p /= now;
    }
    else
      now++;
  m[p]++;
  long long ans = 1;
  for (pair<long long, long long> t : m)
    for (int i = 0; i < t.second / n; i++)
      ans *= t.first;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    Fast;
    long long n,m,t,i,j,k,x=0,y=0,z,q,l,r;
    char c,c1;string s,ss;
    cin>>c>>c1;
    n=c-48;m=c1-48;
    for(i=0;i<n;i++){
        s=s+c1;
    }
    for(i=0;i<m;i++){
        ss=ss+c;
    }
    if(s>ss){
        cout<<ss<<endl;
    }
    else if(ss>s){
        cout<<s<<endl;
    }
    else{
            cout<<s<<endl;
    }


}


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

int main(){
    int A,B,C,X;
    int ans = 0;
    cin >> A >> B >> C >> X;
    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(X == i*500 + j*100 + k*50){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

long long int N;
string s;
char c = -1;
set<string> S;

int main(){
    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> s;
        if(c >= 0 && c != s[0])return 0 & puts("No");
        c = *s.rbegin();
        if(!S.insert(s).second)return 0 & puts("No");
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c), sp(a + 1), sq(b + 1), sr(c + 1);
  REP(i, a) cin >> p[i];
  REP(i, b) cin >> q[i];
  REP(i, c) cin >> r[i];

  sort(ALL(p), greater<ll>());
  sort(ALL(q), greater<ll>());
  sort(ALL(r), greater<ll>());

  priority_queue<P> que;
  REP(i, a) { que.push(P(p[i], 1)); }
  REP(i, b) { que.push(P(q[i], 2)); }
  REP(i, c) { que.push(P(r[i], 3)); }

  ll ans = 0, cnt_p = 0, cnt_q = 0, sum = 0;
  while (true) {
    P now = que.top();
    que.pop();

    if (now.second == 1 && cnt_p == x) continue;
    if (now.second == 2 && cnt_q == y) continue;

    ans += now.first;

    if (now.second == 1)
      ++cnt_p;
    else if (now.second == 2)
      ++cnt_q;

    ++sum;

    if (sum == x + y) break;
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15212
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, 
# s = input()

M, D = map(int, input().split())

ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d = str(d)
        if len(d) == 2:
            d1 = int(d[0])
            d10 = int(d[1])
            if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
                ans += 1
print(ans)
            




Measured memory_bytes: 39408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num1 = scanner.nextInt();
		int num2 = scanner.nextInt();
		
		if(num1>num2)
			System.out.println("a > b");
		else if(num1<num2)
			System.out.println("a < b");
		else
			System.out.println("a == b");
	}
}

Measured memory_bytes: 17344
N = input()
a = int(N[0])
b = int(N[1])
c = int(N[2])
d = int(N[3])
x = d+7
y = -d+7
while True:
    if a+b+c == x:
        print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
        break
    if a+b+c == y:
        print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
        break
    if a-b+c == x:
        print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
        break
    if a-b+c == y:
        print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
        break
    if a+b-c == x:
        print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
        break
    if a+b-c == y:
        print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
        break
    if a-b-c == x:
        print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
        break
    if a-b-c == y:
        print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
        break

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct nums{
  int a;
  int b;
  int c;

  nums(int _a, int _b, int _c){
    a=_a;
    b=_b;
    c=_c;
  }

  bool operator<( const nums &r) const {
    return a!=r.a ? a<r.a : (b!=r.b ? b<r.b : c<r.c);
  }
};


int main(){
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  LL a[x], b[y], c[z];
  REP(i, x) cin>>a[i];
  sort(a, a+x, greater<LL>());
  REP(i, y) cin>>b[i];
  sort(b, b+y, greater<LL>());
  REP(i, z) cin>>c[i];
  sort(c, c+z, greater<LL>());

  vector<LL> ans;

  priority_queue< pair<LL, nums> > q;
  set<int> st;
  q.push(make_pair(a[0]+b[0]+c[0], nums(0, 0, 0)));
  st.insert(0);

  REP(i, k){
    auto work = q.top();
    LL Lw =work.first;
    auto d = work.second;
    q.pop();
    ans.push_back(Lw);

    if(d.a<x-1){
      if(st.find( ((d.a + 1) << 20) + (d.b << 10) + d.c ) == st.end()){
        q.push(make_pair(Lw + a[d.a + 1] - a[d.a], nums(d.a+1, d.b, d.c)));
        st.insert( ((d.a + 1) << 20) + (d.b << 10) + d.c );
      }
    }

    if(d.b<y-1){
      if(st.find((d.a << 20) + ((d.b + 1) << 10) + d.c) == st.end()){
        q.push(make_pair(Lw + b[d.b + 1] - b[d.b], nums(d.a, d.b+1, d.c)));
        st.insert( (d.a << 20) + ((d.b + 1) << 10) + d.c );
      }
    }

    if(d.c<z-1){
      if(st.find((d.a << 20) + (d.b << 10) + d.c+1) == st.end()){
        q.push(make_pair(Lw + c[d.c + 1] - c[d.c], nums(d.a, d.b, d.c+1)));
        st.insert( (d.a << 20) + (d.b << 10) + d.c+1 );
      }
    }
  }


  REP(i, k) cout<<ans[i]<<endl;

  return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	double A, B, H, M;
	cin >> A >> B >> H >> M;

	double l, r;
	l = 2 * M_PI / (12.0*60.0)*(60.0*H + M);
	r = 2 * M_PI / 60.0*M;

	double ang = abs(l - r);

	double d = abs(A*cos(ang) - B);
	double ans = sqrt(d*d + (A*sin(ang))*(A*sin(ang)));
	cout << fixed << setprecision(12) << ans << endl;

	return 0;
}

Measured memory_bytes: 4112
public class Main {
	public static void main(String[] args) {
		java.util.Scanner s = new java.util.Scanner(System.in);
		long a = s.nextLong();
		long b = s.nextLong();
		long c = s.nextLong();
		long d = c-a-b;
		if (d > 0 && 4*a*b<d*d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	int t = 1;
	//cin >> t;
	while(t--){
		ll n;
		cin >> n;
		string s;
		while(n--){
			s += n % 26 + 'a';
			n /= 26;
		}
		string ans = string(s.rbegin(), s.rend());
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<ext/rope>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lowbit(x) x & (-x)
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e4 + 5;
using namespace std;
using __gnu_cxx::crope;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	for(int i = 1; i <= k; i++){
		if(i & 1){
			if(a & 1) a--;
			b += (a / 2);
			a /= 2;
		}
		else{
			if(b & 1) b--;
			a += (b / 2);
			b /= 2;
		}
	}
	cout << a << ' ' << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);

	vector<pair<int, int>> info[100000];
	for (int i = 0; i < M; i++) {
		int L, R, D;
		scanf("%d%d%d", &L, &R, &D);
		L--;
		R--;
		info[L].push_back(make_pair(R, D));
		info[R].push_back(make_pair(L, -D));
	}

	bool used[100000];
	for (int i = 0; i < N; i++)
		used[i] = false;

	for (int i = 0; i < N; i++) {
		if (used[i] || info[i].size() < 1)
			continue;

		queue<int> q;
		q.push(i);
		map<int, int> dist;
		dist[i] = 0;
		while (!q.empty()) {
			int node = q.front(); q.pop();
			if (used[node])
				continue;
			used[node] = true;

			for (int i = 0; i < (int)info[node].size(); i++) {
				int next_node = info[node][i].first;
				int next_dist = info[node][i].second;
				if (dist.count(next_node) == 0) {
					dist[next_node] = dist[node] + next_dist;
					q.push(next_node);
				} else if (dist[next_node] != dist[node] + next_dist) {
					printf("No\n");
					return 0;
				}
			}
		}
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 13556
//Dice and Coin

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n,k;cin>>n>>k;
    double c;
    rep(i,1,n+1){
        double t=1;
        int r=i;
        for(int j=1;r<k;j++){
            r*=2;
            t/=2;
        }
        c+=t;
    }
    cout15(c/n);
    return 0;
}

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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var s = input[0];
            var w = input[1];

            Console.WriteLine(w >= s ? "unsafe" : "safe");
        }
    }
}


Measured memory_bytes: 28300
#include <bits/stdc++.h>
using namespace std;
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define ff              first
#define ss              second
#define LCM(x,y)        (((x)/__gcd((x),(y)))*(y))
#define PI              acos(-1)
#define SZ(x)           x.size() - 1
#define waa             puts("ripon")
#define mem(a,b)        memset(a,b,sizeof(a))
#define rep(i,a,n)      for(int i=(int)(a);i<=(int)(n);i++)
#define per(i,n,a)      for(int i=(int)(n);i>=(int)(a);i--)
#define all(v)          v.begin(), v.end()
#define allr(v)         v.rbegin(), v.rend()
int dx[] = { 0, 1, 0, -1, -1, 1, 1, -1 };
int dy[] = { 1, 0, -1, 0, -1, -1, 1, 1 };
int overlap(int rs,int re,int qs,int qe){ if(rs>qe or re<qs) return 0; else if(qs<=rs and re<=qe) return 1; else return 2;} // 0 no, 1 total, 2 partial
void pvec(auto v){for(auto x:v){cout<<x<<" ";}cout<<endl;}
//*************useless stuff*************//

#define TC 0
#define mod 10000007
#define N 1000000

void solve(int T) {
    int n;
    cin>>n;

    vector<pair<int,int> > v;

    rep(i,1,n){
        int x,l;
        cin>>x>>l;

        int lft = x - l;
        int rgt = x + l;

        v.pb(mp(lft,rgt));

    }

    sort(all(v));
    int last_end = INT_MIN;
    int cnt = 0;
    for(auto p: v){

        if(p.ss<last_end){
            last_end = p.ss;
        }else if(p.ff>=last_end) {
            cnt++;
            last_end = p.ss;
        }
    }
    cout<<cnt<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    #ifdef LOCALDEF
        freopen("input.txt","r",stdin);
    #endif
    int T=1;
    if(TC) cin>>T;
    for(int t=1;t<=T;t++)   solve(t);
    return 0;
}


Measured memory_bytes: 1400
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

# discounts=[]
price=[]
for i in range(M):
    x,y,c=map(int,input().split())
    price.append(a[x-1]+b[y-1]-c)
    # discounts.append([x,y,c])


min_defo = min(a)+min(b)
min_discount = min(price)

print(min(min_defo,min_discount))

Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
const int MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    auto C = getVector<int>(4);
    string com[4] = {"AC", "WA", "TLE", "RE"};
    int N;
    cin >> N;
    while(N --> 0) {
        string s;
        cin >> s;
        for(int i = 0;i < 4;i++) {
            if(s == com[i]) {
                C[i]++;
            }
        }
    }
    for(int i = 0;i < 4;i++) {
        cout << com[i] << " x " << C[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
#include<stdio.h>
int main()
{
	int a, b, c, d;
	double f;
	scanf("%d%d", &a, &b);
	c = a / b;
	d = a%b;
	f = (double)a / (double)b;
	printf("%d %d %f\n", c, d, f);
	return 0;

}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define endl "\n"
#define unll unsigned long long
#define ll long long
#define INF 1<<31-1
#define mmax(x,y) ((x)<(y)?(x):(y))
#define mmin(x,y) ((x)<(y)?(y):(x))
#define pb push_back
#define ffor(i,a,n) for(ll i = (ll)a; i<(ll)n; i++)
#define iscanf(k) scanf("%d", &k)
#define fscanf(k) scanf("%f", &k)
#define llscanf(k) scanf("%ll", &k)
#define pi pair<int, int>;
#define pii pair<pi, pi>;
using namespace std;

typedef struct data {
    long long cost, deadline;
} data;


vector<pair<ll, ll>> v;
ll A, B;
ll sum = 0;

bool compare(pair<ll, ll> a, pair<ll, ll> b) {
    return a.first<b.first;
}

int main() {
    long long n;
    cin >> n;

    ffor(i,0,n) {
        cin >> A >> B;
        v.push_back(make_pair(B, A));
    }

    sort(v.begin(),v.end(), compare);

   // ffor(i,0,n){
  //      cout << a[i].cost << " " << a[i].deadline << endl;
  //  }

    long long tmp=0;
    for(int i=0; i<n; i++) {
        tmp += v[i].second;
        if(tmp>v[i].first) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

}


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

int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;
	if (a + b > c + d)
	{
		cout << "Left" << endl;
	}
	else if (a + b == c + d)
	{
		cout << "Balanced" << endl;
	}
	else
	{
		cout << "Right" << endl;
	}
	return 0;
}


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

int main(){
	int H,W,N;	cin>>H>>W>>N;
	vector<int> A(H*W);
	int count=0;
	for(int i=1;i<=N;i++){
		int a;	cin>>a;
		for(int j=0;j<a;j++){
			A[count]=i;
			count++;
		}
	}

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(j)cout<<" ";

			if(i%2==0)cout<<A[(i*W)+j];
			else cout<<A[(i*W)+(W-1-j)];
		}
		cout<<endl;
	}


	return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i = (n); i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9+7);//998244353;
const int N = (int)(1e6+5);

void pre() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n;  cin>>n;
  ll k = 1000;
  vector<int> a(n);
  rep(i,n)  cin>>a[i];
  ll stocks = 0,price = 200;
  rep(i,n) {
    if(i == 0)  {
      stocks = k/a[i];
      k = k - stocks*a[i];
      continue;
    }
    if(a[i] == a[i-1])  continue;
    else if(a[i] > a[i-1]) {
      k = k + stocks * a[i];
      stocks = k/a[i];
      k = k - stocks * a[i];
    }
    else {
      k = k + stocks * a[i-1];
      stocks = k/a[i];
      k = k - stocks * a[i];
    }
  }
  k = k + stocks*a[n-1];
  cout<<k;
}

int main() {
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
  #endif
  pre();
  int t = 1;
  //cin>>t;
  rep(i,t)  {
    //cout<<"Case #"<<(i+1)<<": ";
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int dp[100001],in[100001];


int main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    vector<vector<int>> e;
    int n,m;
    queue<int> que;
    cin>>n>>m;
    e.resize(n+1);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        e[x].emplace_back(y);
        ++in[y];
    }
    for(int i=0;i<=n;i++)
        if(!in[i]) que.push(i);
    while(que.size())
    {
        int v=que.front();
        que.pop();
        for(auto& u:e[v])
        {
            --in[u];
            dp[u]=max(dp[u],dp[v]+1);
            if(!in[u]) que.push(u);
        }
    }
    int mx=0;
    for(int i=0;i<=n;i++)
        mx=max(mx,dp[i]);
    cout<<mx<<flush;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {

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

	int a, b;

	cin >> a >> b;

	int ans;
	if (a == b) {
		ans = a + b;
	}
	else if (a > b) {
		ans = a + a - 1;
	}
	else {
		ans = b + b - 1;
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
	int n;
	int a[100 + 1] = { 0 };

	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];

	int max = 0;
	int temp = 0;
	for (int i = 0; i <= n; i++) {
		if ((a[i] == 0) && (max < temp)) {
			max = temp;
			temp = 0;
		}
		else if (a[i] == 1)
		{
			temp++;
		}
		else if (a[i] == 0)
		{
			temp = 0;
		}
	}

	cout << max + 1 << endl;

	return 0;
}


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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum4 = 0;
    ll sum2 = 0;
    rep(i, n){
        cin >> a[i];
        if (a[i] % 4 == 0){
            sum4++;
        }else if (a[i] % 2 == 0){
            sum2++;
        }
    }

    ll other = n - sum4 - sum2 + (sum2 > 0 ? 1 : 0);
    if (sum4+1 >= other){
        puts("Yes");
    }else{
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 4032
import std.stdio, std.array, std.conv, std.algorithm, std.string, std.numeric, std.range;
void main() {
        int n;
        while((n=readln.strip.to!int)!=0){
                char[char] con;
                foreach(i; 0..n){
                        auto r = readln.strip.split(' ');
                        con[r[0][0]] = r[1][0];
                }
                n = readln.strip.to!int;
                foreach(i; 0..n){
                        auto c = readln[0];
                        if(c in con){
                                write(con[c]);
                        }else{
                                write(c);
                        }
                }
                writeln();
        }
}

Measured memory_bytes: 3180
#include<iostream>

using namespace std;

int main()
{
    int a,b,c;
    while(scanf("%d %d %d",&a,&b,&c)==3)
    {
        if(a==5 && b==5 && c==7 || a==5 && b==7 && c==5 || a==7 && b==5 && c==5)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int n = sc.nextInt();
			int[] a = new int[n];
			
			for(int i=0;i<n;i++) {
				a[i] = sc.nextInt();
			}
			
			Arrays.sort(a);
			
			int min = a[0];
			int max = a[1];
			
			while(min>0) {
				int max2 = max - min;
				if(min<max2) {
					max = max2;
				}else {
					max = min;
					min = max2;
				}
			}
			int ret1 = max;
			
			int ret2 = Integer.MAX_VALUE;
			for(int i=1;i<n;i++) {
				if(a[i]-a[i-1]==0) {
					continue;
				}else {
					ret2 = Math.min(a[i]-a[i-1], ret2);
				}
			}
			
			System.out.println(Math.min(ret1,ret2));
		}
		
	}


Measured memory_bytes: 54112
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

const ull D = 5000000000000000000;
vector<ull> S;

signed main() {
    string SS;
    ull K;
    cin >> SS >> K;

    S.resize(SS.size());

    REP(i, SS.size()) {
        S[i] = SS[i] - '0';
        if (S[i] != 1) {
            S[i] *= D;
        }
    }

    ull sum = 0;
    REP(i, SS.size()) {
        sum += S[i];
        S[i] = sum;
    }

    auto lb = lower_bound(ALL(S), K);
    if (lb == S.end()) lb = S.end()-1;
    cout << SS[lb - S.begin()] << LF;

    return 0;
}


Measured memory_bytes: 256
# 081
import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def db(x): 
    global debug
    if debug: print(x)
debug = True
def power2(n):
    c = 0
    while n>0:
        if n%2!=0: return c
        c+=1
        n//=2
    return c

n = getInt()
a = getIntList()
cnt = 10**9
for i in range(n): cnt = min(cnt, power2(a[i]))
print(cnt)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}

struct UnionFind {
    vector<int> parent;
    UnionFind(int n=0): parent(n, -1) {}
    int root(int x) {
        if (parent[x] < 0) return x;
        return parent[x] = root(parent[x]);
    }
    bool connect(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -parent[root(x)]; }
};


int main(){
    int n, m;
    cin >> n >> m;

    vector<P> e;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        e.emplace_back(a, b);
    }

    int ans = 0;
    rep(i, m) {
        UnionFind tree(n);
        rep(j, m) if (i != j) tree.connect(e[j].first, e[j].second);
        set<int> s;
        rep(j, n) if (tree.root(j) == j) s.insert(j);
        if (s.size() > 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<iostream>
using namespace std;
int m,n;
typedef long long int LL;
LL cnt = 0;
int main()
{
    LL t;
    scanf("%d%d", &n,&m);
    map<LL,LL>mp;
    mp[0]++;
    LL sum = 0;
    LL ans = 0;
    for(int i = 0; i < n; i++)
    {
        scanf("%lld", &t);
        sum = (t + sum) % m;
        ans += mp[sum];
        mp[sum]++;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4224
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

XX = S()
if XX.isupper():
    print('A')
else:
    print('a')

Measured memory_bytes: 61680
<?php
$str = trim(fgets(STDIN));
$q = intval(trim(fgets(STDIN)));
for($i = 0;$i < $q;++$i){
  $command = explode(" ", trim(fgets(STDIN)));
  switch($command[0]){
    case "replace":
      $a = $command[1];
      $b = $command[2];
      $replace = $command[3];
      $str = substr($str, 0, $a) . $replace . substr($str, $b + 1);
      break;
    case "reverse":
      $a = $command[1];
      $b = $command[2];
      $str = substr($str, 0, $a) . strrev(substr($str, $a, $b - $a + 1)) . substr($str, $b + 1);
      break;
    case "print":
      $a = $command[1];
      $b = $command[2];
      print(substr($str, $a, $b - $a + 1) . "\n");
      break;
  }
}



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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------

struct point {
    int x, y;
};

bool comp(point &p1, point &p2) {
    return (p1.x < p2.x);
}

int main() {
    int n;
    cin >> n;
    point red[n], blue[n];
    rep(i, n) cin >> red[i].x >> red[i].y;
    rep(i, n) cin >> blue[i].x >> blue[i].y;

    sort(blue, blue + n, comp);

    int pair_cnt = 0;

    rep(b, n) {

        REPM(i, blue[b].y - 1, 0) {
            bool loop_cut = false;
            rep(r, n) if (red[r].y == i && red[r].x < blue[b].x) {
                red[r].x = red[r].y = INF;
                pair_cnt++;
                loop_cut = true;
                break;
            }
            if (loop_cut) break;
        }
    }

    cout << pair_cnt << endl;

    return 0;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> a;
  load(a, n);
  p(max(a) - min(a));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 998244353;
const ll mod = 1e9 + 7;
const int mxN = 1e5 + 9;

char ar[7][7];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int x,n,tmp;
	cin >> x >> n;
	map<int, vector<int> > m1;
    for(int i=1; i <= n; i++){
        cin >> tmp;
        m1[abs(x-tmp)].push_back(tmp);
    }
    for(auto &c: m1) sort( (c.second).begin(), (c.second).end() );
    if( m1[0].size() == 0 ){
        cout << x; return 0;
    }
    int i=1;
    while(1){
        if( m1[i].size() == 0 ){ cout << x-i; return 0; }
        else if( m1[i].size() == 1 ){
            int c1 = x-i; int c2 = x+i;
            if( m1[i][0] == c1 ){ cout << c2; return 0;}
            else{
                cout << c1; return 0;
            }
        }
        ++i;
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1001],b[1001],ans;
int main()
{
	cin>>n>>m;
	int sum=2;
	for(int i=1;i<=n;i++)
	{
		a[i]=sum;
		sum+=2;
	}
	sum=1;
	for(int i=1;i<=m;i++)
	{
		b[i]=sum;
		sum+=2;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if((a[i]+b[j])%2==0)ans++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if((a[i]+a[j])%2==0)ans++;
		}
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=i+1;j<=m;j++)
		{
			if((b[i]+b[j])%2==0)ans++;
		}
	}
	cout<<ans;
}



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

int main(){
    double x1, y1, x2, y2, ans;
    cin >> x1 >> y1 >> x2 >> y2;
    ans = sqrt(pow(x1 - x2, 2.0) + pow(y1 - y2, 2.0));
    printf("%lf", ans);
    return 0;
}


Measured memory_bytes: 3216
import sys
from collections import defaultdict

if __name__ == '__main__':
    n, v = map(int, sys.stdin.readline().split())
    a = list(map(int, sys.stdin.readline().split()))
    b = list(map(int, sys.stdin.readline().split()))
    c = list(map(int, sys.stdin.readline().split()))
    d = list(map(int, sys.stdin.readline().split()))
    mp = defaultdict(int)
    ls = []
    for val1 in c:
        for val2 in d:
            mp[val1+val2] += 1
    ans = 0
    for val1 in a:
        for val2 in b:
           ans += mp[v-val1-val2]
    print(ans)



Measured memory_bytes: 179080
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool used[210];
bool graph[100][100] = { false };
bool visited[8];


int main() {
	int n, t, a[100000];
	std::cin >> n >> t;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
	}
	int max[100000], m[100000];
	m[0] = a[0];
	for (int i = 1;i < n;i++) {
		m[i] = min(m[i - 1], a[i]);
	}
	for (int i = 1;i < n;i++) {
		int mina = a[i] - m[i - 1];
		max[i] = mina;
	}
	int maxa = 0;
	for (int i = 0;i < n;i++) {
		if (maxa < max[i])maxa = max[i];
	}
	int ans = 0;
	for (int i = 0;i < n;i++) {
		if (max[i] == maxa)ans++;
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 1408
import sys
fastinput=sys.stdin.readline
N,T=map(int,fastinput().split())
p=[int(_) for _ in fastinput().split()]
oyumin=0
oyumax=0
Showertime=0
for i in p:
    if i>oyumax:
        Showertime+=oyumax-oyumin
        oyumin=i
        oyumax=i+T
    else:
        oyumax=i+T
Showertime+=oyumax-oyumin
print(Showertime)

Measured memory_bytes: 25744