akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio> 
#include <map>
using namespace std;

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

    map<long long, long long> even;
    map<long long, long long> odd;
    map<long long, long long> T;

    for(long long i = 0; i < n; i++){
        long long v;
        cin >> v;

        if(T.find(v) == T.end()){
            T[v] = 1;
        }
        else{
            T[v] += 1;
        }

        if(i % 2 == 0){
            if(even.find(v) == even.end()){
                even[v] = 1;
            }
            else{
                even[v] += 1;
            }
        }
        else{
            if(odd.find(v) == odd.end()){
                odd[v] = 1;
            }
            else{
                odd[v] += 1;
            }
        }
    }

    if(T.size() == 1){
        printf("%lld\n", n/2);
        return 0;
    }

    long long count_even = 0, count_odd = 0;

    long long max_even_value = 0;
    long long max_odd_value = 0;
    long long max_even_key = 0;
    long long max_odd_key = 0;
     long long max2_even_value = 0;
    long long max2_odd_value = 0;
    long long max2_even_key = 0;
    long long max2_odd_key = 0;

    map<long long, long long>::iterator it;

    for(it = even.begin(); it != even.end(); it++){
        if(max_even_value < it->second){
            max_even_value = it->second;
            max_even_key = it->first;
        }
    }
    even.erase(max_even_key);
    for(it = even.begin(); it != even.end(); it++){
        if(max2_even_value < it->second){
            max2_even_value = it->second;
            max2_even_key = it->first;
        }
    }
  
    for(it = odd.begin(); it != odd.end(); it++){
        if(max_odd_value < it->second){
            max_odd_value = it->second;
            max_odd_key = it->first;
        }
    }
    odd.erase(max_odd_key);
    for(it = odd.begin(); it != odd.end(); it++){
        if(max2_odd_value < it->second){
            max2_odd_value = it->second;
            max2_odd_key = it->first;
        }
    }


    if(max_odd_key != max_even_key){
        cout << n - max_odd_value - max_even_value << endl;
        return 0;
    }

    cout << min(n - max_odd_value - max2_even_value, n - max2_odd_value - max_even_value) << endl;

    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

string a,b,c;
int main(){
  cin>>a>>b>>c;
  cout<<a[0]<<b[1]<<c[2]<<endl;
}


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

using namespace std;

const int INF = 1<<30;

int n, a, b, c;
vector<int> l;

int dfs(int d, int x, int y, int z){
    if(d == n){
        if(x > 0 && y > 0 && z > 0){
            return abs(a - x) + abs(b - y) + abs(c - z) - 30;
        }else{
            return INF;
        }
    }
    int res1 = dfs(d + 1, x, y, z);
    int res2 = dfs(d + 1, x + l[d], y, z) + 10;
    int res3 = dfs(d + 1, x, y + l[d], z) + 10;
    int res4 = dfs(d + 1, x, y, z + l[d]) + 10;
    return min({res1, res2, res3, res4});
}

int main(){
    cin >> n >> a >> b >> c;
    l = vector<int>(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    cout << dfs(0, 0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        x: usize,
        v: [usize; n]
    }
    let mut w = v.clone();
    if v.into_iter().sum::<usize>() < x {
        println!("{}", n-1);
        return;
    }
    w.sort();
    let mut c = 0;
    let mut sum = 0;
    for a in w {
        sum += a;
        if sum > x {
            break;
        }
        c += 1;
    }
    println!("{}",c);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;
 
 
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
 
typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};
 
ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}
 
 
//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
ll N, H;
string s;
ll a[100010], b[100010];
 
int main(void) {
    int i;
    cin >> N >> i;
    cout << N-i+1 << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
int binarySearch(int*,int,int);
int main(){
  int a,b,i,j,flag=0;
  int aa[100000];
  int bb[50000];
  int count=0,judge=0;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&aa[i]);
  }
  scanf("%d",&b);
  for(j=0;j<b;j++){
    scanf("%d",&bb[j]);
    judge=binarySearch(aa,bb[j],a);
    if(judge!=0){
      count++;
      flag=1;
    }
  }
  if(flag==0){
    printf("0\n");
  }
  else{
    printf("%d\n",count);
  }
  return 0;
}

int binarySearch(int* A,int key,int n){
  int i,left=0,right,mid;
  right=n;
  while(left<right){
    mid=(left+right)/2;
    if(A[mid]==key){
      return 1;
    }
    else if(key<A[mid]){
      right=mid;
    }
    else{
      left=mid+1;
    }
  }
  return 0;
}


Measured memory_bytes: 2308
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char a[5000000];
int main()
{
    ll n;
    ll c=1;
    int m=0;
    cin>>n;
    while(n>0)
    {
        ll k=n%(26);
        if(k==0)
        {
            k=26;
            a[m++]='z';
        }
        else
        {
            a[m++]='a'+k-1;
        }
        n=(n-k)/26;

    }
    for(int i=m-1;i>=0;i--)
    {
        cout<<a[i];
    }
}

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

int main () {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  
  if (A > B) {
    ans += A;
    A--;
  }
  else {
    ans += B;
    B--;
  }
  if (A > B) {
    ans += A;
    A--;
  }
  else {
    ans += B;
    B--;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

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

    map<ll, ll> cnt;
    rep(i, n)
    {
        ll a;
        cin >> a;
        if (cnt.find(a) == cnt.end())
            cnt[a] = 1;
        else
            cnt[a]++;
    }

    ll ans = 0;
    for (auto iter = cnt.begin(); iter != cnt.end(); iter++)
    {
        ans += (iter->first <= iter->second ? iter->second - iter->first : iter->second);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9436
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const double eps = 1e-9;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vi water, sugar;
  REP(i,f+1) {
    REP(j,f+1) {
      int x = 100*a*i + 100*b*j;
      int y = c*i + d*j;
      if (x <= f) water.push_back(x);
      if (y <= f) sugar.push_back(y);
    }
  }

  SORT(water);
  SORT(sugar);

  water.erase(unique(ALL(water)),water.end());
  sugar.erase(unique(ALL(sugar)),sugar.end());

  //double cnct_max = -1.0;
  double cnct_max = 0;
  int xm, ym;
  for (auto x : water) {
    for (auto y : sugar) {
      //DEBUG(x);
      //DEBUG(y);
      if (x == 0 && y == 0) continue;
      if (y*100 > x*e || x+y > f) {
        continue;
      }
      else {
        double cnct = 100*(double)y/(x+y);
        //DEBUG(cnct);
        if (cnct_max < cnct + eps) {
        //if (cnct_max < cnct) {
          cnct_max = cnct;
          xm = x;
          ym = y;
        }
      }
    }
  }

  cout << xm+ym << " " << ym << endl;
}

Measured memory_bytes: 1400
def sieve(n):
    data = [k for k in range(2,n+1)]
    for d in data:
        data = [x for x in data if (x==d or x%d != 0)]
    return data

def fact(n,prime,arr):
    temp = n
    for i in prime:
        if i > n:
            break
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                temp //= i
                cnt += 1
            arr[i] += cnt
    if temp != 1:
        arr[temp] += 1
    if arr == []:
        arr[n] += 1
    return None

n = int(input())
prime = sieve(n)
arr = [0]*(n+1)
for i in range(2,n+1):
    fact(i,prime,arr)
    
ans = 1
for k in arr:
    if k == 0:
        continue
    ans = (ans*(k+1))%(1e+9+7)

print(int(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

bool check(const vector<int> &a){
    int maxi=a[0];
    for (int i = 1; i < a.size(); ++i) {
        if(a[i]<maxi) return false;
        maxi = a[i];
    }
    return true;
}

void solve(int cn) {
    int N; cin>>N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }

    if(check(a)){
        cout<<"YES"<<endl;
        return;
    }

    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            swap(a[i],a[j]);
            if(check(a)){
                cout<<"YES"<<endl;
                return;
            }
            swap(a[i],a[j]);
        }
    }
    cout<<"NO"<<endl;

}


#define SINGLE
int main() {
#ifdef SINGLE
    solve(1);
#else
    int N;
    cin>>N;
    for(int i=0;i<N;++i){
        solve(i);
    }
#endif
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long
#define ld long double
#define vi vector<int>
#define si set<int>
#define vc vector<char>
#define vll vector<ll>
#define vd vector<double>
#define pb push_back
#define lp(i,a,b) for(int i = a ; i <= b ; i ++)
#define rlp(i,a,b) for(int i = b ; i >= a ; i --)
#define a_sort(v) sort(v.begin(), v.end())
#define d_sort(v) sort(v.rbegin(), v.rend())
#define pii pair<int,int>
#define pi 3.14159265358979323846264338327950
using namespace std ;
// #define debug

const int MOD = 1E9 + 7 ;
const int N = 1E5 ;

int main() {
    #ifdef debug
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif // debug
    optimize

    int n , k ; cin >> n >> k ;
    vi a(n) ; for(auto &x : a) cin >> x ;
    a_sort(a) ; int sum = 0 ;
    lp(i, 0, k-1) sum += a[i] ;
    cout << sum << endl ;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
int main() {
    fio;
    int n;
    cin >> n;
    if (n >= 30) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int H,W;
    cin >> H >> W;
    vector<vector<char>> vec(H,vector<char>(W));
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            cin >> vec.at(i).at(j);
        }
    }
    int L[H][W];
    int R[H][W];
    int D[H][W];
    int U[H][W];
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            if(vec.at(i).at(j) == '#') {
                L[i][j] = 0;
            }
            else if(j == 0) {
                L[i][j] = 1;
            }
            else {
                L[i][j] = L[i][j - 1] + 1;
            }
        }
    }
    for(int i = 0;i < H;i++) {
        for(int j = W - 1;j >= 0;j--) {
            if(vec.at(i).at(j) == '#') {
                R[i][j] = 0;
            }
            else if(j == W - 1) {
                R[i][j] = 1;
            }
            else {
                R[i][j] = R[i][j + 1] + 1;
            }
        }
    }
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            if(vec.at(i).at(j) == '#') {
                U[i][j] = 0;
            }
            else if(i == 0) {
                U[i][j] = 1;
            }
            else {
                U[i][j] = U[i - 1][j] + 1;
            }
        }
    }
    for(int i = H - 1;i >= 0;i--) {
        for(int j = 0;j < W;j++) {
            if(vec.at(i).at(j) == '#') {
                D[i][j] = 0;
            }
            else if(i == H - 1) {
                D[i][j] = 1;
            }
            else {
                D[i][j] = D[i + 1][j] + 1;
            }
        }
    }
    int ret = 0;
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            ret = max(ret,L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 129280
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int ans;
		if(b%a==0){ans=a+b;}else{ans=b-a;}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21204
a, b = gets.split.map(&:to_i)

cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]

if cards.find_index(a) > cards.find_index(b)
  puts 'Alice'
elsif cards.find_index(a) == cards.find_index(b)
  puts 'Draw'
else
  puts 'Bob'
end


Measured memory_bytes: 1788
N = int(input())
lis = [0]*10001

def calc(a,b,c):
    return a*a+b*b+c*c+a*b+b*c+c*a

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            ans = calc(i,j,k)
            if ans > 10000:
                break
            else:
                lis[ans] += 1

for i in range(1,N+1):
    print(lis[i])

Measured memory_bytes: 9376
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();		//たかはし体力
		int b=sc.nextInt();		//たかはし攻撃
		int c=sc.nextInt();		//あおき体力
		int d=sc.nextInt();		//あおき攻撃
		
		while(a>0&&c>0) {
			a=a-d;
			c=c-b;
		}
		if(c<=0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 26864
#include <stdio.h>

int main()
{
  int a[6];
  int i;
  i = 0;
  while (i < 5)
  {
    scanf("%d",&a[i]);
    if (a[i] == 0)
    {
      printf("%d",i + 1);
      return (0);
    }
    i++;
  }
  
}

Measured memory_bytes: 1708
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

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

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline ll read(){
	ll x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
map<ll,int>pos;vector<int>G[MAXN];
int n,id[MAXN],sz[MAXN],fa[MAXN];ll d[MAXN],tmp;
void dfs(int x,int d){tmp+=d;for(auto y:G[x])dfs(y,d+1);}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,1,n)pos[d[i]=read()]=i,id[i]=i;
	sort(id+1,id+n+1,[](int x,int y){return d[x]>d[y];});
	Rep(i,1,n)sz[i]=1;
	Rep(i,1,n-1){
		int x=id[i];ll t=d[x]+2*sz[x]-n;
		if(pos.count(t))fa[x]=pos[t],sz[fa[x]]+=sz[x];
		else return puts("-1"),0;
	}
	Rep(i,1,n)if(fa[i])G[fa[i]].pb(i);
	dfs(id[n],0);if(tmp!=d[id[n]])return puts("-1"),0;
	Rep(i,1,n)if(fa[i])cout<<i<<' '<<fa[i]<<'\n';
	return 0;
}





Measured memory_bytes: 18808
import sys
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

if (a+b+c+d == 7):
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")
    sys.exit
elif (a+b+c-d == 7):
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
    sys.exit    
elif (a+b-c+d == 7):
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
    sys.exit  
elif (a+b-c-d == 7):
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
    sys.exit      
elif (a-b+c+d == 7):
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=" + "7")
    sys.exit  
elif (a-b+c-d == 7):
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=" + "7")
    sys.exit  
elif (a-b-c+d == 7):
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=" + "7")
    sys.exit  
elif (a-b-c-d == 7):
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=" + "7")
    sys.exit  


Measured memory_bytes: 3064
a, b, c, d = [int(i) for i in input().split()]
nums = [a, b, c, d]

if a < 0 and b < 0 and 0 < c and 0 < d:
  print(b * c)
  exit(0)
if c < 0 and d < 0 and 0 < a and 0 < b:
  print(d * a)
  exit(0)


minus_num = len([i for i in nums if i < 0])
if minus_num == 4:
  print(a * c)
  exit(0)
if minus_num == 1 or minus_num == 0:
  print(b * d)
  exit(0)

if a * c < b * d:
  print(b * d)
else:
  print(a * c)

Measured memory_bytes: 9216
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
hs = [int(input()) for _ in range(N)]
def f(k):
    r = 0
    for h in hs:
        r += -(-max(0, (h-B*k)) // (A-B))
    return k>=r

mx,mn=10**18,0
idx=mx//2
while mx-mn>1:
    if f(idx):
        mx,idx=idx,(idx+mn)//2
        continue
    idx,mn=(idx+mx)//2,idx
print(idx+1)


Measured memory_bytes: 44764
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		List<Integer>p = new ArrayList<>();
		int a = 0;
		int min = 101;
		for(int i = 0; i < n; i++)
			p.add(sc.nextInt());
		for(int i = -1; i <= 200; i++){
			if(!p.contains(i) && Math.abs(i - x) < min){
				a = i;
				min = Math.abs(i - x);
			}
		}
		System.out.print(a);
	}
}


Measured memory_bytes: 36180
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

char s[110];
int szS;

int main()
{
	scanf("%s", s);
	szS = strlen(s);
	
	int l = 0;
	int h = szS - 1;
	int count = 0;
	while (l < h)
	{
		if (s[l] != s[h])
			count++;
		
		l++;
		h--;
	}
	
	printf("%d\n", count);
		
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,count=0;
   cin>>n;
   for(int i=1;i<=9;i++)
   {
       for(int j=1;j<=9;j++)
       {
          if (i*j==n)
           {
               count=1;
               break;
           }
       }
   }
   (count==1)?cout<<"Yes"<<endl:cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

template<int mod>
struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint f[101010];

int main(){
    fastcin();
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i]; 
    vector<int> d(n-1);
    rep(i, n-1) d[i] = x[i+1]-x[i];

    int m = n-1;
    f[0] = 1;
    rep1(i, 101010) f[i] = f[i-1]*i;
    modint ans = 0;
    modint p = 1;
    rep(i, n-1){
        ans += p*d[i];
        p += modint(1)/(i+2);
    }
    ans *= f[m];
    cout << ans << endl;
}

Measured memory_bytes: 1408
//Solution By SlavicG
#include "bits/stdc++.h"

using namespace std;
 
#define        ll                   long long
 
#define  forn(i,n)                  for(int i=0;i<n;i++)
#define     all(v)                  v.begin(), v.end()
#define    rall(v)                  v.rbegin(),v.rend()
 
#define        pb                    push_back
#define     sz(a)                    (int)a.size()
 
#define     fastio                  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define       endl                  "\n"

int main()
{
	map<ll,ll> m;
	ll n;
	cin >> n;
	ll a[n];
	ll ans=  0;
	forn(i,n){
		cin >> a[i];
		m[a[i]]++;
		if(m[a[i]] >= 4)
			ans = max(ans, a[i] * a[i]);
	}
	vector<ll> v;
	for(auto x : m){
		if(x.second >= 2){
			v.pb(x.first);
		}
	}
	if(sz(v) <=1){
		cout<<0;
		return 0;
	}
	sort(rall(v));
	ans = max(ans, v[0] * v[1]);
	cout << ans << endl;
}

Measured memory_bytes: 10488
#include <iostream>
#define ll long long
using namespace std;

int main(){

  int n;
  cin >> n;
  ll g[n][n];
  ll dist[n][n];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      int a;
      cin >> a;
      g[i][j] = dist[i][j] = a;
    }
  }
  ll ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        if(g[j][k] > g[j][i] + g[i][k]){ //更新があったら-1
          ans = -1;
          i = j = n;
          break;
        }
        if(g[j][k] == g[i][k] + g[j][i]){
          if(dist[j][i] != 0 && dist[i][k] != 0){
            dist[j][k] = 0;
          }
        }
      }
    }
  }
  if(ans != -1){
    ans = 0;
    for(int i = 0; i < n-1; i++){
      for(int j = i+1; j < n; j++){
        ans += dist[i][j];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1664
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

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

void solve()
{
    string str;
    getline(cin, str);

    int s = 0, sz = str.size();

    for(auto ch : str){
        if (ch == 'S') {
            s++;
        } else if (s > 0) {
            sz -= 2, s--;
        }
    }

    cout << sz << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}


Measured memory_bytes: 720
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    string s;
    cin >> s;
    REP(i, s.size()){
        if (i % 2 == 0) cout << s[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 576
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	bool yj = true;
	int i;
	cin >> n;
	vector<int>h(n);
	for(i=0;i<n;i++)cin >> h[i];
	for (i = n-1; i >= 0; i--) {
		if (i != 0) {
			if (h[i - 1] > h[i])h[i - 1]--;
		}
	}
	for (i = 0; i < n; i++)if (i != 0 && h[i - 1] > h[i])yj = false;
	if (yj)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int x ,y;
   cin >> x>>y;
   if(x<y)
   {
       for(int i = 0 ;i<y ;i++)
        cout<<x;
        cout<<endl;
   }
   else
   {
            for(int i = 0 ;i<x ;i++)
           cout<<y;
           cout<<endl;
   }
}



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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

char b;
map<char,char> base;

int main() {
    cin>>b;
    base['A']='T';
    base['T']='A';
    base['G']='C';
    base['C']='G';
    cout<<base[b]<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int count = 0,dount=0;
    string s;
    cin>>s;
    char ch = 'A';
    for(int i = 0; i<3; i++)
    {
        if(s[i]==ch)
            count++;
        else
            dount++;
    }
    if((count == 2 && dount == 1)||(count ==1 && dount ==2))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
#define db double
const int N = 3e5+10;
int a[N];
signed main(){
    int n;
    cin>>n;
    int res=0;
    for(int i=1;i<=100;i++){
        for(int j=i;j<=100;j++){
            for(int k=j;k<=100;k++){
                int tmp=i*i+j*j+k*k+i*j+i*k+j*k;
                if(i!=k&&i!=j&&j!=k){
                    a[tmp]+=6;
                }
                if(i==j&&i==k)a[tmp]++;
                if(i!=j&&k==j)a[tmp]+=3;
                else if(k!=j&&i==j)a[tmp]+=3;
                else if(j!=i&&i==k)a[tmp]+=3;
            }
        }
    }
    for(int i=1;i<=n;i++)cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 3796
#include<stdio.h>
#define MAX 100000

int main() {
    int N;
    int A[MAX];
    int x[MAX];

    scanf("%d", &N);

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

        if (i%2==0) sum+=A[i];
        else sum-=A[i];
    }
    x[0] = sum;

    for (int i=0; i<N-2; i++) {
        x[i+1] = 2*A[i] - x[i];
    }
    x[N-1] = 2*A[N-1] - x[0];

    for (int i=0; i<N; i++) {
        printf("%d ", x[i]);
    }
    
    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int main(){
  ull len;
  cin >> len;
  string s;
  cin >> s;
  ll sumr=0,sumg=0,sumb=0;
  rep(i,len){
    if(s[i] == 'R'){
      sumr++;
    }else if(s[i] == 'G'){
      sumg++;
    }else{
      sumb++;
    }
  }
  ll sum = 0;
  sum += sumr * sumg * sumb;
  REP(i,1,len){
    rep(j,len){
      t1 = j;
      t2 = t1+i;
      t3 = t2+i;
      if(t3 < len){
        if(s[t1] != s[t2] && s[t2] != s[t3] && s[t3] != s[t1]){
          sum--;
        }
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<vector<ll>> memo(N + 1, vector<ll>(2));
  memo[0][0] = 0;
  memo[0][1] = -INF;
  for (int i = 0; i < N; i++) {
    memo[i + 1][0] = max(memo[i][0] + A[i], memo[i][1] - A[i]);
    memo[i + 1][1] = max(memo[i][0] - A[i], memo[i][1] + A[i]);
  }
  cout << memo[N][0] << endl;
  return 0;
}

Measured memory_bytes: 9516
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    s = list(map(int, input()))
    t = list(input())
    n = len(t)
    for i in range(n):
        if t[i].isdecimal():
            t[i] = int(t[i])
    dp = [[[0]*2 for j in range(2)] for i in range(n+1)]
    dp[0][0] = [1,0]
    p = [pow(10,i,mod) for i in range(n)]
    for i in range(n):
        ni = i+1
        for j in range(2):
            if t[i] == "?":
                x = 9 if j else s[i]
                for d in range(x+1):
                    nj = j|(d < s[i])
                    dp[ni][nj][0] += dp[i][j][0]
                    dp[ni][nj][1] += dp[i][j][0]*d+10*dp[i][j][1]
                    dp[ni][nj][0] %= mod
                    dp[ni][nj][1] %= mod
            else:
                d = t[i]
                nj = j|(d < s[i])
                if d <= s[i]:
                    dp[ni][nj][0] += dp[i][j][0]
                    dp[ni][nj][1] += dp[i][j][0]*d+10*dp[i][j][1]
                    dp[ni][nj][0] %= mod
                    dp[ni][nj][1] %= mod
                else:
                    if nj:
                        dp[ni][nj][0] += dp[i][j][0]
                        dp[ni][nj][1] += dp[i][j][0]*d+10*dp[i][j][1]
                        dp[ni][nj][0] %= mod
                        dp[ni][nj][1] %= mod

    print((dp[-1][0][1]+dp[-1][1][1])%mod)
    return


if __name__ == "__main__":
    solve()



Measured memory_bytes: 84524
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N, M = map(int, input().split())
    graph = {}
    for i in range(N):
        graph[i] = set()
    for _ in range(M):
        A, B = map(int, input().split())
        graph[A-1].add(B-1)
        graph[B-1].add(A-1)
    que = deque([])
    que.append(0)
    seen = [0 for _ in range(N)]
    ans = [0 for _ in range(N)]
    while len(que) != 0:
        v = que.popleft()
        for node in graph[v]:
            if seen[node] == 1:continue
            ans[node] = v
            seen[node] = 1
            que.append(node)
    ok = "Yes"
    for i in range(N):
        if seen[i] == 0:
            ok = "No"
            break
    print(ok)
    if ok == "Yes":
        for i, a in enumerate(ans):
            if i == 0:continue
            print(a+1)
if __name__ == "__main__":
    main()

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


int main(){
  long long int N;
  cin >> N;
  long long int ans=0;
  for(long long int mod=1; mod * mod < N; mod++){
    if((N - mod)%mod==0){
      if((N-mod)/mod == mod) continue;
      ans+=(N-mod)/mod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int a[100001];
int n, m;

int compare(const void *a, const void *b) {
	int an = *(int*)(a);
	int bn = *(int*)(b);
	if (an < bn) {
		return -1;
	}
	else if (an > bn) {
		return 1;

	}
	else {
		return 0;
	}
}

int inarray(int x) {
	void* ans = NULL;
	ans = bsearch(&x, a, m, sizeof(int), compare);
	if (ans != NULL) {
		return 1;
	}
	else {
		return 0;
	}
}

int main(void) {
	/*int p, q, r;
	scanf("%d %d %d", &p, &q, &r);
	int a, b, c;
	a = p + q;
	b = q + r;
	c = r + p;
	printf("%d\n", MIN(a, MIN(b, c)));*/
	/*
	int n;
	int w[101];
	scanf("%d", &n);
	scanf("%d", &w[0]);
	int first = w[0];
	int last = 0;
	for (int i = 1; i < n; i++) {
		scanf("%d", &w[i]);
		last += w[i];
	}

	int min = abs(first - last);
	for (int i = 1; i < n-1; i++) {
		first += w[i];
		last -= w[i];
		int temp = abs(first - last);
		if (min > temp) {
			min = temp;
		}
	}
	printf("%d\n", min);*/
	/*
	scanf("%d %d", &n, &m);
	long long int dp[100001];
	for (int i = 0; i < m; i++) {
		scanf("%d", &a[i]);
		a[i]--;
	}
	if (inarray(0)) {
		dp[0] = 0;
	}
	else {
		dp[0] = 1;
	}
	if (inarray(1)) {
		dp[1] = 0;
	}
	else {
		dp[1] = 1 + dp[0];
	}
	for (int i = 2; i < n; i++) {
		if (inarray(i)) {
			dp[i] = 0;
		}
		else {
			dp[i] = (dp[i - 1] + dp[i - 2])%1000000007;
		}
	}
	printf("%lld\n", dp[n - 1]);*/

	int H, W;
	scanf("%d %d", &H, &W);
	char s[2001][2001];
	for (int i = 0; i < H; i++) {
		scanf("%s", s[i]);
	}
	int vertical[2001] = { 0 };
	int horizontal[2001] = { 0 };
	
	//int v_count[2001] = { 0 };
	//int h_count[2001] = { 0 };

	int max = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') {
				//v_count[j] = 0;
				//h_count[i] = 0;
				vertical[j] = 0;
				horizontal[i] = 0;
			}
			else {
				if (vertical[j] == 0) {
					vertical[j]++;
					while (i+vertical[j]<H) {
						if (s[i + vertical[j]][j] == '#') {
							break;
						}
						else {
							vertical[j]++;
						}
					}
				}
				if (horizontal[i] == 0) {
					horizontal[i]++;
					while (j + horizontal[i] < W) {
						if (s[i][j + horizontal[i]] == '#') {
							break;
						}
						else {
							horizontal[i]++;
						}
					}
				}
				if (max < horizontal[i] + vertical[j] - 1) {
					max = horizontal[i] + vertical[j] - 1;
				}
			}
		}
	}
	printf("%d\n", max);

	return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>
#include<string.h>

#define STR_MAX 80
#define ASCII_BIAS 48

char h_adder(char n1, char n2, char *n3, char carry)
{
  char result = n1 + n2 + carry;
  
  if(result<10){ *n3 = result + ASCII_BIAS; return 0; }
  else{ *n3 = result-10+ASCII_BIAS; return 1; }
}

int main(void)
{
  int i, j;
  int dataset;
  char in[2][STR_MAX+2], out[STR_MAX+2], result[STR_MAX+2];
  int len_in[2], idx_min, idx_max, lmin, lmax, lout, dif;
  char carry;
  char flg;

  scanf("%d\n", &dataset);

  for(i=0;i<dataset;i++){
    flg = 0;
    fgets(in[0], sizeof in[0], stdin); 
    len_in[0] = strlen(in[0])-1;
    if(in[0][len_in[0]]!='\n'){ while( getchar() != '\n' ) ; flg = 1;}
    fgets(in[1], sizeof in[1], stdin);
    len_in[1] = strlen(in[1])-1;
    if(in[1][len_in[1]]!='\n'){ while( getchar() != '\n' ) ; flg = 1;}

    // check # of digits
    if(flg){
      printf("overflow\n"); continue;
    }
    in[0][len_in[0]] = '\0';
    in[1][len_in[1]] = '\0';
    
    idx_min = (len_in[0]>len_in[1]) ? 1 : 0; // idx of shoter str
    idx_max = (idx_min + 1) & 1; // idx of longer str
    lmin = len_in[idx_min]-1; lmax = len_in[idx_max]-1;
    dif = (len_in[0]>len_in[1]) ? len_in[0]-len_in[1] : len_in[1]-len_in[0]; // difference in digits

    // execute addition
    carry = 0;
    for(j=0;j<lmin+1;j++){
      carry = h_adder(in[idx_min][lmin-j]-ASCII_BIAS, in[idx_max][lmin-j+dif]-ASCII_BIAS, &out[j+1], carry);
    }
    for(j=lmin+1;j<lmax+1;j++){
      carry = h_adder(0, in[idx_max][lmin-j+dif]-ASCII_BIAS, &out[j+1], carry);
    }
    
    // if carry is 0, validate overflow
    if(carry==1){
      if(lmax==STR_MAX-1){
  	printf("overflow\n"); continue;
      }    
    }

    lout = carry ? lmax+2 : lmax+1;
    out[lmax+2] = carry ? 1+ASCII_BIAS : 0+ASCII_BIAS;

    
    // if overflow does not occur, addition succeeded
    out[0] = '\0';
    for(j=0;j<lout+1;j++){
      result[j] = out[lout-j];
    }
    printf("%s\n", result);
  }
  
  return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

ll dp[300][300][301];
string s;

ll memo(ll l, ll r, ll k) {
	if(dp[l][r][k]!=INF*INF) return dp[l][r][k];
	if(l==r) return dp[l][r][k]=1;
	if(l==r-1) {
		if(k>=1) return dp[l][r][k]=2;
		else if(s[l]==s[r]) return dp[l][r][k]=2;
		else return dp[l][r][k]=1;
	}
	ll ret=0;
	if(k>0) ret=memo(l+1,r-1,k-1)+2;
	if(s[l]==s[r]) ret=max(ret,memo(l+1,r-1,k)+2);
	ret=max(ret,max(memo(l+1,r,k),memo(l,r-1,k)));
	return dp[l][r][k]=ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k;
	cin>>s>>k;
	ll n=(ll)s.size();
	REP(i,300) REP(j,300) REP(k,301) dp[i][j][k]=INF*INF;
	cout<<memo(0,n-1,k)<<endl;
}


Measured memory_bytes: 211968
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	var h, n int
	fmt.Fscan(read, &h, &n)

	for i := 0; i < n; i++ {
		var a int
		fmt.Fscan(read, &a)
		h -= a
	}
	if h > 0 {
		fmt.Fprintln(write, "No")
	} else {
		fmt.Fprintln(write, "Yes")
	}
}


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


int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (auto i=0; i < N; ++i) {
    cin >> A[i];
  }
  int tot = accumulate(A.begin(), A.end(), 0);
  //cout << "db:" << tot << endl;

  int cnt = 0;
  for (auto xi : A) {
    if ((double) xi >=  ((double)tot/(4*(double) M))) ++cnt;
  }

  if (cnt >= M) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int n,ans;

void sqrsum(int mark,int cou,int sum)
{
  for(int i=mark;i<=sqrt(n);i++){
    if(sum+i*i>n) break;
    if(sum+i*i==n){
      ans++; break;
    } else if(sum+i*i<n&&cou<3){
      sqrsum(i,cou+1,sum+i*i);
    }
  }
}

int main()
{
  for(;;){
    cin>>n;
    if(!n) break;
    ans=0;
    sqrsum(1,0,0);
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 1160
#include <stdio.h>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using lli = long long int;

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

std::vector<lli> S, T;
std::vector<lli> SB, TB;
std::vector<lli> X;

int main(void){
    int n; lli C;
    scanf("%d%lld", &n, &C);
    S.resize(n+1), T.resize(n+1), X.resize(n+2);
    X[0] = 0, X[n+1] = C; S[0] = 0; T[0] = 0;
    FOReq(i, 1, n){ scanf("%lld%lld", &X[i], &S[i]); T[n-i+1] = S[i];}

    REP(i, n){ S[i+1] += S[i]; T[i+1] += T[i];}
    SB.resize(n+1); TB.resize(n+1);
    FOReq(i, 0, n){
        SB[i] = S[i] - 2 * X[i];
        TB[i] = T[i] - 2 * (C - X[n-i+1]);
    }
    REP(i, n){
        if(SB[i] > SB[i+1]) SB[i+1] = SB[i];
        if(TB[i] > TB[i+1]) TB[i+1] = TB[i];
    }
    lli res = -1;
    FOReq(i, 0, n){
        chmax(res, S[i] - X[i] + TB[n-i]);
        chmax(res, T[i] - (C - X[n-i+1]) + SB[n-i]);
    }
    printf("%lld\n", res);

    return 0;
}


Measured memory_bytes: 4224
#/usr/bin/env python
from functools import *
from math import *

n = int(input())
a = list(map(int, input().split()))

gcds = []
lgcd = []
rgcd = [0 for _ in range(n)]
l = r = 0 
for i in range(n):
    if i == 0:
        l = 0 
    else:
        l = gcd(l, a[i-1])
    lgcd.append(l)

for i in range(n):
    if i == 0:
        r = 0 
        rgcd[n-1] = r 
    else:
        r = gcd(r, a[n-i])
        rgcd[n-i-1] = r 

for i in range(n):
    g = gcd(lgcd[i], rgcd[i])
    gcds.append(g)

print(max(gcds))


Measured memory_bytes: 25192