akhauriyash/Code-Regression huggingface dataset:
/*
**    author : dhiraj govindvira
**      date : 20-Sep-2020 ~ Sunday
**      time : 10:40:40 AM
*/

#ifdef Dhiraj
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              (x).begin(), (x).end()
#define rall(x)             (x).rbegin(), (x).rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin >> args), ...);
}
// scan vector
template <typename T> 
inline istream& operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream& operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------


ll Mod = 1e9 + 7;
inline ll md(ll x, ll M = Mod)
{
    x %= M;
    return ((x < 0) ? (x + M) : x);
}
ll power(ll x, ll y, ll p = Mod) 
{
    ll res = 1;
    bool of = true;
    if(of) x = x % p;
    while(y > 0)
    { 
        if(y & 1)
        {
            if(of) res = (res * x) % p;
            else res *= x;
        }
        if(of) x = (x * x) % p;
        else x *= x;
        y >>= 1;
    }
    if(res < 0) res += of * p;
    return res;
}

void solve(int &T)
{
    ll n, x, m;
    cin >> n >> x >> m;

    Mod = m;
    ll ans = 0;

    vector<ll> vis(m + 1, 0);
    while(!vis[x] and n > 0)
    {
        n--;
        vis[x]++;
        ans += x;
        x = power(x, 2);
    }

    if(n == 0) {
        cout << ans << endl;
        return;
    }

    ll sm = 0, len = 0;
    while(vis[x] != 2)
    {
        len++;
        vis[x]++;
        sm += x;
        x = power(x, 2);
    }
    d(len, sm);
    ans += (sm * (n / len));

    n %= len;
    while(n > 0) {
        n--;
        ans += x;
        x = power(x, 2);
    }
    cout << ans << endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

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

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3916
import bisect

n=int(input())
arr=list(map(int,input().split()))
q=int(input())
arr2=list(map(int,input().split()))
ans=0
for i in range(q):
  pos=bisect.bisect_left(arr,arr2[i])
  if pos==n:
    continue
  else:
    if arr[pos]==arr2[i]:
      ans+=1
print(ans)


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

typedef long long ll;
typedef pair<int, int> ii;

int n, a[1 << 18], mx1[1 << 18], mx2[1 << 18];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < (1 << n); ++i) {
    scanf("%d", &a[i]);
    mx1[i] = a[i];
  }

  for (int j = 0; j < n; ++j) {
    for (int K = 1; K < (1 << n); ++K) {
      if (K >> j & 1) {
        int P = K ^ (1 << j);
        auto update = [&](int X) {
          if (X >= mx2[K]) {
            mx2[K] = X;
            if (mx2[K] > mx1[K]) {
              swap(mx1[K], mx2[K]);
            }
          }
        };
        update(mx1[P]);
        update(mx2[P]);
      }
    }
  }

  int mx = 0; 
  for (int K = 1; K < (1 << n); ++K) {
    mx = max(mx, mx1[K] + mx2[K]); 
    printf("%d\n", mx);
  }
}


Measured memory_bytes: 6832
n,m,*t=map(int,open(0).read().split());e=[[]for _ in'_'*n]
for a,b in zip(*[iter(t)]*2):e[a-1]+=b-1,;e[b-1]+=a-1,
s=[0];f=s+[-1]*~-n
while s:
 v=s.pop();p=f[v]^1
 for w in e[v]:
  if-1<f[w]:
   if f[w]^p:print(n*~-n//2-m);exit()
  else:f[w]=p;s+=w,
r=sum(f);print(r*(n-r)-m)

Measured memory_bytes: 30680
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<30;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i,x,n) for(int i=x;i<n;++i)
//vector< vector<int> > v (max1, vector<in t>(max2) );

//bool f[51][51];
bool m[51][51];

int main() {
	int h,w, ans;
	cin >> h >> w;;
	string s;
	rep(i, h) {
		cin >> s;
		rep(j, w) {
			if (s[j] == '#') {
				m[i][j] = 1;
			}
			else {
				m[i][j] = 0;
			}
		}
	}
	bool c = 0;
	rep(i, h)rep(j, w) {
		if (m[i][j]) {
			c = 0;
			rep(k, 4) {
				int ni = i + dxy4[k];
				int nj = j + dxy4[k + 1];
				if (ni < 0 or nj < 0 or ni >= h or nj >= w)continue;
				if (m[ni][nj]) {
					c = 1;
					break;
				}
			}
			if (!c) {
				cout << "No" << endl;
				return 0;
			}
		}
	
	}
	cout << "Yes" << endl;
	
	int nn;
	cin >> nn;
	
	return 0;
}

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

int main() {
    string str;
    cin >> str;
    sort(str.begin(), str.end());
    if(str == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

const int N = 100000 + 10;

int n, T;
int aa[N];

int main() {
	scanf( "%d%d", &n, &T );
	for( int i = 1; i <= n; i++ )
		scanf( "%d", aa + i );
	int amin = aa[1];
	int smax = 0;
	for( int i = 2; i <= n; i++ ) {
		smax = max( smax, aa[i] - amin );
		amin = min( amin, aa[i] );
	}
	int ans = 0;
	amin = aa[1];
	for( int i = 2; i <= n; i++ ) {
		ans += (aa[i] - amin == smax);
		amin = min( amin, aa[i] );
	}
	printf( "%d\n", ans );
}




Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)


    val n = argList.nextLine().toInt()
    val p = argList.nextLine().split(" ").map { it.toInt() }

    val executor = OrdinaryNumber()
    val result = executor.execute(n, p)
    println(result)
}

class OrdinaryNumber {
    fun execute(n: Int, p: List<Int>): Int {
        var count = 0
        val maxIndex = n - 1

        val beginIndex = 1
        val beforeEndIndex = maxIndex - 1
        for (i in beginIndex..beforeEndIndex) {
            val targetList = listOf(p[i - 1], p[i], p[i + 1])
            val sorted = targetList.sorted()

            if (p[i] == sorted[1]) {
                count++
            }
        }

        return count
    }
}

Measured memory_bytes: 34160
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
    while(n != 0){
      if(n % 10 == 7){
        break;
      }
      else{
        n = n / 10;
      }
    }
    if(n != 0){
      System.out.println("Yes");
    }
    else
    {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35844
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

vector <pair <int, long long> > edges[1000];
long long max_d[1000];
int main(){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a;
    int b;
    long long c;
    cin >> a >> b >> c;
    edges[a - 1].push_back(make_pair(b - 1, c));
  }

  for(int i = 1; i < N; i++){
    max_d[i] = LLONG_MIN;
  }



  bool updated_N = false;
  int update_num = 0;
  for(int k = 0; k < 2; k++){
    update_num = 0;
    while(true){
      for(int i = 0; i < N; i++){
        if(max_d[i] == LLONG_MIN){
          continue;
        }
        for(int j = 0; j < edges[i].size(); j++){
          int dst = edges[i][j].first;
          long long cost = edges[i][j].second;
          
          if(max_d[dst] < max_d[i] + cost){
            max_d[dst] = max_d[i] + cost;
            if(dst == N - 1 && k == 1){
              updated_N = true;
            }
          }
        }
      }
      update_num ++;
      if(update_num > N){
        break;
      }
    }
  }

  if(!updated_N){
    cout << max_d[N - 1] << endl;
  } else {
    cout << "inf" << endl;
  }
  return 0;
}

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

int main()
{
    int x;
    cin>>x;
    if (x == 1)
    {
        cout<<"1"<<endl;
        return 0;
    }

    else
    {
        int q[1005],w[1005];
        memset(q,0,sizeof(q));
        memset(w,0,sizeof(w));
        int u=0;
        for (int b = 2; b <= 32 ; b++)
        {
            //  cout<<b<<endl;
            for (int p = 2; p <=10 ; p++)
            {
                int rr = (int )pow(b,p);
                if (rr > x)
                {
                    break;
                }
                else
                {
                    q[u] = b;
                    w[u] = p;
                    u++;
                }
            }
        }
        int ii=0;
        for (int i = 1; q[i] != '\0'; i++)
        {
            if ( pow(q[i],w[i])> pow(q[ii],w[ii]))
            {
                ii=i;
            }
        }

        cout<<pow(q[ii],w[ii])<<endl;
    }
    //  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=23,INF=1<<30;
const long double eps=1e-10;
long double x[MAX],y[MAX];
int DFS(vector<int> state,int nex){
    int N=state.size();
    if(nex==N/2+1){
        vector<double> A;
        
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                if(state[i]==state[j]){
                    if(x[i]==x[j]) A.push_back(INF);
                    else A.push_back((y[j]-y[i])/(x[j]-x[i]));
                    
                    break;
                }
            }
        }
        
        sort(all(A));
        
        int res=0;
        
        for(int i=0;i<N/2;i++){
            for(int j=i+1;j<N/2;j++){
                if(A[i]+eps>A[j]) res++;
            }
        }
        
        return res;
    }
    
    int res=0;
    
    for(int i=0;i<N;i++){
        if(state[i]==0){
            for(int j=i+1;j<N;j++){
                if(state[j]==0){
                    state[i]=nex;
                    state[j]=nex;
                    res=max(res,DFS(state,nex+1));
                    state[i]=0;
                    state[j]=0;
                }
            }
            break;
        }
    }
    
    return res;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    
    for(int i=0;i<N;i++) cin>>x[i]>>y[i];
    
    vector<int> A(N,0);
    
    cout<<DFS(A,1)<<endl;
    
}




Measured memory_bytes: 3292
w, h, n = gets.chomp.split.map(&:to_i)

xya = []
n.times { xya << gets.chomp.split.map(&:to_i) }

left_lower = { x: 0, y: 0 }
right_upper = { x: w, y: h }

(1..n).each do |i|
  x, y, a = xya[i - 1]
  case a
  when 1
    left_lower[:x] = x if left_lower[:x] < x
  when 2
    right_upper[:x] = x if right_upper[:x] > x
  when 3
    left_lower[:y] = y if left_lower[:y] < y
  when 4
    right_upper[:y] = y if right_upper[:y] > y
  end
end

x = right_upper[:x] - left_lower[:x]
y = right_upper[:y] - left_lower[:y]
x = 0 if x < 0 || y < 0

puts x * y


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// trueで初期化した配列pが必要です 遅め
vector<bool> p(200000, true);
void eratos(int n) {
  p[0] = p[1] = false;
  for (int i = 2; i <= sqrt(n); i++)
    if (p[i])
      for (int j = i * 2; j < n; j += i) p[j] = false;
}

// ====================================================================

int main() {
  eratos(200000);

  vector<bool> chika(200000);
  for (int i = 2; i < 200000; i++) {
    if (i % 2 == 0) continue;
    if (p[i] && p[(i + 1) / 2]) chika[i] = true;
  }

  vector<int> rui(200001);
  for (int i = 0; i < 200000; i++) rui[i + 1] = rui[i] + chika[i];

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << rui[r + 1] - rui[l] << endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cmath>

#include <atcoder/math>
#include <atcoder/fenwicktree>
#include <cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;
typedef long long ll;

using namespace atcoder;

int main()
{
    ll t;
    scanf("%lld", &t);
    for (int i = 0; i < t; i++) {
        ll n, m, a, b;
        scanf("%lld %lld %lld %lld", &n, &m, &a, &b);
        ll ans = floor_sum(n, m, a, b);
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int max(int a,int b,int c){
  if(a>b)return a>c?a:c;
  return b>c?b:c;
}
int min(int a,int b,int c){
  if(a<b)return a<c?a:c;
  return b<c?b:c;
}


int main(){
  int count[3];
  char s[100010];
  scanf("%s",s);
  int len=strlen(s),i;
  for(i=0;i<len;i++){
    count[s[i]-'a']++;
  }
  int flag=(max(count[0],count[1],count[2])-min(count[0],count[1],count[2])<=1);
  printf("%s",flag?"YES":"NO");
  return 0;
}


/// confirm df==0 ///

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

std::vector<int> map(500000, 0);


int func(int val) {
    if (val == 0) {
        map[val] = 0;
        return map[val];
    }
    if (map[val] != 0) {
        return map[val];
    }
    std::bitset<20> bs(val);
    int count = bs.count();
    map[val] = func(val % count) + 1;
    return map[val];
}


int main() {
    int N;
    std::string X;
    std::cin >> N >> X;

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (X[i] == '1') {
            count++;
        }
    }

    int c_m = std::max(count - 1, 1);
    int c_p = count + 1;
    std::vector<int> mod_cm(N, 1 % c_m), mod_cp(N, 1 % c_p);

    map[1] = 1;
    map[2] = 1;

    int sum_m = 0, sum_p = 0;
    if (X[N - 1] == '1') {
        sum_m = mod_cm[N - 1];
        sum_p = mod_cp[N - 1];
    }
    for (int i = N - 2; i >= 0; i--) {
        mod_cm[i] = mod_cm[i + 1] * 2 % c_m;
        mod_cp[i] = mod_cp[i + 1] * 2 % c_p;
        if (X[i] == '1') {
            sum_m = (sum_m + mod_cm[i]) % c_m;
            sum_p = (sum_p + mod_cp[i]) % c_p;
        }
    }

    for (int i = 0; i < N; i++) {
        int val;
        if (X[i] == '1') {
            if (count == 1) {
                std::cout << 0 << std::endl;
                continue;
            }
            val = (sum_m - mod_cm[i] + c_m) % c_m;
        } else {
            val = (sum_p + mod_cp[i]) % c_p;
        }
        std::cout << func(val) + 1 << std::endl;
    }
}


Measured memory_bytes: 7112
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

int ans;
int N, S[505], C[505], F[505];


int main(void) {
    scanf("%d", &N);
    rep(i, 0, N-1) scanf("%d %d %d", &C[i], &S[i], &F[i]);
    
    rep(i, 0, N-1) {
      int t = S[i] + C[i];
      rep(j, i+1, N-1) {
        if (t <= S[j]) t = S[j];
        else t = t + (F[j] - (t % F[j]))%F[j];
          
        t += C[j];
      }
      printf("%d\n", t);
    
    }
    puts("0");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define FINOUT freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define FOR(i, a, b) for (int i = a; i < (b); ++i)
#define FORd(i, a, b) for(int i = (b) - 1; i >= a; --i)
#define trav(a, x) for(auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define endl '\n'
const int MOD = 1000000007;

int main(){
    IOS;
    // FINOUT;
    int T = 1;
    ll n;
    ld d;
    cin >> n >> d;
    vpl points;
    ll cnt = 0;
    FOR(i, 0, n){
        ll x, y;
        cin >> x >> y;
        if(sqrt(x*x + y*y) <= d) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<queue>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
#define MAX 100
class State{
public:
int p, b, cost;
State(int p=0, int b=0, int cost=0):p(p), b(b), cost(cost){}
};
int n, B[MAX][2];
int bfs(){
bool V[MAX][2];
queue<State> Q;
rep(i, n) rep(j, 2) V[i][j] = false;
int s0 = 0, s1 = 0;
if ( B[s0][0] == 1 ) while( s0+1 < n && B[s0+1][0] == 1) s0++;
if ( B[s1][1] == 1 ) while( s1+1 < n && B[s1+1][1] == 1) s1++;
V[s0][0] = V[s1][1] = true;
Q.push(State(s0, 0, 0));
Q.push(State(s1, 1, 0));
State u, v;
while(!Q.empty()){
u = Q.front(); Q.pop();
if ( u.p == n-1 ) return u.cost;
for ( int r = 0; r < 3; r++ ){
int np = u.p + r;
int nb = (u.b + 1)%2;
if ( np >= n ) continue;
if ( B[np][nb] == 2 ) while( B[np][nb] == 2 ) np--;
if ( B[np][nb] == 1 ) while( np+1 < n && B[np+1][nb] == 1 ) np++;
if ( V[np][nb] ) continue;
V[np][nb] = true;
Q.push(State(np, nb, u.cost+1));
}
}
return -1;
}
main(){
while( cin >> n ){
if ( n == 0 ) break;
rep(i, n) cin >> B[i][0];
rep(i, n) cin >> B[i][1];
int cost = bfs();
if ( cost < 0 ) cout << "NA" << endl;
else cout << cost << endl;
}
}


Measured memory_bytes: 1200
#include<stdio.h>
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	int a,b,c,d,e,f;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	printf("%.9f\n",1.0*min(b-d+f+f,4*f)/min(a-c+e+e,4*e));
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	int n,m;
	cin >> n >> m;
	vector<pair<int,int>> key;
	rep(i,m){
		int a,b;
		cin >> a >> b;
		int s = 0;
		rep(j,b){
			int c;
			cin >> c;
			--c;
			s |= 1<<c ; // or
		}
		key.push_back({s,a});
	}
	vector<int> dp(1<<n, inf);
	dp[0] = 0;
	rep(s,1<<n){
		rep(j,m){
			int t = s | key[j].first;
			int cost = dp[s] + key[j].second;
			dp[t] = min(dp[t],cost);
		}
	}
	int ans = dp.back();
	if(ans == inf) ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;
 
pint x1[100001],x2[100001];
pint p1[100001],p2[100001];
ll mx1[100001],mx2[100001];
ll v[100001];
int main(){
    int n;
    ll c;
    ll xi,vi;
    cin>>n>>c;
    rep(i,n){
        cin>>xi>>vi;
        x1[i]={xi,vi};x2[i]={c-xi,vi};
        v[i]=vi;
    }
    sort(x1,x1+n);
    sort(x2,x2+n);
    ll mx=0,sum=0;
    ll pre=0;
    rep(i,n){
        sum+=x1[i].second-(x1[i].first-pre);
        mx=max(sum,mx);
        if(i>0)p1[i]={max(p1[i-1].first,sum-x1[i].first),c-x1[i].first};
        else p1[i]={max(0ll,sum-x1[i].first),c-x1[i].first};
        pre=x1[i].first;
    }
    //cout<<mx<<endl;
    sum=0;
    pre=0;
    rep(i,n){
        sum+=x2[i].second-(x2[i].first-pre);
        mx=max(sum,mx);
        if(i>0)p2[i]={max(p2[i-1].first,sum-x2[i].first),c-x2[i].first};
        else p2[i]={max(0ll,sum-x2[i].first),c-x1[i].first};
        pre=x2[i].first;
    }
    //cout<<mx<<endl;
    sum=0;
    pre=0;
    rep(i,n){
        sum+=x2[i].second-(x2[i].first-pre);
        if(i+2<=n)mx=max(sum+p1[n-i-2].first,mx);
        pre=x2[i].first;
    }
    //cout<<mx<<endl;
    sum=0;
    pre=0;
    rep(i,n){
        sum+=x1[i].second-(x1[i].first-pre);
        if(i+2<=n)mx=max(sum+p2[n-i-2].first,mx);
        pre=x1[i].first;
    }
    cout<<mx<<endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int>A(N);
  bool flag=true;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i)%2==0){
      if(A.at(i)%3 != 0 && A.at(i)%5 !=0){
        flag=false;
      }
    }
  }
  if(flag){
    cout << "APPROVED" << endl;
  }
  else{
    cout << "DENIED" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()

    while line:
        N = int(line)
        K = int(sys.stdin.readline())
        X = map(int, sys.stdin.readline().rstrip("\n").split(" ", N))

        distance = 0
        for x in X:
            distance += min(x - 0, K - x) * 2
        print(distance)

        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 2568
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
 
int main()
{
    IOS();
    
    int n,m;
    cin>>n>>m;
    if(n/10 || m/10)
        cout<<-1;
    else
        cout<<n*m;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>
#include<climits>
#include<tuple>
#include<utility>
#include<cassert>

using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
#define pb push_back
#define PB push_back
#define lb lower_bound
#define LB lower_bound
#define ub upper_bound
#define UB upper_bound


//constant
const int MOD = 1000000007;
const int INF = INT_MAX / 3 - 1;
const double EPS = 1e-9;
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy8[8] = { -1,-1,-1,0,0,1,1,1 };

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;


int dat[2*2000];
int n;

void segment_tree(int n_, int x) {
	n = 1;
	while (n < n_) n *= 2;
	REP(i, 2 * n - 1) dat[i] = x;
}


int F(int p, int q) {//function

	return min(p, q);
}

void update(int k, int a) {
	k += n - 1;
	dat[k] = a;

	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = F(dat[k * 2 + 2], dat[k * 2 + 1]);
	}
}


int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return int(1e9+1);
	if (a <= l&&r <= b) return dat[k];
	else {
		int v1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int v2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return F(v1, v2);
	}

}

int main() {
	long long int n1;
	long long int x;
	cin >> n1 >> x;
	vi a(n1);
	REP(i, n1)
		cin >> a[i];
	segment_tree(n1, int(1e9+1));
	REP(i, n1)
		update(i, a[i]);
	long long int res = 1e15;
	REP(i, n1) {
		long long int sum = 0;
		REP(j, n1)
			if (j - i < 0)
				sum += min(query(0, j + 1, 0, 0, n), query(n1 + j - i, n1, 0, 0, n));
			else
				sum += query(j - i, j + 1, 0, 0, n);
			res =min( res,sum + x*i);

	}
	cout << res<< endl;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  vector<long long int> a(n+1);
  for(int i=0; i<n; i++){
    long long int tmp;
    cin >> tmp;
    a[tmp] = i;
  }

  long long int ans = 0;
  set<long long int> s;
  s.insert(-1);
  s.insert(n);
  for(int i=1; i<=n; i++){
    long long int p = a[i];
    auto it = s.lower_bound(p);
    long long int r = *it;
    it--;
    long long int l = *it;
    ans += i * (p-l) * (r-p);
    s.insert(p);
  }

  cout << ans << endl;

  return 0;
}

//


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

int main()
{
	string str;
	cin>>str;
	int start_a=str.length();
	int end_z=0;
	for(int i=0 ; i<str.length() ; ++i)
	{
	    if(str[i]=='A')
	    {  
	       start_a=min(start_a,i); 
	       continue;
	    }
	    if(str[i]=='Z')
	    end_z=max(end_z,i);
	}
	cout<<end_z-start_a+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll unsigned long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000
ll power(ll x,ll n)
{ll x1=0;
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
       //  if(result>=1000000001) return 0;
        x=(x*x);
      //   if(x>=1000000001) return 0;
        n=n/2;
    }
    return result;
}
int vowel(char x){
    if(x=='a') return 1;
    if(x=='e') return 1;
    if(x=='i') return 1;
    if(x=='o') return 1;
    if(x=='u') return 1;
    return 0;
}
int main(){
   IOS;
ll t;t=1;//cin>>t;

while(t--){
string s;cin>>s;
if(s[s.size()-1]=='s') cout<<s<<"es";
else cout<<s<<"s";
} 
    
    

    
return 0;    
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  int n; cin >> n;
  vector<ll> a(n+1);
  rep(i,n+1) cin >> a[i];
  if(n == 0) {
    if(a[0] == 1) cout << 1 << "\n";
    else cout << -1 << "\n";
    return 0;
  }

  if(a[0] != 0) {
    cout << -1 << "\n";
    return 0;
  }
  
  vector<ll> sum(n+1);
  sum[n] = 0;
  for (int i = n-1; i >= 0; --i) {
    sum[i] = sum[i+1] + a[i+1];
  }
  
  ll x = 1;
  ll res = 1;
  rep(i,n) {
    ll e = min(2*x - a[i+1], sum[i+1]);
    if(e < 0) {
      cout << -1 << "\n";
      return 0;
    }
    res += e + a[i+1];
    x = e;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 4844
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

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

	VI v(n);
	REP(i, n) {
		cin >> v[i];
	}

	//奇数番目が正
	long long ans = 0;
	long long sum = 0;
	int now = 1;
	int reserve = -1;
	REP(i, n) {
		sum += v[i];
		if ((now == 1 && sum > 0) || (now == -1 && sum < 0)) {

		}
		else {
			ans += abs(sum - now);
			sum = now;
		}
		swap(now, reserve);
	}
	//ANS(ans);
	//偶数番目が正

	long long ans2 = 0;
	sum = 0;
	now = -1;
	reserve = 1;
	REP(i, n) {
		sum += v[i];
		if ((now == 1 && sum > 0) || (now == -1 && sum < 0)) {

		}
		else {
			ans2 += abs(sum - now);
			sum = now;
		}
		swap(now, reserve);
	}
	//ANS(ans2);

	ANS(min(ans, ans2));

	return 0;
}



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

main() {
    int N; cin >> N; 
    int A[N];
    int count=0,count2=0;
    bool can=false;
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        if(A[i]%4==0) count++;
        else if(A[i]%2==0) count2++;
    }
    if(N/2 <= count)can=true;
    else if(N-count-count2<=count)can=true;
    if(can)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod2=998244353;
ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll spf[10005];
void sieve()
{
  for(int i=1;i<10005;i++)
  spf[i]=i;
  for(int i=2;i*i<=10005;i++)
  if(spf[i]==i)
  for(int j=2*i;j<10005;j+=i)
  spf[j]=min(spf[j],(ll)(i));
}

int main(){
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   ll n;
   cin>>n;
   string s;
   cin>>s;
   ll cnt=0,res=0;
   for(int i=0;i<n;i++){
     if(s[i]=='R')
      cnt++;
   }
   for(int i=0;i<cnt;i++)
    if(s[i]!='R')
      res++;

  cout<<res;
}


Measured memory_bytes: 3776
while True:
    h,w = tuple([int(x) for x in raw_input().split(" ")])
    if h==0 and w==0: break

    for ih in range(h):
        if ih==0 or ih==h-1 or w <= 2: print "#" * w
        else: print "#" + "." * (w-2) + "#"

    print ""
            

Measured memory_bytes: 4208
use std::cmp::Ordering;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let v: Vec<isize> = (0..n).map(|_| read()).collect();

    let (sorted, cnt) = selection_sort((&v).iter().collect());
    let st: String = sorted
        .iter()
        .map(|i| i.to_string())
        .collect::<Vec<String>>()
        .join(" ");
    println!("{}\n{}", st, cnt)
}

fn selection_sort<T: Ord + Copy>(v: Vec<T>) -> (Vec<T>, usize) {
    match v.get(0) {
        Some(&e) => {
            let (a, p, c) = step(v, e);
            let (pp, cc) = selection_sort(p[1..].into());
            return (insert_head(a, pp), c + cc);
        }
        None => (vec![], 0),
    }
}

fn step<T: Ord + Copy>(v: Vec<T>, s: T) -> (T, Vec<T>, usize) {
    match v.get(0) {
        Some(&e) => {
            let (a, p, _) = step(v[1..].into(), s);
            match e.cmp(&a) {
                Ordering::Greater => (a, insert_head(e, p), 1),
                _ => (e, insert_head(s, v[1..].into()), 0),
            }
        }
        None => (s, v, 0),
    }
}

fn insert_head<T>(e: T, mut v: Vec<T>) -> Vec<T> {
    v.insert(0, e);
    v
}



Measured memory_bytes: 5072
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S[200001]; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	sort(S, S + n);
	for (int i = 1; i < n; i++) {
		if (S[i - 1] != S[i])sum++;
	}
	cout << sum + 1 << endl;
	return 0;
}

Measured memory_bytes: 9900
#include<cstdio>
using namespace std;
int main(void)
{
	int a,b,c,d,l,x,y,aso;
	scanf("%d",&l);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	x=a/c;
	y=b/d;
	if(a%c!=0){
		x=x+1;
	}
	if(b%d!=0){
		y=y+1;
	}
	if(x>y){
		aso=l-x;
	}
	else{
		aso=l-y;
	}
	printf("%d\n",aso);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vl A(N+1);
  rep(i,N+1) cin >> A[i];
  
  ll ans=1;
  vl sum(N+1);
  rep(i,N) sum[i+1]=sum[i]+A[i+1];
  ll now=1;
  rep(i,N) {
    if(A[i]>=now) {
      ans=-1;
      break;
    }
    now=min((ll)2*(now-A[i]),sum[N]-sum[i]);
    ans+=now;
  }
  if(N==0&&A[0]>=2) ans=-1;
  if(now!=A[N]) ans=-1;
  
  cout << ans << endl;
}

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

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

  int ans;
  if(n % 2 == 0) {
    ans = n / 2;
  } else {
    ans = n / 2 + 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()

ans = 0

for i in range(n):
    if a[i] == b[i] and b[i] == c[i] and c[i] == a[i]:
        ans += 0
    elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
        ans += 1
    else:
        ans += 2

print(ans) 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	double R;
	cin >> R;
	cout << setprecision(10) << R*2*3.1415926539 << endl;
}

Measured memory_bytes: 3784
s = input()
a = 10*int(s[0]) + int(s[1])
b = 10*int(s[2])+ int(s[3])
if 1 <= a <= 12 and 1 <= b <= 12:
  print('AMBIGUOUS')
elif (a < 1 or a > 12) and 1 <= b <= 12:
  print('YYMM')
elif 1 <= a <= 12 and (b < 1 or b > 12):
  print('MMYY')
else:
  print('NA')


Measured memory_bytes: 3060
import java.util.*;

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

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int T = 0;
		int H = 0;
		for(int i = 0; i < n; i++){
			String sT = scan.next();
			String sH = scan.next();
			if(sT.compareTo(sH) < 0){
				H += 3;
			} else if(sT.compareTo(sH) > 0){
				T += 3;
			} else{
				T++;
				H++;
			}
		}
		System.out.printf("%d %d\n", T, H);
	}
}

Measured memory_bytes: 29964
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int xy[10][10]={};
    int x,y,s,i,j,count=0,max=0;
    void dai(int[10][10],int,int),tyu(int[10][10],int,int),syo(int[10][10],int,int);
    
    while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
        if(s==1)
            syo(xy,x,y);
        if(s==2)
            tyu(xy,x,y);
        if(s==3)
            dai(xy,x,y);
    }
    
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            if(xy[i][j]==0)
                count++;
            //else
                //printf("(%d,%d)\n",i,j);
            if(xy[i][j]>max)
                max=xy[i][j];
        }
    }
    printf("%d\n%d\n",count,max);
    
    return 0;
}

void dai(int xy[10][10],int x,int y){
    int i,j;
    for(i=x-1;i<=x+1;i++){
        for(j=y-1;j<=y+1;j++){
            if(i>=0&&j>=0&&i<=9&&j<=9)
            ++xy[i][j];
        }
    }
    if(x>=2)
        ++xy[x-2][y];
    if(x<=7)
        ++xy[x+2][y];
    if(y>=2)
        ++xy[x][y-2];
    if(y<=7)
        ++xy[x][y+2];
}

void tyu(int xy[10][10],int x,int y){
    int i,j;
    for(i=x-1;i<=x+1;i++){
        for(j=y-1;j<=y+1;j++){
            if(i>=0&&j>=0&&i<=9&&j<=9)
                ++xy[i][j];
        }
    }

}

void syo(int xy[10][10],int x,int y){
    ++xy[x][y];
    if(x>=1)
        ++xy[x-1][y];
    if(x<=8)
        ++xy[x+1][y];
    if(y>=1)
        ++xy[x][y-1];
    if(y<=8)
        ++xy[x][y+1];
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = intArray[0];
            int X = intArray[1];
            int T = intArray[2];

            if(N % X == 0)
            {
                Console.WriteLine((N / X) * T);
            }
            else
            {
                Console.WriteLine((N / X + 1) * T);
            }
        }
    } 
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 28244
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
  cin>>a>>b;
  if(a==1&&b==2)
    cout<<3;
  if(a==2&&b==3)
    cout<<1;
  if(a==1&&b==3)
    cout<<2;
    if(b==1&&a==2)
    cout<<3;
  if(b==2&&a==3)
    cout<<1;
  if(b==1&&a==3)
    cout<<2;
}


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

int n, m, a[50], b[50];
bool visited[50], renketsu[50][50];

void dfs(int k) {
  visited[k] = true;
  rep(i,n) {
    if (visited[i]) continue;   //すでに訪問済なら飛ばす
    if (!renketsu[k][i]) continue;   //連結してないなら飛ばす
    dfs(i);  //残ったものについてdfs
  }
  return;
}

int main() {
  cin >> n >> m;
  rep(i,m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    renketsu[a[i]][b[i]] = renketsu[b[i]][a[i]] = true;
  }
  
  int ans = 0;
  
  rep(i,m) {
    renketsu[a[i]][b[i]] = renketsu[b[i]][a[i]] = false;
    rep(j,n) visited[j] = false;
    dfs(0);
    
    bool bridge = false;
    rep(l,n)
      if (!visited[l]) bridge = true;
    if (bridge) ans++;
    
    renketsu[a[i]][b[i]] = renketsu[b[i]][a[i]] = true;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);
vi v;
void sieve() {
    vector<bool> isPrime(mxN + 1, true);
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i <= mxN; ++i) {
        if (isPrime[i]) {
            v.pb(i);
            for (int j = i * 2; j <= mxN; j += i)
                isPrime[j] = 0;
        }
    }
}
void solve(){
    //8
    sieve();
    int x;
    cin>>x;
    cout<<*lower_bound(allv(v),x)<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3864
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

use std::collections::HashSet;

fn main() {
    let N = get!(i64);
    let A = get!(i64; N);

    // Setで各数字を管理する
    let mut S = HashSet::new();
    for a in A {
        if S.contains(&a) {
            S.remove(&a);
        } else {
            S.insert(a);
        }
    }
    let ans = S.len();

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

Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define lol __int128
#define ld long double
#define pii pair<int, int>
#define dbg(x) cerr << #x << " = " << x << "\n"
using namespace std;
int dp[2005], n;
const int M = 1000000007;
int32_t main() {
	//srand(chrono::steady_clock::now().time_since_epoch().count());
	boost;
	cin >> n;
	dp[0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= i - 3; j++) {
			dp[i] += dp[j];
			if(dp[i] > M) dp[i] -= M;
		}
	}
	cout << dp[n];
}

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

using namespace std;

vector<bool> vis(100000,false);

void dfs(int u,vector<vector<int> > &v){
    vis[u]=true;
    for(auto i:v[u]){
        if(vis[i]==false){
            dfs(i,v);
        }
    }
}



int main(){
	#ifndef ONLINE_JUDGE  
    freopen("i.txt", "r", stdin); 
    freopen("o.txt", "w", stdout); 
    #endif
    int n,m;
    cin>>n>>m;
    vector<vector<int> > v(n+1);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int count=0;
    for(int i=1;i<=n;i++){
        if(vis[i]==false){
            count++;
            dfs(i,v);
        }
    }
    cout<<count-1<<endl;


}

Measured memory_bytes: 9588
#include <stdio.h>

int main(void){
    long long int a, b, k;

    scanf("%lld%lld%lld", &a, &b, &k);

    long long int aa, bb, kk;
    if(a <= k){
        kk = k - a;
        aa = 0;
        bb = b - kk;
    }else{
        aa = a - k;
        bb = b;
    }

    if(bb < 0) bb = 0;

    printf("%lld %lld", aa, bb);
}

Measured memory_bytes: 128
import math

a, b, h, m = map(int, input().split())

agh = (h*360)/12 + (m*360)/(12*60)
agm = (m*360)/60

diff = abs(agh - agm)
diff = min(diff, 360 - diff) #180度以下の角を選択

if h == 5*m: #時針と分針が重なる場合
    ans = abs(a - b)
if diff == 180: #時針と分針が逆方向の場合
    ans = a + b
else:
    ans = (a**2 + b**2 - 2*a*b*math.cos(math.radians(diff)))**0.5

print(ans)

Measured memory_bytes: 9528
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

bool solve(const vector<int> &dir, const vector<int> &which,
	   const int cur, const int len) 
{
  int left = 1, right = len;
  for(int i = dir.size()-1; i >= 0; i--) {

    if(which[i] == 0) { // T
      if(dir[i] == +1) left = max(left-1, 1);
      else if(dir[i] == -1) right = min(right+1, len);
    } else { // S
      if(dir[i] == +1) right --;
      else if(dir[i] == -1) left++;
    }

#ifdef DEBUG

    cout << i << " " << dir[i] << " " << which[i] << ";" << left << " " << right << ":" ;
    cout << endl;
#endif
#ifdef DEBUG
#endif
    if(left > right) return false;
  }
  if(left > cur) return false;
  if(right < cur) return false;
  return true;
}

int main() {
  int H, W, N; cin>>H>>W>>N;
  int sr, sc; cin>>sr>>sc;
  string S, T; cin>>S>>T;
  vector<int> dir,which;
  REP(i,N) {
    switch (S[i]) {
    case 'U': dir.push_back(-1); which.push_back(1); break;
    case 'D': dir.push_back(+1); which.push_back(1); break;
    }
    switch (T[i]) {
    case 'U': dir.push_back(-1); which.push_back(0); break;
    case 'D': dir.push_back(+1); which.push_back(0); break;
    }
  }
  bool ans1 = solve(dir, which, sr, H);
  dir.clear(); which.clear();
  REP(i,N) {
    switch (S[i]) {
    case 'L': dir.push_back(-1); which.push_back(1); break;
    case 'R': dir.push_back(+1); which.push_back(1); break;
    }
    switch (T[i]) {
    case 'L': dir.push_back(-1); which.push_back(0); break;
    case 'R': dir.push_back(+1); which.push_back(0); break;
    }
  }
  bool ans2 = solve(dir, which, sc, W);
  cout << ((ans1 && ans2)  ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 2428