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

using namespace std;

int combi2(int n) {

   if(n%2 == 0) {
      return (n / 2) * (n - 1);
   } else {
      return  ((n - 1) / 2) * n;
   }
}
   

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

   int a = combi2(N) + combi2(M);

   cout << a << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a_list = []
for _ in range(m):
    a, b = map(int, input().split())
    a_list.append([a, b])
a_list.sort(key = lambda x: (x[1], x[0]))
temp = -1
ans = 0
for a, b in a_list:
    if (temp < a):
        temp = b - 1
        ans += 1
print(ans)

Measured memory_bytes: 27700
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

iter = [i + 1 for i in range(N)]
map = {pattern: i for i, pattern in enumerate(permutations(iter, N))}
print(abs(map[P] - map[Q]))


Measured memory_bytes: 10472
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  int n;
  scan(n);
  set<string> s;
  rep (i, n) {
    string tmp;
    scan(tmp);
    s.insert(tmp);
  }
  int ans = s.size(); 
  print(ans);
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 15800
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int x,y; cin >> x >> y;
	bool can = 0;
	forn(i,0,x+1){
		int cranes = i;
		int turtles = x-i;
		if(2*cranes + 4*turtles == y){
			can = 1;
			break;
		}
	}
	cout << (can ? "Yes" : "No");
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

int H, W;
char S[20][20];
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};

int bfs(int x, int y) {
  queue<pii> que;
  vvi d(H, vi(W, INF));
  que.push(pii(x, y));
  int mx = 0;
  d[y][x] = 0;

  while(!que.empty()) {
    pii p = que.front(); que.pop();
    rep(i, 0, 4) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx > -1 && nx < W && ny > -1 && ny < H) {
        if (S[ny][nx] != '#' && d[ny][nx] == INF) {
          que.push(pii(nx, ny));
          d[ny][nx] = d[p.second][p.first] + 1;
          mx = d[ny][nx];
        }
      }
    }
  }
  return mx;
}

void solve() {
  in(H, W);
  rep(i, 0, H) {
    rep(j, 0, W) {
      in(S[i][j]);
    }
  }
  int mx = 0;
  rep(i, 0, H) {
    rep(j, 0, W) {
      if (S[i][j] != '#') {
        mx = max(mx, bfs(j, i));
      }
    }
  }
  print(mx);
}


Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
local str2tbl = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
local N = read.nl()
local cities = {}
for i=1,N do
    local s, p = read.l():split()
    p = tonumber(p)
    cities[s] = cities[s] or {}
    table.insert(cities[s], {i, p})
end

local cities2 = {}
for city in pairs(cities) do
    table.insert(cities2, city)
end
table.sort(cities2, function (x,y) return x<y end)

for _,cname in ipairs(cities2) do
    local city = cities[cname]
    table.sort(city, function (x,y) return x[2]>y[2] end)
    for _, r in ipairs(city) do
        print(r[1])
    end
end


Measured memory_bytes: 760
#include<stdio.h>
#define N 2000

int solve(int,int*,int);

int main(){
    int i,n,A[N],q,m[N];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&m[i]);
    }

    for(i=0;i<q;i++){
        if(solve(m[i],A,n) == 1) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}


int solve(int n,int* arr,int m){
    if(m == 0)return 0;
    if(n == arr[0])return 1;
    if(n < arr[0])return solve(n,arr+1,m-1);
    return solve(n-arr[0],arr + 1, m - 1) || solve(n,arr + 1 , m - 1);
}



Measured memory_bytes: 2048
import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        main1(sc);
    }

    public static void main1(Scanner sc) {

    	char[] base = sc.next().toCharArray();
    	char[] target = sc.next().toCharArray();

    	Map<Character, TreeSet<Integer>> posIndex = new HashMap<Character, TreeSet<Integer>>();

    	for (int i = 0; i < base.length; i++) {
    		char c = base[i];
    		TreeSet<Integer> t = posIndex.get(c);

    		if (t == null) {
    			t = new TreeSet<Integer>();
    			posIndex.put(c, t);
    		}

    		t.add(i);
    	}

    	long pos = 1;
    	int prevPos = -1;

    	for (int i = 0; i < target.length; i++) {
    		char c = target[i];

    		TreeSet<Integer> idx = posIndex.get(c);
    		if (idx == null) {
    			System.out.println("-1");
    			return;
    		}

    		Integer next = idx.higher(prevPos);

    		if (next == null) {
    			next = idx.first();

    			pos += base.length - 1 - prevPos + next + 1;
    			prevPos = next;

    		} else {
    			if (prevPos < 0) {
    				prevPos = 0;
    			}
    			pos += next - prevPos;
    			prevPos = next;
    		}
    	}

    	System.out.println(pos);

    }
	public static void maina(String[] args) throws Exception {
		String in1 = "contest\r\n" +
				"son";

		String in2 = "contest\r\n" +
				"programming";

		String in3 = "contest\r\n" +
				"sentence";

		Scanner sc = new Scanner(new ByteArrayInputStream(in1.getBytes()));
		main1(sc);

		sc = new Scanner(new ByteArrayInputStream(in2.getBytes()));
		main1(sc);

		sc = new Scanner(new ByteArrayInputStream(in3.getBytes()));
		main1(sc);
	}
}

Measured memory_bytes: 33788
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;

int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a+3);
	ostringstream oss;
	oss << a[2] << a[1];
	string m = oss.str();
	int n = stod(m);
	int ans = a[0] + n;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String line = in.nextLine();
		String[] array = line.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);
		int c = Integer.parseInt(array[2]);
		int[] num = {a,b,c};
		for(int i = 0;i<num.length-1;i++){
			for(int j = num.length-1; j>i; j--){
				if(num[j]<num[j-1]){
					int copy = num[j-1];
					num[j-1] = num[j];
					num[j] = copy; 
				}
			}
		}
		System.out.println(num[0]+" "+num[1]+" "+num[2]);
	} 
}

Measured memory_bytes: 25936
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

void out(auto&& mat) {
  REP(i,4) {
    REP(j,8) {
      cerr<<mat[i][j];
    }
    cerr<<"\n";
  }
  cerr<<"\n";
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin>>t;
  REP(csn,t) {
    int n;
    cin>>n;
    vecll a(n);
    for(auto&&e:a)cin>>e;
    string s;
    cin>>s;
    reverse(ALL(a));
    reverse(ALL(s));
    bool ok = true;
    REP(i,n) {
      if (s[i] == '0') continue;
      vector<bitset<202>> mat(60);
      int cnt = 0;
      REP(j,i) {
        if (s[j] == '0') {
          REP(k,60) {
            mat[k].set(cnt, (a[j] >> k) & 1);
          }
          ++cnt;
        }
      }
      REP(j,60) {
        mat[j].set(cnt, (a[i] >> j) & 1);
      }
      ++cnt;
      int rank = 0;
      REP(j,cnt) {
        //out(mat);
        int pivot = -1;
        FOR(k,rank,60) {
          if (mat[k][j] != 0) {
            pivot = k;
            break;
          }
        }
        if (pivot < 0) continue;
        if (j == cnt-1) {
          ok = false;
          break;
        }
        swap(mat[rank], mat[pivot]);
        FOR(k,rank+1,60) {
          if (mat[k][j] != 0) {
            mat[k] ^= mat[rank];
          }
        }
        ++rank;
        if (rank == 60) break;
      }
      if(!ok)break;
    }
    cout<<(ok?0:1)<<endl;
  }
  return 0;
}


Measured memory_bytes: 3620
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int m = sc.nextInt();

    int[] costs = new int[1 << n];
    Arrays.fill(costs, -1);

    for (int i = 0; i < m; i++) {
      int cost = sc.nextInt();
      int opening = 0;
      int num = sc.nextInt();
      for (int j = 0; j < num; j++) {
        opening += 1 << (sc.nextInt() - 1);
      }
      if (costs[opening] < 0 || cost < costs[opening]) {
        costs[opening] = cost;
      }
    }

    for (int i = 0; i < 1 << n; i++) {
      for (int j = 0; j < 1 << n; j++) {
        if (costs[i] < 0 || costs[j] < 0) {
          continue;
        }
        int pattern = 0;
        for (int bit = 0; bit < n; bit++) {
          pattern += (((i >> bit) & 1) | ((j >> bit) & 1)) << bit;
        }
        if (costs[pattern] < 0) costs[pattern] = costs[i] + costs[j];
        else {
          costs[pattern] = Math.min(costs[pattern], costs[i] + costs[j]);
        }
      }
    }

    os.println(costs[(1 << n) - 1]);
  }
}

Measured memory_bytes: 32544
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	int f=1;
	for(ll i=0;i<n;i++){
		ll a;
		cin>>a;
		if(a%2)
			continue;
		if(a%3&&a%5)
			f=0;
	}
	if(f)
		cout<<"APPROVED\n";
	else
		cout<<"DENIED\n";
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while( scan.hasNextInt() ){
            int n = scan.nextInt();
            int a ;
            int b ;
            int d ;
            int c;
            int i ;
            
            for(i=0;i<n;i++){
                
           a = scan.nextInt();
            b = scan.nextInt();
             d = scan.nextInt();
                
             if((a*a)+(b*b)==(d*d)||(a*a)+(d*d)==(b*b)||(d*d)+(b*b)==(a*a)){
                 System.out.println("YES");
            }else{
                    System.out.println("NO");
            }
             
        }
    }
}
}


Measured memory_bytes: 33632
#/*
    AUTHOR:shivam51
    IIESTS
*/
  #include<bits/stdc++.h>
  using namespace std;
  //
  #define add accumulate
  #define ll long long int
  #define ff first
  #define ss second
  #define pb push_back
  #define mp make_pair
  #define vll vector<ll>
  #define lb lower_bound
  #define ub upper_bound
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define all(v) v.begin(), v.end()
  #define rep(i,k,n) for(int i=k;i<n;i++)
  #define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
  const int md=1e8;
  const ll MAX=1e12;
  //
  //
  	void solve(){
  		int arr[3];
  		rep(i,0,3)
  			cin>>arr[i];
  		cout<<min((arr[0]+arr[1]),min((arr[1]+arr[2]),(arr[0]+arr[2])));
  	}
	int main(){ 
		hs;
		ll t;
		// cin>>t;
		t=1;
		while(t--)
			solve();
    return 0; 
} 

Measured memory_bytes: 256
s = input()
 
def is_palindrome( s ):
  for i in range( len( s ) // 2 ):
    if s[i] != s[-i-1]:
      return False
  return True
 
ret = is_palindrome( s ) 
ret &= is_palindrome( s[:(len(s)-1)//2 ] ) 
ret &= is_palindrome( s[ (len(s)+3)//2-1: ] )
if ret:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;


int main(){
    int n;
    cin>>n;
    vi vt(n);
    F0R(i,n) cin>>vt[i];

    sort(all(vt));
    int l=vt[n/2];
    int r=vt[n/2-1];
    int dif=abs(l-r);
    out(dif);
}


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

int main() {
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    ll ans = 0;
    vector<char> strat[k];
    rep(i, n) {
        int group = i % k;
        char winning_hand;
        if (t[i] == 'r') winning_hand = 'p';
        if (t[i] == 's') winning_hand = 'r';
        if (t[i] == 'p') winning_hand = 's';
        if (i < k || strat[group].back() != winning_hand) {
            strat[group].push_back(winning_hand);
            if (winning_hand == 'r') ans += r;
            if (winning_hand == 'p') ans += p;
            if (winning_hand == 's') ans += s;
        } else {  // strat[group].back() == winning_hand
            if (i + k < n) {
                if (strat[group].back() == 'r') {  // can't do 'r' this time
                    if (t[i + k] == 'r')
                        winning_hand = 's';  // wanna do 'p' next
                    else
                        winning_hand = 'p';  // wanna do 'r' or 's' next
                }
                if (strat[group].back() == 's') {  // can't do 's' this time
                    if (t[i + k] == 's')
                        winning_hand = 'p';  // wanna do 'r' next
                    else
                        winning_hand = 'r';  // wanna do 's' or 'p' next
                }
                if (strat[group].back() == 'p') {  // can't do 'p' this time
                    if (t[i + k] == 'p')
                        winning_hand = 'r';  // wanna do 's' next
                    else
                        winning_hand = 's';  // wanna do 'r' or 'p' next
                }
                strat[group].push_back(winning_hand);
            }
        }
    }
    // rep(group, k) {
    //     for (char a : strat[group]) {
    //         cout << a << ' ';
    //     }
    //     cout << endl;
    // }
    cout << ans << endl;
}

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

int main() {
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;
    if (B<0) {
        cout << (B-A)*C << endl;
    } else if (A<0) {
        cout << (0-A)*C+D+B*E << endl;
    } else {
        cout << (B-A)*E << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
    ll n,d;
    cin>>n>>d;
    vcl x(n);
    vcl y(n);
    rep(i,n) cin>>x[i]>>y[i];
    ll ans = 0;
    rep(i,n){
        if(x[i]*x[i] + y[i]*y[i] <= d*d){
            ans++;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 6408
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    int res = 0;
    for (int i = 0; i < (int) s.size() / 2; ++i) {
        res += s[i] != s[s.size() - 1 - i];
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

X = i()
if X >= 30:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 10072
#coding:utf-8
#1_2_B
def selection_sort(ary, n):
    count = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if ary[minj] > ary[j]:
                minj = j
        if ary[minj] != ary[i]:
            ary[minj], ary[i] = ary[i], ary[minj]
            count += 1
    print(*ary)
    print(count)

n = int(input())
selection_sort(list(map(int, input().split())), n)

Measured memory_bytes: 7708
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int W, H;
  cin >> W >> H;
  vector<ll> p(W);
  rep(i, W) {
    cin >> p[i];
  }
  vector<ll> q(H);
  rep(i, H) {
    cin >> q[i];
  }

  ll P = 0;
  rep(i, W) {
    P += p[i];
  }

  ll Q = 0;
  rep(i, H) {
    Q += q[i];
  }

  ll ans = P * (H + 1) + Q * (W + 1);
  sort(all(p));
  sort(all(q));

  rep(i, W) {
    ll temp_p = p[i];
    auto iter = upper_bound(all(q), temp_p);
    ll pos = distance(q.begin(), iter);
    ans -= temp_p * pos;
  }

  rep(i, H) {
    ll temp_q = q[i];
    auto iter = lower_bound(all(p), temp_q);
    ll pos = distance(p.begin(), iter);
    ans -= temp_q * pos;
  }

  cout << ans << endl;
}

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

#define debug(args...) fprintf(stderr, args);

const int maxn = 1e5 + 10;

int n, a[maxn], b[maxn];
string s;

bool ok(int k) {
    int l;

    l = k;
 
    while(l - 1 >= 1 && a[k] == a[l - 1])
	--l;

    if(n - (l - 1) >= k)
	return true;

    l = k;

    while(l - 1 >= 1 && b[k] == b[l - 1])
	--l;

    if(n - (l - 1) >= k)
	return true;
    
    return false;
}

int solve() {
    n = (int)s.size();

    for(int i = 1; i <= n; ++i) {
	a[i] = s[i - 1] - '0';
	b[i] = a[i];
    }

    reverse(b + 1, b + 1 + n);
    
    int l = 1;
    int r = n;

    while(l < r) {
    	int mid = (l + r + 1) / 2;

    	if(ok(mid))
    	    l = mid;
    	else
    	    r = mid - 1;
    }

    return r;
}

int main() {
    cin >> s;

    cout << solve() << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)

int main()
{
    int n; cin>>n;
    int ans = 180*(n-2);
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  vector<int> vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 
                   14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int a;
  cin >> a;
  cout << vec.at(a-1) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;


int main(){
  int n = getInt();
  int t = getInt();
  int s = getInt();

  vector<int> a(n);
  vector<int> b(n);

  REP(i,n){
    a[i] = getInt();
    b[i] = getInt();
  }

  vector<int> now(t + 1, -1);

  now[0] = 0;
  REP(i,n){
    vector<int> next = now;

    REP(j,t) if(now[j] >= 0){
      int end = j + b[i];

      if(j < s) next[s] = max(next[s], now[j]);

      if(end <= t && !(j < s && s < end)){
        next[end] = max(next[end], now[j] + a[i]);
      }
    }

    now.swap(next);
  }

  printf("%d\n", *max_element(now.begin(), now.end()));

  return 0;
}

Measured memory_bytes: 0
let () = Scanf.scanf "%d\n" @@ fun n ->
  let hs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun h -> h in
  Printf.printf "%d\n" @@ Array.fold_left ( + ) hs.(0) @@
  Array.init (n - 1) @@ fun i -> max 0 @@ hs.(i + 1) - hs.(i)



Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final Set<String> march = new HashSet<>(Arrays.asList("MARCH".split("")));
        final Map<String, AtomicLong> countMap = new HashMap<>();
        final int n = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < n; i++) {
            final String prefix = scanner.nextLine().split("")[0];
            if (march.contains(prefix)) {
                countMap.computeIfAbsent(prefix, count -> new AtomicLong())
                        .incrementAndGet();
            }
        }

        final List<AtomicLong> counts = new ArrayList<>(countMap.values());
        long answer = 0;

        for (int i = 0; i < counts.size() - 2; i++) {
            for (int j = i + 1; j < counts.size() - 1; j++) {
                for (int k = j + 1; k < counts.size(); k++) {
                    answer += counts.get(i).get() * counts.get(j).get() * counts.get(k).get();
                }
            }
        }

        System.out.println(answer);
    }
}


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

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

using namespace std;
using lint=long long;

lint f(lint h){ return h==1?1:2*f(h/2)+1; }

int main(){
	lint h; cin>>h;
	cout<<f(h)<<'\n';
	return 0;
}


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

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

    for(int a=0; a<=N; ++a){
        for(int b=0; b<=(N-a); ++b){
            int c=(N-a-b);
            int sum = 10000*a + 5000*b + 1000*c;
            if(sum==Y){
                cout << a << ' ' << b << ' ' << c;
                return 0;
            }
        }
    }
    
    cout << -1 << ' ' << -1  << ' ' << -1;
    
    return 0;
}

Measured memory_bytes: 256
from __future__ import print_function

import sys
input = sys.stdin.readline

def main():
    n = int(input().strip())
    temp = 1
    for i in range(1, n + 1):
        temp *= i
        temp = temp % (10**9 + 7)
    print(temp)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int p[n];
    REP(i,n){
        cin >> p[i];
        p[i]--;
    }
    int a[n], b[n];
    REP(i,n){
        a[i] = 1 + 30000 * i;
        b[i] = 1 + 30000 * (n - 1 - i);
    }
    REP(i,n){
        b[p[i]] += i;
    }
    REP(i,n){
        cout << a[i] << " ";
    }
    cout << endl;
    REP(i,n){
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int n;
	
	cin >> n;
	
	vector<int> vec(n + 1);
	
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		for(int j = i; j <= n; j += i){
			vec[j]++;
		}
	}
	
	for(int i = 1; i <= n; i++){
		ans += ((ll)i * (ll)vec[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

const int N = 100 * 1000 + 5;
int t = 0;

bool mark[N];
int par[N];
int ft[N];
vector <int> adj[N];
vector <int> vec;
void dfs(int v) {
	if (mark[v])
		return ;
	mark[v] = true;
	for (auto u : adj[v]) {
		dfs(u);
	}
	vec.push_back(v);
}
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n + m - 1; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}
	for (int i = 1; i <= n; i++) {
		dfs(i);
	}
	for (int i = 0; i < n; i++) {
		int v = vec[i];
		ft[v] = i; 
	}
	ft[0] = N;
	for (int v = 1; v <= n; v++) {
		for (auto u : adj[v]) {
			if (ft[v] < ft[par[u]]) {
				par[u] = v;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << par[i] << endl;
	}
	return 0;
}


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

const int N = 105;
const int M = 1e5 + 5;
const int MOD = 1e9 + 7;

int n, m;
int a[N];
int dp[N][M][2];
int C[M+N+5][N+5];

void precompute() {
  for (int i = 0 ; i < M+N+5 ; i++) {
    C[i][0] = 1;
    for (int j = 1 ; j < min(i+1, N+5) ; j++) {
      C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
    }
  }
}

void read() {
  cin >> n >> m;
  for (int i = 0 ; i < n ; i++)
    cin >> a[i];
}

int solve(int pos, int sisa, int mode) {
  if (sisa < 0) return 0;
  if (pos == n) {
    int ways = C[sisa+n-1][n-1];
    if (mode == 0) return ways;
    return (MOD-ways) % MOD;
  }

  int &ret = dp[pos][sisa][mode];
  if (ret != -1) return ret;

  ret = (solve(pos+1, sisa, mode) + solve(pos+1, sisa-a[pos]-1, mode ^ 1)) % MOD;
  return ret;
}

int work() {
  memset(dp, -1, sizeof dp);
  return solve(0, m, 0);
}

int main() {
  precompute();
  read();
  cout << work() << endl;
  return 0;
}

Measured memory_bytes: 125312
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
log2K = int(math.log2(10**12))+1
count_bit = [0 for i in range(log2K)]
for ai in A:
    for i in range(log2K):
        if ai & 1:
            count_bit[i] += 1
        ai = ai >> 1
b = 2**(log2K)
ans = 0
k_sum = 0
for i in range(log2K-1, -1, -1):
    if K >> i & 1:
        tmp = k_sum
        b = 1
        for j in range(i):
            tmp += max(count_bit[j], N-count_bit[j]) * b
            b *= 2
        tmp += count_bit[i] * b
        ans = max(tmp, ans)
        k_sum += (N-count_bit[i]) * b
    else:
        k_sum += count_bit[i] * (2**i)
ans = max(k_sum, ans)
print(ans)

Measured memory_bytes: 84648
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        // 主処理
        Set<Integer> set = new HashSet<>();
        for (int i = 1; i <= n; i++) {
            set.add(i * m);
            for (int j = 1; j <= m; j++) {
                set.add(j * n);
                set.add((n * j - (i * j)) + (m * i - (i * j)));
            }
        }

        String result = k == 0 || set.contains(k) ? "Yes" : "No";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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

typedef long long ll;

#define pb push_back
#define MS(x,y) memset((x),(y),sizeof((x)))
#define mn 1000000

using namespace std;

int main()
{
    #if LOCAL_DEBUG
        fstream cin("in.txt");
    #endif

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

    ll n,m;

    cin>>n>>m;

    ll niza[n][2];

    for (ll i = 0; i<n; i++) cin>>niza[i][0]>>niza[i][1];

    ll dp[n+1][m+1];

    MS(dp, -1);

    for (ll i = 0; i<=n; i++) dp[i][0] = 0;
    for (ll i = 0; i<=m; i++) dp[0][i] = 0;

    for (ll i = 1; i<=n; i++) {
        for (ll j = 1; j<=m; j++) {
            if (j-niza[i-1][0] < 0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j], niza[i-1][1] + dp[i-1][j-niza[i-1][0]]);
        }
    }

    cout<<dp[n][m]<<endl;

    return 0;
}


Measured memory_bytes: 79232
N, K = map(int, input().split())

li = []
for i in range(1, N+1):
    score = i
    kakuritu = 1/N
    shisu = 0
    while score < K:
        score *= 2
        shisu += 1
    coin_kakuritu = (0.5**shisu)
    kakuritu *= coin_kakuritu
    li.append(kakuritu)
print(sum(li))

Measured memory_bytes: 6296
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, h;
    cin >> n;
    stack<int> s;
    int ans = 0;
    s.push(0);
    for(int i=0;i<n;i++){
    	cin >> h;
    	if(s.top() >= h){
    		while(s.top() > h) s.pop();
    		s.push(h);
    	}
    	else ans += h - s.top(), s.push(h);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        myLlist list=new myLlist();

        int n=in.nextInt();
        for(int i=0;i<n;i++){
            String cmd=in.next();
            if(cmd.equals("insert")){
                list.insert(Integer.parseInt(in.next()));
                // list.dump();
            }
            else if(cmd.equals("delete")){
                list.deleteOf(Integer.parseInt(in.next()));
            }
            else if(cmd.equals("deleteFirst")){
                list.deleteFirst();
            }
            else if(cmd.equals("deleteLast")){
                list.deleteLast();
            }
        }

        list.dump();
    }
}

class llNode{
    int num;
    llNode prev,next;

    llNode(int num){
        this.num=num;
    }
}

class myLlist{
    llNode dummy;
    int size;

    myLlist(){
        dummy=new llNode(-1);
        dummy.prev=dummy;
        dummy.next=dummy;

        size=0;
    }

    boolean isEmpty(){
        if(size==0)return true;
        else return false;
    }

    void insert(int x){
        llNode nnode=new llNode(x);

        nnode.next=dummy.next;
        nnode.prev=dummy;
        dummy.next.prev=nnode;
        dummy.next=nnode;
        
        size++;
    }

    void deleteOf(int x){
        llNode node=dummy.next;
        while(node.num!=-1){
            if(node.num==x)break;
            node=node.next;
        }
        if(node.num!=-1)delete(node);
    }
    
    void deleteFirst(){
        delete(dummy.next);
    }

    void deleteLast(){
        delete(dummy.prev);
    }

    private void delete(llNode dnode){
        dnode.prev.next=dnode.next;
        dnode.next.prev=dnode.prev;

        size--;
    }

    void dump(){
        PrintWriter out=new PrintWriter(System.out);
        List<Integer> list=new ArrayList<>();
        llNode node=dummy.next;

        while(node.num!=-1){
            list.add(node.num);
            node=node.next;
        }

        for(int i=0;i<list.size()-1;i++){
            out.print(list.get(i)+" ");
        }
        out.println(list.get(list.size()-1));
        out.flush();
    }
}


Measured memory_bytes: 328832
import numpy as np

x1, y1, x2, y2 = map(int, input().split())

a = np.array([[x1], [y1]])
b = np.array([[x2], [y2]])

rot = np.array([[0, -1], [1, 0]])
ab = b - a
bc = np.dot(rot, ab)

c = b + bc
d = a + bc

# print(a, b)
# print(c, d)

print(*c.flatten(), end=" ")
print(*d.flatten())


Measured memory_bytes: 12500
using System;

namespace A_Trapezoids
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            var h = int.Parse(Console.ReadLine());

            Console.WriteLine(((a + b) * h) / 2);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
ll x,b,p[105]={0},n;
int main(void)
{
	scanf("%lld%lld",&x,&n);
	for(ll i=0;i<n;i++)
	{
		ll as;
		scanf("%lld",&as);
		p[as]=1;
	}
	for(ll i=0;i<100;i++)
	{
		if(p[x-i]==0)
		{
			printf("%lld",x-i);
			return 0;
		}
		if(p[x+i]==0)
		{
			printf("%lld",x+i);
			return 0;
		}
	}
}

Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <queue>
#include <utility>
using namespace std;

int main(void){
   long long N,cnt=0,j,k,max2 = -2;
   cin >> N;
  long long A[N];
   for(long long i=0;i<N;i++){
     cin >> A[i];
   }
   long long max = A[0];
   for(long long i=0;i<N;i++){
     if(max==A[i]){
       cnt++;
     }else if(max < A[i]){
       max = A[i];
       cnt = 1;
     }
   }
    for(long long i=0;i<N;i++){
      if(max != A[i] && max2 < A[i]){
        max2 = A[i];
      }
    }

   if(cnt >= 2){
     for(long long i=0;i<N;i++){
       cout << max << endl;
     }
   }else{
     for(long long i=0;i<N;i++){
       if(max == A[i]){
         cout << max2 << endl;
       }else{
         cout << max << endl;
       }
     }
   }
}


Measured memory_bytes: 3200
import math
import itertools

N = int(input())

x = []
y = []
for i in range(N):
    tmp_x, tmp_y = map(int, input().split())
    x.append(tmp_x)
    y.append(tmp_y)

N_fac = math.factorial(N)
towns = [x for x in range(N)]

perm = itertools.permutations(towns)

dist = 0
for i, v in enumerate(perm):
    for j in range(len(v)-1):
        tmp_dist = math.sqrt( (x[v[j]] - x[v[j+1]])**2 + (y[v[j]] - y[v[j+1]])**2 )
        dist += tmp_dist

print(dist/N_fac)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> l(m),r(m);
    rep(i,0,m-1) cin>>l[i]>>r[i];
    ll min = 10000000;
    ll max = 0;
    rep(i,0,m-1){
        if(l[i]>max) max = l[i];
        if(r[i]<min) min = r[i];
    }
    if(max <= min) cout<<min-max+1<<endl;
    else cout<<"0"<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };

signed main() {
	int a, b;
	cin >> a >> b;
	a--;
	loop(i, b - a, b + a + 1) {
		cout << i << ' ';
	}
	ggr
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
const int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

int main()
{
    double L;
    cin >> L;
    double sum = (L / 3) * (L / 3) * (L / 3);
    printf("%.9f\n",sum);
}

Measured memory_bytes: 256
import math
import cmath
A,B,H,M = map(int,input().split())

Hour = A*cmath.exp(((2*(60*H+M)/(12*60))-1/4.0)*cmath.pi*1j)
Min = B*cmath.exp((2*(M/60)-1/4.0)*cmath.pi*1j)
#print(Hour ,Min)
print(math.sqrt((Hour.real-Min.real)**2+(Hour.imag-Min.imag)**2))

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

const int N=400100,M=10000;
typedef long long ll;
int f[N],n;
ll tmp[M][36],len[M],ans[36],l,r;
char s[N];

void MP(){
	int j=f[0]=-1;f[1]=0;
	for(int i=1;i<n;f[++i]=++j)
		for(;~j&&s[i]!=s[j];j=f[j]);
}

void solve1(ll lim,int op){
	memset(tmp,0,sizeof tmp);
	for(int j=0;j<n+n-f[n];++j){
		if(j<n)tmp[0][s[j]]++;
		tmp[1][s[j]]++;
	}
	len[0]=n;len[1]=n+n-f[n];
	int i=2;
	for(;len[i-1]<=lim;++i){
		len[i]=len[i-1]+len[i-2];
		for(int j=0;j<26;++j)tmp[i][j]=tmp[i-1][j]+tmp[i-2][j];
	}
	for(i-=2;i>=0;--i)
		if(lim>=len[i]){
			for(int k=0;k<26;++k)ans[k]+=tmp[i][k]*op;
			lim-=len[i];
		}
	for(int j=0;j<lim;++j)ans[s[j]]+=op;
}

void solve2(ll lim,int op){
	--lim;
	for(int i=0;i<(n-f[n]);++i)
		ans[s[i]]+=(lim+n-f[n]-i)/(n-f[n])*op;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>s>>l>>r;n=strlen(s)/2;
	for(int i=0;i<2*n;++i)s[i]-='a';MP();
	if(n%(n-f[n])){solve1(r,1);solve1(l-1,-1);}
	else{solve2(r,1);solve2(l-1,-1);}
	for(int i=0;i<26;++i)cout<<ans[i]<<" \n"[i==25];
	return 0;
}


Measured memory_bytes: 4096
import Data.List(sort)

zipAdj :: [a] -> [(a, a)]
zipAdj x = zip x $ tail x

main = do
    [n, x] <- map read . words <$> getLine
    y <- map (read :: String -> Integer) . words <$> getLine
    putStrLn $ show $ foldr1 gcd $ fmap (uncurry $ flip (-)) $ zipAdj (sort $ x:y)


Measured memory_bytes: 39932
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N],b[N];
int n;
int t[N],t1[N];
inline int read()
{
	int Num=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {Num=(Num<<1)+(Num<<3)+ch-'0'; ch=getchar();}
	return Num*f;
}
int tot=200,flag=0;
int main()
{
	n=read();int Bit=1,_bit=n;
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++) b[n-i+1]=read();
	for(int i=1;i<=n;i++) 
	if(a[i]==b[i])  
	{
		if(b[Bit]!=a[i]&&b[i]!=a[Bit]) 
			swap(b[Bit++],b[i]);
		else if(b[_bit]!=a[i]&&a[_bit]!=b[i])
			swap(b[_bit--],b[i]);
		else 
		{
			puts("No");
			return 0;
		}
	}
		puts("Yes");
		for(int i=1;i<=n;i++)
		printf("%d ",b[i]);
		return 0;
	return 0;
}

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

int main(){
    int h,w;
    for (;;) {
        scanf("%d %d",&h,&w);
        if (h==0 && w==0) break;
        for (int i=0;i<h;i++) {
            for (int j=0;j<w;j++) {
                if (j<w-1) printf("%c",(i==0 || i==h-1 || j==0)?'#':'.');
                else printf("#\n");
            }
        }
        puts("");
    }
    return 0;
}


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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;

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

const int N = 100001;

int n,x,ans = 0;
string s;
int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> s;
	for(char z : s){
		if (z == 'I'){
			x++;
		}
		else {
			x--;
		}
		ans = max(ans,x);
	}
	cout << ans << endl;
  	return 0;
}


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

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),sum=0;
		int[] a=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			sum+=a[i];
		}
		Arrays.sort(a);
		if(sum%10!=0) {
			System.out.println(sum);
			System.exit(0);
		}else {
			for(int i=0;i<n;i++) {
				if((sum-a[i])%10!=0) {
					System.out.println(sum-a[i]);
					System.exit(0);
				}
			}
		}
		System.out.println(0);
	}
}


Measured memory_bytes: 23124