akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
 
using namespace std;
 
#define y1 hogwhoasjfd
 
#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
 
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;
 
template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
 
constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;
 
int w, h;
int n;
int x1[1005], x2[1005];
int y1[1005], y2[1005];
 
bool fld[1005*6+2][1005*6+2];
 
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
 
int compress(int *x1, int *x2, int w)
{
    vi xs;
 
    rep(i, n) {
        for (int d = -1; d <= 1; ++d) {
            int tx1 = x1[i] + d, tx2 = x2[i] + d;
 
            if (0 <= tx1 && tx1 <= w) xs.PB(tx1);
            if (0 <= tx2 && tx2 <= w) xs.PB(tx2);
        }
    }
 
    sort(all(xs));
    //xs.erase(unique(all(xs)), end(xs));
 
    rep(i, n) {
        x1[i] = lower_bound(all(xs), x1[i]) - begin(xs);
        x2[i] = lower_bound(all(xs), x2[i]) - begin(xs);
    }
 
    return xs.size();
}
 
int main()
{
    while (cin >> w >> h, w) {
        cin >> n;
 
        memset(fld, 0, sizeof fld);
 
        rep(i, n) {
            cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        }
 
        w = compress(x1, x2, w);
        h = compress(y1, y2, h);
 
        rep(i, n) {
            for (int y = y1[i]; y <= y2[i]-1; ++y) {
                for (int x = x1[i]; x <= x2[i]-1; ++x) {
                    fld[y][x] = true;
                }
            }
        }
 
        int ans = 0;
 
        rep(y, h-1) rep(x, w-1) {
            if (fld[y][x]) continue;
 
            ans++;
 
            queue<pii> q;
            q.push(pii(y, x));
 
            while (q.size()) {
                pii p = q.front(); q.pop();
                rep(i, 4) {
                    int ny = p.fst + dy[i], nx = p.scd + dx[i];
 
                    if (ny < 0 || ny >= h-1 || nx < 0 || nx >= w-1 || fld[ny][nx]) continue;
 
                    fld[ny][nx] = true;
                    q.push(pii(ny, nx));
                }
            }
        }
 
        cout << ans << endl;
    }
}

Measured memory_bytes: 38552
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int n;cin >> n;
    vector<char> c;
    for (int i = 0; i < n; i++) {
        char cc;cin >> cc;
        if(cc!='-') c.pb(cc);
    }
    n=c.size();
    vector<vector<LL>> dp(n+1,vector<LL> (n+1,0));
    dp[0][0]=1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if(c[i]=='D'){
                if(j) dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j]*j*j)%mod;
                dp[i+1][j]=(dp[i+1][j]+dp[i][j]*j)%mod;
            }
            else{
                dp[i+1][j]=(dp[i+1][j]+dp[i][j]*j)%mod;
                dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
            }
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int dp[1005][1<<12];
int main(){
    int n,m;cin >> n >> m;
    vector<int> a(m),b(m),c[m];
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
        for(int j=0; j<b[i]; j++){
            int cc;cin >> cc;
            c[i].push_back(cc);
        }
    }
    for(int i=0; i<1005; i++){
        for(int j=0; j<1<<12; j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0; i<m; i++){
        for(int j=0; j<1<<12; j++){
            int sum=0;
            for(int k=0; k<b[i]; k++){
                sum|=1<<(c[i][k]-1);
            }
            dp[i+1][j|sum]=min(dp[i+1][j|sum],dp[i][j]+a[i]);
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        }
    }
    if(dp[m][(1<<n)-1]==INF) cout << -1 << endl;
    else cout << dp[m][(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 16384
n=int(input())
tmp=[['1',set({1})]]
for i in range(1,n):
  tmp2=[]
  for s,c in tmp:
    for j in range(len(c)+1):
      tmp2.append([s+str((j+1)%10),c|set({j+1})])
  tmp=tmp2
ans=[]
dic={'1':'a','2':'b','3':'c','4':'d','5':'e','6':'f','7':'g','8':'h','9':'i','0':'j'}
for s,c in tmp:
  ts=''
  for tc in s:
    ts+=dic[tc]
  ans.append(ts)
ans=sorted(ans)
for s in ans:
  print(s)

Measured memory_bytes: 76652
#include <iostream>
int main()
{
    int k, s;
    std::cin >> k;
    std::cin >> s;

    int cnt = 0;

    if ( k == s )
    {
        cnt = (k + 2)*(k+1)/2;
    }
    else
    {
        // off-diagonal
        for (int ix = 0; ix < k+1; ++ix)
        {
            for (int iy = ix + 1; iy < k+1; ++iy)
            {
                const int z = s - ix - iy;
                if (z < 0) break;
                if (z <= k) ++cnt;
            }
        }
        cnt *= 2;

        // diagonal
        for (int ix = 0; ix < k+1; ++ix)
        {
            const int z = s - 2*ix;
            if (z < 0) break;
            if (z <= k) ++cnt;
        }
    }

    std::cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $q);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
$X = array_map('intval', explode(' ', trim(fgets(STDIN))));

for ($i = 0; $i < $q; ++$i) {
    $x = $X[$i];
    $cnt = 0;

    $sum = 0;
    $r = 0;
    for ($l = 0; $l < $n; ++$l) {
        while ($r < $n && $sum + $A[$r] <= $x) {
            $sum += $A[$r];
            ++$r;
        }

        $cnt += $r - $l;

        if ($r === $l) {
            ++$r;
        } else {
            $sum -= $A[$l];
        }
    }
    echo $cnt, PHP_EOL;
}



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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n, p;
    string s;
    cin >> n >> p;
    cin >> s;
    ll ans = 0;
    if (p == 2)
    {
        for (int i = 0; i < n; i++)
        {
            if ((s[i] - '0') % 2 == 0)
                ans += 1ll * (i + 1);
        }
    }
    else if (p == 5)
    {
        for (int i = 0; i < n; i++)
        {
            if ((s[i] - '0') % 5 == 0)
                ans += 1ll * (i + 1);
        }
    }
    else
    {
        map<int, int> mp;
        int p1 = 1;
        mp[0]++;
        int t = 0;
        for (int i = n - 1; i >= 0; i--)
        {
            t = (t + (s[i] - '0') * p1) % p;
            ans += 1ll * mp[t];
            mp[t]++;
            p1 = p1 * 10 % p;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 916
import java.io.*;
import java.util.*;
public class Main{
	static int n;
	static int[] height;
	public static int solve(){
		int[] dp=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(height[0]-height[1]);
		for(int i=2;i<n;i++){
			dp[i]=Math.min(dp[i-1]+Math.abs(height[i]-height[i-1]),dp[i-2]+Math.abs(height[i]-height[i-2]));
		}
		return dp[n-1];
	}
	public static void main(String[] args) throws IOException{
    	 BufferedReader br = new BufferedReader( 
                              new InputStreamReader(System.in)); 
       
		n=Integer.parseInt(br.readLine()); 
		height=new int[n];
		String[] str=br.readLine().split(" ");
		for(int i=0;i<n;i++){			
		   height[i]=Integer.parseInt(str[i]);		 
		}
		System.out.println(solve());
	
    }
}

Measured memory_bytes: 34188
#include<stdio.h>
main(){
  int H,W,i,d;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0)break;
    for(i=0;i<H;i++){
      for(d=0;d<W;d++){
    if(i==0 || i==H-1){
        printf("#");
      }
    else if(d==0 || d==W-1){
      printf("#");
    }
    else{
      printf(".");
    }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N,mid[100009];
ll maxL[100009], minR[100009];
priority_queue<int> L,R;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    int x;
    ll sumL=0, sumR=0;
    rep(i,N) cin>>x,sumL+=x,L.push(-x);
    rep(i,N) cin>>mid[i];
    rep(i,N) cin>>x,sumR+=x,R.push(x);
    
    maxL[0]=sumL;
    rep(i,N){
        if(mid[i]>-L.top()){
            sumL+=mid[i]+L.top();
            L.pop();
            L.push(-mid[i]);
        }
        maxL[i+1]=sumL;
    }
    
    minR[N]=sumR;
    rrep(i,N-1){
        if(mid[i]<R.top()){
            sumR+=mid[i]-R.top();
            R.pop();
            R.push(mid[i]);
        }
        minR[i]=sumR;
    }
    
    ll ans=-LLINF;
    rep(i,N+1) if(ans<maxL[i]-minR[i]) ans=maxL[i]-minR[i];
    
    cout1(ans)
}

Measured memory_bytes: 3192
n,m=map(int,input().split())
data=[]
for i in range(n):
    data.append(list(map(int,input().split())))

ans=0
tmp=[]


for i in range(-1,3,2):
    for j in range(-1,3,2):
        for k in range(-1,3,2):
            tmp.append([ i*data[l][0] + j*data[l][1] + k*data[l][2] for l in range(len(data))])

result=[]
for i in range(8):
    total=0
    now=sorted(tmp[i])
    for k in range(m):
        total+=now[-1-k]
    result.append(total)
print(max(result))

Measured memory_bytes: 3572
m,i,j,k,c[16],p,d;
main(n){
	for(;scanf("%d%d",&n,&m),n;printf("%d\n",j>m?-1:j)){
		for(k=3;k--;)
			for(scanf("%d",&i);i--;c[j]=k)scanf("%d",&j);
		for(j=k=0;k++<n;p=i%2*2+p&3)
			j+=pow(3,n-k)*abs(i=p-c[k]);
		j=fmin(j,pow(3,n)+~j);
	}
}

Measured memory_bytes: 0
s=input().split()
n,m,q=int(s[0]),int(s[1]),int(s[2])
arr=[[0 for i in range(n+3)] for j in range(n+3)]
for i in range(m):
    s=input().split()
    l,r=int(s[0]),int(s[1])
    for j in range(l+1):
        arr[j][r]+=1
for i in range(q):
    s=input().split()
    p,q=int(s[0]),int(s[1])
    print(sum(arr[p][1:q+1]))


Measured memory_bytes: 58404
s = list(input())
if s[0] == 'A':
    if 'C'in s[2:len(s) - 1]:
        s.remove('A')
        s.remove('C')
        s = ''.join(s)
        if s.islower() == True:
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')

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

#define INF (1<<30);

int dp[1000001][2];
// [下から何番目のケタか][いっこ上のケタに1枚払ってもらう？　1:0]

int main(){
	string s;	cin>>s;
	reverse(s.begin(), s.end());

	int n=s.length(), ans=0;




	/* [memo] DP遷移
		dp[i+1][0] = d(i) + min(dp[i][0], dp[i][1]);

		dp[i][1] = 1+(10-d(i)) + min(dp[i][0]+dp[i][1]);
		
	*/


	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++) dp[i][j]=INF;
	}
	dp[0][0]=0;

	for(int i=0;i<n;i++){
		int D=s[i]-'0';
		dp[i+1][0] = D + min(dp[i][0], dp[i][1]+1);

		dp[i+1][1] = (10-D) + min(dp[i][0], dp[i][1]-1);
	}

	
	ans=min(dp[n][0], dp[n][1]+1);
	cout<<ans<<endl;


	return 0;
}


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

using namespace std;

typedef long long LL;

int n,x,f[100005],ans;

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&x);
		x++;f[x]++;
	}
	for (int i=1;i<=100000;++i) ans=max(ans,f[i-1]+f[i]+f[i+1]);
	printf("%d\n",ans);
	return 0;	
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
struct edge {
  int to,w;
};
#define MAX 1000000005
vector<vector<edge> > g;
//vector<bool> f;
vector<int> min_d;
priority_queue <edge, vector<edge>,greater<edge>> que;
bool operator > (const edge a,const edge b){return a.w>b.w;};

void dfs(int v,int n){
  edge this_p;
  for(int i = 0; i<n; i++)min_d[i] = MAX;
  min_d[v] = 0;
  for(auto e : g[v]){
    que.push(e);
    min_d[e.to] = e.w;
  }
  //f[v]=true;

  while(!que.empty()){
    this_p = que.top();
    que.pop();
    //f[this_p.to] = true;
    for(auto e : g[this_p.to]){
      //if(f[e.to])continue;
      if(min_d[e.to] > min_d[this_p.to]+e.w){
        min_d[e.to] = min_d[this_p.to]+e.w;
        que.push(e);
        //cout<<min_d[i]<<" : "<<min_d[min_node]<<":"<<g[min_node][i]<<endl;
      }
    }
  }
}
int main(){
  int v,e,s,t,r,w;
  edge tmp;
  cin>>v>>e>>r;
  g.resize(v);
  //f.resize(v);
  min_d.resize(v);
  tmp.to=r;
  tmp.w=0;
  g[r].push_back(tmp);
  for(int i=0;i<e;i++){
    cin>>s>>t>>w;
    tmp.to=t;
    tmp.w=w;
    g[s].push_back(tmp);
  }
  dfs(r,v);
  for(auto i : min_d){
    if(i==MAX)cout<<"INF"<<endl;
    else cout<<i<<endl;
  }
  return 0;
}



Measured memory_bytes: 16228
#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

void merge(vector<pair<int, int>>& a, int x, int y, int z)
{
	if (x > y || y > z)
		return;

	int llen = y-x+1;
	int rlen = z-y;

	pair<int, int> l[llen];
	pair<int, int> r[rlen];

	for (int i = x; i <= y; i++)
		l[i-x] = a[i];

	for (int j = y+1; j <= z; j++)
		r[j-y-1] = a[j];

	int li = 0, ri = 0;
	for (int k = x; k <= z; k++) {
		if (li < llen && ri < rlen) {
			if (l[li].second <= r[ri].second)
				a[k] = l[li++];
			else
				a[k] = r[ri++];
		} else if (ri == rlen)
			a[k] = l[li++];
		else
			a[k] = r[ri++];
	}
}

void merge_sort(vector<pair<int, int>>& a, int n)
{
	for (int i = 1; i < n; i *= 2) {
		for (int l = 0; l < n-1; l += 2*i) {
			int m = l+i-1;
			int h = min(l+2*i-1, n-1);

			merge(a, l, m, h);
		}
	}
}

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

	int n, k, d;
	unordered_map<int, int> m;

	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> d;
		if (m.find(d) == m.end())
			m[d] = 1;
		else
			m[d]++;
	}

	vector<pair<int, int>> v;
	for (const auto& p : m)
		v.push_back(p);

	merge_sort(v, v.size());

	int nn = v.size();
	int c = 0;
	for (int i = 0; i < nn-k; i++)
		c += v[i].second;

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 12612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> vc;
    int num;
    for (int i = 0; i < n; i++)
    {
        cin >> num;
        vc.push_back(num);
    }
    sort(vc.begin(),vc.end(),greater<int>()); 
    float sum=0;
    for (int i = 0; i < n; i++)
    {
        if (i==n-1)
        {
            sum = sum+(vc[i]/pow(2,i));
            break;
        }
        sum = sum+(vc[i]/pow(2,i+1));
    }
    cout << sum << endl;
    
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: i32,
    }
    println!("{}", n * n * n);
}


Measured memory_bytes: 4352
//  Copyright © 2020 Kavish Lodha. All rights reserved.
#include <bits/stdc++.h>
using namespace std;
#define vll vector<long long>
#define mll map<long long,long long>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define pb push_back
#define prll pair<long long,long long>
typedef long long ll;
typedef long double ld;
#define rep(i,a,n)   for(ll i=a; i<n; i++)
#define rrep(i,a,n)  for(ll i=n-1; i>=a; i--)
typedef map<string,ll> msl;
#define mx 100001
#define mod 1000000007
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll extgcd(ll a,ll b,ll& x,ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll revrsno(ll n){
    ll k=0;
    vll z;
    while(n>0){
        z.pb(n%10);
        n/=10;
    }
    rep(i,0,z.size()) k=k*10+z[i];
    return k;
}
bool isPrime(ll n){
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
bool isPowerOfTwo(ll n) { 
   if(n==0) 
   return false; 
   return (ceil(log2(n)) == floor(log2(n))); 
}
ll powm(ll a,ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}
ll divide(ll a,ll b) {
	return (a % mod) * powm(b, mod - 2) % mod;
}
ll mul(ll a,ll b) {
	return ((a % mod) * (b % mod)) % mod;
}
 
ll add(ll a,ll b) {
	return (a % mod + b % mod) % mod;
}
ll Totfun(ll n){
    ll z=n;
    if(n%2==0){
        while(n%2==0){
            n/=2;
        }
        z/=2;
    }
    for(ll i=3;i<=sqrt(n);i+=2){
        if(isPrime(i)&&n%i==0){
          while(n%i==0){
            n/=i;
          }
        z-=z/i;  
        }
    }
    if(n>1){
        z-=z/n;
    }
    return z;
}
ll maxPrimeFactor(ll n) { 
    ll maxPrime=-1; 
    while(n%2==0){
        maxPrime=2; 
        n>>=1; 
    } 
    for (ll i=3;i<=sqrt(n);i+=2) { 
        while(n%i==0){ 
            maxPrime=i; 
            n=n/i; 
        } 
    } 
    if (n>2) maxPrime=n; 
    return maxPrime; 
} 
ll nCr(ll n,ll r){
    if(r>n||r<0) return 0;
    ll z=1;
    for(ll i=n-r+1;i<=n;i++){
        z*=i;
        z/=(i+r-n);
    }
    return z;
}
/*
vll a[mx];
ll l[mx],d[mx];
void dfs(ll x,ll y){
   l[x]=1; d[x]=y;
   for(ll i:a[x])
   if(!l[i])
   dfs(i,y+1);
}
void bfs(ll x){
    queue<ll> q;
    q.push(x);
    l[x]=1;
    d[x]=0;
    while(!q.empty()){
        ll cur=q.front();
        q.pop();
        for(ll i : a[cur]){
            if(1-l[i]){
                q.push(i);
                d[i]=d[cur]+1;
                l[i]=1;
            }
        }
    }
}
*/
 /*sort(a,a+n);
    ll d=1;
    vll z;
    for(ll i=1;i<n;i++){
    if(a[i]==a[i-1]){
        d++;
    }
    else{
            z.pb(d);
            d=1;
    }
    }
    z.pb(d);*/
int main(){
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
   cout.tie(NULL);
   ld r;
   cin>>r;
   r*=2;
   r*=3.1415;
   cout<<r;
   return 0;
}

Measured memory_bytes: 3824
n = int(input())
x = input().split()
count = 0
flg = 0
while flg == 0:
  for i in range(0, n):
    if int(x[i]) % 2 != 0:
      flg = 1
  
  if flg == 0:
    count += 1
    for i in range(0, n):
      x[i] = int(x[i]) / 2
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    int N, C, K;
    std::cin >> N >> C >> K;

    std::vector<int> T(N);
    for (int i = 0; i < N; i++) {
        std::cin >> T[i];
    }

    std::sort(T.begin(), T.end());
    int ans = N;
    int count = C-1;
    int t = T[0];
    for (int i = 1; i < N; i++) {
        if (T[i] - t <= K && count > 0) {
            ans--;
            count--;
        } else {
            count = C-1;
            t = T[i];
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int h,w;
string c[300];

int cost[301][301];
int dp[301][301];
int dfs(int x, int y)
{
    if(dp[x][y]>=0) return dp[x][y];
    if(x+y==2*h) return 0;

    int ret=123456789;
    if(x<h) ret=min(ret,dfs(x+1,y)+cost[x][y]);
    if(y<h) ret=min(ret,dfs(x,y+1)+cost[x][y]);

    return dp[x][y]=ret;
}

int main()
{
    cin >>h >>w;
    rep(i,h) cin >>c[i];

    int ans=0;
    rep(i,w-1)
    {
        memset(cost,0,sizeof(cost));
        for(int a=h-1; a>=0; --a)for(int b=h-1; b>=0; --b) cost[a][b]=cost[a+1][b+1]+(c[h-1-a][i]==c[h-1-b][i+1]);
        memset(dp,-1,sizeof(dp));
        ans+=dfs(0,0);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
#include <iterator>     // std::back_inserter
const double PI = acos(-1);
using namespace std;
using ll =long long;
#define rep(i,n)for(ll i=0;i<(n);i++)
const int mod = 1000000007;
const ll inf = 1e18+1;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
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;
}
//小文字=大文字+32
int main() {
	bool x;
	cin >> x;
	if (x) {
		cout << 0;

	}
	else {
		cout << 1;
	}
}


Measured memory_bytes: 3620
//bismillahir rahmanir rahim
#include<bits/stdc++.h>
using namespace std;

int main ()
{
    int a,b,c;
    string s;
    cin >> s;


    if (s=="Sunny")
    {
        cout <<"Cloudy";
    }

    else  if (s=="Rainy")
    {
        cout <<"Sunny";
    }

    else   if (s=="Cloudy")
    {
        cout <<"Rainy";
    }


}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define MAX(a,b) ((a)>(b)?(a):(b))

typedef long long int int64;

void run(void){
  int n;
  int64 k;
  scanf("%d%lld",&n,&k);
  int cnt[41]={0};
  int64 ans=0;
  int i;
  for(i=0;i<n;i++){
    int64 a;
    scanf("%lld",&a);
    ans+=a^k;
    for(int j=0;a>0;j++,a>>=1){
      cnt[j]+=a&1;
    }
  }
  for(i=40;i>=0;i--){
    if(((k>>i)&1)==0) continue;
    int64 local=0;
    int j;
    for(j=i+1;j<=40;j++){
      local+=(1LL<<j)*((k>>j)&1?(n-cnt[j]):cnt[j]);
    }
    local+=(1LL<<i)*cnt[i];
    for(j=i-1;j>=0;j--){
      local+=(1LL<<j)*MAX(cnt[j],n-cnt[j]);
    }
    ans=MAX(ans,local);
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

typedef long long i64;
typedef vector<i64> vx;
typedef vector<vx> vvx;

i64 numways_makeave(const vx &cards, i64 ave) {
    int n=cards.size();
    i64 x=ave;
    vx y(n);
    int i;
    for (i=0; i<n; i++) {
        y[i] = cards[i] - ave;
        if (cards[i] > x)
            x = cards[i];
    }

    vvx dp(n+1, vx(2*n*x+1));
    int j, t;
    dp[0][n*x] = 1;
    for (j=1; j<=n; j++)
        for (t=0; t<=2*n*x; t++)
            if (t-y[j-1]>=0 && t-y[j-1]<=2*n*x) {
                dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j-1]];
            } else {
                dp[j][t] = dp[j-1][t];
            }

    return dp[n][n*x] - 1LL;
}

int main(void) {
    int n;
    i64 a;
    cin >> n >> a;

    vx x(n);
    int i;
    for (i=0; i<n; i++) {
        scanf("%lld", &x[i]);
    }

    cout << numways_makeave(x, a) << endl;
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n;
cin >> n;
int ans = 0;

rep(i,n){
    int a;
    cin >> a;
    ans += a - 1;
}

cout << ans << endl;

return 0;
}

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

using namespace std;

int main(){
  int N, tmp;
  cin >> N;
  int sum = 0;
  int ans = 0;
  vector<int> P;
  for (int i=0; i<N; i++){
    cin >> tmp;
    sum += tmp;
    P.push_back(tmp);
  }
  double opt = (double)sum / (double)N;
  int opt_int = (abs(opt - floor(opt)) < abs(opt - ceil(opt)) ? floor(opt) : ceil(opt));
  for (int i=0; i<N; i++){
    ans += pow(abs(opt_int - P[i]), 2);
  }
  cout << ans << endl;
  return 0;
  
}

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

using namespace std;

using ll = long long;

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (i & 1) {
            cnt++;
        }
    }
    double res = 1. * cnt / n;
    printf("%.7f", res);
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  vll a(n);
  ll gu=0,ki=0;
  rep(i,n){
    if(s[i]=='R'){
      if(i%2) ki++;
      else gu++;
    }else{
      if(i%2) swap(ki,gu);
      a[i-1]+=ki;
      a[i]+=gu;
      ki=gu=0;
    }
  }
  if((n-1)%2) swap(ki,gu);
  a[n-2]+=ki;
  a[n-1]+=gu;
  
  
  gu=ki=0;
  rrep(i,n){
    if(s[i]=='L'){
      if(i%2) ki++;
      else gu++;
    }else{
      if(i%2) swap(ki,gu);
      a[i+1]+=ki;
      a[i]+=gu;
      ki=gu=0;
    }
  }
  swap(ki,gu);
  a[1]+=ki;
  a[0]+=gu;
  
  rep(i,n) cout<<a[i]<<" ";
  cout<<endl;
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


vint c;
vpair e[100005];

void dfs(int v, int color) {
    c[v] = color;
    for (auto u : e[v]) {
        if (c[u.fi] != -1) continue;
        color = 1-c[v];
        if (u.se & 1) {
            dfs(u.fi, color);
        }
        else {
            dfs(u.fi, 1-color);
        }
    }
}


int main() {
    int n;
    cin >> n;
    c.resize(n, -1);
    rep(i, n-1) {
        int u, v, w;
        cin >> u >> v >> w;
        --u;
        --v;
        e[u].emplace_back(v, w);
        e[v].emplace_back(u, w);
    }
    dfs(0, 0);

    rep(i, n) cout << c[i] << endl;
    return 0;
}

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

int main()
{
	int card[3][3];
	rep(i, 3) rep(j, 3) cin >> card[i][j];

	int n;
	cin >> n;

	bool ans[3][3] = { false };
	int b;
	rep(i, n)
	{
		cin >> b;
		rep(i, 3) rep(j, 3) if (b == card[i][j]) ans[i][j] = true;
	}

	bool bingo = false;
	rep(i, 3)
	{
		if (ans[i][0] && ans[i][1] && ans[i][2] || ans[0][i] && ans[1][i] && ans[2][i])
			bingo = true;
	}

	if (ans[1][1])
	{
		if (ans[0][0] && ans[2][2] || ans[0][2] && ans[2][0])
			bingo = true;
	}

	cout << ((bingo) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
S = input()
N = len(S)
output = 0

if N%2==0:
    S1 = S[:(N//2)]
    S2 = S[(N//2):]
else:
    S1 = S[:(N//2)]
    S2 = S[(N//2+1):]

for i in range(len(S1)):
    A = S1[i]
    B = S2[len(S1)-i-1]
    if A!=B:
        output += 1
print(output)

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


int main() {
  vector<int> vec(10000);
  for(int i=0;i<10000;i++){
    cin >> vec.at(i);
    if(vec.at(i)==0){
      break;
    }
    cout << "Case "<< i+1 << ": " << vec.at(i)<<endl;
    
  }
}


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

string a,b="CF";
int al,bl;

int main(){
    getline(cin,a);
    al = a.length();
    for(int i = 0;i < al;i++)
        if(a[i] == b[bl]){
            bl++;
            if(bl == 2)
                break;
        }
    if(bl == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }


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

    int N; cin >> N;
    ll k = 1LL; rep(i,N) k *= 2LL;
    deque<ll>  A;
    rep(i,k) { ll a; cin >> a; A.pub(a); }
    while(A.size() > 1){
        ll p = A.front(); A.pop_front();
        ll q = A.front(); A.pop_front();
        if(p == q) A.pub(p);
        else A.pub(max(p-q, q-p));
    }
    cout << A[0] << endl;
    return 0;
}

Measured memory_bytes: 2432
/* ex6_2
	kanon */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LIMIT 100

int main(void)
{
    //変数を宣言
    char str[LIMIT + 1];
    int length;

    //変数に値を入力する
    scanf("%s", &str);

    //文字列の長さを求めて２を引く
    length = strlen(str) - 2;

    //答えを出力
    printf("%c%d%c\n", str[0], length, str[length + 1]);

    return 0;
}


Measured memory_bytes: 128
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N, H, W;

  sc.scan(N, H, W);

  writeln(((N - H) + 1) * ((N - W) + 1));
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 51;

template<typename T> T inf;
template<> constexpr int inf<int> = 1<<30;
template<> constexpr ll inf<ll> = 1LL<<60;
template<> constexpr double inf<double> = 1e30;

using Cost = int;
using Node = int;
struct Edge{
  Cost cost; Node to;
  Edge(Cost cost,Node to)
    :cost(cost),to(to){}
};
using Graph = vector<vector<Edge>>;

vector<Cost> dijkstra
(Graph &graph, Node start, Cost zero = 0LL)
{
  using Pcn = pair<Cost,Node>;
  priority_queue<Pcn,vector<Pcn>,greater<Pcn>> que;
  vector<Cost> dist(graph.size(),inf<Cost>);
  dist[start] = zero;
  que.push(Pcn(zero,start));
  while(!que.empty()){
    Pcn p = que.top(); que.pop();
    Node v = p.second; //行き先
    if(dist[v] < p.first)  continue;
    for(Edge e : graph[v]){
      if(dist[v]+e.cost < dist[e.to]){
        dist[e.to] = dist[v]+e.cost;
        que.push(Pcn(dist[e.to],e.to));
      }
    }
  }
  return dist;
}

string s[MAX_N];

int main(){
  int H,W; cin >> H >> W;
  rep(i,H) cin >> s[i];
  int N = H*W;
  Graph graph(N);
  int cnt = -1;
  rep(i,H) rep(j,W){
    if(s[i][j]=='.') cnt++;
    else continue;
    for(int k = -1; k <= 1;k += 2) if(i+k>=0 && i+k<H) if(s[i+k][j]=='.'){
      graph[W*i+j].pb(Edge(1,W*(i+k)+j));
      // cout << W*i+j << " to " << W*(i+k)+j << endl;
    }
    for(int k = -1; k <= 1;k += 2) if(j+k>=0 && j+k<W) if(s[i][j+k]=='.'){
      graph[W*i+j].pb(Edge(1,W*i+j+k));
      // cout << W*i+j << " to " << W*(i)+j+k << endl;
    }
  }
  auto dist = move(dijkstra(graph,0));
  rep(i,H) rep(j,W){
    // cout << i << " " << j << " -> " << graph[W*i+j].size() << endl;
  }
  if(dist[N-1]==inf<int>) cout << "-1" << endl;
  else cout << cnt - dist[N-1] << endl;
  return 0;
}

Measured memory_bytes: 384
N, X = map(int,input().split())
x = list(map(int,input().split()))

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

subs = []
for i in range(N):
  subs.append(abs(x[i] - X))
ans = subs[0]
for sub in subs:
  if(sub%ans != 0):
    ans = gcd(ans, sub)
print(ans)

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

int main() {
    int N, K;
    std::cin >> N >> K;

    int sum_A = 0;
    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
        sum_A += A[i];
    }

    std::priority_queue<int> que;
    for (int i = 1; i * i <= sum_A; i++) {
        if (sum_A % i) continue;

        que.push(i);
        if (sum_A / i != i) que.push(sum_A / i);
    }

    while (!que.empty()) {
        int x = que.top();
        que.pop();

        std::vector<long long> v(N), w(N);
        for (int i = 0; i < N; i++) {
            v[i] = A[i] % x;
            w[i] = x - A[i] % x;
        }

        std::sort(v.begin(), v.end());
        std::sort(w.begin(), w.end(), std::greater<int>());

        for (int i = 0; i < N - 1; i++) {
            v[i + 1] += v[i];
            w[i + 1] += w[i];
        }

        for (int i = 0; i < N; i++) {
            if (v[i] <= K && v[i] == w[N - 1] - w[i]) {
                std::cout << x << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int a,b;
    cin>>a>>b;
    repi(i,1,1500){
        if(i*8/100==a&&i*10/100==b){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
}

Measured memory_bytes: 3652
import java.math.BigDecimal;
        import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        BigDecimal x = BigDecimal.valueOf(1);
        for (int i=1; i<=N; i++) {
            x = x.multiply(BigDecimal.valueOf(i)).remainder(BigDecimal.valueOf(1000000007));
        }
        System.out.println(x);
    }
}


Measured memory_bytes: 60328
// 27
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef LOCAL
#define debug(e) cerr << "\033[48;5;196m\033[38;5;15m" << e << "\033[0m";
#else
#define debug(e)
#endif
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << " " << p.se << ")";
}
// 8
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, (int)v.size()) o << setw(7) << left << v[i];
  return o << endl;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 3

int sign(li x) { return x < 0 ? -1 : x > 0; }

//          a / b
li floor(li a, li b) {
  if (sign(a) != sign(b) && a % b)
    return a / b - 1;
  else
    return a / b;
}

//         a / b
li ceil(li a, li b) {
  if (sign(a) == sign(b) && a % b)
    return a / b + 1;
  else
    return a / b;
}

void _main(int tc) {
  li a, b, x;
  cin >> a >> b >> x;
  li leftLimit = x * ceil(a, x);
  li rightLimit = x * floor(b, x);
  // L + x * Z = R --> Z = (R - L) / x
  // Since L is multiple of x and R is also, we can add x to L, Z times
  // until we reach R.
  // therefore the distance (R - L) between multiples of x is always divisible
  // by x
  cout << 1 + (rightLimit - leftLimit) / x << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;


typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;

#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)

int main() {
    ll a ,b, sum , sub, mul;
    cin >> a >> b;
    sum = a + b;
    sub = a - b;
    mul = a * b;
    cout << max( sum , max(sub,mul))<< endl;

    return 0;
}
/*
         ,--"""",--.__,---[],-------._
       ,"   __,'            \         \--""""""==;-
     ," _,-"  "/---.___     \       ___\   ,-'',"
    /,-'      / ;. ,.--'-.__\  _,-"" ,| `,'   /
   /``""""-._/,-|:\       []\,' ```-/:;-. `. /
             `  ;:::      ||       /:,;  `-.\
                =.,'__,---||-.____',.=
                =(:\_     ||__    ):)=
               ,"::::`----||::`--':::"._
             ,':::::::::::||::::::::::::'.
    .__     ;:::.-.:::::__||___:::::.-.:::\     __,
       """-;:::( O )::::>_|| _<::::( O )::::-"""
   =======;:::::`-`:::::::||':::::::`-`:::::\=======
    ,--"";:::_____________||______________::::""----.          , ,
         ; ::`._(    |    |||     |   )_,'::::\_,,,,,,,,,,____/,'_,
       ,;    :::`--._|____[]|_____|_.-'::::::::::::::::::::::::);_
      ;/ /      :::::::::,||,:::::::::::::::::::::::::::::::::::/
     /; ``''''----------/,'/,__,,,,,____:::::::::::::::::::::,"
     ;/                :);/|_;| ,--.. . ```-.:::::::::::::_,"
    /;                :::):__,'//""\\. ,--.. \:::,:::::_,"
   ;/              :::::/ . . . . . . //""\\. \::":__,"
   ;/          :::::::,' . . . . . . . . . . .:`::\
   ';      :::::::__,'. ,--.. . .,--. . . . . .:`::`
   ';   __,..--'''-. . //""\\. .//""\\ . ,--.. :`:::`
   ;    /  \\ .//""\\ . . . . . . . . . //""\\. :`::`
   ;   /       . . . . . . . . . . . . . . . . .:`::`
   ;   (          . . . . . . . . . . . . . . . ;:::`
   ,:  ;,            . . . . . . . . . . . . . ;':::`
   ,:  ;,             . . . . . . . . . . . . .;`:::
   ,:   ;,             . . . . . . . . . . . . ;`::;`
    ,:  ;             . . . . . . . . . . . . ;':::;`
     :   ;             . . . . . . . . . . . ,':::;
      :   '.          . . . . . . . .. . . .,':::;`
       :    `.       . . . . . . . . . . . ;::::;`
        '.    `-.   . . . . . . . . . . ,-'::::;
          `:_    ``--..___________..--'':::::;'`
             `._::,.:,.:,:_ctr_:,:,.::,.:_;'`
________________`"\/"\/\/'""""`\/"\/""\/"____________________________

*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;
using static System.Math;

class Program
{
    static int N;
    static int M;
    static int C;
    static int[] B;

    static void Main()
    {
        int[] inp = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = inp[0];
        M = inp[1];
        C = inp[2];
        B = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] A;
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long t = C;
            for (int j = 0; j < M; j++)
                t += A[j] * B[j];
            ans += t > 0 ? 1 : 0;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11348
#include <cstdio>
      
int main(){
int a,b;
scanf("%d%d",&a,&b);
if(a>b)
{printf("%s\n","a > b");}
else if(a==b)
{printf("%s\n","a == b");}
else if(a<b)
{printf("%s\n","a < b");}
return 0;
}

Measured memory_bytes: 1012
#include<cstdio>
#include<algorithm>
using namespace std;
int jcnt[1001][1001]={0},ocnt[1001][1001]={0},icnt[1001][1001]={0};
int main(void)
{
	int m,n,k,a,b,c,d,i,j,jsum,isum,osum;
	char s[1001][1001];
	scanf("%d %d %d",&m,&n,&k);
	for(i=0;i<m;i++){
		scanf("%s",s[i]);
	}
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			jcnt[i][j]=0;
			ocnt[i][j]=0;
			icnt[i][j]=0;
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			if(j!=0){
				jcnt[i+1][j+1]=jcnt[i+1][j];
				icnt[i+1][j+1]=icnt[i+1][j];
				ocnt[i+1][j+1]=ocnt[i+1][j];
			}
			if(s[i][j]=='J'){
				jcnt[i+1][j+1]++;
			}
			if(s[i][j]=='I'){
				icnt[i+1][j+1]++;
			}
			if(s[i][j]=='O'){
				ocnt[i+1][j+1]++;
			}
		}
	}
	for(i=0;i<k;i++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		jsum=0;
		osum=0;
		isum=0;
		for(j=a;j<=c;j++){
			jsum+=jcnt[j][d]-jcnt[j][b-1];
			osum+=ocnt[j][d]-ocnt[j][b-1];
			isum+=icnt[j][d]-icnt[j][b-1];
		}
		printf("%d %d %d\n",jsum,osum,isum);
	}
	return 0;
}


Measured memory_bytes: 15248