akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int cnt=1;
    ll sum=K;

    REP2(i,1,N){
        sum*=(K-1);
    }

    cout << sum << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

void solve_abc_d() {
	ll n, m;
	//ll a, b;
	ll x, y, z;
	ll h, w;
	ll k;
	ll l_ans = 0;

	cin >> x >> y >> z >> k;

	V a, b, c;
	ll tmp;
	rep(i, x) {
		cin >> tmp;
		a.push_back(tmp);
	}
	rep(i, y) {
		cin >> tmp;
		b.push_back(tmp);
	}
	rep(i, z) {
		cin >> tmp;
		c.push_back(tmp);
	}

	V ab;
	rep(i, x) rep(j, y) {
		ab.push_back(a[i] + b[j]);
	}

	sort(RALL(ab));

	priority_queue<ll> ans;
	rep(i, min(x*y, k)) {
		rep(j, z) {
			ans.push(ab[i] + c[j]);
		}
	}

	rep(i, k) {
		cout << ans.top() << "\n";
		ans.pop();
	}

	return;
}

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

	solve_abc_d();

	return 0;
}


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

using namespace std;

typedef long long LL;

const int MAX_N = 1e5 + 10;

int n;
LL a[MAX_N], pfx[MAX_N] = {};

LL cal(bool neg)
{
	LL now, delta = 0, cnt = 0;
	for (int i = 1; i <= n; i++, neg = !neg)
	{
		now = pfx[i] + delta;
		
		if (now != 0 && (now < 0) == neg) continue;
		
		if (neg)
		{
			cnt += now + 1;
			delta -= now + 1;
		}//if
		else
		{
			cnt += 1 - now;
			delta += 1 - now;
		}//else
	}//for i
	
	return cnt;
}//cal

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		pfx[i] = a[i] + pfx[i - 1];
	}//for i
	
	cout << min(cal(true), cal(false)) << '\n';
	
	return 0;
}//main


Measured memory_bytes: 1792
package main

import (
  "fmt"
)

func main() {
  var a, b, c, d uint64
  fmt.Scan(&a, &b, &c, &d)

  result := b - a + 1 
  start := a/c + 1
  if a%c == 0 {
    start--
  }
  end := b/c
  result -= end - start + 1
  
  start = a/d + 1
  if a%d == 0 {
    start--
  }
  end = b/d
  result -= end - start + 1

  e := c * d / gcd(c, d)
  start = a/e + 1
  if a%e == 0 {
    start--
  }
  end = b/e
  result += end - start + 1
  fmt.Println(result)
}

func gcd(a uint64, b uint64) uint64 {
  if b == 0 {
    return a
  }
  return gcd(b, a % b)
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

			System.out.println(b+b-a);

	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    int mina = 0;
    int maxb = 0;
    rep(i, n){
        if(s.at(i) == '('){
            a++;
            b++;
        }else{
            a--;
            b--;
        }
        if(b < 0) b = 0;
        if(mina > a) mina = a;
        if(maxb < b) maxb = b;
    }
    rep(i, -mina) s = '(' + s;
    rep(i, b) s += ')';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq
import sys

input = sys.stdin.readline

N, M = map(int, input().split())
edge = [[] for _ in range(N + 1)]
for i in range(M):
    a, b, c = map(int, input().split())
    edge[a].append((b, c, i+1))
    edge[b].append((a, c, i+1))

used = [False] * (M + 1)


def dijkstra(start):
    inf = 10**18
    dist = [inf] * (N + 1)
    visited = [False] * (N + 1)
    dist[start] = 0
    visited[start] = False
    node = [(0, start, 0)]
    while node:
        d, s, e = heapq.heappop(node)
        if dist[s] < d:
            continue
        used[e] = True

        for t, cost, ind in edge[s]:
            if dist[t] > d + cost:
                dist[t] = d + cost
                heapq.heappush(node, (d + cost, t, ind))
    return


for i in range(1, N + 1):
    dijkstra(i)

ans = used.count(False)
print(ans)



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

int main(){
    std::string a;
    cin >> a;
 
    if(a=="AAA") cout << "No" << endl;
    if(a=="ABA") cout << "Yes" << endl;
    if(a=="AAB") cout << "Yes" << endl;
    if(a=="ABB") cout << "Yes" << endl;

    if(a=="BAA") cout << "Yes" << endl;
    if(a=="BBA") cout << "Yes" << endl;
    if(a=="BAB") cout << "Yes" << endl;
    if(a=="BBB") cout << "No" << endl; 

}

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

int main() {
  // string str = "abcxyz";
  // reverse(str.begin(), str.end());
  // cout << str << endl;
  string str;
  int n;
  cin >> str >> n;

  rep(i, n) {
    string q, ab;
    int a, b;
    cin >> q >> a >> b;
    ab = str.substr(a, b-a+1);

    if (q == "print") {
      cout << ab << endl;
    } else if (q == "reverse") {
      reverse(ab.begin(), ab.end());
      str = str.replace(a, b-a+1, ab);
    } else if (q == "replace"){
      string strrep;
      cin >> strrep;
      str = str.replace(a, b-a+1, strrep);
    } 
  }
  
  return 0;
}



Measured memory_bytes: 3216
mkList :: Int -> [Int] -> [[Int]]
mkList n x
  | null x = [[]]
  | otherwise = take n x : mkList n (drop n x)

main = getContents >>= mapM_ print . reverse . tail . init . map sum . (\(_:y:xs) -> mkList y (zipWith (*) (cycle $ take y $ reverse xs) (reverse xs))) . map read . words

Measured memory_bytes: 7584
n = gets.to_i
a = gets.split.map(&:to_i)

dpp,dpn = 2.times.map{Array.new(n,0)}

b = [[n-1,10**9]]
f = a[-1]
(n-2).downto(0) do |i|
    if f >= a[i]
        dpp[i] = dpp[i+1]
        j = 0
        while a[i]*(4**(j+1)) <= f
            j += 1
        end
        b.push([i,j]) if j > 0
    else
        dpp[i] = dpp[i+1]
        j = 0
        while f*(4**j) < a[i]
            j += 1
        end
        while j > 0
            if b[-1][1] >= j
                dpp[i] += (b[-1][0]-i)*2*j
                b[-1][1] -= j
                j = 0
                b.pop if b[-1][1] == 0
            else
                dpp[i] += (b[-1][0]-i)*2*b[-1][1]
                j -= b[-1][1]
                b.pop
            end
            #p dpp[i]
        end
    end
    #p(i,b,dpp[i],"")
    f = a[i]
end
dpp.push(0)

b = [[0,10**9]]
f = -a[0]*2
dpn[0] = 1
for i in 1..n-1
    if f <= -a[i]*2
        dpn[i] = dpn[i-1]+1
        j = 0
        while f <= -a[i]*2*(4**(j+1))
            j += 1
        end
        b.push([i,j]) if j > 0
    else
        dpn[i] = dpn[i-1]+1
        j = 0
        while f*(4**j) > -a[i]*2
            j += 1
        end
        while j > 0
            if b[-1][1] >= j
                dpn[i] += (i-b[-1][0])*2*j
                b[-1][1] -= j
                j = 0
                b.pop if b[-1][1] == 0
            else
                dpn[i] += (i-b[-1][0])*2*b[-1][1]
                j -= b[-1][1]
                b.pop
            end
        end
    end
    f = -a[i]*2
end
dpn.unshift(0)

ans = dpp[0]+dpn[0]
for i in 1..n
    ans = dpp[i]+dpn[i] if ans > dpp[i]+dpn[i]
end
#p dpp,dpn
puts ans

Measured memory_bytes: 23852
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll hoge(ll x){
	if (x >= 3) return x*x*x;
	if (x == 2) return x*(x-1)*3 + x;
	return x;
}

int main(){
	ll n, k;
	cin >> n >> k;
	if (k%2){
		ll temp = n/k;
		cout << hoge(temp) << endl;
	}else{
		ll temp1 = n/k;
		ll temp2 = (n+k/2)/k;
		cout << hoge(temp1) + hoge(temp2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	t := getNextString(scanner)
	n := len(t)
	for i := 0; i < n; i++ {
		if t[i] == '?' {
			fmt.Fprintf(writer, "%c", 'D')
			continue
		}
		fmt.Fprintf(writer, "%c", t[i])
	}
	fmt.Fprintln(writer, "")
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
typedef vector<ll> vll;

ll mod = 1e9+7;
int main() {
  ll n;cin >> n;
  vll a(n), t(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>t[i];
  vll x(n,-1);
  if(a[n-1] != t[0]) {
    puts("0");
    return 0;
  }
  x[0]=a[0],x[n-1]=t[n-1];
  for(int i=1;i<n;i++){
	if(a[i] > a[i-1]){
      if(x[i] >= 0 && x[i] != a[i]) {
        puts("0");
        return 0;
      }
      x[i] = a[i];
    }
  }
  for(int i=n-2;i>=0;i--){
	if(t[i] > t[i+1]){
      if(x[i] >= 0 && x[i] != t[i]) {
        puts("0");
        return 0;
      }
      x[i] = t[i];
    }
  }
  ll ret = 1;
  rep(i,n){
    //cout << x[i];
    if(x[i] == -1){
      ret *= (ll)min(a[i],t[i]);
      ret %= mod;
    }
    else if(x[i] > min(a[i],t[i])) {
      puts("0");
      return 0;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 2688
n, k = map(int, input().split())
v = list(map(int, input().split()))
ans = 0
for a in range(min(n, k)+1):
  for b in range(min(n, k)-a+1):
    bag = []
    bag += v[:a]
    bag += v[len(v)-b:]
    bag.sort()
    if len(bag) > 0:
      for c in range(k-a-b):
        if bag[0] < 0:
          bag.pop(0)
        if len(bag) == 0:
          break
    ans = max(ans, sum(bag))
      
print(ans)

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

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio (0);
    cin.tie (0);
    set<ll>all;
    for (ll i = 1; i <= 9; i++) {
        for (ll j = 1; j <= 9; j++) {
            all.insert (i * j);
        }
    }
    ll n;
    cin >> n;
    cout << (all.find (n) != all.end() ? "Yes" : "No") << '\n';

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	ans = max(ans, a * 2 - 1);
	ans = max(ans, b * 2 - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
a = list(li())

cnt = Counter(a)

first = 0
second = 0

keys = list(cnt.keys())
keys.sort(reverse=True)

for k in keys:
    if first != 0 and second != 0:
        break
    
    if first == 0 and second == 0 and cnt[k] >= 4:
        first = k
        second = k
        
    elif first != 0 and cnt[k] >= 2:
        second = k
        
    elif cnt[k] >= 2:
        first = k
        
print(first * second)

Measured memory_bytes: 18728
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


ll k;
vector<ll> ans;
void dfs(ll x){
  if(x > 3234566667) return;
  ans.pb(x);
  dfs(x*10+x%10);
  if(x%10 != 0) dfs(x*10+(x%10)-1);
  if(x%10 != 9) dfs(x*10+(x%10)+1);

  return;
}

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

  cin >> k;
  for(ll i = 1; i <= 9; i++){
    dfs(i);
  }
  sort(all(ans));


  ll index = 1;
  //cout << ans.size() << endl;
  for(ll x : ans){
    //cout << x << endl;
    if(index == k){
      cout << x << endl;
      break;
    }
    index++;
  }
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x,a,b; cin>>x>>a>>b;
	cout << (abs(x-a)<abs(x-b) ? "A" : "B") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] food = new int[5];
		food[0] = scan.nextInt();
		food[1] = scan.nextInt();
		food[2] = scan.nextInt();
		food[3] = scan.nextInt();
		food[4] = scan.nextInt();
		int min = 10;
		int minNum = 0;
		int total = 0;
		int t = 0;
		for(int i=0;i<5;i++){
			if(min>food[i]%10){
				if(food[i]%10!=0){
				min = food[0]%10;
				minNum = i;
			}
			}
		}
		for(int j=0;j<5;j++){
			if(j==minNum){
				total = total + food[j];
			}
			else{
				t=food[j]/10;
				if(food[j]%10==0){total = total + t*10;
				}
				else{total = total + (t+1)*10;}
			}
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int N,M;
int dp[100010];
int ng[100010];

signed main(){
	IOS();
	cin>>N>>M;
	rep(i,0,M){
		int t;
		cin>>t;
		ng[t]=true;
	}
	dp[0] = 1;
	rep(i,0,N){
		if(dp[i]==0)continue;
		if(ng[i+1]==0)(dp[i+1]+=dp[i])%=MOD;
		if(ng[i+2]==0)(dp[i+2]+=dp[i])%=MOD;
	}
	cout<<dp[N]%MOD<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e18
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	f(i,1,n) cin>>a[i];
	int turn=1;
	vector<int> v;
	set<int> s;
	v.pb(1);
	s.insert(1);
	while(s.find(a[turn])==s.end())
	{
		v.pb(a[turn]);
		s.insert(a[turn]);
		turn=a[turn];
	}
	int st=a[turn];
	// cout<<st<<endl;
	// for(auto X:v)
	// cout<<X<<" ";
	vector<int> pp;
	bool f=false;
	int cc=0;
	int xx=v.size();
	for(int i=0;i<xx;i++)
	{
		if(v[i]==st || f==true)
		{
			f=true;
			pp.pb(v[i]);
		}
		else
		{
			cc++;
		}
	}
	// cout<<cc<<endl;
	if(k<cc)
	{
		int aa=v[k];
		cout<<aa;
		return;
	}
	k-=cc;
	int hh=pp.size();
	int kk=k%hh;
	int ans=pp[kk];
	cout<<ans;
}

signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}




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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;
typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int main()
{IOS
ll mod=1e9+7;
int n;
cin>>n;
int a[n][3];
for(int i=0;i<n;++i)
    for(int j=0;j<3;++j) cin>>a[i][j];
int dp[n][3];
memset(dp,0,sizeof(dp));
dp[0][0]=a[0][0];
dp[0][1]=a[0][1];
dp[0][2]=a[0][2];
for(int i=1;i<n;++i)
{
   dp[i][0]=max(a[i][0]+dp[i-1][1],a[i][0]+dp[i-1][2]);
   dp[i][2]=max(a[i][2]+dp[i-1][1],a[i][2]+dp[i-1][0]);
   dp[i][1]=max(a[i][1]+dp[i-1][0],a[i][1]+dp[i-1][2]);
}
int max=-1;
for(int i=0;i<3;++i)
    if(max<dp[n-1][i]) max=dp[n-1][i];
cout<<max<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,flag=0,rem;
    cin>>n;
    while(n!=0)
    {
        rem=n%10;
        if(rem==7)
        {
            flag=1;
            break;
        }
        n=n/10;
    }
    if(flag==1)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;


int main(void) {

  int n, m, a;
  while(true){
    cin >> n >> m >> a;
    if( n == 0 ) break;
    vector< vector<int> > d(m, vector<int>(3));
    int maxh = 0;
    for(int i=0; i<m; i++){
      cin >> d[i][0] >> d[i][1] >> d[i][2];
      maxh = max(maxh, d[i][0]);
    }
    for(int h=maxh; h>=0; h--){

      for(int i=0; i<m; i++){
        if( h == d[i][0] && a == d[i][1] ) a = d[i][2];
        else if( h == d[i][0] && a == d[i][2] ) a = d[i][1];
      }

    }
    cout << a << endl;
  }

  return 0;
}

// EOF

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define N 300050
#define ll long long
#define x first
#define y second
#define all(v) v.begin(),v.end()
using namespace std;

int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            cout.tie(NULL);
            int h,n;
            cin>>h>>n;
            int ar;
            int ans=0;
            for(int i=0;i<n;i++){
                cin>>ar;
            ans+=ar;
            }
            if(ans>=h)cout<<"Yes\n";
            else cout<<"No\n";



            return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
/* global variables */
/* function */
/* main */
int main(){
    int n;
    cin >> n;
    vector<int> B(n - 1);
    for (int &b : B) cin >> b;

    int ans = B[0] + B.back();

    for (int i = 0; i < n - 2; i++) {
        ans += min(B[i], B[i + 1]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3548
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int64_t arr[100];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	arr[0] =2 ;
	arr[1] = 1;
	for (int32_t i = 2; i <= N; i++)
	{
		arr[i] = arr[i - 1] + arr[i - 2];
	}
	out << arr[N] << endl;
	return 0;
}
#endif


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int d, n;
    cin >> d >> n;

    int s = 1; 
    for (int i = 0; i < d; i++) 
        s *= 100;
    
    if(n<=99) cout << s*n << endl;
    else cout << s*101 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,m,ans,cnt,x[1001],y[1001],z[1001];
ll JOJO[9][1001];
int main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
		JOJO[0][i]=x[i]+y[i]+z[i];
		JOJO[1][i]=x[i]+y[i]-z[i];
		JOJO[2][i]=x[i]-y[i]+z[i];
		JOJO[3][i]=x[i]-y[i]-z[i];
		JOJO[4][i]=-x[i]+y[i]-z[i];
		JOJO[5][i]=-x[i]-y[i]+z[i];
		JOJO[6][i]=-x[i]-y[i]-z[i];
		JOJO[7][i]=-x[i]+y[i]+z[i];
	}
	for(int i=0;i<=7;i++){
		sort(JOJO[i]+1,JOJO[i]+1+n);
		for(int j=n;j>=n-m+1;j--)cnt+=JOJO[i][j];
		ans=max(cnt,ans);cnt=0;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d&1)cout<<b-a<<endl;
    else cout<<a-b<<endl;
    return 0;
}
/*#include<bits/stdc++.h>
using namespace std;
int a[100010],b[100010],n;
#define ll long long
bool cmp(int A,int B){
    return a[A]<a[B];
}
ll cal(ll a){
    a=2*a+1;
    if(a<=n)return a;
    else return 2*n+1-a;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++)b[i]=i;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(b,b+n,cmp);
   // for(int i=0;i<n;i++)cout<<b[i]<<" ";cout<<endl;
    ll now=0,goal=((ll)n*(n-1)/2+n)/2+1;
    for(int i=0;i<n;i++){
        now+=cal(b[i]);
       // cout<<now<<"-----"<<goal<<endl;
        if(now>=goal){
            cout<<a[b[i]]<<endl;
            return 0;
        }
    }
    return 0;
}*/


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll last=-1;
    ll n,k;
    cin>>n>>k;
    VL arr;
    ll i=1;
    while(k*i<=n)
    {
        arr.pb(i*k);
        last=(i+1)*k;
        i++;
    }
    ll ans=0;
    // fr(i,0,SZ(arr))
    //     cout<<arr[i]<<" ";
    // cout<<"\n";
    ll ct=0,ct2=0;
    ct2=n/k;
    if(k%2==0)
    {
        ct=(n+k/2)/k;
    }
    // fr(i,1,n+1)
    // {
    //     if(k%2==0)
    //     {
    //         if(i%k==0)
    //         {
    //             ct++;
                
    //         }
    //         else{
    //             if(((i/2)%k==k/2)||((i/2)%k==0))
    //                 ct2++;
    //         }
    //     }
    //     else
    //     {
    //         if(i%k==0)
    //             ct++;
    //     }
    // }
    cout<<ct*ct*ct+ct2*ct2*ct2<<endl;
    // map<ll,ll>mp;
    // fr(i,1,n+1)
    // {
    //     ll pos=SZ(arr)-(lower_bound(ALL(arr),i+1)-arr.begin());
    //     //cout<<i<<" "<<pos<<endl;
    //     if((2*i)%k!=0)
    //         continue;
    //     ll x=*lower_bound(ALL(arr),i+1);
    //     if(x-i<=0)
    //     {
    //         if(pos!=0)
    //             pos--;
    //     }
    //     if(last-i<=n&&last-i>0)
    //     {
    //         if(mp[last-i]==0)
    //             pos++;
    //         //ans+=pos;
    //     }
    //     mp[i]=1;
    //     //cout<<i<<" "<<pos*pos*pos<<endl;
    //     ans+=(pos*pos*pos);
    // }
    //cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

int main(){
  int N,ans;
  cin>>N;
  ans=0;
  vector<int>c(N);
  for(int i=0;i<N;i++){
  cin>>c[i];
  }
    for(int i=1;i<N-1;i++){
  if(c[i]>c[i-1]&&c[i]<c[i+1]){
    ans++;
  }
      else if(c[i]<c[i-1]&&c[i]>c[i+1]){
        ans++;
      }
  }
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;
    cin>>n;
    int a[200000];
    for(int i = 0; i< n; i++) cin>>a[i];
    sort(a, a+n);
    reverse(a, a+n);
    long long ans = a[0];
    int c = 2;
    for(int i = 1; i<n; i++){
        if(c < n) ans += a[i], c++;
        if(c < n) ans += a[i], c++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4352
#include<stdio.h>

#define MAX

int M, D;

int main(void){
    int i, j;
    int d1, d10;
    int ans = 0;

    scanf("%d%d",&M,&D);

if(M>3){
    for (i = 4; i <= M; i++)
    {
        for (j = 1; j <= D; j++)
        {
            d1 = j % 10;
            d10 = (j - d1) / 10;
            if (d1 > 1 && d10 > 1 && d1 * d10 == i)
                ans++;
        }
    }
}
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
use std::collections::VecDeque;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 0..m {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].push(b);
        graph[b].push(a);
    }

    let q: usize = sc.read();
    let mut queries = vec![];
    for _ in 0..q {
        let v = sc.read::<usize>() - 1;
        let d = sc.read::<i64>();
        let c = sc.read::<usize>();
        queries.push((v, d, c));
    }
    queries.reverse();

    let mut dist = vec![0; n];
    let mut color = vec![None; n];
    for (start, d, c) in queries.into_iter() {
        if dist[start] > d {
            continue;
        }
        let mut q = VecDeque::new();
        dist[start] = d;
        q.push_back(start);
        if color[start].is_none() {
            color[start] = Some(c);
        }
        while let Some(v) = q.pop_front() {
            for &next in graph[v].iter() {
                if dist[next] < dist[v] - 1 {
                    dist[next] = dist[v] - 1;
                    q.push_back(next);
                }
                if dist[next] <= dist[v] - 1 && color[next].is_none() {
                    color[next] = Some(c);
                }
            }
        }
    }

    for i in 0..n {
        let color = color[i].unwrap_or(0);
        println!("{}", color);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 21580
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPEQ(i, n) FOREQ(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define LET(name, value) __typeof(value) name = (value)

template <typename T> inline int size(const T& x) { return x.size(); }
template <typename T1, typename T2> inline void
updateMax(T1& x, const T2& y) { if (y < x) { x = y; } }
template <typename T1, typename T2> inline void
updateMin(T1& x, const T2& y) { if (x < y) { x = y; } }
template <typename T1, typename T2, typename K1, typename K2> inline void
updateMax(T1& x, K1& i, const T2& y, const K2& j) { if (y < x) { x = y; i = j; } }
template <typename T1, typename T2, typename K1, typename K2> inline void
updateMin(T1& x, K1& i, const T2& y, const K2& j) { if (x < y) { x = y; i = j; } }

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

  int N;
  while (cin >> N) {
    vector<string> ids(N);
    REP(i, N) cin >> ids[i];
    sort(ALL(ids));

    int M; cin >> M;
    bool open = false;
    REP(i, M) {
      string id; cin >> id;
      LET(p, equal_range(ALL(ids), id));
      if (p.first != p.second) {
        open = !open;
        if (open) cout << "Opened by " << id << endl;
        else cout << "Closed by " << id << endl;
      } else {
        cout << "Unknown " << id << endl;
      }
    }
  }
}

Measured memory_bytes: 1228
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
S = input()
Sum_White = [0]
Sum_Black = [0]

tmp_w = tmp_b = 0
for s in S:
    if s == '#':
        tmp_b += 1
    else:
        tmp_w += 1
    Sum_Black.append(tmp_b)
    Sum_White.append(tmp_w)

#print(Sum_Black,Sum_White)
ans = INF
for i in range(N+1):
    tmp = Sum_Black[i] + (Sum_White[N]-Sum_White[i])
    ans = min(ans,tmp)
    #print(i,tmp)

print(ans)


Measured memory_bytes: 16468
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int ggcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int a,b,c,d;
  cin>>a>>b>>c;
  d=a;
  for(int i=1;i<=max(a,b);i++){
    d=a*i;
    if(d%b==c){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
}
///////////////////////////

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

#define MAX_N 10
int n, m;
int a, b;
int maze[MAX_N][MAX_N];

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

  cin >> n >> m;
  rep(i, 0, m) {
    cin >> a >> b;
    a--; b--;
    maze[a][b] = 1;
    maze[b][a] = 1;
  }

  int array[n];
  rep(i, 0, n) array[i] = i;

  int rsl = 0;
  do {
    if(array[0] != 0) continue;

    bool isClear = true;
    rep(i, 0, n - 1) {
      if(maze[array[i]][array[i + 1]] == 0) {
        isClear = false;
        break;
      }
    }
    if(isClear) ++rsl;
  } while(next_permutation(array, array + n));

  cout << rsl << endl;
}


Measured memory_bytes: 256
'use strict'

function Main(input) {
    const tmp = input.trim().split('\n')
    const N = Number(tmp[0])
    const T = tmp[1].split(' ').map(v => Number(v));
    const M = Number(tmp[2])
    const PX = tmp.splice(3)
    // console.log(N, T, M, PX);

    let defaltTime = 0;
    for (const v of T) {
        defaltTime += v;
    }

    for (const v of PX) {
        const tmp = v.split(' ').map(v => Number(v));
        const diff = T[tmp[0] - 1] - tmp[1];
        const time = defaltTime - diff;
        console.log(time);
    }

}

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

Measured memory_bytes: 8268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m;
	cin>>n>>m;
	string s[n];
	for(int i=0;i<n;++i)
	{
		cin>>s[i];
	}
	int obl[n+1][m+1];
	int obr[n+1][m+1];
	int obu[n+1][m+1];
	int obd[n+1][m+1];
	for(int i=0;i<n;++i)
	{
		int pr=0;
		for(int j=0;j<m;++j)
		{
			if(s[i][j]=='#')
				pr=j+1;
			else
			{
				obl[i][j]=pr;
			}
		}
	}

	for(int i=0;i<n;++i)
	{
		int pr=m-1;
		for(int j=m-1;j>=0;--j)
		{
			if(s[i][j]=='#')
				pr=j-1;
			else
			{
				obr[i][j]=pr;
			}
		}
	}
	for(int i=0;i<m;++i)
	{
		int pr=0;
		for(int j=0;j<n;++j)
		{
			if(s[j][i]=='#')
				pr=j+1;
			else
			{
				obu[j][i]=pr;
			}
		}
	}
	for(int i=0;i<m;++i)
	{
		int pr=n-1;
		for(int j=n-1;j>=0;--j)
		{
			if(s[j][i]=='#')
				pr=j-1;
			else
			{
				obd[j][i]=pr;
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<m;++j)
		{
			// <<s[i][j];
			if(s[i][j]!='#')
			{
				// cout<<ans<<" ";
				ans=max(ans,i-obu[i][j]+obd[i][j]-i+j-obl[i][j]+obr[i][j]-j+1);
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 129664
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;

long long A[100000];
int stand_bit_num[40];

int main(){
    int N;
    long long K;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    for(int i = 0; i < 40; i++){
        stand_bit_num[i] = 0;
    }

    for(int i = 39; i >= 0; i--){
        stand_bit_num[i] = 0;
        for(int j = 0; j < N; j++){
            if(((A[j] >> i) & 1) == 1) {
                stand_bit_num[i] += 1;
            }
        }
    }

    int max_bit_num;
    for(int i = 39; i>= 0; i--){
        if(stand_bit_num[i] > 0){
            max_bit_num = i;
            break;
        }
    }
   
    long long ans = 0;
    bool is_boundary = true;
    for(int i = 39; i >= 0; i--){
        if(i > max_bit_num){
            ans += N * (K & ((long long) 1 << i));
            continue;
        }
        if(is_boundary){
            if(((K >> i) & 1) == 1){
                if(stand_bit_num[i] >= N - stand_bit_num[i]){
                    ans += stand_bit_num[i] * ((long long)1 << i);
                    is_boundary = false;
                } else {
                    ans += (N - stand_bit_num[i]) * ((long long)1 << i);
                }
            } else {
                ans += stand_bit_num[i] * ((long long) 1 << i);
            }
        } else {
            ans += max(stand_bit_num[i], N - stand_bit_num[i]) * ((long long)1 << i);
        }
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
using namespace std;

int main(){
    //freopen("in.txt", "r", stdin);
    int n, k;
    string s;

    cin>>n;
    cin>>s;
    cin>>k;

    k--;
    char c = s[k];

    for (int i=0;i<n;++i){
        if (s[i]!=c) printf ("*");
        else cout<<s[i];
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int S = sc.nextInt();
    
    int[] ans = new int[N];
    int B = S == 1000000000 ? S-1 : S+1;
    Arrays.fill(ans, B);
    for(int i = 0; i < K; i++){
      ans[i] = S;
    }
    for(int i = 0; i < N; i++){
      if(i != N-1){
        System.out.print(ans[i]+" ");
      }else{
		System.out.println(ans[i]);
      }
    }
  }
}


Measured memory_bytes: 42156
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
const int N=200010;
char s[N];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	ll ans=0,cnt=0;
	for (int i=n;i;--i){
		if (s[i]=='W') ++cnt;
		else ans+=cnt;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void){
  int N,R,a;
  
  a=scanf("%d %d",&N,&R);
  
  if(a!=2){
    printf("正しく入力されていません\n");
    exit(1);
  }
  
  if(N>=10){
    printf("%d\n",R);
  }
  else{
    printf("%d\n",R+100*(10-N));
  }
  return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> vec(H,vector<char>(W));
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      cin >> vec.at(i).at(j);
    }
  }
  vector<vector<char>> answer(2 * H,vector<char>(W));
  for(int k = 0;k < 2 * H;k++) {
    for(int l = 0;l < W;l++) {
      answer.at(k).at(l) = vec.at(k / 2).at(l);
    }
  }
  for(int m = 0;m < 2 * H;m++) {
    for(int n = 0;n < W;n++) {
      cout << answer.at(m).at(n);
      if(n == W - 1) {
        cout << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}



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



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

vector<int> adj[100001];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1,i,j;
   // cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        for(i=0;i<m;i++)
        {
            int a,b;
            cin>>a>>b;
            adj[a].push_back(b);
            adj[b].push_back(a);
        }
        
        int level=1;
        queue<pair<int,int>> q;
        int visited[n+1]={false};
        q.push({1,0});
        map<int,pair<int,int>> mp;
        while(!q.empty())
        {
            int num=q.front().first;
            int lev=q.front().second;
            q.pop();
            if(visited[num])
            {
                int tt=mp[num].first;
                if(lev+1<tt)
                {
                    mp[num]={lev+1,num};
                }
                continue;
            }
            visited[num]=true;
            for(i=0;i<adj[num].size();i++)
            {
                if(!visited[adj[num][i]])
                {
                    q.push({adj[num][i],lev+1});
                   // cout<<num<<" "<<adj[num][i]<<" "<<lev+1<<"\n";
                    if(mp.find(adj[num][i])==mp.end())
                        mp[adj[num][i]]={lev+1,num};
                    else
                    {
                            int tt=mp[adj[num][i]].first;
                            if(lev+1<tt)
                            {
                                mp[adj[num][i]]={lev+1,num};
                            }
                    }
                }
            }
        }
        
        if(mp.size()!=n-1)
        {
            cout<<"No";
        }
        else
        {
            cout<<"Yes\n";
            for(auto it:mp)
            {
                cout<<it.second.second<<"\n";
            }
        }
    }
}

Measured memory_bytes: 17076
#include <iostream>
#include <algorithm>
#include <cctype>
using namespace std;

int main(void){
    int W,H;
    string dp[2][70];
    string line,ans;
    while(cin >> W >> H, W){
        for(int i=0;i<70;i++){
            dp[0][i].clear();dp[1][i].clear();
        }
        ans.clear();
        for(int i=0;i<H;i++){
            cin >> line;
            for(int j=0;j<W;j++){
                dp[i&1][j].clear();
                if(isdigit(line[j])){
                    if(dp[(i&1)^1][j]!="0"){
                        dp[i&1][j]=dp[(i&1)^1][j]+line[j];
                    }else{
                        dp[i&1][j].push_back(line[j]);
                    }
                    if(j!=0&&dp[i&1][j-1]!="0") dp[i&1][j]=max(dp[i&1][j],dp[i&1][j-1]+line[j],[](const string& a, const string& b){return a.size()==b.size()? a < b : a.size() < b.size();});
                    ans=max(dp[i&1][j],ans,[](const string& a, const string& b){return a.size()==b.size()? a < b : a.size() < b.size();});
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3132