akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

template<typename T>
struct SegmentTree {
	
	SegmentTree(int _n) : n(_n) { 
		t.resize(n * 4); 
	}
	
	SegmentTree(vector<T>& a) {
		n = (int)a.size();
		t.resize(4 * n);
		build(a, 1, 1, n);
	}
	
	int n;
	vector<T> t;
	
	void build(vector<T>& a, int v, int tl, int tr) {
	    if (tl == tr) {
	        t[v] = a[tl - 1];
	    } else {
	        int tm = (tl + tr) / 2;
	        build(a, v*2, tl, tm);
	        build(a, v*2+1, tm+1, tr);
	        t[v] = min(t[v*2], t[v*2+1]);
	    }
	}
	
	T query(int l, int r) {
		assert(l >= 1 && r <= n && l <= r);
		return _query(1, 1, n, l, r);
	}
	
	T _query(int v, int tl, int tr, int l, int r) {
	    if (l > r) 
	        return (1LL << 31) - 1;
	    if (l == tl && r == tr) {
	        return t[v];
	    }
	    int tm = (tl + tr) / 2;
	    return min(_query(v*2, tl, tm, l, min(r, tm))
	              ,_query(v*2+1, tm+1, tr, max(l, tm+1), r));
	}
	
	void update(int pos, T new_val) {
		assert(pos >= 1 && pos <= n);
		_update(1, 1, n, pos, new_val);
	}
	
	void _update(int v, int tl, int tr, int pos, T new_val) {
	    if (tl == tr) {
	        t[v] = new_val;
	    } else {
	        int tm = (tl + tr) / 2;
	        if (pos <= tm)
	            _update(v*2, tl, tm, pos, new_val);
	        else
	            _update(v*2+1, tm+1, tr, pos, new_val);
	        t[v] = min(t[v*2], t[v*2+1]);
	    }
	}
};

int main() {
	ios_base::sync_with_stdio(0);
	int n, q;
	cin >> n >> q;
	vi vec;
	REP(i, n) vec.pb((1LL << 31) - 1);
	SegmentTree<int> s(vec);
	REP(_, q) {
		int t, x, y;
		cin >> t >> x >> y;
		x++;
		if (t == 0) {
			s.update(x, y);
		} else {
			y++;
			cout << s.query(x, y) << "\n";
		}
	}
	return 0;
}
 



Measured memory_bytes: 5000
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll division[3][30];

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,c;
    cin >> n >> c;
    
    int diff[30][30];
    for ( int i = 0; i < c; i++ )
        for ( int j = 0; j < c; j++ )
            cin >> diff[i][j];
    
    int x;
    for ( int i = 0; i < n; i++ )
        for ( int j = 0; j < n; j++ ){
            cin >> x;
            division[ ( i + j ) % 3 ][ x-1 ]++;
        }
    
    ll ans = 1000000000;
    
    for ( int i = 0; i < c ; i++ ){
        for( int j = 0; j < c; j++ ){
            for( int k = 0; k < c; k++ ){
                if ( i == j || j == k || k == i ) continue;
                ll tmp = 0;
                for ( int p = 0; p < c; p++ )
                    tmp += division[0][p] * diff[p][i];
                for ( int q = 0; q < c; q++ )
                    tmp += division[1][q] * diff[q][j];
                for ( int r = 0; r < c; r++ )
                    tmp += division[2][r] * diff[r][k];
                
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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++)
using ll = long long;
const long long INF = 1LL << 60;
const int MOD = 1e9 + 7;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


/* ACL */

//using namespace atcoder;



int main(){
    int H,W,M;
    cin >> H >> W >> M;
    //vector<vector<bool>> table(H+1,vector<bool>(W+1,false));
    //map<pair<int,int>,bool> table;
    set<pair<int,int>> table;


    //the number of bombs by h,w
    vector<int> h_cnt(H+1,0);
    vector<int> w_cnt(W+1,0);

    //max bombs in arrow    
    int h_max = 0;
    int w_max = 0;

    rep(i,M){
        int h,w;
        cin >> h >> w;
        //table[{h,w}] = true;
        table.insert({h,w});
        h_cnt.at(h) += 1;
        w_cnt.at(w) += 1;

        chmax(h_max,h_cnt.at(h));
        chmax(w_max,w_cnt.at(w));
    }

    //kiyasume
    if(H == 1 || W == 1){
        cout << M << endl;
        return 0;
    }

    //which column or row has max bombs?
    vector<int> maxHs(0);
    vector<int> maxWs(0);

    rep(i,H+1){
        if(h_cnt.at(i) == h_max){
            maxHs.push_back(i);
        }
    }
    rep(i,W+1){
        if(w_cnt.at(i) == w_max){
            maxWs.push_back(i);
        }
    }

    //is there a bomb at hypocenter?
    int ans = h_max + w_max - 1;
    rep(i,maxHs.size()){
        rep(j,maxWs.size()){
            if(table.find({maxHs[i],maxWs[j]}) == table.end()){
                ans += 1;
                cout << ans << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 23772
#include<stdio.h>
int main()
{
    int l, r, d;
    int h = 0;
    scanf("%d %d %d", &l, &r, &d);
    for( int i = l; i <= r; i++)
    {
        if (i % d == 0)
        {
            h++;
        }
    }
    printf("%d", h);
    return 0;
}

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

int main(){
    string A, B, C;
    cin >> A >> B >> C;
    queue<char>a, b, c;
    for(int i=0; i<A.size(); i++){
        a.push(A[i]);
    }
    for(int i=0; i<B.size(); i++){
        b.push(B[i]);
    }
    for(int i=0; i<C.size(); i++){
        c.push(C[i]);
    }
    char tmp;
    tmp = a.front();
    a.pop();
    while(true){
        if(tmp=='a'){
            if(a.size()==0){
                puts("A");
                return 0;
            } 
            tmp=a.front();
            a.pop();
        } else if(tmp=='b'){
            if(b.size()==0){
                puts("B");
                return 0;
            } 
            tmp=b.front();
            b.pop();
        } else {
            if(c.size()==0){
                puts("C");
                return 0;
            } 
            tmp=c.front();
            c.pop();
        }
    }


    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <cmath>
using namespace std;
int main() {
    long long n, m, a, b, c, d, i, j;
    cin >> n >> m;
    vector<long long> v[n];
    long long v2[m][2];

    for(i=0;i<m;i++) {
        cin >> a >> b;
        v[a-1].push_back(b);
        v2[i][0] = a-1;
        v2[i][1] = b;
    }

    for(i=0;i<n;i++) {
        sort(v[i].begin(), v[i].end());
        v[i].erase(unique(v[i].begin(), v[i].end()), v[i].end());
    }
    for(i=0;i<m;i++) {
        long long city = v2[i][0];
        long long id = v2[i][1];
        long long id2 = distance(v[city].begin(), lower_bound(v[city].begin(), v[city].end(), id));
        printf("%06lld%06lld\n", city+1, id2+1);
    }
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string Circle[] = {"Sunny", "Cloudy", "Rainy"};
    string S;
    cin >> S;
    for (int i = 0; i < 3; ++i) {
        if (S == Circle[i]) {
            printf("%s\n", Circle[(i+1)%3].c_str());
        }
    }
    return 0;
}


Measured memory_bytes: 256
# ABC128 C-Switches

n, m = map(int, input().split())

k = []
s = []
for _ in range(m):
    ks = list(map(int, input().split()))
    k.append(ks[0])
    s.append(ks[1:])
p = list(map(int, input().split()))

ans = 0
for bits in range(2**n):
    flag = True
    for i in range(m):
        on_sum = 0
        for switch in s[i]:
            on_sum += ((bits >> (switch - 1)) & 1)
        flag = flag and ((on_sum % 2) == p[i])
    if flag:
        ans += 1
print(ans)

Measured memory_bytes: 40432
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.NoSuchElementException;

public class Main {
	
	static long[] fac = new long[200001];
	static final long mod = 1000000007;
	static final BigInteger MOD = BigInteger.valueOf(1000000007);
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		calc();
		
		long ans = 0;
		for (int i = b; i < w; i++) {
			ans = (ans + modCombi(i + (h - a - 1), i) * modCombi((w - i - 1) + (a - 1), w - i - 1) % mod) % mod;
		}
		
		out.println(ans);
		out.flush();
	}
	
	static void calc() {
		fac[0] = 1;
		for (int i = 1; i < fac.length; i++) {
			fac[i] = (fac[i - 1] * i) % mod;
		}
	}
	
	static long modCombi(int n, int r) {
		
		long a = BigInteger.valueOf(fac[r]).modInverse(MOD).longValue();
		long b = BigInteger.valueOf(fac[n - r]).modInverse(MOD).longValue();
		
		return fac[n] * a % mod * b % mod;
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
}

Measured memory_bytes: 40752
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int n,x;
    cin>>n;
    x=1000-(n%1000);
    if(x==1000)x=0;
    cout<<x<<endl;
    return 0;

}





































Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Diagnostics.Contracts;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ans = 0;
            for (int i = 0; i < 10; i++)
            {
                ans += ReadInt();
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	for(int i=1;i<=9;++i){
		for(int j=1;j<=9;++j){
			cout<<i<<"x"s<<j<<"="s<<i*j<<"\n"s;
		}
	}
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {
	public static int dig;
	public static int ans;
	public static int n;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		ans = 0;
		dig = dig(n);
		for (int i = 3; i < dig; i++) {
			ans += (int)(Math.pow(3,i)-Math.pow(2,i)*3+3);
		}
		dfs(0,0);
		System.out.println(ans);
		sc.close();
	}
	public static int dig(int l) {
		int dig = 0;
		while(l > 0) {
			l = l/10;
			dig++;;
		}
		return dig;
	}
	public static void dfs(int x, int d) {
		if(d < dig) {
			dfs(x*10+3,d+1);
			dfs(x*10+5,d+1);
			dfs(x*10+7,d+1);
		}else if(d == dig){
			if(x <= n) {
				int[] is = new int[3];
				String s = String.valueOf(x);
				for (int i = 0; i < dig; i++) {
					if(s.charAt(i)=='3')is[0] = 1;
					else if(s.charAt(i)=='5')is[1] = 1;
					else if(s.charAt(i)=='7')is[2] = 1;
				}
				if((is[0]==1)&&(is[1]==1)&&(is[2]==1))ans++;
			}

		}
		return;
	}
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
int main(){

int X;
int ans;
cin >> X;

if(X >= 1800){
    ans = 1;
}
else if(X >= 1600){
    ans = 2;
}
else if(X >= 1400){
    ans = 3;
}
else if(X >= 1200){
    ans = 4;
}
else if(X >= 1000){
    ans = 5;
}
else if(X >= 800){
    ans = 6;
}
else if(X >= 600){
    ans = 7;
}
else if(X >= 400){
    ans = 8;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 3616
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

A, B = rl()

def get_divisors(n):
    divs = []
    for i in range(2, int(n**0.5)+1):
        c = 0
        while n % i == 0:
            n = n // i
            c += 1
        if c > 0:
            divs.append((i, c))
    if n > 0:
        divs.append((n, 1))
    return divs

def get_ans(A, B):
	a = get_divisors(A)
	b = get_divisors(B)
	a = [k for k, c in a]+[1]
	b = [k for k, c in b]+[1]
	return len(set(a) & set(b))

ans = get_ans(A,B)
print(ans)


Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
int main()
{
    ios;
    ll n , k ;
    cin >> n >> k;
    vector<ll> v;
    for(ll i =1;i<=n;i=i+2){
        v.push_back(i);
    }
    if(v.size()>=k){
        cout <<"YES\n";
        return 0;
    }
    else cout <<"NO\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String b = sc.next();
		System.out.println(a.charAt(0) == b.charAt(2) && a.charAt(1) == b.charAt(1) && a.charAt(2) == b.charAt(0) ? "YES" : "NO");
	}
}


Measured memory_bytes: 35648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define MOD 1000000007ULL;
#define rep(i,n) for(ll i=0;i<n;i++)



int main() {
	ll N;
  	cin>>N;
	ll a[N];
  	long double log=0;
    bool zero=false;
  	rep(i,N) {
    	cin>>a[i];
      	if(a[i]==0) zero=true;
    }
  	if(zero) cout<<0<<endl;
 	else{
      	ll ans=1;
     	for(int i=0;i<N;i++){
          	if(a[i]<=1000000000000000000/ans){
         	 	ans*=a[i];
            }else{
             	ans=-1;
              	break;
            }
        }
      	cout<<ans<<endl;
    }
  
}

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

using namespace std;



int main () {
  int N;
  cin >> N;
  int Size = 1;
  while (Size <= N)
    Size <<= 1;
  vector < long long > Tree (Size << 1);
  vector < int > h(N), a(N);
  for (int i = 0; i < N; ++i)
    cin >> h[i];
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  vector < long long > dp(N + 1);
  for (int flower = 0; flower < N; ++flower) {
    int x = h[flower] + Size;
    long long best = 0;
    while (x > 1) {
      if (x & 1)
        best = max (best, Tree[x - 1]);
      x >>= 1;
    }
    dp[h[flower]] = best + a[flower];
    for (int i = Size + h[flower]; i > 0; i >>= 1)
      Tree[i] = max (Tree[i], dp[h[flower]]);
  }
  long long ans = 0;
  for (int i = 0; i <= N; ++i)
    ans = max (ans, dp[i]);
  cout << ans;
}


Measured memory_bytes: 10336
a=list(input())
b=list(input())
c=list(input())
read=a[0]

while(1):
    if read=='a':
        try:
            read=a.pop(0)
        except:
            f='A'
            break
    if read=='b':
        try:
            read=b.pop(0)
        except:
            f='B'
            break
    if read=='c':
        try:
            read=c.pop(0)
        except:
            f='C'
            break
print(f)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] += 'a' - 'A';
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int n,u,v;
vector<vector<int>> g(100010);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n>>u>>v;
	u--,v--;
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> dist1(n,INF),dist2(n,INF);
	dist1[u]=0;
	queue<int> que;
	que.push(u);
	while(!que.empty()){
		int x=que.front();
		que.pop();
		for(auto itr:g[x]){
			if(dist1[itr]==INF){
				dist1[itr]=dist1[x]+1;
				que.push(itr);
			}
		}
	}
	queue<int> que1;
	que1.push(v);
	dist2[v]=0;
	while(!que1.empty()){
		int x=que1.front();
		que1.pop();
		for(auto itr:g[x]){
			if(dist2[itr]==INF){
				dist2[itr]=dist2[x]+1;
				que1.push(itr);
			}
		}
	}
	int ans=0;
	rep(i,n){
		if(g[i].size()==1){
			if(dist1[i]<dist2[i]){
				chmax(ans,dist2[i]-1);
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define MOD (ll)(998244353)
#define INF (9e18)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	int n; cin>>n;
	vector<int> cnt(n,0);
	int t; cin>>t;
	if(t!=0){
		cout<<"0\n";
		return 0;
	}
	cnt[0]++;
	For(i,1,n-1){
		cin>>t;
		if(t==0){
			cout<<"0\n";
			return 0;
		}
		cnt[t]++;
	}
	int now=1;
	ll ans=1;
	For(i,1,n-1){
		if(cnt[i]==0 && now!=n){
			cout<<"0\n";
			return 0;
		}
		ans=(ans*fpow(cnt[i-1],cnt[i]))%MOD;
		now+=cnt[i];
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;

//modulo
//dp

long int dp[1000][1000];


int func(int x,int y,int n,int m,char arr[1000][1000])
{
    if(x==n-1 && y==m-1)
    {
        return 1;
    }
    if(x>=n || y>=m || arr[x][y]=='#')
    {
        return 0;
    }
    
    if(dp[x][y]!=-1)
    {
        return dp[x][y];
    }
    
    dp[x][y]=(func(x+1,y,n,m,arr)%MOD+func(x,y+1,n,m,arr)%MOD)%MOD;
    return dp[x][y];
}

int main()
{
    int n,m;
    cin>>n>>m;
    char arr[1000][1000];
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>arr[i][j];
        }
    }
    
    int x=0;
    int y=0;
    memset(dp,-1,sizeof(dp));
    cout<<func(x,y,n,m,arr)<<endl;
    
    
    return 0;
}

Measured memory_bytes: 9216
n, a, b = map(int, input().split())
#4569=n
t = 0
for i in range(1, n+1):
    ans = 0
    s = i
    while s!=0:
        amari = s%10
        s = int(s/10)
        ans += amari
    if a <= ans <= b:
        t += i
print(t)


Measured memory_bytes: 2940
var = list(map(int, input().split()))
N = var[0]
M = var[1]
 
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
C = zip(A,B)
C = sorted(C)
A, B = zip(*C)
 
index = 0
count = 0
for i in range(N):
      if(count<=M):
        index = i
      count += B[i]
count = 0
sum = 0
for i in range (index):
    sum+=A[i]*B[i]
    count+=B[i]
sum +=A[index]*(M-count)
print(sum)

Measured memory_bytes: 26852
import itertools

H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append([int(s) for s in input()])
# print(S)

ans = 2000
for t in itertools.product([0, 1], repeat=H - 1):
    # print("t:",t,"横ライン")
    cnt = t.count(1)
    lst = [[s for s in S[0]]]
    for h in range(H - 1):
        if t[h]: # 切るとき
            lst.append(S[h + 1])
        else: # 切らないとき
            lst[-1] = [lst[-1][i] + S[h + 1][i] for i in range(W)] #縦成分を足す
    L = len(lst)
    # print("lst:",lst)
    # print(cnt,L)
    sum_lst = [0] * L
    for w in range(W):
        # print([lst[i][w] for i in range(L)])
        if max(lst[i][w] for i in range(L)) > K:
            # print("break")
            break
        tmp = [sum_lst[i] + lst[i][w] for i in range(L)]
        # print("w=",w,tmp)
        if max(tmp) > K:
            cnt += 1
            # print("切る!!")
            sum_lst = [lst[i][w] for i in range(L)]
            # print(sum_lst)
        else:
            sum_lst = tmp
    else: # for文がすべて回り切ったら、発動
        ans = min(ans, cnt)
print(ans)
"""
for t in itertools.product([0, 1], repeat=H - 1):
    print(t)
"""

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M) {
  // solver code
  string ans = N == M ? YES : NO;

  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  solve(N, M);
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
H = list(map(int, input().split()))
can = [1] * n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]:
        can[b] = 0
    if H[b] >= H[a]:
        can[a] = 0
print(sum(can))


Measured memory_bytes: 20108
N = int(input())
A_l = [int(_) for _ in input().split()]
N_l = list(range(N))
tmp = sorted(zip(N_l, A_l), key = lambda x:x[1])
N_l, A_l = zip(*tmp)
N_l = [x+1 for x in N_l]
print(*N_l,sep=' ')

Measured memory_bytes: 26632
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 
class Tree {
public:
	Tree(int V, int root) : V(V), root(root), cnum(V), place(V), id(V) {
		T.resize(V);
		for (int i = 0; i < MAXLOGV; i++) {
			parent[i].resize(V);
		}
		depth.resize(V);
	}
	// u??¨v????????????
	// lca????±????????????¨????????????????????§????????°????????¨????????????
	void unite(int u, int v) {
		T[u].push_back(v);
		T[v].push_back(u);
	}
	// init??????
	// ????????????????????????????????????????????????????????°????????¨lca????±???????????????????
	void init() {
		dfs(root, 0, 0);
		int id = 0;
		getid(root, 0, id);
	}
	// u??¨v???lca????±???????
	int lca(int u, int v) const {
		if (depth[u] > depth[v]) swap(u, v);
		for (int k = 0; k < MAXLOGV; k++) {
			if ((depth[v] - depth[u]) >> k & 1) {
				v = parent[k][v];
			}
		}
		if (u == v) return u;
		for (int k = MAXLOGV - 1; k >= 0; k--) {
			if (parent[k][u] != parent[k][v]) {
				u = parent[k][u];
				v = parent[k][v];
			}
		}
		return parent[0][u];
	}
	// u??¨v????????¢????±???????
	// edge????????????????????¨????????????????????????????????????
	int dist(int u, int v) const {
		int p = lca(u, v);
		return (depth[u] - depth[p]) + (depth[v] - depth[p]);
	}
	int dfs(int v, int p, int d) {
		parent[0][v] = p;
		depth[v] = d;
		cnum[v] = 0;
		for (int i = 1; i < MAXLOGV; i++) {
			parent[i][v] = parent[i - 1][parent[i - 1][v]];
		}
		for (int next : T[v]) {
			if (next != p) cnum[v] += dfs(next, v, d + 1);
		}
		return cnum[v] + 1;
	}

	void getid(const int v, const int p, int &nplace) {
		place[v] = nplace;
		id[nplace] = v;
		nplace++;
		for (int next : T[v]) {
			if (next != p) getid(next, v, nplace);
		}
	}
	static const int MAXLOGV = 25;
	// ??°???????????£??\???????????¨???
	vector<vector<int> > T;
	// ???????????°
	int V;
	// ?????????????????????
	int root;

	// ????????????
	vector<int> parent[MAXLOGV];
	// ??????????????±???
	vector<int> depth;

	//????????°
	vector<int>cnum;

	//??????
	vector<int>place;
	vector<int>id;

};

int main() {
	while (1) {
		int N; cin >> N;
		vector<int>isp(N,true);
		vector<pair<int, int>>edges;
		for (int i = 0; i < N; ++i) {
			int K; cin >> K;
			for (int j = 0; j < K; ++j) {
				int a; cin >> a;
				edges.emplace_back(i, a);
				isp[a] = false;
			}
		}
		int pa = find(isp.begin(), isp.end(), 1) - isp.begin();
		Tree t(N, pa);
		for (int i = 0; i < N - 1; ++i) {
			t.unite(edges[i].first, edges[i].second);
		}
		t.init();
		int Q; cin >> Q;
		while (Q--) {
			int a, b; cin >> a >> b;
			int ans = t.lca(a, b);
			cout << ans << endl;
		}
		break;
	}
	return 0;
}

Measured memory_bytes: 24568
program string_palindrome

 implicit none
 character :: s*99
 integer :: n,hanbetu,i,j,k

 read*,s
 !print*,s
 n=len_trim(s)
 !print*,n
 hanbetu=0
 
 do i=1,n/2
  if(s(i:i) /= s(n-i+1:n-i+1)) then
   print*,'No'
   hanbetu=hanbetu+1
   go to 200
  end if
   do j=1,((n-1)/2)/2
    if(s(j:j) /= s((n-1)/2-j+1:(n-1)/2-j+1)) then
     print*,'No'
     hanbetu=hanbetu+1
     go to 200
    end if
     do k=(n+3)/2,n/2
      if(s(k:k) /= s(n-k+1:n-k+1)) then
       print*,'No'
       hanbetu=hanbetu+1
       go to 200
      end if
     end do
   end do
 end do

200 if(hanbetu==0) print*,'Yes'

end program string_palindrome
    

Measured memory_bytes: 768
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = r * g * b

for i in range(n):
    for j in range(i+1, n):
        k = 2 * j - i
        if k < n:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                cnt -= 1

print(cnt)


Measured memory_bytes: 9200
import sys

n , m = map(int,input().split())
#if m == 0:
#    m += 1
a = []

for i in range(m):
    a.append(list(map(int,input().split())))

ans = [-1] * n

for j in a:
    if ans[j[0]-1] == -1:
        if j[0] > n:
            print(-1)
            sys.exit()
        else:
            ans[j[0]-1] = j[1]
    elif ans[j[0]-1] == j[1]:
        continue
    else:
        print(-1)
        sys.exit()

if n == 3 and ans[0] == -1:
    ans[0] = 1

if n == 2 and ans[0] == -1:
    ans[0] = 1

for index,l in enumerate(ans):
    if l == -1 :
        ans[index] = 0
    elif index == 0 and n != 1:
        if ans[index] == 0:
            print(-1)
            sys.exit()

for index , x in enumerate(ans):
    ans[index] = str(ans[index])

b = "".join(ans)

if b == "000" or b == "00" or b == "0":
    print(0)
else:
    if len(b) == n:
        print(int(b))
    else:
        print(-1)

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

int n, x, xi, ans;

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

int main() {
    scanf("%d%d", &n, &x);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &xi);
        ans = gcd(std::abs(xi - x), ans);
    }
    printf("%d\n", ans);
    return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

#define MOD 1000000007

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> A(N); 
    vector<int> counter(N);
    rep(i, N) {
        cin >> A[i];
        counter[A[i]]++;
    }
    
    for (int i = (N%2==0?1:0); i < N; i+=2) {
        if (counter[i] != (i==0?1:2)) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1;

    for (int i = 1; i <= N/2; i++)
        ans = ans * 2 % MOD;

    cout << ans << endl;
}


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

using namespace std;
#define int long long

signed main(){
    int A,B;
    cin >> A >> B;
    
    if(A == B) cout << "Draw" << endl;
    else if(A == 1) cout << "Alice" << endl;
    else if(B == 1) cout << "Bob" << endl;
    else if(A > B) cout << "Alice" << endl;
    else cout << "Bob" << endl;
    
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    map<char, ll> cnt;
    for (char c : S) {
        cnt[c]++;
    }

    ll ans = cnt['R'] * cnt['G'] * cnt['B'];
    for (int i = 0; i < N; i++) {
        for (int d = 1; d < N; d++) {
            int j = i + d;
            int k = j + d;
            if (k >= N || j >= N) {
                break;
            }
            if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) {
                ans--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    vector<long long> x(100), y(100);
    map<pair<long long, long long>, long long> mp;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j)
                continue;
            long long a = x[j] - x[i];
            long long b = y[j] - y[i];
            mp[{a, b}]++;
        }
    }
    long long m = 0;
    for (auto p : mp)
    {
        m = max(m, p.second);
    }
    cout << n - m << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
 string str;
  list<int> li;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      li.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=li.begin(),l=li.end();it!=l;++it){
    if(*it == x){
      li.erase(it);
      break;
    }
      }
    }else if(str == "deleteFirst") li.pop_front();
    else li.pop_back();
  }
  for(it=li.begin(),l=--li.end();it!=l;++it){
  cout << *it << " ";
	}
  cout << *it << endl;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n;
string s;
map <string,int> mp;

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>s;
		mp[s]=1;
	}
	cout<<mp.size()<<endl;
	return 0;
}

Measured memory_bytes: 19176
<?php

$nk = trim(fgets(STDIN));

$nk = explode(" ", $nk);
$n = $nk[0];
$k = $nk[1];
$count = 0;

while ($count <= 100000)
{
    if ($count == 0)
    {
        $n -= $k;
    }
    else
    {
        $n -= $k - 1;
    }
    $count++;
    
    if ($n <= 0)
    {
        break;
    }
}

echo $count;

Measured memory_bytes: 4728
N = int(input())
arr = [int(n) for n in input().split()]

swap_cnt = 0
for i in range(0, N):
    minj = i
    for j in range(i, N):
        if arr[j] < arr[minj]:
            minj = j
    if (i != minj):
        arr[i], arr[minj] = arr[minj], arr[i]
        swap_cnt += 1

print(' '.join(map(str, arr)))
print(swap_cnt)



Measured memory_bytes: 5604
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, d, a = map(int, input().split())
    XH = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[0])

    res = 0
    total = 0
    end = deque([])
    for i in range(n):
        x, h = XH[i]
        while end and end[0][0] < x:
            r = end.popleft()
            total -= r[1]

        if total < h:
            res += ((h - total) + a - 1) // a
            damage = ((h - total + a - 1) // a) * a
            total += damage
            end.append([x + 2 * d, damage])
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 62236
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,L,R) for(i=L;i<R;i++)
#define REP(i,N) FOR(i,0,N)
int main(){
  ll N,A,B,C,ans=1000000000,s=1,i;cin>>N>>A>>B>>C;ll L[N];
  REP(i,N){s*=4;cin>>L[i];}
  REP(i,s){
    ll p=i,j,d[4]={0,0,0,0},c[4]={0,0,0,0};
    REP(j,N){d[p%4]+=L[j];c[p%4]++;p/=4;}
    if(c[0]&&c[1]&&c[2])ans=min(ans,abs(d[0]-A)+abs(d[1]-B)+abs(d[2]-C)+10*(c[0]+c[1]+c[2])-30);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<string,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<Pi,int> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int n;
	int w[101];
	int d[101]={};

	cin>>n;
	rep(i,n){
		cin>>w[i];
		d[i+1]=d[i];
		d[i+1]+=w[i];
	}
	int t=100000000;
	for(int i=1; i<n; i++){
		t=min(t,abs(d[n]-d[i]-d[i]));
	}
	cout<<t<<endl;

	return 0;

}


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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

long long gcd(long long m, long long n) {

    if(m < n)
        std::swap(m, n);

    long long tmp;
    while(m % n != 0) {
        tmp = n;
        n = m % n;
        m = tmp;
    }

    return n;
}

long long lcm(long long m, long long n) { return m * n / gcd(m, n); }

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    a--;
    ll cm = (b / c) - (a / c);
    ll dm = (b / d) - (a / d);
    ll cd = lcm(c, d);
    ll cdm = (b / (cd)) - (a / (cd));

    // cout << b << " " << a << " " << cm << " " << dm << " " << cdm << endl;

    cout << b - a - (cm + dm - cdm) << endl;

    return 0;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 163
//B - Homework
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define reAll(x) (x).rbegin(),(x).rend()
#define zero(a) memset(a, 0, sizeof(a))

using ll = long long;

int main()
{
    int n, m;

    cin >> n >> m;

    int a[m];

    int all = 0;

    rep(i, m){
        cin >> a[i];
        all += a[i];
    }

    if (n < all) {
        cout << -1 << endl;
    }else{
        cout << n - all << endl;
    }


    return 0;
}


Measured memory_bytes: 3664
#![allow(unused_macros)]

macro_rules! read {
	() => {{
		let mut buf = String::new();
		std::io::stdin().read_line(&mut buf).unwrap();
		buf
	}};
	( Vec<$t:ty> ) => {
		read!()
			.trim()
			.split_whitespace()
			.map(|x| x.parse::<$t>().unwrap())
			.collect::<Vec<_>>()
	};
	( $( $t:ty ),* ) => {{
		let buf = read!();
		let mut iter = buf.split_whitespace().collect::<Vec<_>>().into_iter();
		( $( iter.next().unwrap().parse::<$t>().unwrap() ),* )
	}};
}

fn main() {
	println!("{}", 2f64 * std::f64::consts::PI * read!(f64));
}


Measured memory_bytes: 2196
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

constexpr static int MAXN = 5002;
constexpr static int MAXK = 5002;

int N, K;
int a[MAXN];
bool r0[MAXN][MAXK], r1[MAXN][MAXK];

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        a[i] = min(a[i], K);
    }

    r0[0][0] = true;
    r0[0][a[0]] = true;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < K; j++)
            r0[i][j] = r0[i - 1][j];
        for (int j = a[i]; j < K; j++)
            if (r0[i - 1][j - a[i]] && !r0[i][j])
                r0[i][j] = true;
    }
    r1[N - 1][0] = true;
    r1[N - 1][a[N - 1]] = true;
    for (int i = N - 2; i >= 0; i--) {
        for (int j = 0; j < K; j++)
            r1[i][j] = r1[i + 1][j];
        for (int j = a[i]; j < K; j++)
            if (r1[i + 1][j - a[i]] && !r1[i][j])
                r1[i][j] = true;
    }

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        vector <int> s1;
        if (i == 0) {
            s1.push_back(0);
        }
        else {
            for (int j = 0; j < K; j++)
                if (r0[i - 1][j])
                    s1.push_back(j);
        }

        vector <int> s2;
        if (i == N - 1) {
            s2.push_back(0);
        }
        else {
            for (int j = 0; j < K; j++)
                if (r1[i + 1][j])
                    s2.push_back(j);
        }

        // can get sum >= K - a[l] and < K without i
        bool needed = false;
        int idx = 0;
        for (int sum1 : s1) {
            while (idx + 1 < s2.size() && sum1 + s2[idx] < K - a[i])
                idx++;
            if (sum1 + s2[idx] >= K - a[i] && sum1 + s2[idx] < K) {
                needed = true;
                break;
            }
        }
        if (!needed)
            cnt++;
    }
    cout << cnt << endl;
}


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

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

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

    int res = 0;
    while (true) {
        bool exist_odd = false;
        for (int i = 0; i < n; ++i){
            if (A[i] % 2 != 0) exist_odd = true;
        }

        if (exist_odd) break;

        for (int i = 0; i < n; ++i){
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
}
int n,a[N];
void input()
{
	n=read<int>();
	For(i,1,n)a[i]=read<int>();
}
int num[65],stk[N],top;
bool check(int d)
{
	memset(num,0,sizeof num);
	For(i,1,n)if(a[i]<=60&&a[i]<=a[i-1])
	{
		num[a[i]]++;
		For(j,a[i]+1,60)num[j]=0;
		for(int pos=a[i];num[pos]==d;pos--)
		{
			num[pos]=0;num[pos-1]++;
			if(pos==1)return 0;
		}
	}
	return 1;
}
void work()
{
	int flag=0;
	For(i,2,n)if(a[i]<=a[i-1])flag=1;
	if(!flag){puts("1");return;}
	int l=2,r=n,mid,ans=-1;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	write(ans,'\n');
}
int main()
{
	input();
	work();
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll se=0;
ll sume(vector<int> a,int n){

}
int main(){
    string s;cin>>s;
    int q,t,f,sw=1;
    char c;
    cin>>q;
    deque<char> que;
    for(int i=0;i<(int)s.size();i++){
        que.push_back(s[i]);
    } 
    for(int i=0;i<q;i++){
        cin>>t;
        if(t==1) sw*=-1;
        else{
            cin>>f>>c;
            if((f==1&&sw==1)||(f==2&&sw==-1)){
                que.push_front(c);
            }else que.push_back(c);
        }
    }
    if(sw==1){
        while(!que.empty()){
            cout<<que.front();que.pop_front();
        }
        cout<<endl;
    }else{
        while(!que.empty()){
            cout<<que.back();que.pop_back();
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K;
ll A[200005];
ll sosuu[200005];
bool found;
ll ans;
ll si;
priority_queue<ll> so[200005];
ll m;
map<ll,ll> mm;
char a;
int main() {
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> m;
        A[m-1] += 1;
        ans += m;
    }
    cin >> K;
    for(int i=0;i<K;i++){
        ll b,c;
        cin >> b >> c;
        ans += (c-b)*A[b-1];
        A[c-1] += A[b-1];
        A[b-1] = 0;
        cout << ans << endl;
    }
    
}


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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int q, query, i;
  cin >> q;
  bitset<64> x(0);
  for(int j = 0; j < q; j++){
    cin >> query;
    switch(query){
      case 0:
        cin >> i;
        if(x[i] == 1){
          cout << "1\n";
        }else{
          cout << "0\n";
        }
        break;
      case 1:
        cin >> i;
        x[i] = 1;
        break;
      case 2:
        cin >> i;
        x[i] = 0;
        break;
      case 3:
        cin >> i;
        x[i] = ~x[i];
        break;
      case 4:
        if(x.all()){
          cout << "1\n";
        }else{
          cout << "0\n";
        }
        break;
      case 5:
        if(x.any()){
          cout << "1\n";
        }else{
          cout << "0\n";
        }
        break;
      case 6:
        if(x.none()){
          cout << "1\n";
        }else{
          cout << "0\n";
        }
        break;
      case 7:
        cout << x.count() << "\n";
        break;
      case 8:
        cout << x.to_ulong() << "\n";
        break;
    }
  }
  return 0;
}



Measured memory_bytes: 3200