akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <complex>
#include <iomanip>
using namespace std;
typedef complex<double> P;
const double EPS = 1e-10;
int n;
double l[10];

struct C {
	P p;
	double r;

	C() {
		p = P(0, 0);
		r = 0;
	}

	C(const P& p, double r) : p(p), r(r) {
	}

	bool in(P t) {
		return norm(p - t) < r * r + EPS;
	}

	bool in(C t) {
		return abs(p - t.p) + t.r < r + EPS;
	}
} c[10];

bool check(double h) {
	for (int i = 0; i < n; i++) {
		if (l[i] * l[i] - h * h < EPS) return false;
		c[i].r = sqrt(l[i] * l[i] - h * h);
	}

	vector<P> cs;
	for (int i = 0; i < n; i++) {
		cs.push_back(c[i].p);
	}

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			C c1 = c[i], c2 = c[j];
			if (abs(c1.p - c2.p) > c1.r + c2.r) return false; // ????????????
			if (c1.in(c2) || c2.in(c1)) continue;

			P v = c2.p - c1.p;
			double t = (c1.r * c1.r + norm(v) - c2.r * c2.r) / (2 * abs(v));
			double theta = acos(t / c1.r);
			P b[2];
			b[0] = c1.p + v / abs(v) * c1.r * polar(1.0, theta);
			b[1] = c1.p + v / abs(v) * c1.r * polar(1.0, -theta);
			cs.push_back(b[0]);
			cs.push_back(b[1]);
		}
	}

	for (int i = 0; i < cs.size(); i++) {
		bool flag = true;
		for (int m = 0; m < n; m++) {
			if (!c[m].in(cs[i])) {
				flag = false;
				break;
			}
		}
		if (flag) return true;
	}
	return false;
}

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

	while (cin >> n , n) {
		for (int i = 0; i < n; i++) {
			double x, y;
			cin >> x >> y >> l[i];
			c[i].p = P(x, y);
		}
		check(0);
		double ok = 1, ng = 300;
		for (int loop = 0; loop < 100; loop++) {
			double h = (ok + ng) / 2;
			if (check(h)) ok = h;
			else ng = h;
		}
		cout << setprecision(15) << ok << endl;
	}
}

Measured memory_bytes: 1396
N = int(input())
S = []
for i in range(N):
    S.append(int(input()))

Sum = sum(S)
S.sort()

for i in range(len(S)):
    if (Sum)%10!=0:
        print(Sum)
        exit()
    else:
        if S[i]%10!=0:
            Sum -=S[i]
print(0)
        



Measured memory_bytes: 3060
import Data.List

chk' x@(xh:_) =
  let l = length x
  in
    l == (length $ takeWhile (== xh) x)

chk x =
  let t = chk' $ take  9 x
      b = chk' $ drop 21 x
      n = chk' $ take  3 $ drop 18 x
      e = chk' $ take  3 $ drop 12 x
      w = chk' $ take  3 $ drop 15 x
      s = chk' $ take  3 $ drop  9 x
  in
    t && b && n && e && w && s

swap (i,j) x =
  let y = zip [1..] x
  in
    map (\ (n,e) -> if i == n
                    then x!!(j-1)
                    else if j == n
                         then x!!(i-1)
                         else e ) y

patn = [(1,28),(2,29),(3,30),(15,16),(19,21)]
pate = [(3,22),(6,25),(9,28),(12,19),(13,15)]
patw = [(1,24),(4,27),(7,30),(10,21),(16,18)]
pats = [(7,22),(8,23),(9,24),(13,18),(10,12)]

trn 'N' x = foldl (\x p -> swap p x) x patn
trn 'E' x = foldl (\x p -> swap p x) x pate
trn 'W' x = foldl (\x p -> swap p x) x patw
trn 'S' x = foldl (\x p -> swap p x) x pats

ans' n x =
  let x' = nub x
      c = any chk x'
      tn= map (trn 'N') x'
      te= map (trn 'E') x'
      tw= map (trn 'W') x'
      ts= map (trn 'S') x'
  in
    if c
    then n
    else if n == 8
         then 9
         else ans' (n+1) (tn ++ te ++ tw ++ ts)

ans x = ans' 0 [x]
    
main = do
  _ <- getLine
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = map ans i
  mapM_ print o



Measured memory_bytes: 6532
import collections
n=int(input())
A=list(map(int,input().split()))

c = collections.Counter(A)
all_combi=0

for i in c:
    # print(c[i])
    all_combi +=  c[i]*(c[i]-1)//2

count = [c[A[i]] for i in range(len(A))]

for i in range(len(A)):
    

    n_same_i = count[i]-1 
    ans = all_combi - n_same_i
    
    print(ans)
        


Measured memory_bytes: 123008
#include <bits/stdc++.h>
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> multi_vector(size_t a){return vector<T>(a);}template<class T, class... Ts>auto multi_vector(size_t a, Ts... ts){return vector<decltype(multi_vector<T>(ts...))>(a, multi_vector<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}

/* ここからコード開始 */

int main(){
  kyopro;
  ld T, X;
  cin >> T >> X;
  fixsp(10);
  cout << T / X;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(v<n)break;
  }
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs(){
  int u;
  for(u=0;u<n;u++){
    if(u<n)break;
  }
  for(u=0;u<n;u++)color[u]=WHITE;
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}


int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}
  



Measured memory_bytes: 2132
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

int main(void)
{
  char S[101], K[20];
  scanf("%s %s", S, K);
  long limit;
  if(strlen(K) > 4){
    limit = strlen(S);
  } else {
    int k = atoi(K);
    limit = min(strlen(S), k);
  }
  char ans = '1';
  for(int i = 0; i < limit; i++){
    if(S[i] != '1'){
      ans = S[i];
      break;
    }
  }
  printf("%c\n", ans);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
p = [int(input()) for i in range(n)]
q = [0]*(n+1)
for i in range(n):
  q[p[i]] = i
cnt = 1
m = 1
for i in range(1, n):
  if q[i]<q[i+1]:
    cnt += 1
    m = max(m, cnt)
  else:
    cnt = 1
print(n-m)

Measured memory_bytes: 18960
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N,M;
    cin >> N >> M;
    int A = M;
    vector<int> vec;
    vec.push_back(1);
    vec.push_back(M);
    for(int i = 2;i * i <= M;i++) {
        if(M % i == 0) {
            vec.push_back(i);
            vec.push_back(M / i);
        }
    }
    sort(vec.begin(),vec.end());
    int ret = 1;
    for(int i = 0;i < vec.size();i++) {
        if(vec.at(i) <= M / N) {
            ret = vec.at(i);
        }
    }
    cout << ret << endl;
}

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

signed main() {
  int n;
  cin >> n;

  int two = 0;
  int answer = 1;

  for (int i = 1; i <= n; i++) {
    int x = i;
    int cnt = 0;
    while(x % 2 == 0) {
      cnt++;
      x/=2;
    }
    if(cnt > two) {
      answer = i;
      two = cnt;
    }
  }
  cout << answer << '\n';
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>

#define inRange(x, y, w, h) (0 <= x && x < w && 0 <= y && y < h)

using namespace std;

int w, h;
int fd[50][50];

int dx[] = { 0, 0, -1, 1, -1, 1, -1, 1 };
int dy[] = { -1, 1, 0, 0, -1, -1, 1, 1 };

void dfs( int x, int y )
{
	fd[y][x] = 0;
	for(int i=0; i < 8; ++i) {
		int mx = x + dx[i];
		int my = y + dy[i];
		if(inRange(mx, my, w, h) && fd[my][mx])
			dfs(mx, my);
	}
}

int main( void )
{
	while(cin >> w >> h, w | h) {
		for(int y=0; y < h; ++y)
			for(int x=0; x < w; ++x)
				cin >> fd[y][x];
		int count = 0;
		for(int y=0; y < h; ++y)
			for(int x=0; x < w; ++x)
				if(fd[y][x]) {
					++count;
					dfs(x, y);
				}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
/* ex 9_2
   kohei0713 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 100001

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
void pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
}

int main(void){
    int count = 0, i;
    char cube[SIZE];
    //最初のノードの指す先
    node *first = NULL;

    //input
    scanf("%s", cube);

    for(i = 0; i < strlen(cube); i++){
        if(first == NULL || cube[i] == first->elem){
            //スタックにノードを追加
            push(&first, cube[i]);
        }else{
            //スタックからデータを取り出し,countに2を足す
            pop(&first);
            count = count + 2;
        }
    }

    //countを表示
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 4920
import java.util.Scanner;

public class Main {

	private static int fiveHundredCoin;

	private static int hundredCoin;

	private static int fiftyCoin;

	private static int totalFare;

	public static void main(String[] args) {

		int result = process();
		System.out.println(result);
	}

	private static int process() {

		scan();
		int combinationCount = 0;

		return count(combinationCount);
	}

	private static void scan() {

		Scanner sc = new Scanner(System.in);
		fiveHundredCoin = sc.nextInt();
		hundredCoin = sc.nextInt();
		fiftyCoin = sc.nextInt();
		totalFare = sc.nextInt();
		sc.close();
	}

	private static int count(int combinationCount) {

		int total = 0;
		for (int i = 0; i <= fiveHundredCoin; i++) {
			for (int j = 0; j <= hundredCoin; j++) {
				for (int k = 0; k <= fiftyCoin; k++) {
					total = (500 * i) + (100 * j) + (50 * k);

					if (totalFare == total) {
						combinationCount++;
					}
				}
			}
		}

		return combinationCount;
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int N,M;
	cin>>N>>M;
	int X,Y;
	cin>>X>>Y;
	int x[100],y[100];
	rep(i,N)cin>>x[i];
	rep(i,M)cin>>y[i];
	
	int war=0;
	
	int xma=-150,ymi=150;
	rep(i,N)xma=max(xma,x[i]);
	rep(i,M)ymi=min(ymi,y[i]);
	
	if(xma>=ymi)war=1;
	int sep=0;
	for(int Z=X+1;Z<=Y;Z++){
		if(xma<Z && Z<=ymi)sep=1;
	}
	if(sep==0)war=1;
	
	if(war)cout<<"War";
	else cout<<"No War";
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

int gcd(int a,int b) {
  if (a % b == 0) return b;
	else return gcd(b,a % b);
}

int main() {
	ll n;
	cin >> n;

	vector<string> s(n);
	vector<int> t(n);
	rep(i,n) cin >> s[i] >> t[i];

	string x;
	cin  >> x;
	bool sleep = false;
	int time = 0;
	rep(i, n) {
	  if (sleep) time += t[i];
		if (s[i] == x) sleep = true;
	}

	cout << time << endl;
}


Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int,input().split())) + [0]
acc = [abs(A[i] - A[i - 1]) for i in range(1, N + 2)]
su = sum(acc)
for i in range(N):  print(su - acc[i] - acc[i + 1] + abs(A[i] - A[i + 2]))

Measured memory_bytes: 92820
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
 
 
const ll INF = 1e18;
const ll N =(2e5+5); // TODO : change value as per problem
const ll MOD = 1e9+9;
const ll p = 1000003;
long long compute_hash(vll v){
    ll ans = 0;
    ll p_pow = 1;
    for(int i =0;i<5;i++){
        ans = (ans + v[i] * p_pow) % MOD;
        p_pow = (p_pow * p)%MOD;
    }
    return ans;
}
void solve(){
    ll a,b;
    cin >> a >> b;
    if(a<=0 && b >=0) {
        cout << "Zero"<< endl;
        return;
    }
    if(a < 0){
        if((b-a+1) & 1) cout << "Negative\n";
        else cout << "Positive\n";
        return;
    }
    else if(a > 0){
        cout << "Positive\n";
    }
}

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    

 
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

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

using namespace std;

int
main(){
  int n, l, t = 0, i;

  cin >> n >> l;

  if (l > 0) {
    for (size_t i = 2; i <= n; i++) {
      t += l + i - 1;
    }
  }else if ((l+n-1) < 0) {
    for (size_t i = 1; i <= n-1; i++) {
      t += l + i - 1;
    }
  }else{
    for (size_t i = 1; i <= n; i++) {
      t += l + i - 1;
    }
  }

  cout << t << endl;

        return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split()))

dp = [[0, 0] for _ in range(N+1)]
# dp[i][j]: j=0 -> A[1] + ... + A[i] の MAX
#           j=1 -> A[i] and A[i+1] を反転させた状態での和の最大値

dp[0][0] = 0
dp[0][1] = -float("inf")

for i in range(N):
    dp[i+1][0] = max(dp[i][0] + A[i+1], dp[i][1] - A[i+1])
    dp[i+1][1] = max(dp[i][0] - A[i+1], dp[i][1] + A[i+1])

print(dp[N][0])

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

int main() {
    long long n, k;
    cin >> n >> k;

    vector<long long> h(n);
    for(int i=0;i<n;i++){
        cin >> h.at(i);
    }

    sort(h.begin(),h.end());

    long long c=0;
    for(int i=0;i<n-k;i++){
        c+=h.at(i);
    }

    cout << c << endl;
}


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

int main() {
	int x;
	cin >> x;
	int ans = 1;
	for (int b = 2; b <= x; b++) {
		int power = b*b;
		for (int p = 2;; p++) {
			if (power > x) break;
			ans = max(ans, power);
			power *= b;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
    int s,w;
    cin >> s >> w;
    if(w>=s){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}

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

#define LL long long

#define FOR(INDEX, START, END) for (int INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (int INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
    string S;
    LL K = 0;
    cin >> S >> K;
    
    // 1以外の数字を見つける
    LL not1Index = 0;
    for (LL i = 0; i < S.length(); ++i)
    {
        if (S[i] != '1') {
            not1Index = i;
            break;
        }
    }
    
    if (K < not1Index + 1)  // 1から始まるインデックスにするために+1
    {
        cout << 1 << endl;
    }
    else
    {
        cout << S[not1Index] << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1')cout << "9";
        else if(s[i]=='9')cout << "1";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 250

int parent(int z);
int L(int z);
int R(int z);

int main(){
  int n,i,A[N+1];

  scanf("%d",&n);

  for(i = 1;i <= n;i++){
    
    scanf("%d",&A[i]);
    
  }

  for(i = 1;i <= n;i++){
    
    printf("node %d: key = %d, ",i,A[i]);
    
    if(parent(i) >= 1){
      
      printf("parent key = %d, ",A[parent(i)]);
      
    }
    
    if(L(i) <= n){
      
      printf("left key = %d, ",A[L(i)]);
      
    }
    
    if(R(i) <= n){
      
      printf("right key = %d, ",A[R(i)]);

    }
    
    printf("\n");
    
  }

  return 0;
  
}
int parent(int z){
  
  return z / 2;
  
}

int L(int z){
  
  return 2 * z;
  
}

int R(int z){
  
  return 2 * z + 1;
  
}



Measured memory_bytes: 2064
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
double f(double a[],int p,int q){
  if(q==1&&a[p])
    return a[p];
  else if(p){
    if(q==pow(2,30))
      return f(a,p-1,1);
    else{
      if(q==1){
	a[p]=1.0/q+f(a,p-1,q*2)/q+f(a,p-1,1)*(q-1)/q;
	return a[p];
      }else
	return 1.0/q+f(a,p-1,q*2)/q+f(a,p-1,1)*(q-1)/q;
    }
  }else
    return 0.0;
}
int main(){
  int n;
  double a[100001];
  memset(a,0.0,sizeof(a));
  for(n=1;n<100001;n++)
    a[n]=f(a,n,1);
  while(cin>>n&&n)
    printf("%lf\n",a[n]);
  return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair

using namespace std;
const int N=1e5+5;
int a[4];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>a[1]>>a[2]>>a[3];
    swap(a[1],a[2]);
    swap(a[1],a[3]);
    cout<<a[1]<<' '<<a[2]<<' '<<a[3];
}


Measured memory_bytes: 764
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int N, M;
string s;

int main() {
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'o') {
      N++;
    }
  }
  cout << 700 + 100 * N << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 998244353
#define rep(i,n) for(int i=0;i<(int)(n);++i)

ll ruijo(ll x,ll n){
	long long p,ans;
	if(n==0)return 1;
	if(n==1)return x;
	if(n%2){
		p = ruijo(x,n/2);
		ans = (x*p)%mod;
		ans = (ans*p)%mod;
		return ans;
	}else{
		p = ruijo(x,n/2);
		ans = (p*p)%mod;
		return ans;
	}
}

int main(){
    int n;
    cin >> n;
    if(n<=2){
        cout << 0 << endl;
        return 0;
    }
    vector<int> x(n),y(n);
    rep(i,n){
        cin >> x[i] >> y[i];
    }
    bool flag[210][210]={};
    vector<int> c;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            vector<int> p;
            if(flag[i][j])continue;
            p.push_back(i);
            p.push_back(j);
            for(int k=j+1;k<n;k++){
                if((x[i]-x[j])*(y[i]-y[k])==(x[i]-x[k])*(y[i]-y[j])){
                    p.push_back(k);
                }
            }
            for(int s=0;s<p.size();s++){
                for(int t = s+1;t<p.size();t++){
                    flag[p[s]][p[t]] = 1;
                }
            }
            c.push_back(p.size());
        }
    }
    ll res = ruijo(2,n);
    res += mod-1-n;
    res %= mod;
    for(int x:c){
        res += 2*mod - (ruijo(2,x)-x-1);
        res %= mod;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;
	string s;
	
	ll cr =1;
	while(n){
		if(n%(abs(2*cr))){
			n -=cr;
			s = "1" + s;
		}else s ="0" +s;
		cr *= -2;
	}
	cout << (sz(s)? s:"0") <<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

unordered_map<int, vector<int>> e;
void dfs(int node, vector<int>& w, int parent) {
    w[node] += w[parent];
    for(int child: e[node]) {
        if (child != parent) {
            dfs(child, w, node);
        }
    }
}
int main() {
    int n, q, a, b, p, x;
    cin >> n >> q;
    vector<int> weight(n+1, 0);

    for(int i = 0; i < n-1; i++) {
        cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    while(q--) {
        cin >> p >> x;
        weight[p] += x;
    }
    dfs(1, weight, 0);
    for(int i = 1; i <= n; i++)
        cout << weight[i] << " ";
    return 0;
}



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


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;


int N, M;
vector<int> S, T;
mint dp[2100][2100];
mint sdp[2100][2100];

int main() {
    cin >> N >> M;
    S.resize(N), T.resize(M);
    for (int i = 0; i < N; ++i) cin >> S[i];
    for (int i = 0; i < M; ++i) cin >> T[i];

    memset(dp, 0, sizeof(dp));
    memset(sdp, 0, sizeof(dp));
    dp[0][0] = 1;
    sdp[1][1] = 1;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= M; ++j) {
            if (i == 0 && j == 0) continue;
            if (i-1 >= 0 && j-1 >= 0 && S[i-1] == T[j-1]) {
                dp[i][j] = sdp[i][j];
            }
            sdp[i+1][j+1] = sdp[i+1][j] + sdp[i][j+1] - sdp[i][j] + dp[i][j];
        }
    }
    cout << sdp[N+1][M+1] << endl;
}


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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

signed main(){
  int n,x;
  cin>>n>>x;
  vector<int> ans;
  if(x==1||x==2*n-1){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
    if(n==2){
      cout<<1<<endl;
      cout<<2<<endl;
      cout<<3<<endl;
    }
    else{
      int m=n*2-1;
      int next=1;
      lp(i,m){
        if(x==m-1){
        if(next==x-2){
          next=x+2;
        }
        if(i==n-2){
          ans.push_back(x-1);
          ans.push_back(x);
          ans.push_back(x+1);
          ans.push_back(x-2);
          i+=3;
        }
        else{
          ans.push_back(next);
          next++;
        }
          continue;
        }
        if(next==x-1){
          next=x+3;
        }
        if(i==n-2){
          ans.push_back(x+1);
          ans.push_back(x);
          ans.push_back(x-1);
          ans.push_back(x+2);
          i+=3;
        }
        else{
          ans.push_back(next);
          next++;
        }
      }
      lp(i,ans.size()){
        cout<<ans[i]<<endl;
      }
    }/*
    vector<int> bef,af;
    bef=ans;
    lp(i,n){
      lp(j,i) cout<<" ";
      lp(j,bef.size()){
        cout<<bef[j];
      }
      cout<<endl;
      lp(j,bef.size()-2){
        int a=bef[j],b=bef[j+1],c=bef[j+2];
        int mini;
        if(a<=b&&b<=c)mini=b;
        else if(c<=b&&b<=a)mini=b;
        else if(b<=a&&a<=c)mini=a;
        else if(c<=a&&a<=b)mini=a;
        else mini=c;
        af.push_back(mini);
      }
      bef=af;
      af.clear();
    }*/
  }
  return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <vector>
#define rep(i,n) for(long long i=0;i<n;i++)

using namespace std;
using ll = long long;

int main(void)
{
    ll n,ans,num=0;
    cin >> n;
    char s[n];
    vector<ll> r,g,b;
    rep(i,n)
    {
        cin >> s[i];
        if(s[i]=='R') r.push_back(i);
        if(s[i]=='G') g.push_back(i);
        if(s[i]=='B') b.push_back(i);
    }
    ans = r.size()*g.size()*b.size();

    if(n>2)
    {
        for(ll i=0;i<n-2;i++)
        {
            for(ll j=1;i+2*j<n;j++)
            {
                if(s[i]!=s[i+j] && s[i]!=s[i+2*j])
                {
                    if(s[i+j]!=s[i+2*j]) num++;
                }
            }
        }
    }
    ans -= num;
    cout << ans << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int y = 700;
  int c = 0;
  
  if(s[0]=='o') ++c;
  if(s[1]=='o') ++c;
  if(s[2]=='o') ++c;
  
  cout << y + 100 * c << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include<stack>
#include<string>
#include<algorithm> 
#include <set>
#include<list>
#include <bit>
#include <bitset>
#include <cstdint>
#include <initializer_list>
using namespace std;
#define F first
#define S second
#define li long long int 
#define ld long double
#define pb push_back
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

li val(li x, li y, li z)
{
	li ans = x * x + y * y + z * z + x * y + y * z + x * z;
	return ans;
}

li countSetBits(string s)
{
	li count = 0;
	for (auto it : s)
	{
		if (it == '1')
			count++;
	}
	return count;
}
li countSetBits(li n)
{
	li count = 0;
	while (n > 0) {
		count += n & 1;
		n >>= 1;
	}
	return count;
}
li f(li x)
{
	int c = 0;
	while (x > 0)
	{
		x = x % countSetBits(x);
		c++;
	}
	return c;
}
li power(string s, li mod)
{
	if (mod <= 0)
		return 0;
	li n = s.size(); li ans = 0; li p = 1;
	for (int i = n - 1; i >= 0; i--)
	{
		li val=0;
		if (s[i] == '1')
			val = p % mod;
		ans = (ans + val) % mod;
		p = (p * 2) % mod;
	}
	return ans;
}
int main()
{
	li N; cin >> N; string s;
	cin >> s;
	li cnt = countSetBits(s);
	map<li, li> mp;
	mp[cnt - 1] = power(s, cnt - 1);
	mp[cnt] = power(s, cnt);
	mp[cnt + 1] = power(s, cnt + 1);
	vector<li> cnt1(N), cnt_1(N); li p = 1,p2=1;
	for (int i = s.size() - 1; i >= 0; i--)
	{
		cnt1[i] = p % (cnt + 1);
		if (cnt > 1)
		{
			cnt_1[i] = p2 % (cnt - 1); p2 = (p2 * 2) % (cnt - 1);
		}
		p = (p * 2) % (cnt + 1);
	}
	for (int i = 0; i < N; i++)
	{
		if (s[i] == '1')
		{
			if (cnt == 1)
			{
				cout << "0\n";
			}
			else
			{
				li val = (mp[cnt - 1] - cnt_1[i] + 3*cnt -3) % (cnt - 1);
					cout << f(val) + 1 << "\n";
			}
		}
		else
		{
			li val = (mp[cnt + 1] + cnt1[i]) % (cnt + 1);
			cout << f(val) + 1 << "\n";
		}
	}
	
	return 0;
}

Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
 
#define test        int tc;cin>>tc;while(tc--)

bool check(string str){

    for(int i=1;str[i];i++){
        if(str[i]!=str[0]){
            for(int j=i+1;str[j];j++){
                if(str[j]==str[0])
                    return 1;
            }
        }
    }
    return 0;
}

int32_t main(){
        
    int n;cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    bool ok=false;
    for(int i=0;i<n;i++){
        if(arr[i]%2==0){
            if(arr[i]%3==0 || arr[i]%5==0)
                continue;
            else{
                ok=true;
                break;
            }
        }
    }
    if(ok)
        cout<<"DENIED"<<endl;
    else
        cout<<"APPROVED"<<endl;
        
}


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

int main() {
    int n;
    cin>>n;
    int cnt[2][100001];
    memset(cnt, 0, sizeof(cnt));
    for (int i=0; i<n; i++) {
        int a; cin>>a;
        cnt[i%2][a]++;
    }
    priority_queue<int> heap1, heap2;
    heap1.push(0); heap2.push(0);
    int max1=0, max2=0, max1num, max2num;
    for (int i=1; i<=100000; i++) {
        if (cnt[0][i])
            heap1.push(cnt[0][i]);
        if (cnt[1][i])
            heap2.push(cnt[1][i]);
        if (cnt[0][i] > max1)
            max1=cnt[0][i], max1num=i;
        if (cnt[1][i] > max2)
            max2=cnt[1][i], max2num=i;
    }
    if (max1==max2 && max1num==max2num) {
        int tmp = heap1.top();
        heap1.pop(); heap2.pop();
        int tmp2 = max(heap1.top(), heap2.top());
        cout<<n/2-tmp + n/2-tmp2<<endl;
    }else
        cout<<n/2-heap1.top() + n/2-heap2.top()<<endl;
    return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
#include<string.h>
#define M 1046527
#define NIL (-1)
#define L 14
 
char H[M][L];
 
int getChar(char ch){
    if (ch == 'A')return 1;
    else if(ch == 'C')return 2;
    else if (ch == 'G')return 3;
    else if (ch == 'T')return 4;
    else return 0;
}
 
long long getKey(char str[]){
    long long sum = 0,p=1,i;
    for (i = 0; i < strlen(str); i++){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}
 
int h1(int key){
    return key % M;
}
 
int h2(int key){
    return 1 + key % (M - 1);
}
 
int find(char str[]){
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++){
        h = (h1(key) + i*h2(key))% M;
        if (strcmp(H[h], str) == 0)return 1;
        else if (strlen(H[h]) == 0)return 0;
    }
    return 0;
}
 
int insert(char str[]){
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++){
        h = (h1(key) + i*h2(key)) % M;
        if (strcmp(H[h], str) == 0)return 1;
        else if (strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}
 
int main(){
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++)H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%s %s", com, str);
        if (com[0] == 'i'){
            insert(str);
        }
        else{
            if (find(str)){
                printf("yes\n");
            }
            else{
                printf("no\n");
            }
        }
    }
    return 0;
}

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

int main()
{	int count =0 ,n; 
	string a,b;

	cin >>a >> b;
	n= a.size();
	for (int i=0 ; i< n; i++ )
	{
		if (a[i]!=b[i])
		count++ ;
		
	} 
	
		
	cout<< count ;
	return 0;
	
	}
	
	


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

using namespace std;

// 多次元 mul_array<int, 1, 2, 3> a
//template <typename T, std::size_t... Ns>
//struct index_reverse_for_array;
//template <typename T, std::size_t N, std::size_t... Ns>
//struct index_reverse_for_array<T, N, Ns...> { using type = std::array< typename index_reverse_for_array<T, Ns...>::type, N>; };
//template <typename T, std::size_t N>
//struct index_reverse_for_array<T, N> { using type = std::array<T, N>; };
//template <class T, std::size_t... Ns> using mul_array = typename index_reverse_for_array<T, Ns...>::type;
//
//using u32 = uint32_t;
//using s32 = uint32_t;
//using u64 = uint64_t;
//using s64 = uint64_t;

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

    while (true) {
        int N;
        cin >> N;
        if (N == 0) break;
        vector<pair<int, int> > p(N);
        p[0].first = 0;
        p[0].second = 0;
        int maxx = 0, maxy = 0, minx = 0, miny = 0;
        for (int i = 0; i < N-1; i++) {
            int A, B;
            cin >> A >> B;
            if (B == 0) {
                p[i + 1].first = p[A].first - 1;
                p[i + 1].second = p[A].second;
            }
            else if (B == 1) {
                p[i + 1].first = p[A].first;
                p[i + 1].second = p[A].second + 1;
            }
            else if (B == 2) {
                p[i + 1].first = p[A].first + 1;
                p[i + 1].second = p[A].second;
            }
            else if (B == 3) {
                p[i + 1].first = p[A].first;
                p[i + 1].second = p[A].second - 1;
            }
            if (maxx < p[i + 1].first) maxx = p[i + 1].first;
            if (maxy < p[i + 1].second) maxy = p[i + 1].second;
            if (minx > p[i + 1].first) minx = p[i + 1].first;
            if (miny > p[i + 1].second) miny = p[i + 1].second;
        }
        cout << (maxx - minx + 1) << " " << (maxy - miny + 1) << endl;


    }

    return 0;
}




Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int sumodd = 0;
    for(int i = 0; i < n; i++){
        int j;
        cin >> j;
        if(j % 2 == 1)sumodd += j;
    }
    cout << (sumodd % 2 == 0 ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
 
using namespace std;
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,b[105];
    memset(b,INF,sizeof(b));
    cin >> n;
    lol sum = 0;
    reps(i,n - 1){
      cin >> b[i];
    }
    sum += b[1];
    reps(i, n - 1){
      sum += min ( b[i],b[i+1] );
    }
    cout << sum << '\n';
    return 0;
}


Measured memory_bytes: 256
N, u, v = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(N - 1)]

def BFS(K, edges, N):
    roots = [[] for _ in range(N)]
    for a, b in edges:
        roots[a-1] += [(b-1)]
        roots[b-1] += [(a-1)]
    dist = [-1]*N
    stack = []
    stack.append(K)
    dist[K] = 0
    while stack:
        label = stack.pop(-1)
        for i in roots[label]:
            if dist[i] == -1:
                dist[i] = dist[label] + 1
                stack += [i]
    return dist

U = BFS(u - 1, ABs, N)
V = BFS(v - 1, ABs, N)

max_ = 0
for a, b in zip(U, V):
    if a < b:
        max_ = max(max_, b - 1)

print(max_)

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

int main()
{
  string str;
  char type;
  for(;cin>>str>>type,type!='X';)
    {      
      if(type=='U')
	{
	  for(int i=0;i<str.size();i++)
	    {
	      bool up=false;
	      if(i==0 || str[i]=='_')
		up=true;
	      if( str[i]=='_')
		i++;
	      if(up)
		cout<<(char)toupper(str[i]);
	      else
		cout<<str[i];
	    }
	}
      else if(type=='L')
	{
	  for(int i=0;i<str.size();i++)
	    {
	      if(str[i]=='_')
		{
		  i++;
		  cout<<(char)toupper(str[i]);
		}
	      else if(i==0)
		cout<<(char)tolower(str[i]);
	      else
		cout<<str[i];
	    }
	}
      else
	{
	  for(int i=0;i<str.size();i++)
	    {
	      if(i!=0 && isupper(str[i]))
		  cout<<"_";	      
	      cout<<(char)tolower(str[i]);	      
	    }
	}
      cout<<endl;
    }

}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  sort(all(A));
  cout << A[N - 1] - A[0] << endl;
}

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

using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<int>> mh(h);
    vector<vector<int>> mw(w,vector<int>(1,-1));
    vector<string> mp;
    for (int i = 0; i < h; ++i) {
        string t;
        cin>>t;
        mp.emplace_back(t);
        mh[i].emplace_back(-1);
        for (int j = 0; j < w; ++j) {
            if(t[j]=='#'){
                mh[i].emplace_back(j);
                mw[j].emplace_back(i);
            }
        }
        mh[i].emplace_back(w);
    }
    for (int i = 0; i < w; ++i) {
        mw[i].emplace_back(h);
    }
    int ans=0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(mp[i][j]=='#')continue;
            int tans=0;
            auto hu=upper_bound(mh[i].begin(),mh[i].end(),j);
            auto hl=hu-1;
            tans+=*hu-*hl-1;

            auto wu=upper_bound(mw[j].begin(),mw[j].end(),i);
            auto wl=wu-1;
            tans+=*wu-*wl-1;
            ans=max(ans,tans);
        }
    }
    cout<<ans-1<<endl;
    return 0;
}

Measured memory_bytes: 40320
#include "bits/stdc++.h"
using namespace std;
int dp[80000][11];
int main() {
	string s;
	while (cin >> s, s != "0") {
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < s.size(); i++) {
			if (s[i] != '0') dp[i][s[i] - '0']++;
		}
		for (int i = 0; i + 1 < s.size(); i++) {
			for (int j = 0; j < 11; j++) {
				dp[i + 1][(j * 10 + (s[i + 1] - '0')) % 11] += dp[i][j];
			}
		}
		int ans = 0;
		for (int i = 0; i < s.size(); i++) ans += dp[i][0];
		cout << ans << endl;
	}
}


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

using namespace std;

struct Memo
{

  int count;

  Memo()
  {
    count = 0;
  }

};

Memo memo[31];

int ProgressNumberOfYears(int step_num)
{

  int kind_count = 0;

  if(step_num == 0) return 1;
  else if(memo[step_num].count) return memo[step_num].count;

  if(step_num - 3 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 3);
  if(step_num - 2 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 2);
  if(step_num - 1 >= 0)  kind_count = kind_count + ProgressNumberOfYears(step_num - 1);

  memo[step_num].count = kind_count;

  return kind_count;

}

int main()
{

  int step_num;

  while(cin >> step_num && step_num != 0) cout << ProgressNumberOfYears(step_num)/10/365 + 1<< endl;

  return 0;

}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <string>

using namespace std;

class Dice
{
  public:
    vector<int> diceNum;
    Dice(vector<int>& inputs);
    void toS();
    void toN();
    void toW();
    void toE();
};

Dice::Dice(vector<int>& inputs)
{
  diceNum=inputs;
}

void Dice::toE()
{
  swap(diceNum[0],diceNum[2]);
  swap(diceNum[0],diceNum[5]);
  swap(diceNum[0],diceNum[3]);
}

void Dice::toW()
{
  swap(diceNum[0],diceNum[3]);
  swap(diceNum[0],diceNum[5]);
  swap(diceNum[0],diceNum[2]);
}

void Dice::toS()
{
  swap(diceNum[0],diceNum[1]);
  swap(diceNum[0],diceNum[5]);
  swap(diceNum[0],diceNum[4]);
}

void Dice::toN()
{
  swap(diceNum[0],diceNum[4]);
  swap(diceNum[0],diceNum[5]);
  swap(diceNum[0],diceNum[1]);
}

int main(int argc,char* argv[])
{
  vector<int> inputs(6);
  string operation;
  for(int i=0;i<6;i++){cin >> inputs[i];}
  Dice dice(inputs);
  cin >> operation;
  for(int i=0;i<operation.size();i++)
  {
    if(operation[i]=='E') dice.toE();
    else if(operation[i]=='W') dice.toW();
    else if(operation[i]=='S') dice.toS();
    else if(operation[i]=='N') dice.toN();
  }
  cout << dice.diceNum[0] << endl;
}

Measured memory_bytes: 3224
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
  int n, a;
  int ans = 0;
  vector<int> l;

  cin >> n;
  for(int i = 0; i<n*2; i++){
    cin >> a;
    l.push_back(a);
  }
  sort(l.begin(), l.end());
  for(int i = l.size() - 2; i >= 0; i=i-2){
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main(){
	int m[50];
	int f[50];
	int r[50];
	int stu[50] = { 0 };
	for (int a = 0;; a++){
		cin >> m[a] >> f[a] >> r[a];
		stu[a] = m[a] + f[a];
		if (m[a]==-1&&f[a]==-1&&r[a]==-1){
			for (int b = 0; b < a;b++){
				if (m[b] == -1 || f[b] == -1){
					cout << "F" << endl;
				}
				else if (stu[b] >= 80){
					cout << "A" << endl;
				}
				else if (stu[b] >= 65 && stu[b] < 80){
					cout << "B" << endl;
				}
				else if (stu[b] >= 50 && stu[b] < 65){
					cout << "C" << endl;
				}
				else if (stu[b] >= 30 && stu[b] < 50 && r[b] >= 50){
					cout << "C" << endl;
				}
				else if (stu[b] >= 30 && stu[b] < 50){
					cout << "D" << endl;
				}
				else if (stu[b] < 30){
					cout << "F" << endl;
				}
			}
			break;
		}
	}
	
	return 0;
	}


Measured memory_bytes: 3092
public class Main {
    public static void main(String args[]) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int h = sc.nextInt(), n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }
        if (sum >= h) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 48932
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());
        var array = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        for (int i = 0; i < array.Length; i++)
        {
            array[i] -= i+1;
        }
        var sorted = array.OrderBy(x => x).ToArray();
        var minL = sorted[N / 2];
        var minH = N==1?sorted[0]:sorted[(N / 2)+1];
        Console.WriteLine(Math.Min(abs(minL, N, sorted), abs(minH, N, sorted)));
    }
    static long abs(long b,long N, long[] array)
    {
        long res = 0;
        for (long i = 0; i < N; i++)
        {
            res += Math.Abs(array[i]-b);
        }
        return res;
    }
}

Measured memory_bytes: 42784
#include<iostream>
using namespace std;
int N;
long K;
int A[2<<17],T[2<<17],E[2<<17];
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		A[i]--;
		E[i]=i;
	}
	while(K)
	{
		if(K&1)
		{
			for(int i=0;i<N;i++)T[i]=A[E[i]];
			for(int i=0;i<N;i++)E[i]=T[i];
		}
		K>>=1;
		for(int i=0;i<N;i++)T[i]=A[A[i]];
		for(int i=0;i<N;i++)A[i]=T[i];
	}
	cout<<E[0]+1<<endl;
}


Measured memory_bytes: 6012
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

a, b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6:
    print(b//2)
else:
    print(0)


Measured memory_bytes: 5048
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> M >> N;
	vector<vector<int>>v(N);
	for (int i = 0; i < N; i++) {
		cin >> K;
		v[i].resize(K);
		for (auto &j : v[i]) {
			cin >> j;
			j--;
		}
	}
	int ans = 0;
	vector<int>p(N);
	for (auto &i : p)cin >> i;
	for (int i = 0; i < 1 << M; i++) {
		vector<int>num(N);
		for (int j = 0; j < M; j++) {
			if ((i >> j) & 1)continue;
			for (int k = 0; k < N; k++) {
				for (auto l : v[k])if (j == l)num[k]++;
			}
		}
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			if ((num[j] & 1) == p[j])cnt++;
			//cout << j << " " << num[j] << endl;
		}
		if (cnt == N)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256