akhauriyash/Code-Regression huggingface dataset:
// CODING BEAST
/*******************************************************************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define Precision(a) cout << fixed << setprecision(a)

using ll = long long;
ll inf = 1e18;
using vb = vector<bool>; using vc = vector<char>; using vd = vector<double>; using vi = vector<int>; using vvi = vector<vi>;
using vll = vector<ll>; using vvll = vector<vll>; using pi = pair<int, int>; using pll = pair<ll, ll>;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i = 0; i < n; i++)
#define repc(i,a,n) for(ll i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define pow2(x) (1ll<<(x))
#define Blazing_fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trav(a,v) for(auto &a:v)
int a[8] = { -1, -1, -1, 0, 0, 1, 1, 1};
int b[8] = { -1, 0, 1, -1, 1, -1, 0, 1};
inline ll power(ll x, ll y)
{
    ll temp;
    if ( y == 0)
        return 1;
    temp = power(x, y / 2) ;
    if (y % 2 == 0)
        return (temp * temp) ;
    else
        return (x * temp * temp) ;
}
bool sortbysec(pll & a, pll & b) {
    return (a.second < b.second);
}
/*
ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = (res * i) ;
    return res;
}

ll ncr(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}
bool isprime(ll n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if ((n % 2 == 0) || (n % 3 == 0)) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if ((n % i == 0) || (n % (i + 2) == 0)) return false;

    return true;
}*/
/*********************************************************************************************************************************************************/

signed main() {
    string s;
    cin >> s;
    ll ans = 0;
    rep(i, s.size()) {
        ans += (s[i] - '0');
    }
    if (ans % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}




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

int N;
char S[100 + 10];

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

    bool f = true;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'Y') {
            f = false;
            break;
        }
    }

    if (f) cout << "Three" << endl;
    else cout << "Four" << endl;
    
    return 0;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const M: i64 = 1_000_000_000;

fn main() {
    let (N, K, S) = read!(usize, usize, i64);

    let padding = if S == M && K < N { 1 } else { M };

    let A = (0..N).map(|i| if i < K { S } else { padding });

    let s = A.map(|n| n.to_string()).collect::<Vec<_>>().join(" ");
    println!("{}", s)
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
multimap<string,int>mp;
int main() {
	int q;
	cin >> q;
	while (q--) {
		int Q;
		cin >> Q;
		string s, l, r;
		int x;
		if (Q == 0) {
			cin >> s >> x;
			mp.insert(make_pair(s, x));
		}
		if (Q == 1) {
			cin >> s;
			for (auto it = mp.lower_bound(s); it != mp.end() && it->first == s; it++) {
				cout << it->second << endl;
			}
		}
		if (Q == 2){
			cin >> s;
			mp.erase(s);
		}
		if (Q == 3) {
			cin >> l >> r;
			auto now = mp.lower_bound(l);
			auto end = mp.upper_bound(r);
			assert(l <= r);
			while (now!=end) {
				cout << now->first << " " << now->second << endl;
				++now;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 24824
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c)              c.begin(), c.end()
#define CC(x) cout << (x) << endl
#define rep(i,n) for(int i=0;i<n;i++)
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define EPS 1e-9
typedef unsigned long long ull;
using namespace std;

int main()
{
   
    ll x,y;cin >> x >>y;
    ll ans=0;
    while(x>=1)
    {
        x-=y;
        ans++;
    }
    cout <<ans <<endl;
}


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

void goToX(int &cx, int tx) {
	while (cx < tx) {
		cx++;
		putchar('R');
	}
	while (cx > tx) {
		cx--;
		putchar('L');
	}
}

void goToY(int &cx, int tx) {
	while (cx < tx) {
		cx++;
		putchar('U');
	}
	while (cx > tx) {
		cx--;
		putchar('D');
	}
}

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int cx = x1, cy = y1;
	goToY(cy, y2);
	goToX(cx, x2);
	goToY(cy, y1);
	goToX(cx, x1);
	
	goToX(cx, cx - 1);
	goToY(cy, y2 + 1);
	goToX(cx, x2);
	goToY(cy, y2);
	
	goToX(cx, x2 + 1);
	goToY(cy, y1 - 1);
	goToX(cx, x1);
	goToY(cy, y1);
	return 0;
}


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

const int INF = 1001001001;

int main(void){
  int k;
  cin >> k;
  int o = (k+1)/2;
  int e = k/2;
  cout << o*e << endl;
  return 0;
}

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

using namespace std;

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

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

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

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

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

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

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

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

  int h, w, m; cin >> h >> w >> m;
  vi vh(h), vw(w);
  map<P, bool> mp;

  REP(i, m) {
    int r, c; cin >> r >> c;
    r--; c--;
    vh[r]++;
    vw[c]++;
    mp[{r, c}] = true;
  }

  int mah = 0, maw = 0;
  REP(i, h) {
    chmax(mah, vh[i]);
  }
  REP(i, w) {
    chmax(maw, vw[i]);
  }

  ll cntmah = 0, cntmaw = 0;
  REP(i, h) {
    cntmah += vh[i] == mah;
  }
  REP(i, w) {
    cntmaw += vw[i] == maw;
  }

  ll cnt = 0;
  for(auto &e: mp) {
    if(vh[e.first.first] == mah && vw[e.first.second] == maw) {
      cnt++;
    }
  }


  if(cnt == cntmah * cntmaw) {
    cout << mah + maw - 1 << endl;
  } else {
    cout << mah + maw << endl;
  }


}








Measured memory_bytes: 24316
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    auto s = readln.chomp;
    int from = s.size, to = -1;
    foreach (int i, c; s) {
        if (c == 'A') {
            from = min(i, from);
        } else if (c == 'Z') {
            to = max(i, to);
        }
    }
    writeln(to - from + 1);
}


Measured memory_bytes: 2556
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    ll n, k;
    cin >> n >> k;
    vector <ll> v(n), visited;
    for (int i = 0; i< n; i++) cin >> v[i];
    map <int, int> m;
    ll len = 1;
    int start = 1;
    while (!m[start]) {
        visited.pb(start);
        m[start] = len;
        start = v[start-1];
        len++;
        //cout << start << ' ';
    }
    ll cycle = len - m[start];
    //cout << cycle << endl;
    if (k < m[start]-1) cout << visited[k] << endl;
    else {
        //cout << start << endl;
        k -= m[start]-1;
        //cout << cycle <<' ' << k <<  endl;
        ll index = k%cycle;
        cout << visited[m[start]-1+index] << endl;
    }
}



Measured memory_bytes: 15380
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b,c=map(int,input().split())
    from fractions import gcd
    d=gcd(a,b)
    print("NO" if c%d else "YES")
resolve()

Measured memory_bytes: 64492
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

const int MAXN = 1e5 + 10;
int n, a[MAXN];

void decomp() {

    vector <int> v;

    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        v.pb(a[i]);
    }

    sort(all(v));

    v.resize(unique(all(v)) - v.begin());

    for(int i = 1; i <= n; ++i) {

        a[i] = lower_bound(all(v), a[i]) - v.begin() + 1;

    }

}

int main(){

cin >> n;

decomp();

ll res = 0;

for(int i = 1; i <= n; ++i) {
    if(a[i] % 2 != i % 2) {res++;}
}

cout << res / 2;

return 0;
}



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

int main() {
	int N;
	cin >> N;
	int l, r;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum << endl;
	return 0;
}

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


int main() {
	string str;
	int n;
	cin >> n >> str;
	int maxcount = 0;
	for (int i = 1; i < str.size() -1; i++) {
		string a = str.substr(0, i);
		string b = str.substr(i, str.back());
		//cout << a << " " << b << endl;

		map<char, int> mp;
		for (int i = 0; i < 26; i++) {
			char a = 'a';
			a += i;
			//cout << a;
			mp[a] = 0;
		}

		int count = 0;
		for (int i = 0; i < a.size(); i++) {
			mp[a[i]] = 1;
		}

		for (int i = 0; i < b.size(); i++) {
			if (mp[b[i]] == 1) {
				mp[b[i]] = 2;
				count++;
			}
		}
		if (count >= maxcount)
			maxcount = count;
	}
	cout << maxcount << endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("Sunny")) {
            System.out.println("Cloudy");
        }else if (s.equals("Cloudy")) {
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }


    }

}

Measured memory_bytes: 19412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

constexpr int mod = 998244353;

ll mod_pow(ll x, ll y) {
    if (!y) return 1;
    ll a = mod_pow(x, y >> 1);
    if (y & 1) return a * a % mod * x % mod;
    else return a * a % mod;
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    vector<vector<ll>> dp(C - A + 1, vector<ll>(D - B + 1, 1));
    for (int i = 1; i <= C - A; ++i) dp[i][0] = dp[i - 1][0] * B % mod;
    for (int j = 1; j <= D - B; ++j) dp[0][j] = dp[0][j - 1] * A % mod;
    for (int i = 1; i <= C - A; ++i) {
        for (int j = 1; j <= D - B; ++j) {
            dp[i][j] = (dp[i - 1][j] * (B + j) + dp[i][j - 1] * (A + i) - (A + i - 1) * (B + j - 1) % mod * dp[i - 1][j - 1] % mod + mod) % mod;
        }
    }
    cout << dp[C - A][D - B] << "\n";
    return 0;
}


Measured memory_bytes: 73532
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	int n, k = 0;
	cin >> n;

	FORR(1,10)
		if (n / i <= 9 && n % i == 0) {
			cout << "Yes" << endl;
			k = 1;
			break;
		}
	if(k != 1)
		cout << "No" << endl;
	return 0;
}

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

using namespace std;

int ABS(int n){
    if (n < 0) n = -1 * n;
    return n;
}

int main(){
    int N; cin >> N;
    
    vector <int> X, Y, H;
    vector <int> X0, Y0;
    int size = 0;
    for (int i = 0; i < N; i++){
        int x, y, h; cin >> x >> y >> h;
        if (h != 0){
            X.push_back(x);
            Y.push_back(y);
            H.push_back(h);
            size++;
        }else{
            X0.push_back(x);
            Y0.push_back(y);
        }
    }


    for (int Cx = 0; Cx <= 100; Cx++){
        bool f1 = false;
        for (int Cy = 0; Cy <= 100; Cy++){
            
            bool f = true;
            for (int i = 0; i < size - 1; i++){
                int h1 = H[i] + ABS(X[i] - Cx) + ABS(Y[i] - Cy);
                int h2 = H[i + 1] + ABS(X[i + 1] - Cx) + ABS(Y[i + 1] - Cy);
                if (h1 != h2){
                    f = false;
                    break;
                }
            }
            int h = H[size-1] + ABS(X[size-1] - Cx) + ABS(Y[size-1] - Cy);
            bool f2 = true;
            if (f == true){
                for (int i = 0; i < N - size; i++){
                    if (h - ABS(X0[i] - Cx) - ABS(Y0[i] - Cy) > 0){
                        f2 = false;
                    }
                }
            }else{
                f2 = false;
            }

            if (f2 == true){
                cout << Cx << " " << Cy << " " << h << endl;
                f1 = true;
            }
            

        }
        if (f1 == true) break;
    }
    

    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        p: [usize; n],
    }

    let expected_value = |x| (x+1.0) / 2.0;
    let mut maximum = 0.0; 
    for i in 0..k {
        maximum += expected_value(p[i] as f64);
    }
    let mut previous = maximum;

    for i in k..n {
        let current = previous - expected_value(p[i-k] as f64) + expected_value(p[i] as f64);
        previous = current;
        if maximum < current {
            maximum = current;
        }
    }
    println!("{}", maximum);
}


Measured memory_bytes: 4472
#include<bits/stdc++.h>
using namespace std;
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int a[n][3];
	for(int i = 0; i < n; ++i) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	} 
	int dp[n][3];
	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) {
		for(int j = 0; j < 3; ++j) {
			dp[i][j] = max(dp[i - 1][(j + 1)%3], dp[i - 1][(j + 2) % 3]) + a[i][j];
		}
	}
	cout<<max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}

Measured memory_bytes: 5900
h,w = (int(i) for i in input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
 
row = [False]*h
col = [False]*w
for i in range(h):
  for j in range(w):
    if a[i][j] =='#':
      row[i]= True
      col[j]= True
for i in range(h):
  if row[i]:
    for j in range(w):
      if col[j]:
        print(a[i][j],end='')
    print()

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL dp[100002][101];
LL weight[100 + 1], value[100 + 1];
LL cal(LL rem_weight, LL items_left)
{
    if (items_left == 1)
    {
        if (rem_weight >= weight[1])
        {
            return value[1];
        }
        else
        {
            return 0;
        }
    }
    else
    {
        if (dp[rem_weight][items_left] == -1)
        {
            LL sum = 0;
            LL first = -1, second = -1;
            if (rem_weight - weight[items_left] >= 0)
            {
                first = value[items_left]+cal(rem_weight - weight[items_left], items_left - 1);
            }

            second =cal(rem_weight,items_left-1);
            dp[rem_weight][items_left]=max(first,second);
        }
        return dp[rem_weight][items_left];
    }
}
int main()
{
    fastinput;
    LL n, i, j, k, t, temp, capacity;
    cin >> n >> capacity;
    for (i = 0; i <= capacity; i++)
    {
        for (j = 1; j <= n; j++)
        {
            dp[i][j] = -1;
        }
    }

    for (i = 1; i <= n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    LL ans=cal(capacity,n);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 79232
n, q = map(int, input().split())
s = input()
numofac = [0]*len(s)
cnt = 0
for i in range(1, len(s)):
    if s[i-1] == "A" and s[i] == "C":
        cnt += 1
    numofac[i] = cnt

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


Measured memory_bytes: 6084
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = 0;
            while ((n = int.Parse(Console.ReadLine())) != 0)
            {
                var s = Console.ReadLine();
                var h = s.Split(' ').Select(int.Parse).ToArray();

                for (int i = 0; i < n + 1; i++)
                {
                    var a = h.ToList();
                    a.RemoveAt(i);
                    var d = new List<int>();
                    for (int j = 1; j < n; j++)
                    {
                        d.Add(a[j] - a[j - 1]);
                    }

                    if (d.Max() == d.Min())
                    {
                        Console.WriteLine(h[i]);
                        break;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 6196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;

	if (n % 2 == 0) {
		n /= 2;
		puts(n >= k ? "YES" : "NO");
	}
	else {
		n = (n + 1) / 2;
		puts(n >= k ? "YES" : "NO");
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
   int h,s,h2,s2;
   cin>>h>>s>>h2>>s2;
   while(h>0&&h2>0){
     h2 -= s;
     if(h2<=0)break;
     h-=s2;
   }
   if(h>0)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main(){
	int i,j,n,f;
	char s[210];
	scanf("%d",&n);
	while(n--){
		scanf("%s",s);
		if(s[0]=='>' && s[1]=='\''){
			i=2;f=0;
			while(1){
				if(s[i]=='#')break;
				if(s[i]=='=')f++;
				else{f=0;break;}
				i++;
			}
			if(f==0)printf("NA\n");
			else{
				for(j=0;j<f;j++)if(s[i+j+1]!='=')break;
				if(j==f){
					if(s[i+f+1]=='~')printf("A\n");
					else printf("NA\n");
				}else printf("NA\n");
			}
		}else if(s[0]=='>' && s[1]=='^'){
			for(i=2;i<strlen(s)-2;i+=2){
				if(s[i]!='Q' || s[i+1]!='=')break;
			}
			if(strlen(s)>=6 && i==strlen(s)-2){
				if(s[i]=='~' && s[i+1]=='~')printf("B\n");
				else printf("NA\n");
			}else printf("NA\n");
		}else printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
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; }

// GCD ユークリッドの互除法バージョン
long long GCD(long long a, long long b) {
    if(b == 0) return a;
    else return GCD(b, a%b);
}

long long k;

int main() {
    cin >> k;
    long long sum = 0;
    for(int i = 1; i <= k; ++i) {
        for(int j = 1; j <= k; ++j) {
            for(int l = 1; l <= k; ++l) {
                long long ans = GCD(i, j);
                sum += GCD(ans, l);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
#include <vector>
#include <set>
using namespace std;

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

const int INF = 1LL << 60;
const int MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(n, i) {
        cin >> a[i];
    }
    int xor_all = 0;
    rep(n, i) {
        xor_all ^= a[i];
    }
    cout << ((xor_all == 0) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		String S=stdIn.next();
		boolean fin=false;
		int z=1;
		char b=S.charAt(0);
		while(z<4){
			char a=S.charAt(z);
			if(a==b){
				fin=true;
				break;
			}
			b=a;
			z++;
		}
		if(fin)
			System.out.println("Bad");
		else
			System.out.println("Good");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  int n,y;
  cin >> n >> y;
  int ic,go,se,kei;
  ic = y / 10000;
  go = (y % 10000) / 5000;
  se = (y % 5000) / 1000;
  kei = ic + go + se;
 
  if(n < kei){
      cout << "-1 -1 -1" << endl;
      return 0;
  }else if(n == kei){
      cout << ic << " " << go << " " << se;
      return 0;
  }else{
      int sa;
      sa = n - kei;
      if(sa < ic + 1){
        int a,b;
          a = ic - sa;
          b = go + 2 * sa;
          cout << a << " " << b << " " << se;
          return 0;
      }else{
          int p = sa - ic;
          int q = 0;
        for(int l = 0; l < 4; l++){
          if((p + l) % 4 == 0 && (p + l) / 4 <= go + 2 * (ic - l)){
            int a,b,c;
            a = l;
            b = go + 2 * (ic - l) - ((p + l)/ 4);
            c = se + ((p + l) / 4) * 5;
              cout << a << " " << b << " " << c;
            q = 1;
            return 0;
          }
        }
            cout << "-1 -1 -1" << endl;
  }
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    double B = sc.nextDouble();
    long C = A * (long)(B * 100 + 0.5);
    System.out.println(C / 100);
  }
}


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

using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	int count = 0;
	for(int i = 0; i < s.size(); i++){
		if(s.at(i) != t.at(i)) {
			count++;
		}
	}
	
	cout << count << endl;
	
}

Measured memory_bytes: 3912
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
    int h, w;
    while(true){
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            if(i == 0 || i == h - 1){
                for(int j = 0; j < w; j++){
                    printf("#");
                }
                printf("\n");
            } else {
                printf("#");
                for(int k = 0; k < w - 2; k++){
                    printf(".");
                }
                printf("#\n");
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3128
#![allow(dead_code)]

fn main() {
    let _n:usize = read();
    let num:Vec<u128>= read_vec();
    
    let mut _s:u128 = 1;
    
    if num.iter().any(|&x| x == 0) {
        println!("{}", 0);
    } else {

        for i in num.iter() {
            _s *= i;
            if _s > 10_u128.pow(18)  {
                break;
            }
        }


        if _s > 10_u128.pow(18) {
            println!("{}", -1);
        } else {
            println!("{}", _s);
        }
    }
}


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}


fn read_n<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}


Measured memory_bytes: 6452
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>

using namespace std;
const long long P = 1000000007;

int main() {
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1] = s[k-1] + 0x20;
  cout << s << endl;
  return 0;
}


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

ll N;
ll L[4000];
void input (){
    cin >> N;
    for (int i=0;i<N;i++) cin >> L[i];
    
}
void solve(){
    input();
    vector<ll> data(N);
    for (int i=0;i<N;i++) data[i] = L[i];
    sort(data.begin(), data.end());
    ll ans = 0;
    for (int i=N-1;i>=0;i--){
        for (int j=i-1;j>=0;j--){
            auto itr = lower_bound(data.begin(),data.end(), data[i]+data[j]);
            
            ll loc = distance(itr, data.end());
            
            ans += (N-1-i) - loc;
        }
    }
    cout << ans << endl;
  return ;
}


int main (){
	solve();
    return 0;
}






Measured memory_bytes: 256
inf = float('inf')

N,Ma,Mb = map(int,input().split())
abc = [list(map(int,input().split())) for _ in range(N)]

# dp[i][j][k]: i番目までみてj(g), k(g)となるような最小予算
dp = [[[inf]*401 for _ in range(401)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    a,b,c = abc[i]
    for j in range(401):
        for k in range(401):
            if j - a >= 0 and k - b >= 0:
                dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a][k-b] + c)
            else:
                dp[i+1][j][k] = dp[i][j][k]

ans = inf

for j in range(1,401):
    for k in range(1,401):
        if j * Mb == Ma * k:
            ans = min(ans, dp[N][j][k])

if ans == inf:
    ans = -1
print(ans)

Measured memory_bytes: 146012
#include<bits/stdc++.h>
using namespace std;
#define N 2000 + 5
#define Mod 1000000007
#define rep(i, l, r) for(int i = l; i <= r; ++i)
#define dep(i, l, r) for(int i = r; i >= l; --i)
int n, k, sum[N], dp[N][N];
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int Inc(int a, int b){
    return (a += b) >= Mod ? a - Mod : a;
}
int Mul(int a, int b){
    return 1ll * a * b % Mod;
}
int Qpow(int a, int b){
    int ans = 1;
    while(b){
        if(b & 1) ans = Mul(ans, a);
        a = Mul(a, a), b >>= 1;
    }
    return ans;
}
int main(){
    n = read(), k = read();
    dp[0][n + 1] = 1;
    rep(i, 1, n + 1) sum[i] = 1;
    rep(i, 1, k){
        dep(j, 1, n - i + 1){
            if(j != 1) dp[i][j] = Inc(dp[i][j], dp[i - 1][j]);
            dp[i][j] = Inc(dp[i][j], sum[j + 1]);
        }
        sum[n + 1] = 0;
        dep(j, 1, n) sum[j] = Inc(sum[j + 1], dp[i][j]);
    }
    if(n == k) printf("%d\n", dp[k][1]);
    else printf("%d", Mul(dp[k][1], Qpow(2, n - k - 1)));
    return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    vector<pair<int, int>> pv(n);
    rep(i, m) {
        cin >> p.at(i) >> s.at(i);
    }
    
    pair<int, int> ans;
    ans.first = 0;
    ans.second = 0;
    rep(i, m) {
        if (s.at(i) == "WA") {
            pv.at(p.at(i)-1).second++;
        }
        else { // "AC"
            if (pv.at(p.at(i)-1).first == 0) {
                ans.second += pv.at(p.at(i)-1).second;
                ans.first++;
                pv.at(p.at(i)-1).first++;
            }
        }
    }
    cout << ans.first << " " << ans.second << endl;
}

Measured memory_bytes: 6912
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int Q;
    cin >> Q;
    rep(k, Q){
        string X, Y;
        cin >> X >> Y;
        X = ' ' + X;
        Y = ' ' + Y;

        vector< vector<int> > A(X.size(), vector<int>(Y.size(), 0));
        for(int i = 1; i < X.size(); i++){
            for(int j = 1; j < Y.size(); j++){                
                if(X[i] == Y[j]){
                    A[i][j] = A[i-1][j-1] + 1;
                } else {
                    A[i][j] = max(A[i-1][j], A[i][j-1]);
                }
            }
        }
        cout << A[X.size() - 1][Y.size() - 1] << endl;
    }
}


Measured memory_bytes: 6824
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=5005*5005;
ll dp[2][maxn];
int a[4],b[4];
void work(int A[],int B[],ll f[],int n)
{
    ll mx=0;
    for(int i=1;i<maxn;i++)
    {
        f[i]=++mx;
        for(int j=0;j<3;j++)
            if(A[j]<=i) f[i]=max(f[i],f[i-A[j]]+B[j]);
        mx=max(mx,f[i]);
    }
}
ll cal(int n)
{
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        ans=max(ans,dp[1][dp[0][i]+n-i]);
    }
    return ans;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<3;i++)
        cin>>a[i];
    for(int i=0;i<3;i++)
        cin>>b[i];
    work(a,b,dp[0],n);
    work(b,a,dp[1],n);
    printf("%lld\n",cal(n));
    return 0;
}


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

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

  vector<long long int> num(N);
  rep(i,N){
    cin >> num.at(i);
  }

  long long int height = 0;
  for(int i = 1; i < N; i++){
    if(num.at(i) < num.at(i-1)){
      height += num.at(i-1) - num.at(i);
      num.at(i) += num.at(i-1) - num.at(i);
    } 
  }

  cout << height << endl;
}

Measured memory_bytes: 4820
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 51, M = 9;
int n, k, S, T;
//S - AND, T - OR

int C[N][N];
int from[N];
int a[N], al[N], ar[N];

struct Rec {
int S, T;
bool know[M], want[M];
int getmask(int *a) {
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        bool ban = 0;
        for (int bit = 0; bit < M; ++bit) {
            if (know[bit] && ((a[i] >> bit) & 1) != want[bit]) {
                ban = 1;
                break;
            }   
        }
        if (!ban) {
            ans += 1ll << i;
        }
    }   
    return ans;
}   
int ans = 0;
void solve(int i, int st, int *a, vector <ii> &s) {
    if (i == M) {
        int mask = getmask(a);
        s.app(mp(mask, st&1));
        return;
    }   

    solve(i + 1, st, a, s);

    if (((T >> i) & 1) && !((S >> i) & 1)) {
        know[i] = 1;
        want[i] = 0;
        solve(i + 1, st + 1, a, s);
        know[i] = 0;

        know[i] = 1;
        want[i] = 1;
        solve(i + 1, st + 1, a, s);
        know[i] = 0;
    }
}   
} d;

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    for (int i = 0; i < N; ++i) 
        C[i][0] = 1;
    for (int i = 1; i < N; ++i)
        for (int j = 1; j < N; ++j) 
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];

    cin >> n >> k >> S >> T;

    for (int i = 0; i < 18; ++i) {
        if (!((T >> i) & 1) && ((S >> i) & 1)) {
            cout << 0 << endl;
            exit(0);
        }   
    }   

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= k; ++j) {
            from[i] += C[i][j];
        }   
    }   

    int ptr = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if ((x&S) == S) {
            if ((x&T) == x) {
                a[ptr++] = x;
            }   
        }   
    }   
    n = ptr;
    for (int i = 0; i < n; ++i) {
        al[i] = a[i]&((1 << M) - 1);
        ar[i] = a[i]>>M;
    }   

    //pair (good, st mod 2)

    memset(d.know, 0, sizeof d.know);
    memset(d.want, 0, sizeof d.want);
    d.S = S&((1 << M)-1);
    d.T = T&((1 << M)-1);

    vector <ii> s1;
    d.solve(0, 0, al, s1);

    memset(d.know, 0, sizeof d.know);
    memset(d.want, 0, sizeof d.want);
    d.S = S>>M;
    d.T = T>>M;

    vector <ii> s2;
    d.solve(0, 0, ar, s2);

    /*
    for (auto e : s1) {
        cout << e.f << ' ' << e.s << endl;
    }
    */  

    int ans = 0;
    for (auto l : s1) {
        for (auto r : s2) {
            int can = l.f & r.f;
            int x = from[bp(can)];
            if (l.s^r.s) {
                ans -= x;
            }   
            else {
                ans += x;
            }   
        }   
    }   
    cout << ans << endl;
}


Measured memory_bytes: 4296
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int INF = 110101010;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ri = 0, gi = 0, bi = 0;
    rep(i, n){
        if (s[i] == 'R'){
            ri++;
            continue;
        }
        if (s[i] == 'G'){
            gi++;
            continue;
        }
        if (s[i] == 'B'){
            bi++;
            continue;
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == 'R') ri--;
        if (s[i] == 'G') gi--;
        if (s[i] == 'B') bi--;
        int tmpRi = ri, tmpGi = gi, tmpBi = bi;
        for (int j = i+1; j < n; j++){
            if (s[i] == s[j]) continue;
            if (s[i] == 'R'){
                if(s[j] == 'G'){
                    gi--;
                    if (s[j+(j-i)] == 'B') ans += (bi-1);
                    else ans += bi;
                }
                if(s[j] == 'B'){
                    bi--;
                    if (s[j+(j-i)] == 'G') ans += (gi-1);
                    else  ans += gi;
                }
            } 
            if (s[i] == 'G'){
                if(s[j] == 'R'){
                    ri--;
                    if (s[j+(j-i)] == 'B') ans += (bi-1);
                    else ans += bi;
                }
                if(s[j] == 'B'){
                    bi--;
                    if (s[j+(j-i)] == 'R') ans += (ri-1);
                    else ans += ri;
                }
            }
            if (s[i] == 'B'){
                if(s[j] == 'R'){
                    ri--;
                    if (s[j+(j-i)] == 'G') ans += (gi-1);
                    else ans += gi;
                }
                if(s[j] == 'G'){
                    gi--;
                    if (s[j+(j-i)] == 'R') ans += (ri-1);
                    else ans += ri;
                }
            }
        }
        ri = tmpRi; bi = tmpBi; gi = tmpGi;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
k, x = map(int, input().split())
l = list(map(int, input().split()))
hl = [i // 2 for i in l]
from fractions import gcd
from functools import reduce
def lcm(a, b):
    return a * b // gcd(a, b)
def lcm_list(l):
    return reduce(lcm, l, 1)
a = lcm_list(hl)
i = hl[0]
cnt = 0
while i % 2 == 0:
    cnt += 1
    i //= 2
flag = True
for i in hl:
    if i % (2 ** cnt) == 0 and i % (2 ** (cnt + 1)) != 0:
        continue
    else:
        flag = False
        break
if flag:
    print((x - a) // (a * 2) + 1)
else:
    print(0)


Measured memory_bytes: 84704
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

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

const int MOD = 1000000007;

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

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

int main(){
	int k,x;cin>>k>>x;
	int l=max(-1000000,x-k+1);
	int r=min(1000000,x+k-1);
	for(int i=l;i<=r;i++){
		cout<<i<<' ';
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter as D, defaultdict as dd
from math import factorial as ft, ceil as aron, log
from fractions import gcd as pg 
from bisect import insort as ins, bisect_left as bl, bisect_right as br
import sys

#sys.stdin=open("./testfile1.py","r")
raw_input=sys.stdin.readline

f1=lambda : map(int,raw_input().split())
f2=lambda : map(int,list(raw_input()))
f3=lambda : int(raw_input())
f4=lambda : raw_input().rstrip()
f5=lambda : raw_input().split()


def main():
    
    h,w=f1()
    a1=[[0]*w for i in xrange(h)]
    a2=[[0]*w for i in xrange(h)]
    a=[]

    inf=-10**1
    for i in xrange(h):
        a.append(f4())

    for i in xrange(h):
        oc=1
        m=inf
        for j in xrange(w):
            if a[i][j]=='#':
                k=j-1
                while k>-1 and a[i][k]!='#':
                    a1[i][k]=oc-1
                    k=k-1
                oc=1
                a1[i][j]=inf
            else:
                a1[i][j]=oc
                oc=oc+1
        if a[i][j]!='#':
            k=j-1
            while k>-1 and a[i][k]!='#':
                a1[i][k]=oc-1
                k=k-1

    for i in xrange(w):
        oc=1
        for j in xrange(h):
            if a[j][i]=='#':
                k=j-1
                while k>-1 and a[k][i]!='#':
                    a2[k][i]=oc-1
                    k=k-1
                oc=1
                a2[j][i]=inf
            else:
                a2[j][i]=oc
                oc=oc+1
        
        if a[j][i]!='#':
            k=j-1
            while k>-1 and a[k][i]!='#':
                a2[k][i]=oc-1
                k=k-1
        
    ans=inf
    for i in xrange(h):
        for j in xrange(w):
            #if i==j==1:
            #    #print a1[i][j],a2[i][j], a[i][j]
            if a[i][j]!='#':
                oc=a1[i][j]+a2[i][j]-1
                #print oc
                if oc>ans:
                    ans=oc

    # for i in xrange(h):
    #    print a1[i], a2[i]
    print ans


if __name__ == '__main__':
	main()

Measured memory_bytes: 100632
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;

int n;
int arr[MAXN];
int nxt_not_zero[MAXN];
void solve(){
    int i = 0;
    nxt_not_zero[n] = n;
    for(i = n - 1; i >= 0; i--){
        if(arr[i] == 0)
            nxt_not_zero[i] = nxt_not_zero[i + 1];
        else
            nxt_not_zero[i] = i;
    }
    long long ans = 0;
    for(i = 0; i < n; i++){
        int j = i;
        int sum = 0, xorr = 0;
        while(j < n){
            if(arr[j] == 0) {
                ans += nxt_not_zero[j] - j;
                j = nxt_not_zero[j];
            }
            else{
                sum += arr[j];
                xorr ^= arr[j];
                if(sum != xorr)
                    break;
                else
                    ans++;
                j++;
            }
        }
    }
    cout << ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int i = 0;
    for(i = 0; i < n; i++)
        cin >> arr[i];
    solve();
    return 0;
}

Measured memory_bytes: 5160
def main():
    N=int(input())
    X=input().split()
    if "0" in X:
        print(0)
        return
    ans=1
    for i in X:
        ans = int(i) * ans
        if 1000000000000000000<ans:
            print(-1)
            return
    print(ans)
main()

Measured memory_bytes: 82732
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  string N;
  ll K;
  cin >> N >> K;
  ll dp[N.size() + 1][2]
       [5];  // dp[上からi桁目まで][N以下確定か][0でない数の個数]
  reverse(N.begin(), N.end());
  REP(i, N.size() + 1) REP(j, 2) REP(k, 5) dp[i][j][k] = 0;
  dp[N.size() - 1][1][1] = N[N.size() - 1] - '0' - 1;
  dp[N.size() - 1][0][1] = 1;
  dp[N.size() - 1][1][0] = 1;
  for (int i = N.size() - 1; i > 0; i--) {
    for (int j = 0; j <= 9; j++) {
      REP(k, 4) {
        if (j == 0) {
          dp[i - 1][1][k] += dp[i][1][k];
        } else {
          dp[i - 1][1][k + 1] += dp[i][1][k];
        }
      }
    }
    for (int j = 0; j <= N[i - 1] - '0'; j++) {
      REP(k, 4) {
        if (j != N[i - 1] - '0') {
          if (j == 0) {
            dp[i - 1][1][k] += dp[i][0][k];
          } else {
            dp[i - 1][1][k + 1] += dp[i][0][k];
          }
        } else {
          if (j == 0) {
            dp[i - 1][0][k] += dp[i][0][k];
          } else {
            dp[i - 1][0][k + 1] += dp[i][0][k];
          }
        }
      }
    }
  }
  cout << dp[0][1][K] + dp[0][0][K] << endl;
  int a = 10;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(){
    int def,s,m,h;
    cin >> def;
    s = def % 60;
    def = def / 60;
    m = def % 60;
    def = def / 60;
    h = def;
    cout << h << ":" << m << ":" << s <<endl;
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <cstring>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int main(){
  ll a, b;
  cin >> a >> b ;

  cout << (b-a) * (b-a+1) / 2 - b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, m, a;
long long sum;

int main()
{
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a;
    sum += a;
  }
  int dif = n - sum;
  cout << max (-1, dif);
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){

	int n;

	long long a;

	long long minvalue = 1000000;

	long long maxvalue = -1000000;

	long long sum = 0;

	cin >> n;

	for ( int i = 0; i < n; i++ ){

		cin >> a;

		if ( a < minvalue ) minvalue = a;

		if ( a > maxvalue ) maxvalue = a;

		sum += a;

	}

	cout << minvalue << " " << maxvalue << " " << sum << endl;

	return 0;

}

Measured memory_bytes: 1172
#include<stdio.h>
#define SIZE10 100000

typedef long long int ll;
typedef unsigned char u8;

int main(void){
    int A = 0, B = 0, C = 0;
    int N = 0;
    int sum = 0;

    char w[10];

    scanf("%s", w);

    if(w[0] == 'S'){
        printf("Cloudy");
    }

    else if(w[0] == 'C'){
        printf("Rainy");
    }

    else{
        printf("Sunny");
    }

    return 0;
}

Measured memory_bytes: 128