akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 300003;
const ll so = 998244353;
class comb{
	vector<ll> f,fr;
	ll MOD;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % so;
		return y;
	}
	void init(ll n,ll mod){
		MOD = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
			fr[i] = calc(f[i],mod-2,mod);
		}
	}
	ll nCr(ll n,ll r){
		return f[n] * fr[r] % MOD * fr[n-r] % MOD;
	}
};

ll n,a,b,k,ans=0;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>a>>b>>k;
	if(k==0){
		cout<<1<<endl;
		return 0;
	}
	comb c;
	c.init(n,so);
	FOR(i,0,n+1){//A i ko
		ll j = (k-i*a);
		if(j%b!=0)continue;
		if(j<0||j>n*b)continue;
		j = j / b;
		ans += c.nCr(n,i) * c.nCr(n,j) % so;
		ans = ans % so;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
input_line = []
while line = gets
  input_line << line.chomp.split(" ")
end

input_line.each do |line|

  a = line[0].to_i
  b = line[2].to_i
  op = line[1].to_s

  if op == "?"
    break
  else
    case op
    when "+" then
      puts a + b
    when "-" then
      puts a - b
    when "*" then
      puts a * b
    when "/" then
      puts a / b
    end
  end
end

Measured memory_bytes: 8632
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main() 
{ 
	SPEED
    int n, d;
    cin >> n >> d;
    cout << n/(2*d+1) + (n%(2*d+1)!=0) << '\n';
    return 0;      
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,1,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)
#define pb push_back

template<typename T> 
void chmax(T &a,T b){ a = max(a, b);};
template<typename T> 
void chmin(T &a,T b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
string s;

void solve(){
	ll ans=0;
	ll c=0;
	rep(i,s.size()){
		if(s[i]=='W'){
			ans+=(i-c);
			c++;
		}
	}
	cout<<ans<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>s;
		solve();
	return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;

  vector<int> c(n), s(n), f(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i] >> s[i] >> f[i];
  }

  for (int i = 0; i < n; i++) {
    int t = 0;
    for (int j = i; j < n - 1; j++) {
      if (t >= s[j]) {
        t = (t - s[j] + f[j] - 1) / f[j] * f[j] + s[j];
      } else {
        t = s[j];
      }
      t += c[j];
    }
    cout << t << endl;
  }

  return 0;
}

Measured memory_bytes: 256
def main():
    n, a, b, *x = map(int, open(0).read().split())
    ans = 0
    for i, j in zip(x, x[1:]):
        if a * (j - i) > b:
            ans += b
        else:
            ans += a * (j - i)

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

#define fi first
#define sc second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define up(x, v) upper_bound(all(x), v)
#define low(x, v) lower_bound(all(x), v)
#define bin(x, v) binary_search(all(x), v)
#define FOR(k, a, b) for(int k = (a); k < (b); ++k)
#define ROF(k, a, b) for(int k = (a); k > (b); --k)
#define pq priority_queue

typedef long long ll;
typedef unsigned long long ull;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {

	int n, k;

	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);

	cin >> n >> k;

	vi p(n);

	vector<double> preffix(n + 1);

	preffix[0] = 0;

	FOR(i, 0, n) {

		cin >> p[i];
		preffix[i + 1] = preffix[i] + (p[i] + 1.0) / 2.0;
	}

	double E = 0;

	FOR(i, k - 1, n)
		E = max(E, preffix[i + 1] - preffix[i - k + 1]);

	cout << fixed << setprecision(12) << E << '\n';

    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	int k;
	cin>>a>>b>>c>>k;
	if(max(a,max(b,c))==a){
		for(int i=0;i<k;i++){
			a=a*2;
		}
	}
	if(max(a,max(b,c))==b){
		for(int i=0;i<k;i++){
			b=b*2;
		}
	}
	if(max(a,max(b,c))==c){
		for(int i=0;i<k;i++){
			c=c*2;
		}
	}
	cout<<a+b+c;
}

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

using std::cout;
using std::cin;
using std::endl;
using std::vector;

int prime (int num) {
    int max = sqrt(num);
    for (int i = 3; i <= max; i += 2) {
        if (num % i == 0) {
            return 0;
        }
    }
    return 1;
}

int main(void) {
    int a;
    int d;
    int n;
    int target;
    int kosuu;

    vector<int> v(1000001, 0);
    v[2] = 1;


    for (int i = 3; i < 1000000; i += 2) {
        v[i] = prime(i);
    }

    while (1) {
        cin >> a >> d >> n; 
        if (a == 0 && d == 0 && n == 0) {
            break; 
        }
        target = a - d;
        kosuu = 0;
        while (1) {
            if (kosuu == n) {
                break;
            }
            target += d;
            if (v[target] == 1) {
                kosuu++;
            }
        }
        cout << target << endl;
    }
    return 0;
}

Measured memory_bytes: 6608
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string s; int n, r, c, h[20007], l[20007], a[10007];
int main() {
	cin >> s; n = s.size();
	for(int i = 0; i < n; i++) {
		switch(s[i]) {
			case 47: h[i + 1] = h[i] + 1; break;
			case 95: h[i + 1] = h[i]; break;
			case 92: h[i + 1] = h[i] - 1; break;
		}
	}
	for(int i = 0; i <= n; i++) {
		int lc = h[i], rc = h[i];
		for(int j = 0; j < i; j++) lc = max(lc, h[j]);
		for(int j = i + 1; j <= n; j++) rc = max(rc, h[j]);
		l[i] = min(lc, rc);
	}
	int ret = 0;
	for(int i = 0; i < n; i++) ret += (l[i + 1] - h[i + 1]) + (l[i] - h[i]);
	cout << ret / 2 << endl;
	for(int i = 0; i <= n; i++) {
		if(l[i] == h[i] && r) a[c++] = r / 2, r = 0;
		if(i != n) r += (l[i + 1] - h[i + 1]) + (l[i] - h[i]);
	}
	cout << c;
	for(int i = 0; i < c; i++) cout << ' ' << a[i];
	cout << endl;
}

Measured memory_bytes: 3396
n, d = list(map(int, input().rstrip().split()))
a = []
for i in range(0, n):
    b = list(map(int, input().rstrip().split()))
    a.append(b)


def nijou(a,n):
    korelist = 0
    for i in range(0, n-1):
        for j in range(i+1, n ):
            c = [x - y for (x, y) in zip(a[i], a[j])]
            kore = 0
            for u in c:
                kore += u**2
            kore1 = kore ** (1/2)
            if kore1 - int(kore1) == 0:
                korelist += 1
    return print(korelist)

nijou(a,n)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, X;
	int L;
	int c = 0, con = 1;
	
	cin>>N>>X;
	
	for(int i = 0; i < N; i++){
		cin>>L;
		c = c + L;
		if(c <= X) con++;
	}
	
	cout<<con<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

int main(void){ 
    int n;
    cin >> n;
    set<string> words;
    int flag = 0;
    string w_now, w_prev; // 場所注意しないと上書き、、
    for(int i=0; i<n; i++){
        string w;
        cin >> w;
        if(i!=0) w_prev = w_now;
        w_now = w;
        if(words.find(w_now) != words.end()){
            flag = 1;
        }
        else{
            words.insert(w_now);
        }
        if(i > 0 && w_now[0] != w_prev[w_prev.length() - 1]){
            flag = 1;
        }
    }
    if(flag == 1) cout << "No";
    else cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
n, k = gets.chomp.split(" ").map(&:to_i)
count = 0
for i in (k+1)..n
  x, y = n.divmod(i)
  if k == 0
    count += (x * (i - k))
    count += [0, y - k].max
  else
    count += (x * (i - k))
    count += [0, y - k + 1].max
  end
end

p count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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 long long INF = 1LL << 60;

//Knapsack1はWが小さく、vが大きい
//　→ wに注目してDP

vector<vector<ll>> dp(200, vector<ll>(110000, 0));

int main(){
  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  for(int i = 0; i < N; i++){
    cin >> w.at(i) >> v.at(i);
  }

  for(int i = 0; i <= W; i++){
    if(w.at(0) <= i) dp.at(0).at(i) = v.at(0);
  }

  for(int i = 0; i <= W; i++){
    for(int j = 1; j < N; j++){
      chmax(dp.at(j).at(i), dp.at(j-1).at(i));
      if(i - w.at(j) >= 0) chmax(dp.at(j).at(i), dp.at(j-1).at(i - w.at(j)) + v.at(j));
    }
  }

  cout << dp.at(N-1).at(W) << endl;


}

Measured memory_bytes: 173056
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using ll =long long;

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int n,m;
  cin>>n>>m;
  int lr[m][2];
  for(int i =0; i<m; i++){
    for(int j=0; j<2 ;j++){
      cin>>lr[i][j];
    }
  }
  int left=0;
  int right=100001;
  for(int i=0; i<m;i++){
    left = max(left,lr[i][0]);
    right = min(right, lr[i][1]);
  }
  if(right<left){
    cout<<0<<endl;
  }
  else{
    cout<<right-left+1<<endl;
  }
}

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

#define ll long long
using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  constexpr char nl = '\n';
  const int mod = 1e9 + 7;

  int N;
  cin >> N;
  vector<double> p(N + 1, 0.0);
  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0.0));
  // dp[i][j]: j coins head after i-th toss
  for (int i = 1; i <= N; ++i) {
    cin >> p[i];
  }
  dp[1][0] = 1 - p[1];
  dp[1][1] = p[1];
  for (int i = 2; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
    }
  }

  double ans = 0.0;
  for (int i = N / 2 + 1; i <= N; ++i) {
    ans += dp[N][i];
  }
  cout << setprecision(10) << ans << nl;

  return 0;
}


Measured memory_bytes: 70784
n = int(input())
s = input()
countwhite = [0] * (n+1)
countblack = [0] * (n+1)

#whitecount
cnt = 0
for i in range(n):
    if s[i] == "#":
        cnt += 1
    countwhite[i+1] = cnt

cnt = 0
for i in range(n-1, -1, -1):
    if s[i] == ".":
        cnt += 1
    countblack[i] = cnt

#print(countwhite)
#print(countblack)
res = 999999999999999
for i in range(n+1):
    res = min(res, countblack[i] + countwhite[i])
print(res)

Measured memory_bytes: 44000
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<queue>
#include<iostream>
#include <iomanip>
#include<string>
#include<math.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int m, n, i, j, k, a, b, d;
int dis[1010][1010],e[1010], r[1010];
void init()
{
	memset(dis, inf, sizeof(dis));
	for (i = 0; i < 1010; i++)
		dis[i][i] = 0;
}
void add(int a, int b, int c)
{
	dis[a][b] = min(dis[a][b], c);
}
void floyd()
{
	for (k = 0; k < n; k++)
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				if (dis[i][j] > dis[i][k] + dis[k][j])
					dis[i][j] = dis[i][k] + dis[k][j];
}
int main()
{
	int x, t, u, v;;
	scanf("%d", &n);
	init();
	for (i = 0; i < n; i++)
	{
		scanf("%d %d", &x, &t);
		for (j = 0; j < t; j++)
		{
			scanf("%d %d", &u, &v);
			add(i, u, v);
		}
	}
	floyd();
	for(i=0;i<n;i++)
		printf("%d %d\n",i, dis[0][i]);
	return 0;
}


Measured memory_bytes: 7204
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define endl        "\n"
#define si(a)       scanf("%d",&a)
#define si2(a,b)    scanf("%d%d",&a,&b)
#define si3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define sl(a)       scanf("%lld",&a)
#define sl2(a,b)    scanf("%lld%lld",&a,&b)
#define sl3(a,b,c)  scanf("%lld%lld%lld",&a,&b,&c)
#define pb          push_back
#define mk          make_pair
#define loop(n)     for(int i=0; i<n; i++)
#define FOR(a,b)    for(int i=a; i<=b; i++)
#define sz          size()
#define pY          printf("YES")
#define pN          printf("NO")
#define py          printf("Yes")
#define pn          printf("No")
#define mem(a,val)  memset(a, val, sizeof(a))



string s,t;
int main()
{
   cin>>s>>t;
   ll mn=INT_MAX, cnt=0;
   for(int i=0; i<=s.sz-t.sz; i++)
   {
       cnt=0;

       for(int j=0; j<t.sz; j++)
       {
           if(s[i+j]!=t[j])
            cnt++;
       }
      // cout<<i<<" "<<cnt<<endl;
       mn=min(mn, cnt);
   }
   cout<<mn;
}







Measured memory_bytes: 3608
#include <stdio.h>

int main(){
  int a,b,ai,am,as,ae,bi,bm,bs,be;

  scanf("%d %d %d %d\n%d %d %d %d",&ai,&am,&as,&ae,&bi,&bm,&bs,&be);
  a = ai+am+as+ae;
  b = bi+bm+bs+be;
  printf("%d\n",a>b?a:b);
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in read(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    N = readi()
    a = reads()
    e = arr(N + 1)
    w = arr(N + 1)
    for i in range(N):
        e[i + 1] = e[i] + (1 if a[i] == "E" else 0)
        w[i + 1] = w[i] + (1 if a[i] == "W" else 0)

    dbg(e=e)
    dbg(w=w)

    ans = 10 ** 10
    for i in range(N):
        ans = min(ans, w[i] + e[N] - e[i + 1])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 34212
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vi wei;
ll n,k;
bool check(ll mid){
  ll cnt=1;
  ll now=0;
  for(int i=0;i<n;i++){
    if(wei[i] > mid)return false;
    if(now+wei[i] > mid){
      now=wei[i];
      cnt++;
    }else{
      now+=wei[i];
    }
  }
  if(cnt<=k)return true;
  else return false;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll le=0,ri=1e18;
  cin>>n>>k;
  wei.resize(n);
  for(auto &a:wei)cin>>a;
  while(ri-le>1){
    ll mid=(le+ri)/2;
    if(check(mid))ri=mid;
    else le=mid;
  }
  cout<<ri<<endl;
  return 0;
}



Measured memory_bytes: 3548
N,K = map(int, input().split())
P = [int(p) for p in input().split()]

for i in range(N):
    P[i] = (P[i]+1)/2

num = 0
for i in range(K):
    num += P[i]
ans = num
for i in range(K, N):
    num += P[i]-P[i-K]
    ans = max(ans, num)
print(ans)

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

int main(){
  int N;
  cin >>N;
  int B[N-1];
  for(int i=0;i<N-1;i++)
    cin >>B[i];
  int A[N];

  A[0]=B[0];
  A[N-1]=B[N-2];
  int count=A[0]+A[N-1];
  for(int i=1;i<N-1;i++){
    A[i]=min(B[i-1],B[i]);
      count+=A[i];


  }
    
  cout <<count<<endl;


  return 0;
}


Measured memory_bytes: 256
using namespace std;

#include <cstdio>
#include <cstdint>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

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

    string  N;
    int     n = 0;
    cin >> N;
    int     cnt = 0;
    string  ans;
    for(n = 0; n < N.size(); n++){
        if(N.substr(n,1).compare("7") != 0){
            cnt++;
        }
    }
    if(cnt == N.size()){
        ans = "No";
    }else{
        ans = "Yes";
    }


    cout << ans << "\n";
    return 0;
    
}


Measured memory_bytes: 3656
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();
		long[] a = new long[n + 1];
		long gcd = 0;
		long lcm = 1;
		for(int i = 0 ; i < n ; i++) {
			a[i] = sc.nextLong() / 2;
			gcd = gcd(lcm , a[i]);
			lcm = lcm * a[i] / gcd;
			if(lcm > m) {
				System.out.println(0);
				return;
			}
		}
		for(int i = 0 ; i < n ; i++) {
			if((lcm / a[i]) % 2 == 0) {
				System.out.println(0);
				return;
			}
		}

		sc.close();
		System.out.println((m / lcm + 1 ) / 2);

	}
	public static long gcd(long num1,long num2) {
        if(num2 == 0) return num1;
        else return gcd(num2 , num1 % num2 );
 }
}



Measured memory_bytes: 59832
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi; 
typedef vector<ll> vll;
 
#define rep(i,a,b) for (int i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
 
#define all(x) begin(x), end(x)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);

void solve(){
	char c;
	cin>> c;
	cout<< (char)((int)c + 1);
}
 
int main()
{
	fast;
	int t = 1;
	//cin>> t;
	while(t--){  
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args)throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = in.readLine().split(" ");
    int[] a = new int[n];
    int[] b = new int[n];
    int[] c = new int[n-1];
    int sum = 0;
    
    for(int i=0; i<n; i++) {
      a[i] = Integer.parseInt(str[i]);
    }
    str = in.readLine().split(" ");
    for(int i=0; i<n; i++) {
      b[i] = Integer.parseInt(str[i]);
      sum += b[i];
    }
    str = in.readLine().split(" ");
    for(int i=0; i<n-1; i++) {
      c[i] = Integer.parseInt(str[i]);
    }
    
    for(int i=0; i<n-1; i++) {
        if(a[i]+1==a[i+1]){
          sum += c[a[i]-1];
      }
    }
    
    System.out.println(sum);
  }
}

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

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	vector<int>nums(4);
	while (1) {
		vector<int>vs(3);
		cin >> vs[0] >> vs[1] >> vs[2];
		sort(vs.begin(), vs.end());
		if (vs[0] + vs[1] <= vs[2]) {
			break;
		}
		else {
			int l = vs[0] * vs[0] + vs[1] * vs[1];
			int r = vs[2] * vs[2];
			if (l < r) {
				nums[3]++;
			}
			else if (l == r) {
				nums[1]++;
			}
			else {
				nums[2]++;
			}
			nums[0]++;
		}

	}
	cout << nums[0] << " " << nums[1] << " " << nums[2] << " " << nums[3] << endl;
	return 0;
}

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

using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  // int get = (n - (n % k)) / k;
  if (n % k == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String[] line = sc.nextLine().split(",");
			int num = Integer.parseInt(line[0]);
			double weight = Double.parseDouble(line[1]);
			double height = Double.parseDouble(line[2]);
			double bmi = weight / (height*height);
			if(bmi >= 25){
				System.out.println(num);
			}
		}
	}
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if (a==b ) {
		cout << "Draw" << endl;
	}
	else if(a==1){
		cout << "Alice" << endl;
	}
	else if(b==1){
		cout << "Bob" << endl;
	}
	else if (a>b){
		cout << "Alice" << endl;
	}
	else if (a<b){
		cout << "Bob" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] oddList = new int[100001];
    int[] evenList = new int[100001];
    for (int i =1; i<n+1; i++) {
      int v = sc.nextInt();
      if (i % 2 ==1) oddList[v]++;
      if (i % 2 ==0) evenList[v]++;
    }
    int maxOdd =0, maxEven =0, secondmaxOdd =0, secondmaxEven =0, countOdd =0, countEven =0;
    for (int i =1; i<100001; i++) {
      maxOdd = Math.max(oddList[i],maxOdd); 
      maxEven = Math.max(evenList[i],maxEven);
    }

    int oddnum =0, evennum =0;
    for (int i =1; i<100001; i++) {
      if (oddList[i] == maxOdd) {
        oddnum = i;
        countOdd++;
      }
      if (evenList[i] == maxEven) {
        evennum = i; 
        countEven++;
      }
    }  
    for (int i =1; i<100001; i++) {
      if (oddList[i] != maxOdd) {
        secondmaxOdd = Math.max(oddList[i], secondmaxOdd);
      }
      if (evenList[i] != maxEven) {
        secondmaxEven = Math.max(evenList[i], secondmaxEven);
      }
    }   
    if (countOdd >= 2) secondmaxOdd = maxOdd;
    if (countEven >= 2) secondmaxEven = maxEven;
    
    for (int i =1; i<100001; i++) {
      if (oddList[i] == maxOdd) oddnum = i;
      if (evenList[i] == maxEven) evennum = i; 
    }


    if (oddnum == evennum) {
      if(maxOdd > maxEven) {
        maxEven = secondmaxEven;
      } else if (maxOdd < maxEven) {
        maxOdd = secondmaxOdd;
      } else {
        maxEven = Math.max(secondmaxOdd,secondmaxEven);
      } 
    }
    int ans = n - maxOdd - maxEven;
    System.out.println(ans);
  }
}

Measured memory_bytes: 60312
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i=0;
    int flag=1;
    int n;
    int j,h;
    int A[100];
    scanf("%d",&n);
    for(j=0;j<n;j++)
    {
        scanf("%d",&A[j]);
    }
    
    while(flag==1){
        flag=0;
        int k;
        for(k=n-1;k>0;k--){
            if(A[k]<A[k-1]){
                int tmp;
                tmp=A[k];
                A[k]=A[k-1];
                A[k-1]=tmp;
                flag=1;
                i++;
            }
            
        }
        
        
    }
    for(h=0;h<n-1;h++){
        printf("%d ",A[h]);
        
}
    printf("%d\n",A[n-1]);
    printf("%d\n",i);
    return 0;
        }

Measured memory_bytes: 600
#include <iostream>
#include<vector>
#include<algorithm>
int main(){
    int a,b,c;
    b=1;
    c=0;
    std::vector<int> data;
    for(int i=0;i<28;i++){
        std::cin>>a;
    data.push_back(a);
    }
    std::sort(data.begin(),data.end());
    for(int i=0;i<data.size();i++){
        if(data[i]!=b){
            std::cout<<b<<std::endl;
            b++;
            c++;
        }
        if(b==29&&c==1)
        std::cout<<30<<std::endl;
        b++;
    }
    return 0;
}


Measured memory_bytes: 3112
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n, k := readInt(), readInt()
	a := make([]int, n)
	for i := range a {
		a[i] = readInt() - 1
	}

	startLoop := -1
	exist := make(map[int]bool)
	root := make([]int, 0)
	next := 0
	for {
		if _, ok := exist[next]; ok {
			startLoop = next
			break
		}
		exist[next] = true
		root = append(root, next)
		next = a[next]
	}

	singlePathLen := 0
	for i := range root {
		if root[i] == startLoop {
			break
		}
		singlePathLen++
	}

	if k < len(root) {
		fmt.Println(root[k] + 1)
	} else {
		k -= singlePathLen
		idx := k % (len(root) - singlePathLen)
		fmt.Println(root[singlePathLen+idx] + 1)
	}

	// fmt.Println(k, startLoop, singlePathLen, root)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

int main() {
  int n;
  cin >> n;
  vll a(n+2);
  a[0] = 0;
  a[n+1] = 0;
  rep(i,n) cin >> a[i+1];
  vll b(n+1);
  rep(i,n+1) b[i] = abs(a[i+1]-a[i]);
  vll c(n);
  rep(i,n) c[i] = abs(a[i+2]-a[i]);
  ll cnt = 0;
  rep(i,n+1) cnt += b[i];
  rep(i,n) {
    ll ans = cnt;
    ans -= (b[i]+b[i+1]);
    ans += c[i];
    cout << ans << endl;
  }
  return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, long long K, std::vector<long long> x){

    lli sum = 0;
    REP(i,0,N){
        sum += 2*min(x[i],K-x[i]);
    }
    cout<<sum<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> x(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
    }
    func(N, K, std::move(x));
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
list1 = []
for i in range(N):
    list1.append(int(input()))
list1.sort()
ans=[]
for i in range(0,N-K+1,1):
    ans.append(list1[i+K-1] - list1[0+i])
    
print(min(ans))

Measured memory_bytes: 11292
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int i, n, k, cut=0;
	scanf("%d%d", &n, &k);
	int h[n];
	rep(i,n){
		scanf("%d", &h[i]);
		if(h[i] >= k) cut++;
	}
	printf("%d", cut);
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  string s;
  cin >> s;

  if (s == "keyence") {
    cout << "YES" << "\n";
    return 0;
  }

  for (int i = 1; i <= s.length(); ++i) {
    for (int j = 0; j <= s.length()-i; ++j) {

      string tmps = "";
      for (int k = 0; k < s.length(); ++k) {
        if (k >= j && k <= j+i-1) continue;
        tmps += s[k];
      }

      if (tmps == "keyence") {
        cout << "YES" << "\n";
        return 0;
      }
    }
  }

  cout << "NO" << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 100000000

using namespace std;

int main()
{
    //COMinit();
    ios::sync_with_stdio(false);
    cin.tie(0);
    llong n; cin>>n;
    llong sum=0;
    vector<llong> cnt;
    llong vv=0;
    for(int i=1; ; i++)
    {
        sum+=i;
        cnt.push_back(i);
        if(sum>=n)
        {
           vv=sum-n;
            break;
        }
    }

    if(vv>0) cnt.erase(cnt.begin()+vv-1);

    for(int i=0; i<(llong)cnt.size(); i++)
    {
       cout<<cnt[i]<<endl;
    }
    return  0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
#define endl '\n'
#define int int64_t
#define double long double
template<int D, typename T>struct dense:public vector<dense<D-1,T>>{static_assert(D>=1,"dim err");template<typename... Args>dense(int n=0,Args... args):vector<dense<D-1,T>>(n,dense<D-1,T>(args...)){}};
template<typename T>struct dense<1,T>:public vector<T>{dense(int n=0,const T& val=T()):vector<T>(n,val){}};
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using reverse_queue = priority_queue<T, vector<T>, greater<T>>;
mt19937_64 rnd(time(0));
const int64_t FIXED_RANDOM = rnd();
template<typename T> struct custom_hash{T operator()(T x)const{return (T) x^FIXED_RANDOM;}}; // check hash in whether int64 or int32
template<typename T1, typename T2> using hash_map = gp_hash_table<T1, T2, custom_hash<T1>>;
const int MAXN = (int) 3e5 + 2;
const int INF = numeric_limits<int>::max() >> 1;
const int MOD = (int) 1000000007;
// Tao luyện kỹ thuật trong 8 năm mày luyện kỹ thuật trong buồng tắm nam
struct disjoint_set_union{
  vector<int> p;
  void init(int _){
    p.assign(_ + 1, -1);
  }
  int par(int u){
    return p[u] < 0 ? u : (p[u] = par(p[u]));
  }
  bool same(int u, int v){
    return par(u) == par(v);
  }
  void join(int u, int v){
    if((u = par(u)) == (v = par(v))) return;
    if(p[u] > p[v]) swap(u, v);
    p[u] += p[v];
    p[v] = u;
  }
} dsu;
signed main(){
  ios_base::sync_with_stdio(0); 
  cin.tie(0);
  // freopen("FDT.txt", "r", stdin);
  int n, m;
  cin >> n >> m;
  dsu.init(n);
  while(m --){
    int u, v;
    cin >> u >> v;
    dsu.join(u, v);
  }
  set<int> s;
  for(int i = 1; i <= n; i ++) s.insert(dsu.par(i));
  cout << s.size() - 1;
}

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

using namespace std;

#define REP(i,a,b) for(ll i = a; i < b; i++)
#define DB( x ) cout << #x << " = " << x << endl;
#define sz(s) ((int)((s).size()))
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef pair<int, pii> tri;
typedef vector <vector <ll>> matrix;
typedef pair<string, string> pss;

const ll mod = (ll)1e9 + 7;
const int MAX = (int)3e3 + 100;

const int oo = 0x3f3f3f3f;

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

    int n, m; cin >> n >> m;

    vector<vector<int> > g(n + 1);

    vector<int> in(n + 1, 0);

    vector<ll> dp(n + 1, 0);

    for(int i = 0;i < m;++i){
        int a, b; cin >> a >> b;
        g[a].push_back(b);
        in[b]++;
    }

    queue<int> Q;

    for(int i = 1;i <= n;++i)
        if(!in[i])
            Q.push(i);

    vector<int> order;

    while(!Q.empty()){
        int curr = Q.front(); Q.pop();
        order.push_back(curr);
        for(auto newn : g[curr]){
            in[newn]--;
            if(!in[newn])
                Q.push(newn);
        }
    }

    ll solve = 0;

    for(auto node : order)
        for(auto newn : g[node])
            dp[newn] = max(dp[newn], dp[node] + 1);
    for(auto node : order)
        solve = max(solve, dp[node]);

    cout << solve << endl;
}


Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


vector<int> G[100000];
int color[100000];
int white = 0;

bool dfs(int v, int c) {
    color[v] = c;
    if (c == 1) white++;
    for (ll i = 0; i < G[v].size(); i++) {
        if (color[G[v][i]] == c) return false;
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) return false;
    }
    return true;
}

int main()
{   
    memset(color, 0, 100000);
    ll N, M;
    cin >> N >> M;
    for (ll i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; 
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (dfs(0,1)) {cout << white*(N-white) - M << endl;} 
    else {cout << N*(N-1)/2 - M << endl;}
    return 0;
}


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

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template <typename T1, typename T2>
inline auto mini(T1 a, T2 b) { return (a < b ? a : b); }
template<typename T, typename... Args>
inline auto mini(T a, Args... args) { return mini(a, mini(args...)); }
template <typename T1, typename T2>
inline auto maxi(T1 a, T2 b) { return (a > b ? a : b); }
template<typename T, typename... Args>
inline auto maxi(T a, Args... args) { return maxi(a, maxi(args...)); }
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // use mt19937_64 for 64 bit

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 1e7+3;

int f[maxn];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    for(int i=1; i<maxn; i++) {
        for(int j=i; j<maxn; j+=i) {
            f[j]++;
        }
    }
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++) {
        ans += i * f[i];
    }
    cout << ans << "\n";
    return 0;
}



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

typedef pair<int,int> P;
int flg[1000][1000];

void ini(int x,int y){
	for(int k=0;k<y;k++){for(int j=0;j<x;j++){flg[k][j]=-1;}}
}

int main()
{
	int x,y,n,sum=0;
	char map[1000][1001];
	char ntoi[10]="123456789";	
	queue<P> q;
	int dx[4]={0,0,-1,1},dy[4]={-1,1,0,0};

	cin>>y>>x>>n;
	for(int i=0;i<y;i++)
	{
		for(int j=0;j<x;j++)
		{
			cin>>map[i][j];
			if(map[i][j]=='S')
			{
				q.push(make_pair(i,j));
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		ini(x,y);
		flg[q.front().first][q.front().second]=0;
		while(!q.empty())
		{
			P temp=q.front();
			q.pop();
			if(map[temp.first][temp.second]==ntoi[i])
			{
				sum+=flg[temp.first][temp.second];
				while(!q.empty()){q.pop();}
				q.push(temp);
				break;
			}
			for(int j=0;j<4;j++)
			{
				if(temp.first+dy[j]>-1&&temp.first+dy[j]<y&&temp.second+dx[j]>-1&&temp.second+dx[j]<x&&map[temp.first+dy[j]][temp.second+dx[j]]!='X'&&flg[temp.first+dy[j]][temp.second+dx[j]]==-1)
				{
					flg[temp.first+dy[j]][temp.second+dx[j]] = flg[temp.first][temp.second]+1;
					q.push(make_pair(temp.first+dy[j],temp.second+dx[j]));
				}
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 6096
from collections import defaultdict
import sys
input = sys.stdin.readline

H, W, N = map(int, input().split())
ans = [0] * 10
ans[0] = (H - 2) * (W - 2)
# print (ans)
tmplst = [-1, 0, 1]
dic = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for i in tmplst:
        if 0 <= a + i <= H - 1:
            for j in tmplst:
                if 0 <= b + j <= W - 1: #範囲に入っている
                    tmp = dic[(a + i, b + j)]
                    dic[(a + i, b + j)] += 1
                    if 1 <= a + i <= H - 2 and 1 <= b + j <= W - 2:
                        ans[tmp] -= 1
                        ans[tmp + 1] += 1

print (*ans, sep = '\n')

Measured memory_bytes: 166912
#include<bits/stdc++.h>
#define int long long
using namespace std;


long double getDis(pair<int,int> i, pair<int,int> j)
{
  int xx = (i.first - j.first);
  xx *= xx;
  int yy = (i.second - j.second);
  yy *= yy;
  return (long double) sqrt( xx + yy );
}

int32_t main()
{
		
  int n;
  cin>>n;
  pair<int,int> p[n+1];
  for( int i = 0; i < n ; i++)
  {
    cin>>p[i].first>>p[i].second;
  }
  string s;
  for( int i = 0; i < n; i++)
  {
    s += to_string(i);
  }
  int cn = 0;
  long double tDis = 0;
  do{
	    cn++;
	    string xx = s;
	    for( int i = 0; i < n - 1; i++)
	    {
	     	int aa = xx[i] - '0';
	      	int bb = xx[i+1] -'0';
	      	
	      	tDis += getDis( p[aa] , p[bb] );
	    }
  }while(next_permutation(begin(s), end(s)));

  
 cout << fixed << setprecision(10) << (tDis)/cn << endl;
  
}

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

typedef long long int ll;
typedef double d;

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>0; i--)

#define be(a) a.begin(),a.end()
#define sz(x) x.size()

#define nl cout<<"\n";
#define sp cout<<" ";

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    su;
    string s;
    int l;
    cin>>l>>s;
    int n=sz(s);
    lo(i,0,n)
    {
       int x=s[i]-'A';
       x=(x+l)%26;
       s[i]=x+'A';
    }
    cout<<s;
    nl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String line = in.readLine();

      if(line.length()  == 2)
        System.out.println(line);
      else {
        StringBuilder sb = new StringBuilder();
        sb.append(line).reverse();
        System.out.println(sb);
      }
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 21076
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
struct edge{long long to,cost;};
typedef pair<int,int>P;
#define inf 1000000007
string alph("abcdefghijklmnopqrstuvwxyz");
vector<int> es[114514];
signed main(){
    int n,k;cin>>n>>k;
    int a[55],b[55],fa[55],fb[55];
    rep(i,0,n){
        cin>>a[i]>>b[i];
        fa[i]=a[i],fb[i]=b[i];
    }
    sort(fa,fa+n);sort(fb,fb+n);
    unsigned long long ans=(fa[n-1]-fa[0])*(fb[n-1]-fb[0]);
    rep(i,0,n-1){
        rep(j,i+1,n){
            rep(l,0,n-1){
                rep(h,l+1,n){
                    int q=fa[i],w=fa[j],e=fb[l],r=fb[h];
                    int count=0;
                    rep(so,0,n){
                        if(q<=a[so]&&a[so]<=w&&e<=b[so]&&b[so]<=r)count++;
                    }if(count>=k&&ans>(w-q)*(r-e))ans=(w-q)*(r-e);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while (true) {
		minv = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1)break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK&&M[u][v] != INFTY) {
				if (d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != -1)sum += M[i][p[i]];
	}

	return sum;	
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int e; cin >> e;
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}
	cout << prim() << endl;
	return 0;
}



Measured memory_bytes: 3128
N = int(input())
T = []
[T.append(int(input())) for _ in range(N)]

def gcd(a,b):
    if max(a,b)%min(a,b) == 0:
        return min(a,b)
    return gcd(max(a,b)%min(a,b),min(a,b))

ans = 1
for t in T:
    ans = ans * t // gcd(ans,t)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	ll A, B;
	cin >> N >> A >> B;
	vector<ll> H(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> H[i];
	}

	ll l = 0;
	ll h = INT_MAX;
	auto diff = A - B;
	while (l <= h)
	{
		auto mid = (l + h) / 2;
		auto sum = 0ll;
		for (auto i = 0; i < N; ++i)
		{
			auto temp = H[i] - B * mid;
			if (temp <= 0)
			{
				continue;
			}
			sum += (temp - 1) / diff + 1;
		}

		if (sum <= mid)
		{
			h = mid - 1;
		}
		else
		{
			l = mid + 1;
		}
	}

	cout << l << endl;

	return 0;
}

Measured memory_bytes: 1024
import scala.io.StdIn.readLine

object Main extends App {

  val alpha = Array.fill[Int](128)(0)

  def count():Unit = {
    val l = readLine
    if(l != null) {
      l.trim.foreach { s => alpha(s.toLower) += 1 }
      count()
    }
  }

  count()
  for(i <- 'a' to 'z')
    println(i + " : " + alpha(i))
}

Measured memory_bytes: 44616
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;
using qul = queue<ll>;

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vel a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    string A, B;
    int num;
    bool ans = false;
    cin >> A >> B;
    A = A + B;
    num = atoi(A.c_str());
    REP(i,1100){
        if(num == i*i) ans = true;
    }
    Yes(ans);
    return 0;
}

Measured memory_bytes: 3580