akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#include <set>
#include <random>
#include <sstream>
#include <stack>
#include <deque>

using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

ll N;
ll T[101010], A[101010];
ll ans = 1;

int main() {
  cin >> N;
  rep(i,N) cin >> T[i];
  rep(i,N) cin >> A[i];
  ll lo[N], hi[N];
  lo[0] = hi[0] = T[0];
  REP(i,1,N) {
    if (T[i] < T[i-1]) {
      cout << 0 << endl;
      return 0;
    } else if (T[i] == T[i-1]) {
      lo[i] = 1;
      hi[i] = T[i];
    } else {
      lo[i] = hi[i] = T[i];
    }
  }
  if (A[N-1] < lo[N-1] || hi[N-1] < A[N-1]) {
    cout << 0 << endl;
    return 0;
  }
  lo[N-1] = hi[N-1] = A[N-1];
  for (int i = N-2; i >= 0; --i) {
    if (A[i] < A[i+1]) {
      cout << 0 << endl;
      return 0;
    } else if (A[i] == A[i+1]) {
      hi[i] = min(hi[i], A[i]);
    } else {
      if (A[i] < lo[i] || hi[i] < A[i]) {
        cout << 0 << endl;
        return 0;
      }
      hi[i] = lo[i] = A[i];
    }
  }
  //rep(i,N) cout << lo[i] << " " << hi[i] << endl;
  rep(i,N) {
    ans *= hi[i] - lo[i] + 1;
    ans %= (ll) 1e9+7;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  int H,W;cin>>H>>W;
  vs C(H);rep(i,H)cin>>C[i];
  rep(i,H){
    cout<<C[i]<<endl;
    cout<<C[i]<<endl;
  }
  
}





Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
    cin>>n>>m;
    if(n>9 || m>9)
    {
      cout<<"-1";
      return 0;
    }
    cout<<n*m;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 7296
n, k = map(int, input().split())
pos = []
neg = []
for x in map(int, input().split()):
    if x < 0:
        neg.append(-x)
    else:
        pos.append(x)
neg.reverse()
INF = 10**18
ans = INF
for neg_cnt in range(k+1):
    pos_cnt = k-neg_cnt
    if len(neg) < neg_cnt or len(pos) < pos_cnt:
        continue
    tmp = []
    if pos:
        tmp.append(pos[pos_cnt-1])
    else:
        tmp.append(0)
    if neg:
        tmp.append(neg[neg_cnt-1])
    else:
        tmp.append(0)
    s = min(tmp)+sum(tmp)
    if s < ans:
        ans = s
print(ans)

Measured memory_bytes: 14480
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func gets() string {
	sc.Scan()
	return sc.Text()
}

func toInt(value string) int {
	num, _ := strconv.Atoi(value)
	return num
}

func main() {
	s := strings.Split(gets(), "/")
	days := make([]int, len(s))
	for index, elem := range s {
		days[index] = toInt(elem)
	}

	y, m := days[0], days[1]

	if y < 2019 {
		fmt.Println("Heisei")
	} else if m < 5 {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define next nxt

int n,m,tx,ty,x[N],y[N],next[N],p[N],f[N],c[N],s[N],k[N];
vector<int> q;

void travel(int x){
	for (int t=p[x];t;t=next[t])
		if (y[t]!=f[x]){
			if (!c[y[t]])
			f[y[t]]=x,c[y[t]]=-c[x],travel(y[t]);
			else tx=x,ty=y[t];
		}
}

void solve(int x){
	s[x]=c[x];
	for (int t=p[x];t;t=next[t])
		if (y[t]!=f[x]&&!(x==tx&&y[t]==ty)&&!(x==ty&&y[t]==tx))
		solve(y[t]),s[x]+=s[y[t]],k[x]+=k[y[t]];
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();
	for (int i=1;i<=m;i++){
		x[2*i-1]=y[2*i]=read();
		y[2*i-1]=x[2*i]=read();
		next[2*i-1]=p[x[2*i-1]];p[x[2*i-1]]=2*i-1;
		next[2*i]=p[x[2*i]];p[x[2*i]]=2*i;
	}
	c[1]=1;travel(1);long long ans=0;
	if (m==n-1){
		solve(1);
		if (s[1]) {printf("-1\n");return 0;};
		for (int i=1;i<=n;i++) ans+=abs(s[i]);
	}
	else if (c[tx]==c[ty]){
		solve(1);
		if (s[1]%2) {printf("-1\n");return 0;};
		c[tx]-=s[1]/2;c[ty]-=s[1]/2;
		ans=abs(s[1]/2);solve(1);
		for (int i=1;i<=n;i++) ans+=abs(s[i]);
	}
	else {
		k[tx]=1;k[ty]=-1;solve(1);
		if (s[1]) {printf("-1\n");return 0;};
		for (int i=1;i<=n;i++)
			if (k[i]==0) ans+=abs(s[i]);
			else q.push_back(s[i]*k[i]);
		q.push_back(0);
		sort(q.begin(),q.end());
		for (int i=0,j=(int)q.size()-1;i<j;i++,j--)
			ans+=q[j]-q[i];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 22780
a = int(input())
ai = a
a_set = set()
flag_1 = 0
flag_2 = 1
while(flag_1 == 0):
  if ai in a_set:
    flag_1 += 1
    print(flag_2)
  else:
    a_set.add(ai)
    flag_2 += 1 
    if ai % 2 == 0:
      ai //= 2
    else:
      ai = 3 * ai + 1

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

bool is_prime(ll x) {
    if (x == 1) return false; 
    bool ok = true;
    FOR (i, 2, sqrt(x) + 1) {
        if (x % i == 0) {
            ok = false;
            break;
        }
    }
    return ok;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c;
    int ans = 0;
    cin >> a >> b;
    if (a < b) swap(a, b);
    c = gcd(a, b);
    vector<ll> divisors;
    for (ll i = 1; i * i <= c; ++i) {
        if (c % i != 0) continue;
        divisors.push_back(i);
        if (c / i == i) continue;
        divisors.push_back(c / i);
    }
    rep (i, divisors.size()) {
        if (is_prime(divisors[i])) ans++;
    }
    cout << ans + 1 << endl;
    
    return 0;
}



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

int main() {
  int a,b,c,sum;
  cin >> a >> b >> c;
  for(int i=0; a*i<a*b; i++) {
    if(a*i%b==c) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}


Measured memory_bytes: 256
// Problem Code: abc177_c

#include <bits/stdc++.h>

using namespace std;

int C(int N, vector<int>& A) {
	const int mod = 1e9 + 7;
	long long sum = 0;
	vector<long long> prefix(N + 1);
	
	for (int i = 0; i < N; i++)
		prefix[i + 1] = (prefix[i] + A[i]);
	
	for (int i = 0; i < N - 1; i++) {
		sum += (long long) A[i] * ((prefix[N] - prefix[i + 1]) % mod);
		sum %= mod;
	}
	
	return sum % mod;
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	cout << C(N, A);
	return 0;
}

Measured memory_bytes: 5640
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	sort.Ints(A)
	ans := 0
	for i := 0; i < N-1; i++ {
		ans += abs(A[i] - A[i+1])
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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


int main(){
  while(true){
    int n, m, t, p, d, c, x, y, temp[100][100] = {}, ll, bb;
    cin>>n>>m>>t>>p;

    if(!m&&!n&&!t&&!p)break;
    
    for(int i = 1; i <= m; i++)for(int j = 1; j<= n; j++)temp[i][j] = 1;
    ll = 1; bb = m;
    for(int i = 1; i <= t; i++){
      cin>>d>>c;
      if(d==1){
        //c = min(c, (n-ll+1)-c);
	if(c > (n-ll+1)-c){
	  c = (n-ll+1)-c;
	  for(int j = n; j >= ll ; j--){
	    for(int k = 1; k<= bb; k++){
	      if(j < n-j+ll)break;
	      swap(temp[k][j],temp[k][n-j+ll]);
	    }
	  }
	}
	
	
	for(int j = 1; j <= c; j++){
	  for(int k = 1; k <= bb; k++){
	    temp[k][ll+c+j-1]+=temp[k][ll+c-j];
	    temp[k][ll+c-j] = 0;
	  }
	}
	ll += c;
      }else if(d==2){
	//c = min(c, bb-c);
	if(c > bb-c){
	  c = bb - c;
	  for(int j = 1; j <= bb; j++){
	    for(int k = ll; k <= n; k++){
	      if(j > bb-j+1)break;
	      swap(temp[j][k],temp[bb-j+1][k]);
	    }
	  }
	}
	
	for(int j = 1; j <= c; j++){
	  for(int k = ll; k <= n; k++){
	    temp[bb-c-j+1][k]+=temp[bb-c+j][k];
	    temp[bb-c+j][k] = 0;
	  }
	}
	bb -= c; 
      }
      /*
      for(int i = 0; i <= m+1; i++){
	for(int j = 0; j<= n+1; j++){
	  cout<<temp[i][j]<<" ";
	}
	cout<<endl;
      }cout<<endl;
      

      cout<<bb<<" "<<ll<<endl<<endl;
      */
    }
    
    for(int i = 1; i <= p; i++){
      cin>>x>>y;
      cout<<temp[bb-y][ll+x]<<endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3120
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

//グローバル変数
vector<long long> fact, fact_inv, inv;

//二項係数前処理計算量O(SIZE)
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
    
//nCk　計算量(1)
ll nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

int main(){
    init_nCk(100000);
    ll S;
    cin>>S;
    ll ans=0;
    REP2(i,1,S+1){
        if(S-3*i<0) break;
        if(S-3*i==0) ans++;
        else ans+=nCk(S-2*i-1,i-1);
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5484
S = input()

evenS=[]
oddS=[]

for i in range(len(S)):
    if i%2 == 0:
        oddS.append(S[i])
    else:
        evenS.append(S[i])

if('R' in evenS) or ('L' in oddS):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = 0;

		if (x == y){
			System.out.println("0");
			System.exit(0);
		}

		if (x >= 0 && y >= 0){
			if ( x < y) {
				ans = y - x;
			} else {
				if (y != 0) {
				ans = y + x ;
				} else{
					ans = y + x + 1;
				}
			}
			System.out.println(ans);
			System.exit(0);

		}


		if (x < 0 && y < 0) {
			if ( x > y) {
				ans = Math.abs(y) - Math.abs(x) + 2;
			} else {
				ans = Math.abs(x) - Math.abs(y);
			}

			System.out.println(ans);
			System.exit(0);
		}


		if (x > y) {
				if ( x > Math.abs(y)){
					ans = x - Math.abs(y) +1;
				}else {

				ans = Math.abs(y) - Math.abs(x) + 1;
				}
		} else {

			if (Math.abs(x) < y){
				ans = y - Math.abs(x) + 1;
			}else if (y != 0) {
				ans = Math.abs(x) - Math.abs(y)+ 1;
			} else {
				ans = Math.abs(x) - Math.abs(y);
			}
		}
		System.out.println(ans);
		System.exit(0);

		sc.close();
	}


}


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	int n, x;
	cin >> x >> n;
	set<int> s;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		s.insert(x);
	}
	int ans, diff = 1e17;
	for (int i = -200; i <= 200; i++) {
		if (s.find(i) == s.end() && diff > abs(x - i)) {
			ans = i;
			diff = abs(x - i);
		}
	}
	cout << ans << endl;
	return 0;
}

//!

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int H, W; cin >> H >> W;
	vector<string> s(H + 2);
	s[0] = string(W + 2, '@');
	s[H + 1] = string(W + 2, '@');
	for (int i = 1; i <= H; i++) cin >> s[i], s[i] = '@' + s[i] + '@';
	vector<vector<int>> dp(H + 2, vector<int>(W + 2, 1e9));
	deque<pair<int, pair<int, int>>> que;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i][j] != '#') continue;
			que.push_back({ 0, {i, j} });
		}
	}
	vector<int> dx = { 1, 0, -1, 0, 1 };
	while (!que.empty()) {
		int d = que.front().first;
		auto p = que.front().second;
		que.pop_front();
		if (dp[p.first][p.second] <= d) continue;
		dp[p.first][p.second] = d;
		for (int i = 0; i < 4; i++) {
			if (s[p.first + dx[i]][p.second + dx[i + 1]] != '.') continue;
			if (dp[p.first + dx[i]][p.second + dx[i + 1]] < d + 1) continue;
			que.push_back({ d + 1, {p.first + dx[i], p.second + dx[i + 1]} });
		}
	}
	int ans = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) ans = max(ans, dp[i][j]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 18320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int n;
  cin >> n;
  VI a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int ali=0;
  int bob=0;
  rep(i,n){
    if(i%2==0) ali+=a.at(i);
    else if(i%2==1) bob+=a.at(i);
  }
  cout << ali-bob << 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 rep1(i, N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << "{" << p.first << ", " << p.second << "}";
    return os;
}

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;
}

const int INF = (ll) 1e9;
const ll INFLL = (ll) 1e18 + 1;
const ll MOD = (ll) 1e9 + 7;
const double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string s;
    cin >> s;
    if(s.size() == 2){
        cout << s << endl;
    }
    else{
        reverse(all(s));
        cout << s << endl;
    }
}

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

// n以下の素数の列挙
vector<ll> sieve(ll n){
	vector<ll> res;
	vector<bool> is_prime(n+1, true);
	is_prime[0] = is_prime[1] = false;
	
	for(int i = 2; i <= n; i++){
		if(is_prime[i]){
			res.push_back(i);
			for(int j = 2*i; j <= n; j += i){
				is_prime[j] = false;
			}
		}
	}
	
	return res;
}

int main(){
	int n;
	cin >> n;
	
	vector<ll> prime = sieve(55555);
	
	vector<ll> res;
	
	rep(i,prime.size()){
		if(prime[i]%5 == 1){
			res.push_back(prime[i]);
		}
		if(res.size() == n) break;
	}
	
	rep(i,n) cout << res[i] << " ";
	return 0;
}

Measured memory_bytes: 384
# 2019/07/23

input=open(0).readline

n,m=map(int,input().split())
py=[]
for i in range(m):
    p,y=map(int,input().split())
    py.append((p,y,i+1))

py.sort()

ans=[]

pre_cty=0
cnt=1
for i in range(m):
    p,y,idx=py[i]
    cty=p
    if pre_cty==cty:
        cnt+=1   

    else:
        pre_cty=p
        cnt=1
    
    p=str(p).zfill(6)
    x=str(cnt).zfill(6)
    ans.append((idx,p+x))

ans.sort()

for i in range(m):
    print(ans[i][1])

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

int main()
{
	int n, mx = -1, mn = 1e9, cnt = 0, x, t;
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> x;
		if (mn > x) {
			mn = x;
		} else {
			if (x - mn > mx) {
				mx = x - mn;
				cnt = 0;
			}
			if (mx == x - mn) ++cnt;
		}
	}
	cout << cnt << '\n';
}


Measured memory_bytes: 256
import sys
num = [int(x) for x in input()]
sign = ["-","+"]
ans = str(num[0])
for x in range(2 ** (len(num)-1)):
  sum = num[0]
  for i in range(len(num) - 1):
    if ((x >> (2-i)) & 1) == 1:
      sum += num[i+1]
    else:
      sum -= num[i+1]
  if sum == 7:
    for i in range(len(num) - 1):
      ans = "{}{}{}".format(ans,sign[(x >> (2 - i)) & 1],num[i+1])
    print(ans+"=7")
    sys.exit()


Measured memory_bytes: 3064
#include <iostream>
#include <set>

int main()
{
  int N,K;
  std::cin>>N>>K;
  
  std::set<int> set;
  
  for(int i=0;i!=K;i++)
  {
    int d;
    std::cin>>d;
    for(;d!=0;d--)
    {
      int A;
      std::cin>>A;
      set.insert(A);
    }
  }
  
  std::cout<<N-set.size()<<std::endl;
  
  return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();
        int k = sc.nextInt();

        if (n < k) {
            out.println(0);
        } else {
            out.println(10);
        }
        
        out.flush();
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 21204
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let h = scan.read::<usize>();
    let w = scan.read::<usize>();
    let a = scan.read::<usize>();
    let b = scan.read::<usize>();
    let mut ret = vec![vec![0;w];h];
    for y in 0..h {
        for x in 0..w {
            ret[y][x] = (x < a) as usize ^ (y < b) as usize;
        }
    }
    for y in 0..h {
        println!("{}", join(&ret[y], ""));
    }
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 13436
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=200050;
vector<pair<int,int>> ans;
void AddEdge(int u, int v){ ans.pb({u,v});}
int n;
void Answer()
{
	printf("Yes\n");
	for(auto p:ans) printf("%i %i\n",p.first,p.second);
}
void SolveOdd()
{
	if(n==1) printf("No\n");
	else
	{
		for(int i=2;i<=n;i+=2)
		{
			int x0=i,x1=i+n,y0=i+1,y1=i+1+n;
			AddEdge(x1,1);
			AddEdge(y1,1);
			AddEdge(x0,y1);
			AddEdge(y0,x1);
		}
		AddEdge(1+n,2);
		Answer();
	}
}
void SolveEven()
{
	if(__builtin_popcount(n)==1) printf("No\n");
	else
	{
		int xr=n^(n-1),a,b,c,d;
		for(int i=2;i<n;i+=2)
		{
			int x0=i,x1=i+n,y0=i+1,y1=i+1+n;
			if(y0==xr)
			{
				a=y1;
				b=x0;
				c=x1;
				d=y0;
				continue;
			}
			AddEdge(x1,1);
			AddEdge(y0,x1);
			AddEdge(x0,y1);
			AddEdge(y1,1);
		}
		AddEdge(1+n,n-1);
		AddEdge(n-1,a);
		AddEdge(a,b);
		AddEdge(n+n,a);
		AddEdge(n-2+n,c);
		AddEdge(c,d);
		AddEdge(n,n-1);
		Answer();
	}
}
int main()
{
	scanf("%i",&n);
	if(n&1) SolveOdd();
	else SolveEven();
	return 0;
}

Measured memory_bytes: 4080
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
using namespace std;
using P=pair<int,int>;
using ll=long long;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> e[n];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    vector<int> dis(n,INT_MAX);
    dis[0]=0;
    priority_queue<P,vector<P>,greater<>> task;
    task.push(P(0,0));
    while(!task.empty()){
        P p=task.top();
        int cost=p.first,v=p.second;
        task.pop();
        if(cost>dis[v])continue;
        for(int i=0;i<e[v].size();i++){
            if(dis[e[v][i]]>cost+1){
                dis[e[v][i]]=cost+1;
                task.push(P(dis[e[v][i]],e[v][i]));
            }
        }
    }
    vector<int> ret(n,-1);
    for(int i=1;i<n;i++){
        if(ret[i]!=-1){
           if(dis[ret[i]]==dis[i]-1)continue;
           else {
               cout<<"No"<<endl;
               return 0;
           }
        }
        for(int j=0;j<e[i].size();j++){
            if(dis[e[i][j]]==dis[i]-1){
                ret[i]=e[i][j];
            }
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++){
        cout<<ret[i]+1<<endl;
    }
}


Measured memory_bytes: 10988
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e17;																									
ll mpow(ll a,ll b){a=a%MOD;ll res=1;while(b>0){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b=b>>1;}return res%MOD;}             

int main()
{ 
ios_base::sync_with_stdio(false);
cin.tie(NULL);
///freopen("input.txt", "r", stdin);
ll n;
cin>>n;
ll a[n];
forn(i,n)
cin>>a[i];
ll c[n];
forn(i,n)
{
	c[i]=a[i]-i-1;
}
sort(c,c+n);
ll b=c[n/2];
ll ans=0;
forn(i,n)
{
	ans+=abs(a[i]-b-i-1);
}
cout<<ans;
return 0;    
} 

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        // ビジネスロジックここから
        int ans = 0 ;
        String S = scanner.next();
        String T = scanner.next();
        
		for(int i = 0; i<3; i++) {
			if(S.charAt(i)==T.charAt(i))
				ans++;
		}

        System.out.println(ans);
        
        // ビジネスロジックここまで

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21076
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> l(n);
    for(int i=0; i<n; i++) cin>>l[i];
    sort(l.begin(), l.end());

    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                ans += (l[k] < l[i] + l[j]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"sort"
)

func main() {
	var arr []int
	var a int
	for i := 0; i < 3; i++ {
		fmt.Scanf("%d", &a)
		arr = append(arr, a)
	}
	sort.Ints(arr)
	fmt.Printf("%d", arr[0]+arr[1])
}


Measured memory_bytes: 512
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t,u;
    int a,b;


    cin>>s>>t;
     cin>>a>>b;
     cin>>u;
     if(u==s)
     {
         a-=1;
     }
     else if(u==t){
        b-=1;}

     cout<<a<<" "<<b<<endl;
     return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    
    
    
    
    
    int n;
    cin>>n;
    vector<long long int >h(n);
    for(auto & v : h){
        cin>>v;
    }
    int k=1;
    int min= h[0];
    for(int i=1;i<n;i++){
        if(min>=h[i]){
            k++;
            min = h[i];
        }
    }
    
    cout<<k<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
class Point
  attr_accessor :x, :y
  def initialize(x=0.0, y=0.0)
    @x, @y = x.to_f, y.to_f
  end
end

class Circle
  include Comparable
  attr_accessor :x, :y, :r
  def initialize(x=0.0, y=0.0, r=1.0)
    @x, @y, @r = x.to_f, y.to_f, r.to_f
  end
  def <=>(c)
    @x!=c.x ? @x<=>c.x : (@y!=c.y ? @y<=>c.y : @r<=>c.r)
  end
  def distance(c)
    Math::hypot(c.x-@x, c.y-@y)
  end
  def touch?(c)
    distance(c) <= @r + c.r
  end
  def crossPoint(c)
    angle = Math::atan2(c.y-@y, c.x-@x)
    d = distance(c)
    add = Math::acos((d**2 + @r**2 - c.r**2) / (2.0*d*@r))
    p1 = Point.new(@x+@r*Math::cos(angle+add), @y+@r*Math::sin(angle+add))
    p2 = Point.new(@x+@r*Math::cos(angle-add), @y+@r*Math::sin(angle-add))
    [p1, p2]
  end
  def include?(p)
    Math::hypot(p.x-@x, p.y-@y) <= @r
  end
end

while (n = gets.to_i) != 0 do
  answer = 1
  seal = Array.new
  n.times do
    x, y = gets.split(",").map(&:to_f)
    r = 1.0
    seal.push(Circle.new(x, y, r))
  end
  point = Array.new
  seal.each do |s1|
    seal.each do |s2|
      next if s1 == s2
      next if !s1.touch?(s2)
      p1, p2 = s1.crossPoint(s2)
      point.push(p1, p2)
    end
  end
  point.each do |p|
    count = 0
    seal.each do |s|
      count += 1 if s.include?(p)
    end
    answer = [answer, count].max
  end
  p answer
end

Measured memory_bytes: 6316
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long

  

int32_t main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin>>n;
    if(n>=30)
    cout<<"Yes";
    else
    cout<<"No";   		
   

		
	
		  
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 1000000001
int nC;

void merge_sort(int nA[], int nLeft, int nMid, int nRight)
{
	int n1 = nMid - nLeft, n2 = nRight - nMid;

	int nL[MAX / 2 + 1], nR[MAX / 2 + 1];
	for (int i = 0; i < n1; i++)
	{
		nL[i] = nA[nLeft + i];
	}
	for (int i = 0; i < n2; i++)
	{
		nR[i] = nA[nMid + i];
	}
	nL[n1] = SENTINEL;
	nR[n2] = SENTINEL;
	int i = 0, j = 0;
	for (int k = nLeft; k < nRight; k++)
	{
		nC++;
		if (nL[i] <= nR[j])
		{
			nA[k] = nL[i++];
		}
		else
		{
			nA[k] = nR[j++];
		}
	}
}

void merge(int nA[], int nLeft, int nRight)
{
	int nMid = 0;
	if (nLeft + 1 < nRight)
	{
		nMid = (nLeft + nRight) / 2;
		merge(nA, nLeft, nMid);
		merge(nA, nMid, nRight);
		merge_sort(nA, nLeft, nMid, nRight);
	}
}

int main()
{
	int nIn;
	nC = 0;
	cin >> nIn;
	int nA[MAX];
	for (int i = 0; i < nIn; i++)
	{
		cin >> nA[i];
	}
	merge(nA, 0, nIn);
	for (int i = 0; i < nIn; i++)
	{
		if (i)
		{
			cout << " ";
		}
		cout << nA[i];
	}
	cout << endl << nC << endl;
	//system("pause");
}


Measured memory_bytes: 6960
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <map>
#include <queue>
#include <clocale>
#include <bitset>
#include <cstring>
#include <memory.h>
#include <numeric>
#include <iomanip>
#include <stack>
#include <list>
#include <functional>
#include <unordered_set>

using namespace std;

#pragma comment (linker, "/STACK:667177216")
#define ll long long
#define LL long long
#define ull unsigned long long
#define ld long double
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
const ll mod = 1000000007;
#define INF (int)(2e9)
#define LINF (ll)(4e18)
#define forit(mas) for(auto(it)=(mas).begin();(it)!=(mas).end();(it)++)
#define pii pair<int,int>


int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n == 1) cout << "Hello World\n";
	if (n == 2) {
		ll a, b;
		cin >> a >> b;
		cout << a + b;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

n, *x = map(int, sys.stdin.read().split())

def main():
    m = round(sum(x) / n)
    s = 0
    for i in range(n):
        s += (m - x[i]) ** 2
    
    return s

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 2940
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

vector<string> split(char d,string s)
{
	stringstream ss(s);
	string t;
	vector<string> words;
	while(getline(ss,t,d))
	{
		words.pb(t);
	}

	return words;
}

int main(int argc, char *argv[])
{
#ifdef LOCAL
	auto start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	double r;
	cin>>r;
	double circum=2*pi*r;
	cout<<circum;


#ifdef LOCAL
	auto end = chrono::high_resolution_clock::now();
	double time_taken =
		chrono::duration_cast<chrono::nanoseconds>(end - start).count();

	time_taken *= 1e-9;

	cerr << "\nTime taken by program is : " << fixed
		 << time_taken << setprecision(9);
	cerr << " sec" << endl;
#endif
	return 0;
}

Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
using namespace std;
int main(){
  long long N,M;
  cin>>N>>M;
  long long *a,*b;
  a=new long long[N];
  b=new long long[N];
  vector<pair<long long,long long>>shop;
  
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i];
    shop.push_back(make_pair(a[i],b[i]));
  }
  sort(shop.begin(),shop.end());
  long long count=0;
  long long sum=0;
  for(int i=0;i<N;i++){
    if(shop[i].second+count<=M){
      sum+=shop[i].first*shop[i].second;
      count+=shop[i].second;
    }else{
      sum+=(M-count)*shop[i].first;
      count=M;
    }
    if(count==M)break;
  }
  cout<<sum;
  return 0;
}

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

int c[33], s[444][33], l[33];
int main() {
    int d, r = 0;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    for(int i = 0; i < d; i++) {
        int t;
        cin >> t;
        t--;
        l[t] = i + 1;
        r += s[i][t];
        for(int j = 0; j < 26; j++)
            r -= c[j] * (i + 1 - l[j]);
        cout << r << '\n';
    }
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>

 

using namespace std;

 

int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r >= 0 && y-r >= 0 && r+x <= w && r+y <= h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long int
int main(){
  ll n,k;
  cin>>n>>k;
  vector<double>a(n);
  vector<double>v(n);
  for(ll i=0;i<n;i++){
    cin>>v[i];
    a[i]=(v[i]+1)/2;
  }
  //for(ll i=0;i<n;i++)
    //cout<<a[i]<<" ";
  double sum=0,ans=0;
  for(ll i=0;i<n;i++){
    sum+=a[i];
    if(i>=k)
      sum-=a[i-k];
    ans=max(ans,sum);
  }
  cout<<setprecision(10)<<fixed<<ans;
  return 0;
}

Measured memory_bytes: 3328
n,k = map(int,input().split())
L = [0]
P = list(map(int,input().split()))
L = L+P
cur = 0
for i in range(n+1):
  if i != 0:
    L[i] = (L[i]+1)/2
    L[i] += L[i-1]
for i in range(n-k+1):
  cur = max(L[i+k]-L[i],cur)
print(cur)

Measured memory_bytes: 24548
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0; i < n; i++){
		    x[i] = sc.nextInt();
		    y[i] = sc.nextInt();
		}
		
		// 計算
		long result = 0;
		long[] distA = new long[n];
		long[] distB = new long[n];
		for(int i = 0; i < n; i++){
		    distA[i] = abs(2 - x[i] - y[i]);
		    distB[i] = abs(1000000001 - x[i] + y[i]);
		}
		
		Arrays.sort(distA);
		Arrays.sort(distB);
		
		result = max(distA[n-1] - distA[0], distB[n-1] - distB[0]);
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}

}


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

int main()
{
    int x, y; cin >> x >> y;
    if (2*x <= y && y <= 4*x && y % 2 == 0)
        cout << "Yes";
    else
        cout << "No";
    cout << '\n';
    return 0;
}

Measured memory_bytes: 3600
#include <stdint.h>

#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
  int h, w;
  std::cin >> h >> w;
  std::vector<std::vector<bool>> map_is_passable =
      std::vector<std::vector<bool>>(h, std::vector<bool>(w, false));
  std::vector<std::vector<int>> map_op_count =
      std::vector<std::vector<int>>(h, std::vector<int>(w, 0));
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      char c;
      std::cin >> c;
      map_is_passable[y][x] = c == '.';
    }
  }
  if (!map_is_passable[0][0]) {
    map_op_count[0][0] = 1;
  }

  for (int y = 1; y < h; y++) {
    if (map_is_passable[y][0]) {
      map_op_count[y][0] = map_op_count[y - 1][0];
    } else {
      map_op_count[y][0] =
          map_op_count[y - 1][0] + (map_is_passable[y - 1][0] ? 1 : 0);
    }
  }
  for (int x = 1; x < w; x++) {
    if (map_is_passable[0][x]) {
      map_op_count[0][x] = map_op_count[0][x - 1];
    } else {
      map_op_count[0][x] =
          map_op_count[0][x - 1] + (map_is_passable[0][x - 1] ? 1 : 0);
    }
  }
  for (int y = 1; y < h; y++) {
    for (int x = 1; x < w; x++) {
      int yp;
      if (map_is_passable[y][x]) {
        yp = map_op_count[y - 1][x];
      } else {
        yp = map_op_count[y - 1][x] + (map_is_passable[y - 1][x] ? 1 : 0);
      }
      int xp;
      if (map_is_passable[y][x]) {
        xp = map_op_count[y][x - 1];
      } else {
        xp = map_op_count[y][x - 1] + (map_is_passable[y][x - 1] ? 1 : 0);
      }
      map_op_count[y][x] = std::min(yp, xp);
    }
  }
  std::cout << map_op_count[h-1][w-1] << std::endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
import copy

def main():
    N,K = map(int,input().split())
    MOD = 10**9+7

    fac = [0 for _ in range(4*10**5+1)]
    fac[0],fac[1] = 1,1
    inv = copy.deepcopy(fac)
    invfac = copy.deepcopy(fac)
    
    for i in range(2,4*10**5+1):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = MOD-(MOD//i)*inv[MOD%i]%MOD
        invfac[i] = (invfac[i-1]*inv[i])%MOD

    def coef(x,y):
        num = (((fac[x]*invfac[y])%MOD)*invfac[x-y]%MOD)
        return num
    
    ans = 0
    for i in range(min(N,K+1)):
        a = coef(N,i)
        b = coef(N-1,N-i-1)
        ans += ((a*b)%MOD)
        
    print(ans%MOD)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 51108