akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> asum(n, 0), bsum(m, 0);
  rep(i, n) {
    int a;
    cin >> a;
    if (i) asum[i] = asum[i - 1];
    asum[i] += a;
  }
  rep(i, m) {
    int b;
    cin >> b;
    if (i) bsum[i] = bsum[i - 1];
    bsum[i] += b;
  }

  int ans = upper_bound(all(bsum), k) - bsum.begin();

  rep(i, n) {
    ll v = k - asum[i];
    if (v < 0) break;
    ans = max(ans, i + 1 + (int)(upper_bound(all(bsum), v) - bsum.begin()));
  }

  cout << ans << endl;
}


Measured memory_bytes: 6428
#include <stdio.h>

int main(void)
{
  int A,B;
  scanf("%d %d",&A,&B);
  if(A == B) printf("%d\n",2 * A);
  else if(A > B) printf("%d\n",2 * A - 1);
  else if(B > A) printf("%d\n",2 * B - 1);
  
  return 0;
}

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

def main():
    N, M = map(int, input().split())
    V = [True] * N
    H = [int(v) for v in input().split()]
    AB = [[int(v) - 1 for v in input().split()] for _ in range(M)]
    for a, b in AB:
        # if V[a] or V[b]:
        if H[a] <= H[b]:
            V[a] = False
        if H[a] >= H[b]:
            V[b] = False
    
    print(V.count(True))

if __name__ == '__main__':
    main()

Measured memory_bytes: 30384
using System;
using System.Collections.Generic;
using System.Linq;

public class Program {
    public static void Main() {
        var n = Library.ParseLong();

        long b = 10000000001;
        long a = 0;
        long max = (long)Math.Round(Math.Sqrt(n), MidpointRounding.AwayFromZero); 
        for (long i = 1; i <= max; i++) {
            if (n % i != 0)
                continue;

            a = i;
            b = n / i;
        }

        Console.WriteLine(Math.Max(a.ToString().Length, b.ToString().Length));
    }
}

static class Library {
    public static long ParseLong() {
        return long.Parse(Console.ReadLine());
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

bool has_two_rocks(string S, int A, int C) {
    for (int i = A; i <= C - 1; i++) {
        if (S[i] == '#' && S[i+1] == '#') {
            return true;
        }
    }
    return false;
}

bool has_three_spaces(string S, int A, int C) {
    for (int i = A; i <= C; i++) {
        if (i >= S.length() - 1 || i == 0) {
            continue;
        }
        if (S[i-1] == '.' && S[i] == '.' && S[i+1] == '.') {
            return true;
        }
    }
    return false;
}

int main(int argc, char const *argv[])
{
    int N, A, B, C, D;
    string S;
    cin >> N >> A >> B >> C >> D;
    A -= 1;
    B -= 1;
    C -= 1;
    D -= 1;
    cin >> S;
    if (C < D) {
        if (has_two_rocks(S, A, C) || has_two_rocks(S, B, D)) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else {
        // A jumps over B
        if (!has_two_rocks(S, B, D) && has_three_spaces(S, B, D) && !has_two_rocks(S, A, C)) {
            cout << "Yes" << endl;
        }  else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1156
import itertools
a=list(map(int,input().split()))
b=[]
ans=0
c=range(1,a[1]+1)
d=[]
for _ in range(a[2]):
    b.append(list(map(int,input().split())))


for i in itertools.combinations_with_replacement(c,a[0]):
    for l in range(a[2]):
        if i[b[l][1]-1]-i[b[l][0]-1]==b[l][2]:
            ans+=b[l][3]
    d.append(ans)
    ans=0
print(max(d))

Measured memory_bytes: 12848
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    possible = 0
    for i in range(1, N + 1):
        this_poss = 1
        if i < K:
            t = i
            while t < K:
                this_poss *= 0.5
                t *= 2
        possible += this_poss / N
    print(possible)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
unittest
{
	assert( [ "4 3", "1 2 3 4", "1 3", "2 3", "2 4" ].parse.expand.solve == 2 );
	assert( [ "6 5", "8 6 9 1 2 1", "1 3", "4 2", "4 3", "4 6", "4 6" ].parse.expand.solve == 3 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	input.popFront;
	auto hs = input.front.split.to!( long[] );
	auto abs = new long[ 2 ][ nm[ 1 ] ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	return tuple( hs, abs );
}

auto solve( long[] hs, long[ 2 ][] abs )
{
	auto nss = toAdjacencyList!true( hs.length, abs );
	auto ans = 0L;
	foreach( i, h; hs )
	{
		auto m = 0L;
		foreach( j; nss[ i ] )
		{
			m = max( m, hs[ j ] );
		}
		if( m < h ) ans++;
	}
	return ans;
}

// 辺配列から隣接リストを作成
auto toAdjacencyList( bool undirected = false )( long n, long[ 2 ][] es )
{
	auto nss = new long[][ n ];
	foreach( e; es )
	{
		nss[ e[ 0 ] ] ~= e[ 1 ];
		static if( undirected ) nss[ e[ 1 ] ] ~= e[ 0 ];
	}
	return nss;
}


Measured memory_bytes: 14192
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()

{
  //int A, B, C, X, Y;
  char s[101]={};
  char s_temp[101]={};
  char t[101]={};
  int len=0;
  //  int a, b, c;
  int a[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=101;
  int max=0;

  long cnt =0;
  long long A_temp;
//    int k=0;

  scanf("%s", s);
  scanf("%s", t);
//  printf("%s\n", s);

  len = strlen(s);

  for(j=0;j<len;j++){
    for(i=0;i<len;i++){
      if(i==len-1) s_temp[0]=s[i];
      else         s_temp[i+1]=s[i]; 
    }
    strcpy(s,s_temp);
   if(strcmp(s, t)==0){
     printf("Yes\n", s);
     return 0;
   }
  }
  
  printf("No\n");  
  
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    constexpr i64 inf = std::numeric_limits<i64>::max() / 2;
    int n, m;
    std::cin >> n >> m;
    std::vector<std::tuple<int, int, i64, int>> evs;
    for (int i = 0; i < m; i++) {
        int l, r;
        i64 c;
        std::cin >> l >> r >> c;
        evs.emplace_back(l - 1, 0, c, i);
        evs.emplace_back(r - 1, 1, c, i);
    }

    std::sort(evs.begin(), evs.end());

    std::vector<i64> dist(n, inf), rr(m);
    dist[0] = 0;
    auto it = evs.begin();
    std::set<std::pair<i64, int>> ss;
    for (int i = 0; i < n; i++) {
        if (i) {
            if (ss.empty()) {
                std::cout << -1 << std::endl;
                return 0;
            }
            dist[i] = ss.begin()->first;
        }
        while (it != evs.end() && std::get<0>(*it) == i) {
            int index = std::get<3>(*it);
            if (std::get<1>(*it) == 0) {
                i64 cc = dist[i] + std::get<2>(*it);
                ss.emplace(cc, index);
                rr[index] = cc;
            } else {
                ss.erase(ss.lower_bound(std::make_pair(rr[index], index)));
            }
            it++;
        }
    }

    std::cout << dist[n - 1] << std::endl;

    return 0;
}


Measured memory_bytes: 10732
#include <cstdio>
#include <algorithm>
#include <numeric>
using namespace std;

const int MAX_H = 500;
const int MAX_N = 100;

int H, N, P, M, K;

bool is_used[MAX_H];
int bridge[MAX_H];

double dp[MAX_H + 1][MAX_N + 2][MAX_N];

double solve(){
	dp[H][0][P-1] = 1.0;

	for(int h=H; h>=1; h--){
		if(is_used[h]){
			for(int i=0; i<=K; i++){
				for(int j=0; j<N; j++){
					dp[h-1][i][j] += dp[h][i][j];
				}
				swap(dp[h-1][i][bridge[h]], dp[h-1][i][bridge[h]+1]);
			}
		}
		else{
			int free_count = count(is_used + 1, is_used + (h + 1), false);
			for(int i=0; i<=K; i++){
				double chosen_prob = (double)(K - i) / free_count;
				for(int j=0; j<N; j++){
					if(j>0) dp[h-1][i+1][j-1] += chosen_prob * 1.0 / (N-1) * dp[h][i][j];
					if(j<N-1) dp[h-1][i+1][j+1] += chosen_prob * 1.0 / (N-1) * dp[h][i][j];
					dp[h-1][i+1][j] += chosen_prob * (1.0 - (j==0 || j==N-1 ? 1.0 : 2.0)/(N-1)) * dp[h][i][j];
					dp[h-1][i][j] += (1.0 - chosen_prob) * dp[h][i][j];
				}
			}
		}
	}

	return *max_element(dp[0][K], dp[0][K] + N);
}

int main(){
	scanf("%d%d%d%d%d",&H, &N, &P, &M, &K);
	for(int i=0; i<M; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		is_used[a] = true;
		bridge[a] = b - 1;
	}

	printf("%.10f\n", solve());

	return 0;
}

Measured memory_bytes: 0
function main(lines) {
  const N = n();
  
  const nSqrt =  Math.sqrt(N);
  let divisor;
  for (let i = 1; i <= nSqrt; i++) {
    if (N % i != 0) continue;
    divisor = i;
  }
  const ans = Math.max(divisor, N/divisor).toString(10).length;
  
  return ans;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 33068
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
 
p.sort()
q.sort()
r.sort()
 
tmp = p[-x:] + q[-y:]
tmp.sort()
 
from collections import deque
tmp = deque(tmp)
 
while r and tmp[0] < r[-1]:
    tmp.popleft()
    tmp.append(r.pop())
#whileの条件文はr=True(rが存在（r.popで中身が無くなるまで）)とrの一番大きい数字がtmpの一番小さなものより大きいこと
#その限りはtmpの一番小さな数を取り除き(tmp.popleft)、rの一番大きい（右側、r.pop）のものをくっつける(append)

print(sum(list(tmp)))

Measured memory_bytes: 110444
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

    struct City {
        int prefecture { 0 };
        int year { 0 };

        string key() const {
            return to_string(this->prefecture) + "_" + to_string(this->year);
        }
    };


    vector<City> cities {};
    map<string, int> indexMap {};
    map<int, vector<City>> cityMap;

    for (int i { 0 }; i < M; ++i) {
        int p, y;
        cin >> p >> y;

        if (!cityMap.count(p)) {
            cityMap[p] = {};
        }

        City city { p, y };
        cities.push_back(city);
        cityMap[p].push_back(city);
    }

    for (auto pair : cityMap) {
        int prefecture { pair.first };
        vector<City> cities { pair.second };
        vector<City> newCities {};

        sort(cities.begin(), cities.end(), [](City c1, City c2){
            return c1.year < c2.year;
        });

        for (int i { 0 }; i < cities.size(); ++i) {
            City c = cities[i];
            indexMap[c.key()] = i + 1;
        }

        cityMap[prefecture] = cities;
    }

    for (const City& c : cities) {
        printf("%06d%06d\n", c.prefecture, indexMap[c.key()]);
    }

    return 0;
}


Measured memory_bytes: 20980
S = input()

count_list = []
for i in S:
    if i == 'A' or i == 'C' or i == 'G' or i == 'T':
        count_list.append(True)
    else:
        count_list.append(False)

l = len(S)
freq_list = []
for i in range(l):
    count = 0
    for j in range(l-i):
        if count_list[i+j] is True:
            count += 1
            freq_list.append(count)
        else:
            freq_list.append(count)
            break

print(max(freq_list))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int ret = 0;
  if(N>=2){
    ret += N*(N-1)/2;
  }
  if(M>=2){
    ret += M*(M-1)/2;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
//const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
//約数の列挙O(√n)
vector<ll>divisor(ll n){
  vector<ll>res;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(n/i);
    }
  }
  return res;
}
ll factorial(ll x){
  if(x==0)return 1;
  return x*factorial(x-1)%MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll comb(ll n, ll r){
  ll res=1;
    for(ll i=0;i<r;i++){
      res*=n-i;
      res%=MOD;
    }
  res*=modpow(factorial(r),MOD-2,MOD);
  res%=MOD;
  return res;
}

int main(){
  
  ll a,b,c;cin>>a>>b>>c;
  cout<<min({a+b,b+c,c+a})<<endl;
}

Measured memory_bytes: 256
/* #region template */
#![allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, Bytes, Read, Stdin, StdinLock, Stdout, StdoutLock, Write};
use std::iter::{repeat, repeat_with};
use std::mem::swap;
use std::str::FromStr;
#[allow(dead_code)]
struct Io<'a> {
    reader: Bytes<StdinLock<'a>>,
    writer: StdoutLock<'a>,
    in_buf: [u8; BUF_SIZE],
}
#[allow(dead_code)]
impl<'a> Io<'a> {
    fn new(stdin: &'a Stdin, stdout: &'a Stdout) -> Io<'a> {
        Io {
            reader: stdin.lock().bytes(),
            writer: stdout.lock(),
            in_buf: [0; BUF_SIZE],
        }
    }
    fn r<T: FromStr>(&mut self) -> T {
        let mut count = 0;
        loop {
            match self.reader.next() {
                Some(Ok(b' ')) | Some(Ok(b'\n')) => break,
                Some(Ok(c)) => self.in_buf[count] = c,
                _ => panic!(),
            }
            count += 1;
        }

        let s = unsafe { std::str::from_utf8_unchecked(&self.in_buf[0..count]) };
        s.parse().unwrap_or_else(|_| panic!())
    }
    fn ru(&mut self) -> usize {
        self.r()
    }
    fn iter<'b, T>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter::new(self)
    }
    fn c<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        self.iter().take(n).collect()
    }
    fn cu(&mut self, n: usize) -> Vec<usize> {
        self.c(n)
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.writer, "{}", v).unwrap();
    }
    fn wn<T: std::fmt::Display>(&mut self, v: T) {
        write!(self.writer, "{}", v).unwrap();
    }
}
#[allow(dead_code)]
struct IoIter<'a: 'b, 'b, T> {
    io: &'b mut Io<'a>,
    m: std::marker::PhantomData<T>,
}
#[allow(dead_code)]
impl<'a: 'b, 'b, T> IoIter<'a, 'b, T> {
    fn new(io: &'b mut Io<'a>) -> IoIter<'a, 'b, T> {
        IoIter {
            io,
            m: std::marker::PhantomData,
        }
    }
}
impl<'a, 'b, T: FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<Self::Item> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let mut io = Io::new(&stdin, &stdout);
    unsafe {
        solve(&mut io);
    }
}
/* #endregion */

const BUF_SIZE: usize = 4096;

unsafe fn solve(io: &mut Io) {
    let n = io.ru();
    let s: Vec<char> = io.r::<String>().chars().collect();

    let mut r = 0;
    let mut g = 0;
    let mut b = 0;

    for si in &s {
        match si {
            'R' => r += 1,
            'G' => g += 1,
            'B' => b += 1,
            _ => (),
        }
    }

    let mut count: usize = r * g * b;
    for i in 0..n {
        for j in i + 1..n {
            if s[i] != s[j] {
                let k = 2 * j - i;
                if k < n && s[k] != s[i] && s[k] != s[j] {
                    count -= 1;
                }
            }
        }
    }
    io.w(count);
}


Measured memory_bytes: 2148
#include <cstdio>
#include <algorithm>
#define mp make_pair
#define fs first
#define sc second
#define rep(i,j,k) for (i=j;i<=k;i++)
#define down(i,j,k) for (i=j;i>=k;i--)
using namespace std;
const int N=2e5+5,INF=2e9,mod=1e9+7;
typedef pair<int,int> Pair;
int n,i,j,p,sum,ans,v[N],l[N],r[N],dp[N];
Pair a[N];
int main()
{
//	freopen("incubator.in","r",stdin);
//	freopen("incubator.out","w",stdout);
	scanf("%d",&n);
	rep(i,1,n) scanf("%d%d",&a[i].fs,&a[i].sc),v[i]=a[i].sc;
	sort(a+1,a+1+n);
	sort(v+1,v+1+n);
	rep(i,1,n)
	{
		p=max(p,a[i].sc);
		r[i]=lower_bound(v+1,v+1+n,p)-v;
	}
	p=INF;
	down(i,n,1)
	{
		p=min(p,a[i].sc);
		l[i]=lower_bound(v+1,v+1+n,p)-v;
	}
	l[0]=0; r[0]=0; dp[0]=sum=1; p=0;
/*	rep(i,1,n)
	{
		printf("%d %d\n",l[i],r[i]);
	}
*/
	rep(i,1,n)
	{
		while (r[p]<l[i]-1 && p<i)
		{
			sum=(sum+mod-dp[p])%mod;
			p++;
		}
		dp[i]=sum;
		sum=(sum+dp[i])%mod;
		if (r[i]==n) ans=(ans+dp[i])%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4864
S = list(input())
l_index = {}
r_index = {}
l = 0
r = 0
n = len(S) - 1
for i in range(len(S)):
    j = n - i
    l += 1
    r += 1
    if S[j] == 'L':
        l = 0
    if S[i] == 'R':
        r = 0
    r_index[i] = r
    l_index[j] = l

p = [0] * len(S)
for i in range(len(S)):
    s = S[i]
    if s == 'R':
        if l_index[i] % 2 == 0:
            p[i + l_index[i]] += 1
        else:
            p[i + l_index[i] - 1] += 1
    else:
        if r_index[i] % 2 == 0:
            p[i - r_index[i]] += 1
        else:
            p[i - r_index[i] + 1] += 1

print(*p)

Measured memory_bytes: 74488
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define endl '\n';
typedef long long ll;
typedef long double ld;
using namespace std;



int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a = [list(input()) for _ in range(h)]

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            row[i]=True
            col[j]=True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()


Measured memory_bytes: 4596
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scanf("%d %d %d/n", &n, &a, &b)

	if a > b {
		fmt.Println(0)
	} else if (n == 1) && (a != b) {
		fmt.Println(0)
	} else {
		max := b*(n-1) + a
		min := b + (n-1)*a
		fmt.Println((max - min + 1))
	}

}


Measured memory_bytes: 1860
#include <stdio.h>

int main(void)
{
   int N;
   int A[100001];
   int B[100001]={0,};
   scanf("%d",&N);
   int n;
   int ans=0;
   for(n=0;n<N;n++){
   	scanf("%d",&A[n]);
   	if(A[n]<=N){
   		B[A[n]]++;
   	}else{
   		ans++;
   	}
   }
   for(n=0;n<N;n++){
   	if(B[n+1]>0&&B[n+1]<=100000&&B[n+1]!=n+1){
   		if(B[n+1]>n+1){
   		ans+=B[n+1]-(n+1);
   		}else{
   			ans+=B[n+1];
   		}
   	}
   }
   printf("%d\n",ans);
	return 0;
}

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> grid(h);
    rep(i, h) cin >> grid[i];

    int ans = 0;
    for (int bitr = 0; bitr < (1 << h); bitr++) {
        for (int bitc = 0; bitc < (1 << w); bitc++) {
            int cnt = 0;
            rep(i,h){
                rep(j,w){
                    if (1 & (bitr >> i)) continue;
                    if (1 & (bitc >> j)) continue;
                    if (grid[i][j] == '.') continue;
                    cnt++;
                }
            }
            if (cnt == k) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	ll a[30]={};
	string w;
	cin>>w;
	rep(i,w.size()){
		a[w[i]-'a']++;
	}
	bool b=true;
	rep(i,30){
		if(a[i]%2!=0){
			b=false;
			break;
		}
	}
	if(b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    A, B, C, X, Y = map(int, input().split())
    ans = 10**10
    max_c = max(X, Y) + 1
    for i in range(max_c):
        num_c = i * 2
        num_a = max(0, X - i)
        num_b = max(0, Y - i)
        price = num_a * A + num_b * B + num_c * C
        ans = min(price, ans)
    print(ans)

if __name__ == '__main__':
    main()


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

typedef long long ll;

struct line {
  ll m, c;
  line(const ll& mm, const ll& cc) : m(mm), c(cc) {
  }
  ll eval(const ll& x) const {
    return m * x + c;
  }
};

template <class Compare = std::less<ll>>
struct li_chao {
  template <class Compare2>
  struct node {
    ll s, e, m;
    node *left, *right;
    line cur;
    const Compare2 cmp;

    bool no_line;

    node(ll s, ll e)
        : s(s), e(e), m(s + (e - s) / 2), left(0), right(0), cur(0, 0), cmp() {
      no_line = true;
    }

    node(ll s, ll e, line l) : node(s, e) {
      cur = l;
      no_line = false;
    }

    ~node(void) {
      delete left;
      delete right;
    }

    void insert(line l) {
      if (no_line) {
        cur = l;
        no_line = false;
        return;
      }

      const bool b1 = cmp(l.eval(s), cur.eval(s));
      const bool b2 = cmp(l.eval(m), cur.eval(m));

      if (b2)
        std::swap(cur, l);

      if (s == e)
        return;

      if (b1 != b2) {
        if (left == nullptr)
          left = new node(s, m, l);
        else
          left->insert(l);
      } else {
        if (right == nullptr)
          right = new node(m + 1, e, l);
        else
          right->insert(l);
      }
    }

    ll query(const ll& x) {
      ll y = cur.eval(x);
      if (x < m && left)
        y = std::min(y, left->query(x), cmp);
      else if (x > m && right)
        y = std::min(y, right->query(x), cmp);
      return y;
    }
  };

  node<Compare>* root;

  li_chao(ll ss, ll ee) {
    root = new node<Compare>(ss, ee);
  }

  ~li_chao(void) {
    delete root;
  }

  void insert(const line& l) {
    root->insert(l);
  }

  ll query(ll x) {
    return root->query(x);
  }
};

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

  ll n, c;
  std::cin >> n >> c;

  li_chao<std::less<ll>> lct(0, 1e6 + 1);

  ll h;
  std::cin >> h;

  lct.insert({-2 * h, h * h});

  ll ans;
  for (ll i = 1; i < n; ++i) {
    std::cin >> h;

    ans = lct.query(h) + h * h + c;

    lct.insert({-2 * h, h * h + ans});
  }

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

  return 0;
}


Measured memory_bytes: 15872
"""
NTC here
"""
import sys
inp = sys.stdin.readline


def input(): return inp().strip()


flush = sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**25)


def iin(): return int(input())


def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input


def main():
    l = iin()
    a = l/3
    print(pow(a, 3))
main()
# threading.Thread(target=main).start()


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

#define int long long
#define F first
#define S second
#define vi vector<int>


void mymain(){
    int n;
    cin >> n;
    string a,b;
    cin >> a >> b;
    string c;
    for(int i=0;i<n;i++){
        c += a[i];
        c += b[i];
    }
    cout << c << endl;

}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        mymain();
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}
const int N=1e4+10,mod=1e9+7;
typedef long long ll;
ll d,dp[N][102][3];
string k;
int solve(int i=0,int sum=0,bool f=0){
    if(i==k.length()){
        if(sum==0)return 1;
        return 0;
    }
    ll &ret=dp[i][sum][f];
    if(~ret)return ret;

    int num;
    if(!f)num=k[i]-'0';
    else num=9;
    ret=0;
    for(int j=0;j<=num;j++){
        bool flag=f;
        if(j<num)flag=1;
        int tmp=sum;
        tmp+=j;
        tmp%=d;
        ret+=solve(i+1,tmp,flag);
        ret%=mod;
    }
    return ret%mod;
}
int main(){
    Elhabashy
    input();
    cin>>k>>d;
    memset(dp,-1,sizeof dp);
    cout<<(solve()-1+mod)%mod<<endl;
}


Measured memory_bytes: 28344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        Tuple<long, long>[] robots = new Tuple<long, long>[n];

        for (int i = 0; i < n; i++)
        {
            long x = sc.NextLong();
            long l = sc.NextLong();
            robots[i] = Tuple.Create(x - l, x + l);
        }

        robots = robots.OrderBy(t => t.Item2).ToArray();

        long answer = n;

        long right = int.MinValue;
        foreach (var robot in robots)
        {
            if (robot.Item1 < right)
            {
                answer--;
            }
            else
            {
                right = robot.Item2;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 51172
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()

#bを決めて、条件を満たすa,cの組を求める
def down_bin(i,list):
    ok=-1
    ng=n
    while abs(ng-ok)>1:
        mid=(ng+ok)//2
        if list[mid]<i:ok=mid
        else:ng=mid
    return ok+1
def up_bin(i,list):
    ok=n
    ng=-1
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if list[mid]>i:ok=mid
        else:ng=mid
    return n-ok

ans=0
for i in b:
    ans+=down_bin(i,a)*up_bin(i,c)
print(ans)

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;i++) cin>>h[i];
  if(K>=N){
    cout<<abs(h[N-1]-h[0])<<endl;
    return 0;
  }
  vector<long> c(N,1234567890);
  c[0]=0;

  for(int i=0;i<N;i++){
    for(int j=1;j<min(K+1,N-i);j++){
      c[i+j] = min(c[i+j], c[i]+abs(h[i+j]-h[i]));
    }
  }

  //for(int i=0;i<N;i++) cout<<c[i]<<endl;
  cout<<c[N-1]<<endl;




  }


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

using namespace std;
#define ll long long

const int A = 1000000000;
ll s;
int main() {
	scanf("%lld", &s);
	printf("%d %d %lld %lld %d %d\n", A, 0, (s-1)%A+1, (s-1)/A+1, 0, 1);
	return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<functional>
#include<algorithm>
#include<queue>
using namespace std;
long long ma[100001],mia[100001];
int a[300000];
int main(void)
{
	priority_queue<long long> mxq;
	priority_queue<long long ,vector<long long >, greater<long long> > mnq;
	int i,j,n,p;
	long long mx,sum;
	
	scanf("%d",&n);
	for(i=0;i<n*3;i++)	scanf("%d",&a[i]);
	sum=0;
	for(i=0;i<n;i++)	{
		sum+=a[i];
		mnq.push(a[i]);
	}
	p=0;
	ma[p]=sum;	p++;
//	printf("sum=%lld\n",sum);
	for(i=n;i<n*2;i++)	{
		mnq.push(a[i]);
		sum=sum+a[i];
		sum=sum-mnq.top();
//		printf("sum=%lld\n",sum);
		mnq.pop();
		ma[p]=sum;
		p++;
	}
	sum=0;
	for(i=3*n-1;i>=n*2;i--)	{
		sum+=a[i];
		mxq.push(a[i]);
	}
//	printf("sum=%lld\n",sum);
	p=n;
	mia[p]=sum;	p--;
	for(i=n*2-1;i>=n;i--)	{
		mxq.push(a[i]);
		sum=sum+a[i];
		sum=sum-mxq.top();
//		printf("sum=%lld\n",sum);
		mxq.pop();
		mia[p]=sum;
		p--;
	}	
	mx=ma[0]-mia[0];
	for(i=1;i<=n;i++)	{
		mx=max(mx,ma[i]-mia[i]);
	}
	printf("%lld\n",mx);
	return 0;
}
	

Measured memory_bytes: 4724
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin>>n;
    if(n%1000 == 0) cout << 0 << endl;
    else            cout << 1000-n%1000 << endl;
}


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

int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  cout << (a[n - 1] - a[0]) << endl;
}


Measured memory_bytes: 256
use proconio::{input, fastout};

fn make_dp(n:usize) -> Vec<i32> {
    let mut dp = vec![0; n];
    for i in 1 .. n {
        let bits = i.count_ones() as usize;
        dp[i] = dp[i % bits] + 1;
    }
    dp
}

fn source_dp(n:usize, m:u32, x:&[u8]) -> (i32, i32, Vec<i32>) {
    let mut dp = vec![1;n];
    let mut score = 0;
    let m = m as i32;

    if m == 0 {
        return (m, score, dp);
    }

    for i in (0 .. n - 1).rev() {
        dp[i] = (dp[i + 1] * 2) % m;
    }
    
    for i in 0 .. n {
        if x[i] == b'1' {
            score = (score + dp[i]) % m;
        } 
    }
    (m, score + m, dp)
}

#[fastout]
fn main() {
    input!{
        n:usize,
        x:String,
    }

    let dp = make_dp(n);
    let x:Vec<u8> = x.as_bytes().to_vec();
    let popcount = x.iter().filter(|&b| *b == b'1').count() as u32;
    let (mod1, score1, dp1) = source_dp(n, popcount + 1, &x);
    let (mod2, score2, dp2) = source_dp(n, popcount - 1, &x);
    for i in 0 .. n {
        if x[i] == b'0' {
            let k = (score1 + dp1[i]) % mod1;
            println!("{}", dp[k as usize] + 1);
        } else if popcount == 1 {
            println!("{}", 0);
        } else {
            let k = (score2 - dp2[i]) % mod2;
            println!("{}", dp[k as usize] + 1);
        }
    }
}


Measured memory_bytes: 5024
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const long long SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑





void dijkstra(int n) {
	priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>>que;
	fill(dij.begin(), dij.end(), INF);
	dij[n] = 0;
	que.push(pair<long long, long long>(0, n));

	while (!que.empty()) {
		pair<long long, long long>p = que.top();
		que.pop();
		long long mon = p.second;
		if (dij[mon] < p.first) continue;
		for (int i = 0; i < G[mon].size(); ++i) {
			edge e = G[mon][i];
			if (dij[e.to] > dij[mon] + e.cost) {
				dij[e.to] = dij[mon] + e.cost;
				que.push(pair<long long, long long>(dij[e.to], e.to));
			}
		}
	}
}

int main() {
	int n;
	cin >> n;
	G.resize(n + 1);
	dij.resize(n + 1);
	for (int i = 0; i < n - 1; ++i) {
		long long a, b, c;
		cin >> a >> b >> c;
		addedge(a - 1, b - 1, c % 2);
	}
	dijkstra(0);
	for (int i = 0; i < n; ++i) {
		cout << dij[i] % 2 << endl;
	}
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int H, N; cin >> H >> N;
    int total = 0;
    F0R(i, N) {
        int c; cin >> c; total += c;
    }

    cout << ((total >= H) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N=int(input())
a=[]
b=[]
for i in range(N):
  x,y=input().split()
  a.append(float(x))
  b.append(y)
total=0
for j in range(N):
  if b[j]=='JPY':
    total += a[j]
  else:
    total += 380000.0*a[j]
print(total)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int m, n;
int buckets[60];
int main(){
  cin>>n>>m;
  int city[2*m];for(int i=0;i<2*m;i++)cin>>city[i];
  for(int i=0;i<2*m;i++){buckets[city[i]]++;}
  for(int i=1;i<=n;i++){cout<<buckets[i]<<"\n";}
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int X = fs.nextInt();
        int N = fs.nextInt();
        int[] arr = new int[102];

        for (int i = 0; i < N; ++i) {
            arr[fs.nextInt()] = 1;
        }

        int ans = 0;
        int tmp = Integer.MAX_VALUE;
        for (int i = 0; i <= 101; ++i) {
            if (N == 0) {
                ans = X;
                break;
            }
            if (arr[i] == 1) continue;
            if (tmp > Math.abs(X - i)) {
                tmp = Math.abs(X - i);
                ans = i;
            }
        }

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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




Measured memory_bytes: 32484
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
  char arr[][] ;
  long dp[][];
  long M = 1000000007;
  	
	public static void main (String[] args) throws java.lang.Exception
	{
      	FastReader s = new FastReader();
      	int m = s.nextInt();
      	int n = s.nextInt();
      	Main ob = new Main();
		ob.arr = new char[m][n];
      	ob.dp = new long[m][n];
		for(int i=0;i<m;i++){
          String st = s.next();
          for(int j = 0;j<n;j++)
            ob.arr[i][j] = st.charAt(j);
        }
      for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
          ob.dp[i][j]=-1;
		long ans = ob.getCount(m-1,n-1);
      	System.out.println(ans);
	}

  long getCount(int i, int j){
    if(dp[i][j]!=-1) return dp[i][j];
    if(i==0&&j==0) return 1;
    if(arr[i][j]=='#') return 0;
    long a = 0, b=0;
    if(i-1>=0)
     a=getCount(i-1,j);
    if(j-1>=0)
      b=getCount(i,j-1);
    dp[i][j] = (a%M+b%M)%M;
    return dp[i][j];
  }


  static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36668
#include <bits/stdc++.h>
using namespace std;
string s;
map<int,int>mp, cnt;
int main(){
    cin>>s;
    int cur = 0, x;
    for(int i = 0; i < s.size(); ++i){
        cur ^= (1 << (s[i] - 'a'));
        if(cur == 0){
            if(i == s.size() - 1){
                cout<<1<<endl;return 0;
            }
        }
        else{
            int x = 1e8;
            if(cnt[cur] > 0){
                x = min(x, cnt[cur]);
            }
            for(int j = 0; j < 26; ++j){
                if((cur ^ (1 << j)) == 0){ x = 1;break;}
                else{
                    if(cnt[cur ^ (1 << j)] > 0) x = min(x, cnt[cur ^ (1 << j)] + 1);
                    else{
                        x = min(x, cnt[cur ^ (1 << (s[i] - 'a'))] + 1);
                    }
                }
            }
            cnt[cur] = x;
            if(i == s.size() - 1){
                cout<<x<<endl;return 0;
            }
        }
      //  cout<<cnt[cur]<<endl;
    }
}



Measured memory_bytes: 204292
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

class Point{
private:
    double x;
    double y;
public:
    double getX(){return x;};
    double getY(){return y;};
    void setPoint(double inX, double inY){x = inX; y = inY;};
    void disp(){printf("%.12f %.12f\n", x,y);}
};


int main(){
    int n;
    double inX, inY;
    Point P, P1, P2, Output;
    cin >> inX >> inY;
    P1.setPoint(inX, inY);
    cin >> inX >> inY;
    P2.setPoint(inX, inY);
    cin >> n;
    double ax = P2.getX() - P1.getX();
    double ay = P2.getY() - P1.getY();
    double length = ax*ax + ay*ay;
    for(int i=0; i<n; i++){
        cin >> inX >> inY;
        P.setPoint(inX, inY);
        double bx = P.getX() - P1.getX();
        double by = P.getY() - P1.getY();
        double dot = ax*bx + ay*by;

        double outX = ax * dot/length + P1.getX();
        double outY = ay * dot/length + P1.getY();

        bx = outX - inX;
        by = outY - inY;
        outX += bx;
        outY += by;

        Output.setPoint(outX, outY);
        Output.disp();
    }
    return 0;
}

Measured memory_bytes: 1252
n=int(input())
S=tuple(map(int,input().split()))
ans=0
for c in range(1,n-1):
    k=1
    tmp=0
    while c*k<n-1:
        a=n-1-k*c
        if a<=c or (a<=k*c and a%c==0):
            break
        tmp+=S[n-1-k*c]+S[k*c]
        k+=1
        ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 63216
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 br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      String[] num;
      int a,b,t,gdc;
      long lcm;
      StringBuilder result = new StringBuilder();
      while(true) {

        if( ((line = br.readLine()) == null) || line.isEmpty() ) break;

        num = line.split(" ");
        a = Integer.parseInt(num[0]);
        b = Integer.parseInt(num[1]);
        if( a<b ) {
          t=a; a=b; b=t;
        }

        gdc = gdc(a, b);
        lcm = lcm(a, b, gdc);

        result.append(gdc).append(" ").append(lcm).append("\n");
      }

      System.out.print(result);
    }
    catch( IOException e) {
      System.out.println("IOException!");
    }
  }

  private int gdc(int x, int y) {
    int d = x%y;
    if( d == 0 ) return y;
    else return gdc(y, d);
  }

  private long lcm(long x, long y, int gdc) {
    return x * y / gdc;
  }
}


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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	friend modnum inv(const modnum& m) { return m.inv(); }
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	friend modnum neg(const modnum& m) { return m.neg(); }

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9)+7>;

num fact(int n) {
	return n ? n * fact(n-1) : 1;
}
num pref(int r, int c) {
	if (r < 0 || c < 0) return 0;
	return fact(r+c+2)/(fact(r+1) * fact(c+1)) - 1;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2; r1--, c1--;
	cout << pref(r1, c1) + pref(r2, c2) - pref(r1, c2) - pref(r2, c1) << '\n';

	return 0;
}


Measured memory_bytes: 62720
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
const int LLINF = 1LL << 60;

signed main()
{
  int N;
  int cand[26], cnt[26];
  string S;
  
  fill_n(cand, 26, LLINF);
  
  cin >> N;
  Rep(i, N) {

    fill_n(cnt, 26, 0);
    
    cin >> S;
    Rep(j, S.size()) cnt[S[j] - 'a']++;

    Rep(j, 26) {
      cand[j] = min(cand[j], cnt[j]);
    }
  }

  Rep(i, 26) {
    Rep(j, cand[i]) {
      cout << (char)('a' + i);
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int e[169];
int main(){
	string s;
	while(cin>>s){
		for(int i=0;i<s.size();i++){
			if(('A'<=s[i]&&s[i]<='Z')||('a'<=s[i]&&s[i]<='z')){
				if('A'<=s[i]&&s[i]<='Z'){
					s[i]-='A'-'a';
				}
				e[(int)(s[i]-'a')]++;
			}
		}
	}
	for(int i=0;i<26;i++){
		cout<<(char)(i+'a')<<" : "<<e[i]<<endl;
	}
}



Measured memory_bytes: 3208
N = int(input())
x_y = [[int(_) for _ in input().split(" ")] for _ in range(N)]

n_path = 1
for i in range(N):
    n_path = n_path * (i + 1)

import math

distance_list = []
for i in range(N * (N-1)):
    j = i + 1
    while j < N:
        distance = math.sqrt((x_y[i][0] - x_y[j][0])**2 + (x_y[i][1] - x_y[j][1])**2)
        distance_list.append(distance)
        j = j + 1

print(sum(distance_list) * 2/N )

Measured memory_bytes: 3064
#include <stdio.h>

long long int gcd(long long int m,long long int n){
	return ((n == 0) ? m : gcd(n,m % n));
}

long long int lcm(long long int m,long long int n){
	long long int g = gcd(m,n);
	return m / g * n;
}

int count(int a,int m){
	int num = 1;
	int count = 0;
	
	do{
		num = (num*a)%m;
		count++;
	}while(num != 1);
	
	return count;
}

int main(int argc,char** argv){
	int a1,a2,a3,m1,m2,m3;
	long long int x1,x2,x3,l;
	
	for(;;){
		scanf("%d %d %d %d %d %d",&a1,&m1,&a2,&m2,&a3,&m3);
		
		if(a1 == 0 || m1 == 0 || a2 == 0 || m2 == 0 || a3 == 0 || m3 == 0){
			break;
		}
		
		printf("%lld\n",lcm(count(a1,m1),lcm(count(a2,m2),count(a3,m3))));
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int n, k;
	string s;
	cin >> n >> s >> k;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == s[k-1])continue;
		s[i] = '*';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256