akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}
use std::cmp::max;
use std::collections::HashMap;

fn main() {
    let N: usize = read();
    let A: Vec<usize> = (0..N).map(|_| read()).collect();
    let MOD = 10_u64.pow(9) + 7;
    let mut lcm = HashMap::new();
    let mut primes = vec![];
    for v in &A {
        primes.push(prime_factorization(*v));
    }
    for primes in &primes {
        for (p, &count) in primes {
            let entry = lcm.entry(p).or_insert(0);
            *entry = max(*entry, count);
        }
    }
    let mut lcm_num = 1;
    for (p, count) in lcm {
        lcm_num *= bin_pow(*p as u64, count as u64, MOD);
        lcm_num %= MOD;
    }
    let mut ans = 0;
    for v in A {
        ans += lcm_num * inverse_mod(v as u64, MOD);
        ans %= MOD;
    }
    println!("{}", ans)
}

fn bin_pow(x: u64, n: u64, MOD: u64) -> u64 {
    if n == 0 {
        return 1;
    }
    if n % 2 == 0 {
        (bin_pow(x, n / 2, MOD) % MOD).pow(2) % MOD
    } else {
        bin_pow(x, n - 1, MOD) % MOD * x % MOD
    }
}

fn inverse_mod(n: u64, MOD: u64) -> u64 {
    bin_pow(n, MOD - 2, MOD)
}

fn prime_factorization(n: usize) -> HashMap<usize, usize> {
    let mut ans = HashMap::new();
    let mut n = n;
    for i in 2..=((n as f64).sqrt().ceil() as usize) {
        while n % i == 0 && n != 1 {
            n /= i;
            let entry = ans.entry(i).or_insert(0);
            *entry += 1;
        }
    }
    if n != 1 {
        let entry = ans.entry(n).or_insert(0);
        *entry += 1;
    }
    ans
}


Measured memory_bytes: 4624
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
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);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[13][1 << 12], bm[13], bw[13];
int M, W;
 
signed main() {
    while(cin >> M >> W, M || W) {
        for(int i=0; i<M; i++) {
            cin >> bm[i];
        }
        for(int i=0; i<W; i++) {
            cin >> bw[i];
        }

        fill(dp[0], dp[W+1], -1);
        dp[0][0] = 0;
        for(int i=0; i<W; i++) {
            for(int bit=0; bit<(1<<M); bit++) {
                if(dp[i][bit] < 0) continue;
                chmax(dp[i+1][bit], dp[i][bit]);

                for(int j=0; j<M; j++) {
                    if(bit >> j & 1) continue;
                    int nbit = bit | (1 << j);
                    int diff = abs(bm[j] - bw[i]);
                    int cost = diff * (diff - 30) * (diff - 30);

                    chmax(dp[i+1][nbit], dp[i][bit] + cost);
                }
            }
        }

        cout << *max_element(dp[W], dp[W] + (1 << M)) << endl;
    }
    return 0;
}


Measured memory_bytes: 3496
x = []
y = []
while True:
    try:
        tmp = list(input().split(','))
        x.append(int(tmp[0]))
        y.append(int(tmp[1]))
    except EOFError:
        break
    
sum = 0
for i in range(len(x)):
    sum += x[i]*y[i]
total = 0
for i in range(len(y)):
    total += y[i]
print(sum)
print(int(total / len(y) + 0.5))

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

int count;

void swap(int *a, int *b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;

    count += 1;
}

void selectionSort(int A[], int N)
{
    int i;
    int j;
    int minj;

    for(i = 0; i < N; i++) {
        minj = i;
        for(j = i; j < N; j++) {
            if(A[j] < A[minj]) {
                minj = j;
            }
        }
        if(i != minj) {
            swap(&A[i], &A[minj]);
        }
    }
}

int main()
{
    int N;
    int *A;
    int i;

    scanf("%d", &N);
    A = (int *)malloc(sizeof(int) * N);
    for(i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    count = 0;
    selectionSort(A, N);

    for(i = 0; i < N-1; i++) {
        printf("%d ", A[i]);
    }
    printf("%d\n", A[N-1]);
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2088
#include <stdio.h>

int n, m;
int connected[8][8];

int dfs(int pos, int visited[8])
{
    int i;
    int cnt = 0;

    visited[pos] = 1;
    for (i = 0; i < n; ++i){
        if (visited[i] == 0){
            break;
        }
    }
    if (i == n){
        visited[pos] = 0;
        return 1;
    }
    for (i = 0; i < n; ++i){
        if (connected[pos][i] && visited[i] == 0){
            cnt += dfs(i, visited);
        }
    }
    visited[pos] = 0;

    return cnt;
}

int main(void)
{
    int i;
    int visited[8] = {0};

    scanf("%d %d", &n, &m);

    while (m-- > 0){
        int a, b;

        scanf("%d %d", &a, &b);
        connected[--a][--b] = 1;
        connected[b][a] = 1;
    }

    printf("%d\n", dfs(0, visited));

    return 0;
}


Measured memory_bytes: 128
s = list(input())
n = len(s)
m = n//2
s_f = []
s_l = []
for i in range(m):
    s_f.append(s[i])
for i in range(1,m + 1):
    s_l.append(s[-i])
s_r = list(reversed(s))
s_f_r = list(reversed(s_f))
s_l_r = list(reversed(s_l))
if s_r == s:
    if s_f_r == s_f and s_l_r == s_l:
        print("Yes")
    else:
        print("No")
else:
    print("No")




Measured memory_bytes: 9012
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
typedef pair<int,int> P;
const int MOD = 1e9 + 7;
const ll mod = 1e9 + 7;
const int mxN = 2e6 + 9;

ll fact[mxN];

int mult(int a, int b){
    ll a1 = ((ll) a)% MOD;
    ll b1 = ((ll) b)% MOD;
    return (int) ((a1*b1)%MOD);
}

int pow(int a, int b){
    int res = 1;
    while( b > 0 ){
        if( b%2 == 1 ) res = mult(res, a);
        a = mult(a, a);
        b /= 2;
    }
    return res;
}

int inv(int n){
    return pow(n, MOD-2);
}

int nCr(int n, int r){
    if( n < r ) return 0;
    return mult( fact[n] , inv( mult(fact[r], fact[n-r]) ) );
}

int subt( int a, int b ){
    return (((a-b)%MOD) + MOD ) % MOD;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,k;
	n = 2000009;
	fact[0] = fact[1] = 1;
	for(int i = 2; i <= n; i++) fact[i] = (fact[i-1]*((ll)i))%MOD;
	ll ans = 0;
    int N,K;
    string s;
    cin >> N >> s;
    K = s.length();
    swap(N,K);
    //cout << N << " " << K << endl;
    for(int i=N; i <= N+K; ++i){
        ll tmp  = ((ll) pow( 25, N+K-i ));
        ll tmp2 = nCr( N+K, i );
        ll tmp3 = ((tmp%MOD)*(tmp2%MOD))%MOD;
        //
        //cout << tmp << " " << tmp2 << " " << tmp3 << endl;
        //
        ans = (ans + (tmp3%MOD))%MOD;
    }
    cout << ans;


}


Measured memory_bytes: 19872
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;
int main()
{
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++)
      cin>>v[i];
    ll ans=0;
    sort(v.begin(),v.end());
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
          ll k=upper_bound(v.begin()+i+1,v.end(),v[j]-v[i])-v.begin();
            if(v[k]>v[j]-v[i])
            {
                ans+=(j-k);
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x1,x2,x3,x4,x5;
	scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
	if(x1==0){
		printf("1\n");
	}
	else if(x2==0){
		printf("2\n");
	}
	else if(x3==0){
		printf("3\n");
	}
	else if(x4==0){
		printf("4\n");
	}
	else if(x5==0){
		printf("5\n");
	}
	return 0;
}

Measured memory_bytes: 1644
import sys
input = sys.stdin.readline

a,b = map(int,input().split())
aa = []
d = []
for i in range(b):
    k,kk = map(int,input().split())
    d.append([k, kk,i+1])

da = sorted(d)

kkk = da[0][0]
ll = 0
for i in range(b):
    kkkk = da[i][0]
    if kkk == kkkk:
        ll += 1
    else:
        kkk = kkkk
        ll = 1
    aa.append([da[i][2],da[i][0],ll])
aa.sort()

for i in aa:
    m = str(i[1])
    n = str(i[2])
    m = "0"*(6-len(m))+m
    n = "0"*(6-len(n))+n
    print(m+n)


Measured memory_bytes: 73088
#include <cstdio>

int A[100000 + 5];

int partition(int p, int r) {
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if (A[j] <= x) {
      ++i;
      int tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  int tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;
  return i + 1;
}

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

  int q = partition(0, n - 1);

  for (i = 0; i < n; ++i) {
    if (i) printf(" ");
    if (i == q) printf("[");
    printf("%d", A[i]);
    if (i == q) printf("]");
  }
  printf("\n");
}

Measured memory_bytes: 2992
n = int(input())
s = []
for i in range(n):
    s.append(input())
s.sort()
ans = 1
ansar = [s[0]]
now = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        now = now +1
    else:
        now = 1
    if now == ans:
        ansar.append(s[i+1])
    if now > ans:
        ans = now
        ansar = [s[i+1]]
for i in range(len(ansar)):
    print(ansar[i])

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

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

int main()
{
  cin >> n >> m;
  vector<ll> h(n);
  vector<int> good(n, 1);

  REP(i, n){
    cin >> h[i];
  }

  REP(i, m){
    cin >> a >> b;
    if(h[a-1] <= h[b-1]){
      good[a-1] = 0;
    }
    if(h[a-1] >= h[b-1]){
      good[b-1] = 0;
    }
  }

  ans = accumulate(good.begin(), good.end(), 0);

  cout << ans << endl;
}

Measured memory_bytes: 4252
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>

using namespace std;

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const db PI = acos(-1);
const db ERR = 1e-12;

const int MX = 2005;
const int MM = 1000000007;

ll pw(ll a, ll b){
	ll r = 1;
	while(b){
		if( b&1 ) r = r*a % MM;
		a = a*a%MM; b /= 2;
	}
	return r;
}

ll rv(ll a){ return pw(a, MM-2); }

ll C[MX][MX];
ll D[MX][MX], E[MX][MX];

int main()
{
	C[0][0] = 1;
	for(int i = 1; i < MX; i++){
		C[i][0] = 1;
		for(int j = 1; j < MX; j++){
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MM;
		}
	}
	int A, B;
	scanf("%d%d", &A, &B);
	if( B == 0 ) return !printf("1\n");
	for(int B = 1; B < MX; B++){
		E[B][0] = 1;
		for(int A = 1; A < MX; A++){
			E[B][A] = (E[B][A-1] + C[B-1][A]) % MM;
		}
	}
	for(int B = 1; B < MX; B++){
		D[B][0] = 1;
		for(int A = 1; A < MX; A++){
			D[B][A] = (D[B][A-1] + E[B][A]) % MM;
		}
	}
	ll ans = 0;
	for(int a = 0; a <= A; a++){
		ans++;
		for(int i = max(1, B-a); i <= B; i++){
			ans = (ans + D[B-i][a-B+i] * C[B-1][i-1]) % MM;
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 94592
#include <iostream>
#include <algorithm>
#include<string.h>
using namespace std;
const int maxn = 2e5 + 10;
#define ll long long
ll a[200005];
ll b[200005], c[200005], d[200005], ans; 
int upperbound(int l, int r, ll s){
        while(l<r){
            int m = (l+r)/2;
            ll h = b[m] ^ b[s - 1];
            if(c[m] - c[s - 1] - h <= 0) 
 				l = m + 1;
            else    
				r = m;
        }
        return l;
}
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		b[i] = a[i] ^ b[i - 1];
		c[i] = a[i] + c[i - 1]; 
		d[i] = c[i] - b[i];
	}
	c[n + 1] = 1e17;
	for (int i = 1; i <= n; i++)
	{
		int x = upperbound(i, n + 1, i);
		ans += x - i;		
	}
	printf("%lld", ans);
}


Measured memory_bytes: 6528
import os, sys, re, math, fractions

N = int(input())
A = list(map(int,input().split(' ')))

memo_L = [1] * N
memo_R = [1] * N

for i in range(N):
    if i == 0:
        memo_L[i] = A[i]
        memo_R[i] = A[N-1]
    elif i == N - 1:
        memo_L[i] = fractions.gcd(A[i], memo_L[i-1])
        memo_R[i] = fractions.gcd(A[0], memo_R[i-1])
    else:
        memo_L[i] = fractions.gcd(A[i], memo_L[i-1])
        memo_R[i] = fractions.gcd(A[N-1-i], memo_R[i-1])

memo_R.reverse()

ret = 1
for j in range(N):
    if j == 0:
        ret = max(ret, memo_R[1])
    elif j == N-1:
        ret = max(ret, memo_L[j-1])
    else:
        common_gcd = fractions.gcd(memo_L[j-1], memo_R[j+1])
        ret = max(ret, common_gcd)

print(ret)


Measured memory_bytes: 16088
#include<iostream>
#include<string>

using namespace std;

class Dice{
public:
  int originalD[6];
  int realD[6];
  string s;
  void setD(int originalD[],int realD[]);
  void moveD(int realD[],string s,int n);
  void outu(int realD[]);
};

void Dice::setD(int orinalD[],int realD[]){
  for(int i=0;i<6;i++){
    cin>>originalD[i];
    realD[i]=originalD[i];
  }
}

void Dice::moveD(int realD[],string s,int n){
  int aD[6];
  int x;
  for(int i=0;i<n;i++){
    if(s[i]=='N')x=0;
    if(s[i]=='S')x=1;
    if(s[i]=='E')x=2;
    if(s[i]=='W')x=3;
    switch(x){
      case 0:
              aD[0]=realD[1];
              aD[1]=realD[5];
              aD[2]=realD[2];
              aD[3]=realD[3];
              aD[4]=realD[0];
              aD[5]=realD[4];
              break;
      case 1:
              aD[0]=realD[4];
              aD[1]=realD[0];
              aD[2]=realD[2];
              aD[3]=realD[3];
              aD[4]=realD[5];
              aD[5]=realD[1];
              break;
      case 2:
              aD[0]=realD[3];
              aD[1]=realD[1];
              aD[2]=realD[0];
              aD[3]=realD[5];
              aD[4]=realD[4];
              aD[5]=realD[2];
              break;
      case 3:
              aD[0]=realD[2];
              aD[1]=realD[1];
              aD[2]=realD[5];
              aD[3]=realD[0];
              aD[4]=realD[4];
              aD[5]=realD[3];
              break;
      }
      for(int v=0;v<6;v++){
        realD[v]=aD[v];
      }
  }
}

void Dice::outu(int realD[]){
  cout<<realD[0]<<endl;
}

int main(){
  Dice dice;
  string s;
  int originalD[6],realD[6];
  dice.setD(originalD,realD);
  cin>>s;
  int n=s.length();
  dice.moveD(realD,s,n);
  dice.outu(realD);
  return 0;
}



Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <queue>

std::vector<std::vector<int>> adj;
std::vector<std::pair<int, int>> edges;

int min(int a, int b) {
	return a < b ? a : b;
}

int bfs(int center, int k) {
	std::queue<std::pair<int, int>> q;
	bool visited[2000] = { false };
	int maxDist, numClose;
	if (k % 2 == 0) {
		maxDist = k / 2;
		q.push(std::pair<int, int>(center, 0));
		visited[center] = true;
		numClose = 1;
	} else {
		maxDist = (k - 1) / 2;
		q.push(std::pair<int, int>(edges[center].first, 0));
		q.push(std::pair<int, int>(edges[center].second, 0));
		visited[edges[center].first] = true;
		visited[edges[center].second] = true;
		numClose = 2;
	}
	while (!q.empty()) {
		int cur = q.front().first;
		int dist = q.front().second;
		q.pop();
		if (dist < maxDist) {
			for (int i : adj[cur]) {
				if (!visited[i]) {
					visited[i] = true;
					q.push(std::pair<int, int>(i, dist + 1));
					++numClose;
				}
			}
		}
	}
	return numClose;
}

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

	int n, k;
	std::cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		adj.push_back(std::vector<int>());
	}

	for (int i = 0; i < n - 1; ++i) {
		int u, v;
		std::cin >> u >> v;
		--u; --v;
		adj[u].push_back(v);
		adj[v].push_back(u);
		edges.push_back(std::pair<int, int>(u, v));
	}

	int res = (int) 2e9;
	for (int i = 0; i < n - 1; ++i) {
		res = min(res, n - bfs(i, k));
	}
	if (k % 2 == 0) {
		res = min(res, n - bfs(n - 1, k));
	}
	
	std::cout << res << '\n';
	return 0;
}

Measured memory_bytes: 384
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;

#if 0
#define INT8_MIN	(-127)
#define INT8_MAX	( 128)
#define UINT8_MAX	( 255)
#define INT16_MIN	(-32768)
#define INT16_MAX	( 32767)
#define UINT16_MAX	( 65535)
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int main(void)
{
	func();

	VS_ENDPAUSE();
	return 0;
}



void func(void)
{
	char a[103][103];
	memset(a, '#', sizeof(a));
	int32 h, w;
	int l = scanf("%d %d", &h, &w);

	a[0][w+2] = '\0';
	for(int j=1; j<=h; j++){
		l=scanf("%s", &a[j][1]);
		a[j][w+1] = '#';
		a[j][w+2] = '\0';
	}
	a[h+1][w+2] = '\0';
	for(int j=0; j<h+2; j++){
		printf("%s\n", a[j]);
	}

}




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

Measured memory_bytes: 1656
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 110000000000
#define MAX 100000
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int K,X,minA,maxA;
  cin>>K>>X;
  minA=X-K+1;
  maxA=X+K-1;
  cout<<minA;
  for(int i=minA+1;i<=maxA;i++){
    cout<<" "<<i;
  }
  cout<<endl;
}


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

int main() {
  int N,n,cnt=0,stl=0;
  cin >> N;
  vector<string> s(N);

  for(int i=0;i<N;i++){
  cin >> s[i];
  }

  for(int i=0;i<N;i++){
     for(int j=0;j<N;j++){
      if( s[i]==s[j] ){
       cnt++;
      }
     }
  }

  if(cnt !=N){
  cout << "No" << endl;
  }
  else{
  for(int i=0;i<N-1;i++){
    if(s[i][s[i].size()-1] == s[i+1][0]){
      stl++;
    }
  }
  if(stl==N-1){
   cout << "Yes" << endl;
  }
  else{
   cout << "No" << endl;
  }
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  bool y = false;
  REP(i, n){
    char c;
    cin >> c;
    if(c == 'Y') y = true;
  }
  if(y) cout << "Four" << endl;
  else cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[])
{
    int A,B,X;

    cin>>A>>B>>X;
    if(A<=X&X<=A+B){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
 
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##

## main ##
N = ri()
S = rs()
R = S.count('R')
B = N - R
print("Yes" if R > B else "No")




Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define int long long
using namespace std;
int h, w;
char map[1010][1010];
int p[1011][1011];
queue<pair<pair<int,int>,int>>q;
signed main() {
	cin >> h >> w;
	int ans = 0, cnt = h * w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			p[i][j] = 1000000007;
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> map[i][j];
			if (map[i][j] == '#') {
				q.push(make_pair(make_pair(i, j), 0));
			}
		}
	}
	while (cnt) {
		int i = q.front().first.first, j = q.front().first.second, c = q.front().second;
		q.pop();
		if (p[i][j] == 1000000007) {
			cnt--; p[i][j] = c; ans = max(ans, c);
			if (map[i - 1][j] == '.'&&p[i - 1][j] == 1000000007)q.push(make_pair(make_pair(i - 1, j), c + 1));
			if (map[i + 1][j] == '.'&&p[i + 1][j] == 1000000007)q.push(make_pair(make_pair(i + 1, j), c + 1));
			if (map[i][j - 1] == '.'&&p[i][j - 1] == 1000000007)q.push(make_pair(make_pair(i, j - 1), c + 1));
			if (map[i][j + 1] == '.'&&p[i][j + 1] == 1000000007)q.push(make_pair(make_pair(i, j + 1), c + 1));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 33460
'use strict'
function Main(input) {
  const tmp = input.trim().split("\n");
  let Arr = tmp[0].split(" ").map(Number);
  let num = Arr.pop();
  let cake0 = tmp[1].split(" ").map(Number);
  let cake1 = tmp[2].split(" ").map(Number);
  let cake2 = tmp[3].split(" ").map(Number);
  let Cake = [cake0, cake1, cake2];
  // console.log({ Arr, num });
  // console.log({ Cake0 });
  // console.log({ Cake1 });
  // console.log({ Cake2 });
  
  for (let i = 0; i < 3; i++) {
    Cake[i].sort((a, b) => b - a);
  }
  // console.log({ Cake });
  
  let maxList = [];

  for (let i = 0; i < Arr[0]; i++){
    for (let j = 0; j < Arr[1]; j++){
      for (let k = 0; k < Arr[2]; k++){
        if ((i + 1) * (j + 1) * (k + 1) <= 3000) {
          maxList.push((Cake[0][i]) + (Cake[1][j]) + (Cake[2][k]));
        } else {
          break;
        }
      }
    }
  }
  maxList.sort((a, b) => b - a);
  let Answer = maxList.slice(0, num);

console.log(Answer.join('\n'));

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int N=210,M=50000,inf=1000000000;
struct Edge{
	int from,to,cap;
	Edge(int from=0,int to=0,int cap=0):from(from),to(to),cap(cap){}
}edges[M];
int G[N],ne[M],cnt,cur[N],S,T;

void add_edge(int x,int y,int z){
	ne[cnt]=G[x];edges[cnt]=Edge(x,y,z);G[x]=cnt++;
	ne[cnt]=G[y];edges[cnt]=Edge(y,x,0);G[y]=cnt++;
}

int d[N],q[N];
bool bfs(){
	int t=-1,w=0;memset(d,-1,sizeof d);d[T]=0;q[0]=T;
	for(;t<w;)
		for(int x=q[++t],i=G[x];~i;i=ne[i])
			if(!~d[edges[i].to]&&edges[i^1].cap)d[q[++w]=edges[i].to]=d[x]+1;
	return~d[S];
}

int dfs(int x,int a){
	if(x==T||!a)return a;
	int fw=0,f;
	for(int&i=cur[x];~i;i=ne[i])
		if(d[x]==d[edges[i].to]+1&&(f=dfs(edges[i].to,min(a,edges[i].cap)))){
			edges[i].cap-=f;edges[i^1].cap+=f;
			fw+=f;a-=f;if(!a)break;
		}
	return fw;
}

int max_flow(){
	int fw=0;
	for(;bfs();fw+=dfs(S,inf))memcpy(cur,G,sizeof G);
	return fw;
}
int n,m;
int sx,sy,tx,ty;
char s[N];
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;S=0;T=n+m+1;memset(G,-1,sizeof G);
	for(int i=1;i<=n;++i){
		cin>>(s+1);
		for(int j=1;j<=m;++j)
			switch(s[j]){
				case 'S':{
					add_edge(S,i,inf);
					add_edge(S,j+n,inf);
					sx=i;sy=j;
					break;
				}
				case 'T':{
					add_edge(i,T,inf);
					add_edge(j+n,T,inf);
					tx=i;ty=j;
					break;
				}
				case 'o':{
					add_edge(i,j+n,1);
					add_edge(j+n,i,1);
					break;
				}
			}
	}
	if(sx==tx||sy==ty){
		cout<<-1<<'\n';
		return 0;
	}
	cout<<max_flow()<<'\n';
	return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int MOD = 1000000007;
const ll INF = 1LL << 60;

int n,k;
int h[101000];
ll dp[101000];

int main(){
  cin >> n >> k;
  rep(i,n) cin >> h[i];
  rep(i,101000) dp[i] = INF;
  dp[0] = 0;
  rep(i,n){  
    for(int j = 1; j <= k;j++){
      chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  
  cout << dp[n-1] << endl;

  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    int a,b,c;a=b=c=0;
    int n=s.size();
    for (int i = 0; i < n; ++i) {
        if(s[i]=='a')a++;
        if(s[i]=='b')b++;
        if(s[i]=='c')c++;
    }
    if(max({a,b,c})-min({a,b,c})<=1)puts("YES");
    else puts("NO");
}


Measured memory_bytes: 3736
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>





int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> min_cost(1 << n, INT_MAX);
	min_cost[0] = 0;
	for (auto _i = 0; _i < m; ++_i) {
		int price, b; std::cin >> price >> b;
		int pattern = 0;
		for (auto j = 0; j < b; ++j) {
			int c; std::cin >> c;
			pattern |= 1 << (c - 1);
		}
		for (auto i = 0; i < min_cost.size(); ++i) {
			if (min_cost[i] != INT_MAX) {
				if (min_cost[i | pattern] > min_cost[i] + price) {
					min_cost[i | pattern] = min_cost[i] + price;
				}
			}
		}
	}
	if (min_cost.back() == INT_MAX) std::cout << -1 << std::endl;
	else std::cout << min_cost.back() << std::endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,m;
  cin >> n >> m;
  if(n>m) swap(n,m);
  if(n==1&&m==1) cout << 1 << endl;
  else if(n==1) cout << m-2 << endl;
  else cout << (n-2)*(m-2) << endl;
  return 0;
}


Measured memory_bytes: 256
lim = 10 ** 5
ans = [0] * (lim + 1)
like = [1] * (lim + 1)
like[0] = 0
like[1] = 0
for i in range(2, lim + 1):
    if like[i]:
        for j in range(i ** 2, lim + 1, i):
            like[j] = 0

for i in range(3, lim + 1, 2):
    if like[i] and like[(i + 1) // 2]:
        ans[i] = 1

for i in range(2, lim + 1):
    ans[i] += ans[i - 1]

q = int(input())
for _ in range(q):
    r, l = map(int, input().split())
    print(ans[l] - ans[r - 1])


Measured memory_bytes: 7156
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int X = reader.nextInt();
		int Y = reader.nextInt();
		int Z = reader.nextInt();
		int K = reader.nextInt();
		long[] A = new long[X];
		long[] B = new long[Y];
		long[] C = new long[Z];
//		long[] arr = new long[X * Y * Z];
		ArrayList<Long> list = new ArrayList<Long>();
		for (int i = 0; i < X; i++) {
			A[i] = reader.nextLong();
		}
		for (int i = 0; i < Y; i++) {
			B[i] = reader.nextLong();
		}
		for (int i = 0; i < Z; i++) {
			C[i] = reader.nextLong();
		}
		Arrays.sort(A);

		Arrays.sort(B);

		Arrays.sort(C);
		for (int i = 1; i <= Math.min(X, K); i++) {
			for (int j = 1; j <= Math.min(Y, K); j++) {
				for (int k = 1; k <= Math.min(Z, K); k++) {
					if (i*j*k > K) {
						break;
					}
					list.add(A[X-i] + B[Y-j] + C[Z-k]);
				}
			}
		}
		Collections.sort(list);
		int size = list.size();
		for (int i = 1; i <= K; i++) {
			System.out.println(list.get(size - i));
		}


		reader.close();
	}
}

Measured memory_bytes: 32648
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello
{

    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        HashSet<int> list = new HashSet<int>();

        for (int i = 0; i < N; i++)
        {
            int n = int.Parse(Console.ReadLine());
            if (list.Contains(n))
            {
                list.Remove(n);
            }
            else list.Add(n);
        }
        Console.WriteLine(list.Count);
    }
}

Measured memory_bytes: 19424
fn main() {
    let (n, r) = {
        let s = {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            s.trim_right().to_owned()
        };
        let mut integers = s.split_whitespace();
        let n: i32 = integers.next().unwrap().parse().unwrap();
        let r: i32 = integers.next().unwrap().parse().unwrap();
        (n, r)
    };
    if n >= 10 {
        println!("{}", r);
    }
    else {
        let answer = r + 100 * (10 - n);
        println!("{}", answer);
    }
}


Measured memory_bytes: 4352
#include <iostream>  
#include <string.h> 
using namespace std;
int main() {
    int x, y=0,z=0; cin >> x; 
    string s;
    cin >> s;
    for (int i=0;i<x;i++){
        if (s[i] == 'I')
            y++;
        else 
            y--;

        if (y>z)
        z = y;
        
    
    }
    cout << z;
    return 0;
}



Measured memory_bytes: 3612
#include<stdio.h>
main()
{
  int a,b,i,j,k;
  scanf("%d %d",&a,&b);
  
  if(a > b){
    i = a;
    j = b;
  }
  else {
    i = b;
    j = a;
  }
  while(j != 0){
    k = j;
    j = i%j;
    i = k;
  }
  printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define F first
#define s second
#define int long long		
int a[214514];
int b[214514];
signed main(){
	int c,d;
	cin>>c>>d;
	c(max({c+d,c*d,c-d}))
}	

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main(){
	var n, v int
	sum, max, min := 0, int(-1e+7), int(1e+7)
	fmt.Scan(&n)
	for i:=0; i<n; i++{
		fmt.Scan(&v)
		if v > max{
			max = v
		}
		if v < min{
			min = v
		}
		sum += v
	}
	fmt.Printf("%d %d %d\n", min, max, sum)
}


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

void zeroOrOneSwap(int& size, int arr[])
{
    bool swap = false;

    for (int i = 0; i < size; i++)
    {
        //printf("arr[i]: %d\n", arr[i]);
        
        if ((arr[i] != (i+1)) && swap)
        {
            printf("NO\n");
            return;
        }

        else if (arr[i] != (i+1))
        {
            int other = arr[arr[i]-1];
            
            // swap...
            if (other == (i+1))
            {
                //printf("other: %d\n", other);
                swap = true;
                arr[arr[i]-1] = arr[i];
                arr[i] = other;
            }

            else
            {
                printf("NO\n");
                return;
            }
        }
    }

    printf("YES\n");
}

int main()
{
    int size;
    
    scanf("%d", &size);

    int arr[size];

    for (int i = 0; i < size; i++) scanf("%d", &arr[i]);

    zeroOrOneSwap(size, arr);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[ten5];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,sum=0;
    string s;
    cin>>n;
    for(i=0;i<n;i++) cin>>num[i];
    for(i=0;i<n;i++)
        for(j=i+1;j<n;j++)
            for(k=j+1;k<n;k++)
    {
        if(num[i]==num[j]||num[i]==num[k]||num[j]==num[k]) continue;
        m=max(num[i],max(num[j],num[k]));
        if(m*2<num[i]+num[j]+num[k])
            sum++;
    }
    cout<<sum;
    return 0;
}





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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

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

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

struct FenwickTree {
  vector<long long> v;
  int n;
  FenwickTree(int n) : n(n), v(n) {}
  void add(int i, long long x) {
    i++;
    while (i <= n) {
      v[i - 1] += x;
      i += i & -i;
    }
  }
  long long get(int i) {
    long long r = 0;
    while (i >= 1) {
      r += v[i - 1];
      i -= i & -i;
    }
    return r;
  }
};

struct ExFenwickTree {
  FenwickTree p, q;
  ExFenwickTree(int n) : p(n + 1), q(n + 1) {}
  void add(int l, int r, long long w) {
    p.add(l, -w * l);
    p.add(r, w * r);
    q.add(l, w);
    q.add(r, -w);
  }
  long long get(int r) {
    return p.get(r) + q.get(r) * r;
  }
};

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

  ll n, k; cin >> n >> k;
  vll a(n);
  REP(i, n) {
    cin >> a[i];
  }

  ExFenwickTree bit(n);
  REP(i, n) {
    bit.add(i, i+1, a[i]);
  }
  REP(j, k) {
    if(bit.get(n) >= n * n) break;
    ExFenwickTree bit2(n);
    REP(i, n) {
      ll val = bit.get(i+1) - bit.get(i);
      bit2.add(max(0ll, i-val), min(n, i+val+1), 1);
    }
    bit = bit2;
  }

  REP(i, n) {
    cout << bit.get(i+1) - bit.get(i);
    if(i == n-1) cout << endl;
    else cout << " ";
  }

}
























Measured memory_bytes: 10972
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define ff first
#define ss second
#define MAXN  1000005
#define endl "\n"
using namespace std;
vector<ll>v;
ll dp[100003];
ll a,n,k;
ll rec(int i){
    if(i==n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll ans=LLONG_MAX;
    for(int j=1;j<=k&&i+j<n;j++){
        ans=min(ans,abs(v[i]-v[i+j])+rec(i+j));
    }
    return dp[i]=ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>a;
        v.pb(a);
    }
    memset(dp,-1,sizeof(dp));
    ll ans=rec(0);
    cout<<ans<<endl;



    return 0;
}



Measured memory_bytes: 9716
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var s = cin.Read;
            WriteLine(s.Count(x => x == '1'));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    double ans = 0;
    rep(i,n){
        double num;
        cin >> num;
        ans += 1.0/num;
    }
    cout <<  setprecision(12) << 1.0/ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")

#include <bits/stdc++.h>
using namespace std;

int c[26];
int64_t csum;
int64_t s[366][26];

int64_t eval(const vector<int> &state, int d){
    int last[26] = {0};
    int64_t decl = -csum;
    int64_t score = 0;

    for(int i=1;i<=d;++i){
        score += s[i][state[i]];
        decl += (i - last[state[i]])*c[state[i]];
        last[state[i]] = i;
        score += decl;
        decl -= csum;
    }
    return score;
}

vector<int> beam(int D, int w){
    map<int64_t, vector<int>, greater<int64_t>> mp;
    for(int i=0;i<26;++i){
        mp[s[1][i] + c[i] - csum] = vector<int>{2, i};
    }
    for(int d=2;d<=D;++d){
        if(d % 20 == 0) w -= 45;
        int cnt = 0;
        vector<vector<int>> states;
        for(auto p: mp){
            states.push_back(p.second);
            ++cnt;
            if(cnt >= w) break;
        }
        mp.clear();
        for(auto v: states){
            for(int i=0;i<26;++i){
                vector<int> state{v};
                state.emplace_back(i);
                mp[eval(state, d)] = state;
            }
        }
    }
    return mp.begin()->second;
}

int main(){
    int d;
    scanf("%d", &d);
    for(int i=0;i<26;++i) scanf("%d", &c[i]);
    for(int i=0;i<26;++i) csum += c[i];

    for(int i=1;i<=d;++i){
        for(int j=0;j<26;++j) scanf("%" SCNd64, &s[i][j]);
    }

    auto ans = beam(d, 700);
    for(int i=1;i<=d;++i) printf("%d\n", ans[i] + 1);

    return 0;
}

Measured memory_bytes: 11600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int M = max(A,max(B,C));
  
  for (int i = 0; i < K; i++) {
    M *= 2;
  }
  cout << A + B + C + M - max(A,max(B,C)) << endl;
}

  

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
  int n;
  int score[1000];
  double stdev;

  double a;

  while(true){
    double sum1=0, sum2=0, ave=0;

    cin>>n;
    if(n==0){
      break;
    }else{
      for(int i=0; i<n; ++i){
        cin>>score[i];
        sum1 = sum1 + score[i];
      }
      ave =sum1/n;
      for(int i=0; i<n; ++i){
        a = score[i] - ave;
        a = a * a;
        sum2 = sum2 + a;
      }
      stdev = sum2/n;
      stdev = sqrt(stdev);
    }
    printf("%.15lf\n", stdev);
  }
}

Measured memory_bytes: 3124
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

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

	bool ok = true;
	int n = (int) s.length();

	for(int i =0; i< n / 2; ++i)
	{
		if(s[i] != s[n-i-1])
			ok = false;
	}

	int half = n / 2;
	for(int i = 0; i< (n / 4); ++i)
	{
		if(s[i] != s[half - i-1])
			ok = false;
	}

	half++;
	int new_half = (half + n) / 2;

	int k = 0;
	for(int i =half; i< new_half; ++i)
	{
		if(s[i] != s[n-k-1])
		{
			ok = false;
		}
		k++;
	}

	if(ok)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	


    return 0;
}

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

using namespace std;

const int Log=31, maxn=1e5+5;

unordered_map < int, int > bio;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int a;
	vector < int > l;
	int br=0;
	for(int i=0; i<n; i++){
		cin >> a;
		if(bio[a]==0){
			bio[a]=1;
			br++;
			l.push_back(a);
		}
		else{
			bio[a]++;
		}
	}
	sort(l.begin(), l.end());
	if(br==3){
		if(bio[l[0]]==bio[l[1]] && bio[l[1]]==bio[l[2]] && (l[0]^l[1])==l[2]){
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}
	}
	else if(br<3 && bio[0]>0){
		if(br==1){
			cout << "Yes\n";
		}
		else if(br==2 && bio[0]*2==bio[l[1]]){
			cout << "Yes\n";
		}
		else{
			cout << "No\n";
		}
	}
	else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3996
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    static PrintWriter out;
    static Scanner sc;

    static void solve() {
        int n = nextInt();
        int a = nextInt();

        if (n % 500 <= a) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

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

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

    static String nextString() {
        return sc.next();
    }

    static int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    static List<Integer> nextIntList(int n) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextInt());
        }
        return list;
    }

    static List<Long> nextLongList(int n) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextLong());
        }
        return list;
    }

    static <T extends Comparable<? super T>> void sort(List<T> list) {
        Collections.sort(list);
    }

    // greatest common divisor
    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

    // intをlength桁のbit文字列に変換
    static String toBinaryString(int input, int length) {
        return toBinaryString(input).substring(29 - length);
    }

    // intを29桁のbit文字列に変換
    static String toBinaryString(int input) {
        String ret = "";
        int max = 0x10000000;
        for (int i = 0; i < 29; i++) {
            int tmp = input / max;
            ret += tmp;
            input %= max;
            max /= 2;
        }
        return ret;
    }

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        sc = new Scanner(System.in);

        solve();

        out.flush();
        sc.close();
    }

}


Measured memory_bytes: 22996
N = int(input())
board = []

def isGoodBoard(b):
	for i in range(N):
		for j in range(i,N):
			if b[i][j] != b[j][i]:
				return False
	return True
for i in range(N):
	board.append(list(input()))

ans = 0
for i in range(N):
	board2 = [board[(x+i) % N] for x in range(N)]
	if isGoodBoard(board2):
		ans += N
print(ans)

Measured memory_bytes: 3828