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

using namespace std ;

#define N 5010
#define ll long long
const int mod = 1e9+7 ;

int n ;
char s[ N ] ;
int f[ N ][ N ] ;
//f[ i ][ j ] 表示按了i次键盘，出现了j个字母 

ll power( ll a , ll b ) {
    ll ans = 1 , base = a ;
    while( b ) {
        if( b&1 ) ans = ( ans * base ) % mod ;
        base = ( base * base ) % mod ;
        b >>= 1 ;
    }
    return ans % mod ;
}

int main() {
    scanf( "%d%s" , &n , s+1 ) ;
    int len = strlen( s + 1 ) ;
    f[ 0 ][ 0 ] = 1 ;
    for( int i = 0 ; i <= n ; i ++  ) {
        for( int j = 0 ; j <= i ; j ++ ) {
            f[ i + 1 ][ j + 1 ] += 2 * f[ i ][ j ] ;
            f[ i + 1 ][ j + 1 ] %= mod ;
            f[ i + 1 ][ max( j - 1 , 0 ) ] += f[ i ][ j ] ;
            f[ i + 1 ][ max( j - 1 , 0 ) ] %= mod ;
        }
    }
    ll ans =1ll*power( power( 2 , len ) , mod - 2 ) % mod * f[ n ][ len ] ;
    ans %= mod ;
    printf( "%lld" , ans ) ;
    return 0 ;
} 

Measured memory_bytes: 96512
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
int x;
int main(){
	cin>>x;
	int m=0;
	for (int i=1;;i++){
		m+=i;
		if (m>=x){
			cout<<i;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



int LIS(vector<int> a){
  vector<int> v(a.size(),inf);
  rep(i,a.size()){
    int x = lower_bound(all(v),a[i])-v.begin();
    v[x] = a[i];
  }

  return lower_bound(all(v),inf)-lower_bound(all(v),0);
}

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

  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }

  cout<<LIS(a)<<endl;


}


Measured memory_bytes: 5264
#include <bits/stdc++.h>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1000000007;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

void solve(){
    ll n;
    cin >> n;
    pair<pair<string,ll> , ll> a[n];
    forn(i,n){
    	string t1;
    	ll t2;
    	cin >> t1 >> t2;
    	a[i]=mp(mp(t1,-1*t2),i);
    }
    sort(a,a+n);
    forn(i,n){
    	cout << a[i].se+1 << ln;
    }
}


int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
void yes(bool c) { if (c)print("Yes"); else print("No"); };


void solve() {
	int N; cin >> N;
	vector<int>A(N);
	map<int, int>mp;
	int ans = 0;
	REP(i, N) {
		cin >> A[i];
		ans += mp[i - A[i]];
		mp[i + A[i]]++;
	}
	print(ans);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 27452
import 'dart:convert';
import 'dart:io';
import 'dart:async';

Future main() async {
  List nck = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  Stream<String> tLines =
      stdin.transform(utf8.decoder).transform(LineSplitter()); // ここ大事（複数行入力）

  int ti;
  List ab = [];
  List abi = [];
  List limits = [];
  int limit0 = 0;
  int limit1 = 0;
  List tList0 = [];
  int lineNum;
  lineNum = 1;
  await for (String line in tLines) {
    lineNum = lineNum + 1;
    ti = int.parse(line);
    tList0.add(ti);
    limits.add(ti + nck[2]);

    if (lineNum > nck[0]) break; // ここの場所！
  }
  List tList = tList0..sort((a, b) => a.compareTo(b));

  int start = tList[0];
  // print(tList);
  int count = 1; // バスの数
  int s = 0;
  int numb = 0; // ひとの数
  // print(tList);
  for (int j = 1; j < nck[0]; j++) {
    if (tList[j] >= tList[s] && tList[j] <= tList[s] + nck[2]) {
      numb++;
      if (numb == nck[1]) {
        count++;
        s = j;
        numb = 0;
      }
    } else {
      count++;
      s = j;
      numb = 0;
    }
  }

  print(count);
}


Measured memory_bytes: 34604
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, k = map(int, input().split())

    for i in range(k):
        if i % 2 == 0:
            if a % 2:
                a -= 1
                b += a // 2
                a //= 2
            else:
                b += a // 2
                a //= 2
        else:
            if b % 2:
                b -= 1
                a += b // 2
                b //= 2
            else:
                a += b // 2
                b //= 2

    print(a, b)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a,b,ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
      cin >> a;
      b=1;
      for(int j=2; j*j<=a; j++) {
          if(a%j==0) {
              b=0;
              break;
          }
      }
      ans+=b;
  }
  cout << ans << endl;
}


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

using namespace std;

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

    vector<int> A(N + 1);
    vector<bool> C(N + 1);
    for (int i = 1; i <= N; ++i) cin >> A[i];

    int ans = 0;
    for (int i = N; i >= 1; --i) {
        // iの倍数の個数の偶奇
        bool odd = A[i] == 1;
        for (int j = 2; i * j <= N; ++j)
            if (C[i * j]) odd = !odd;
        C[i] = odd;
        if (odd) ans += 1;
    }

    cout << ans << endl;
    if (ans) {
        for (int i = 1; i <= N; ++i)
            if (C[i]) cout << i << ' ';
        cout << endl;
    }
}

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

int main() 
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s; cin>>s;
	int o=0,n=s.length();
	for (int i = 0; i < n; i++)if(s[i]=='1')o++;
	if(o==0 || n-o==0)return cout<<0,0;
	cout<<2*min(o, n - o);
}

Measured memory_bytes: 3732
import java.util.Scanner;

public class Main {
    static Scanner in;

    void solve() {
        String string = in.nextLine();
        if(string.indexOf("AC") >= 0) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }

    public static void main(String[] args) {
        in = new Scanner(System.in);
        new Main().solve();
    }
}


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

int main() {
    int n, k;
    std::cin >> n >> k;
    std::string s;
    std::cin >> s;

    int ans = 0, num = 0;
    char prev = '0';
    for (int i = 0; i < n; i++) {
        if (s[i] == prev) {
            ans++;
        } else {
            prev = s[i];
            num++;
        }
    }

    for (int i = 2; i <= num; i += 2) {
        if (k > 0) {
            ans += 2;
            k--;
            if (i == num) {
                ans--;
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 512
use std::str::FromStr;
use std::io::BufRead;
fn main() {
    let handle = std::io::stdin();
    let mut buf = String::new();
    handle.lock().read_line(&mut buf).unwrap();
    let num: usize = usize::from_str(&buf.trim()).unwrap();
    if num < 112 { println!("111"); }
    else if num < 223 { println!("222"); }
    else if num < 334 { println!("333"); }
    else if num < 445 { println!("444"); }
    else if num < 556 { println!("555"); }
    else if num < 667 { println!("666"); }
    else if num < 778 { println!("777"); }
    else if num < 889 { println!("888"); }
    else if num < 1000 { println!("999"); }
    else { println!("u r wrong"); }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  int N; cin >> N;
  int arg1th = 0; 
  int max1st = -1; int max2nd = -2;
  int A = 0; 
  REP0(i, N) {
      cin >> A;
      if (A > max1st) {
          max2nd = max1st;
          max1st = A;
          arg1th = i;
      } else if (A > max2nd) {
          max2nd = A;
      }
  }
  REP0(i, N) cout << ((i == arg1th) ? max2nd : max1st) << endl;

}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 1664
def main():
    import sys
    input = sys.stdin.readline

    from bisect import bisect_left

    N = int(input())
    A = list(map(int, input().split()))

    G = [[] for _ in range(N)]

    for _ in range(N - 1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        G[u].append(v)
        G[v].append(u)

    root = 0
    stack = [root]
    visited = set()
    visited.add(root)
    done = set()
    vs = []

    ans = [0] * N
    memo = [None] * N
    memo[root] = (0, A[root])

    INF = 10 ** 10
    dp = [INF] * N

    while stack:
        now_ = stack[-1]
        if now_ in done:
            j, a = memo[now_]
            dp[j] = a
            stack.pop()
            vs.append(now_)
        else:
            for next_ in G[now_][::-1]:
                if next_ in visited:
                    continue
                visited.add(next_)
                stack.append(next_)
            done.add(now_)

            tmp = bisect_left(dp, A[now_])
            memo[now_] = (tmp, dp[tmp])
            dp[tmp] = A[now_]
            ans[now_] = bisect_left(dp, INF)

    # print (vs)
    print (*ans, sep = '\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 99516
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(20);
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> re(a),gr(b),cl(c);
    for(int i=0;i<a;i++)cin>>re[i];
    for(int i=0;i<b;i++)cin>>gr[i];
    for(int i=0;i<c;i++)cin>>cl[i];
    sort(re.begin(),re.end(),greater<int>());
    sort(gr.begin(),gr.end(),greater<int>());
    sort(cl.begin(),cl.end(),greater<int>());
    vector<int> tmp;
    int ans=0;
    for(int i=0;i<x;i++)tmp.pb(re[i]),ans+=re[i];
    for(int j=0;j<y;j++)tmp.pb(gr[j]),ans+=gr[j];
    sort(tmp.begin(),tmp.end());
    int i=0,k=0;
    while(i<tmp.size()&&k<c&&tmp[i]<cl[k]){
        ans+=cl[k]-tmp[i];
        i++;
        k++;
    }
    cout<<ans;
}

Measured memory_bytes: 4852
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main()
{
  int a, b;
  cin >> a >> b;
  if(max(a,b)>8){
    cout << ":(" << endl;
  }else{
    cout << "Yay!" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import math
x=list(input().split())
n=int(x[0])
d=int(x[1])
zahyou=[]
count=0
for i in range(n):
  zahyou.append(list(input().split()))
for i in range(n-1,0,-1):
  for j in range(i):
    total=0
    for k in range(d):
      total=total+(int(zahyou[i][k])-int(zahyou[j][k]))**2
    
    if math.sqrt(total).is_integer():
      count+=1
print(count)


Measured memory_bytes: 38256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

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

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    ld n;
    cin >> n;
    ld side = n / 3.0;
    cout << setprecision(10) << (1.0 * side * side * side) << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import kotlin.math.abs
import kotlin.math.min

fun main() {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }

    val dp = IntArray(n + 1) { 0 }
    dp[2] = abs(h[1] - h[0])

    for (i in 3..n) {
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i - 2]), dp[i - 2] + abs(h[i - 1] - h[i - 3]))
    }
    println(dp[n])
}

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

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

// Greatest Common Multiple (GCD)
// 2数の最大公約数 by ユークリッド互助法
template <typename T=long long>
T gcd(T a, T b)
{
    if(b == 0) return a;
    else return gcd<T>(b, a % b);
}

// Least Common Multiple (LCM)
// 2数の最小公倍数
template <typename T=long long>
T lcm(T a, T b) {return a * b / gcd<T>( a, b );}

int main()
{
    long long N, M;
    cin >> N >> M;
    vector<long long> a(N);
    REP(i, N) cin >> a[i];

    long long LCM = 1;
    int prev_count = -1;
    REP(i, N){
        a[i] = a[i]/2;
        LCM = lcm<long long>(LCM, a[i]);
        if(LCM > M){
            cout << 0 << endl;
            return 0;
        }
        // 2で割れる回数は同じじゃないとダメ
        int count = 0;
        while(a[i]%2 == 0){
            a[i] /= 2;
            ++count;
        }
        if(prev_count == -1) prev_count = count;
        else if(prev_count != count){
            cout << 0 << endl;
            return 0;
        }
        prev_count = count;
    }
    cout << (M/LCM+1)/2 << endl;

    return 0;
}

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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

vector<int> dp(100100,-1);

int main(){
    int N,T; cin >> N >> T;
    P dish[N];
    int ma=0;
    for(int i=0;i<N;i++){
        int a,b; cin >> a >> b;
        ma=max(b,ma);
        dish[i]={a,b};
    }
    sort(dish,dish+N);
    dp[0]=0;
    int maxtime=T+dish[N-1].first-1;
    for(int i=0;i<N;i++){
        int a=dish[i].first;
        int b=dish[i].second;
        for(int t=maxtime;t>=a;t--){
            if(t-a>=T) continue;
            if(dp[t-a]!=-1){
                dp[t]=max(dp[t],dp[t-a]+b);
            }
        }
    }
    int ans=0;
    for(int i=0;i<=maxtime;i++){
        ans=max(dp[i],ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pll, pii> P;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int N;
	int A[20];
	int B[20], C[20];
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	REP(i, N) scanf("%d", B + i);
	
	int ans = 0;
	REP(i, N) ans += B[i];
	
	REP(i, N - 1) scanf("%d", C + i);
	REP(i, N - 1) {
		if (A[i + 1] - A[i] == 1) ans += C[A[i] - 1];
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, s, N) for(ll i{N - 1}; i > s - 1; i--)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll H, W, h, w;
  cin >> H >> W >> h >> w;
  cout << (H - h) * (W - w) << rt;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
struct edge
{
	ll x,y,w;
}e[400005];
struct node
{
	ll dsu,w;
}a[200005];
ll n,i,d,u,ans=0,v,cnt=0,tr[2][200005],vp[200005],fx,fy;
const ll inf=1e18;
ll lowbit(ll p){return p&-p;}
bool cmp(node a,node b){return a.w<b.w;}
bool cmp2(edge a,edge b){return a.w<b.w;}
bool cmp3(node a,node b){return a.dsu<b.dsu;}
int getf(int p){return a[p].dsu==p?p:a[p].dsu=getf(a[p].dsu);}
ll vl(ll u,ll v){return d*(v-u)+vp[u]+vp[v];}
ll pvl(ll t,ll u){return u==0?inf:(t==0?(-u*d+vp[u]):(d*u+vp[u]));}
ll ask(ll t,ll p)
{
	ll ans=0,tp,tmp=inf;
	while(p)
	{
		if((tp=pvl(t,tr[t][p]))<tmp)
		{
			ans=tr[t][p];
			tmp=tp;
		}
		p-=lowbit(p);
	}
	return ans;
}
void ins(ll t,ll p,ll v)
{
	ll tmp,tp;
	tp=pvl(t,v);
	while(p<=n)
	{
		tmp=pvl(t,tr[t][p]);
		if(tp<tmp)tr[t][p]=v;
		p+=lowbit(p);
	}
}
int main()
{
	scanf("%lld%lld",&n,&d);
	for(i=1;i<=n;i++)scanf("%lld",&a[i].w),a[i].dsu=i,vp[i]=a[i].w;
	sort(a+1,a+n+1,cmp);
	for(i=1;i<=n;i++)
	{
		u=ask(0,a[i].dsu);
		v=ask(1,n+1-a[i].dsu);
		if(u)e[++cnt]=(edge){u,a[i].dsu,vl(u,a[i].dsu)};
		if(v)e[++cnt]=(edge){a[i].dsu,v,vl(a[i].dsu,v)};
		ins(0,a[i].dsu,a[i].dsu);
		ins(1,n+1-a[i].dsu,a[i].dsu);
	}
	sort(e+1,e+cnt+1,cmp2);
	sort(a+1,a+n+1,cmp3);
	for(i=1;i<=cnt;i++)
	{
		fx=getf(e[i].x);fy=getf(e[i].y);
		if(fx!=fy)
		{
			ans+=e[i].w;
			a[fx].dsu=fy;
		}
	}
	printf("%lld\n",ans);
	return 0;
} 

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

using namespace std;

int main(){ 
	cin.tie(0);
	ios::sync_with_stdio(0);
	int h,w,n;
	cin>>h>>w>>n;
	h=max(w,h);
	int val=n/h+(n%h!=0);
	cout<<val;

	return 0;
}



Measured memory_bytes: 256
H, W, K = map(int, input().split())
c=[['' for i in range(W)] for j in range(H)]
yokoB=[0 for i in range(H)]
tateB=[0 for i in range(W)]
tateBcopy=[0 for i in range(W)]
countAll = 0
for i in range(H):
    cin = list(input())
    for j in range(W):
        c[i][j]=cin[j]
        if c[i][j]=="#":
            yokoB[i]+=1
            tateB[j]+=1
            countAll+=1
countAll-=K
count=0
countBin=0
countBin2=0
for ii in range(pow(2,W)):
    check=format(countBin,'0'+str(W)+'b')
    countBin2 = 0
    for jj in range(pow(2,H)):
        check2=format(countBin2,'0'+str(H)+'b')
        countB=0
        for i in range(W):
            if check[i]=="1":
                countB+=tateB[i]
                for j in range(H):
                    if check2[j]=="1" and c[j][i]=="#":
                        countB -= 1
        for j in range(H):
            if check2[j]=="1":
                countB+=yokoB[j]
        if countB==countAll:
            count+=1
        countBin2+=1
    countBin+=1
    
print(count)

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

int main () {
  int n;
  ll ans = 0;
  cin>>n;
  ll a[10000];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
        ll r=a[i]+a[j];
        ll u=lower_bound(a,a+n,r)-a;
       ans+=u-(j+1);
    }
  }
  
    cout<<ans<<endl;
}

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

int main() {
    int n;
    cin>>n;
    if(n<10) cout<<n;
    else if(n>=10&&n<100) cout<<9;
    else if(n>=100&&n<1000) cout<<9+n-99;
    else if(n>=1000&&n<10000) cout<<9+900;
    else if(n>=10000&&n<100000) cout<<9+900+n-9999;
    else if(n==100000) cout<<9+900+90000;
}
 

Measured memory_bytes: 256
n, m = map(int, input().split())
a, b = [], []

for i in range(n):
    a.append(list(map(int, input().split()))) 

for j in range(m):
    b.append(int(input()))

for i in range(n):
    sum = 0
    
    for j in range(0, m):
        sum += a[i][j] * b[j]
    
    print(sum)

Measured memory_bytes: 7932
import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }finally{
      out.close();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));
    Integer[] numbers = new Integer[3];
    IntStream.range(0,3).boxed().forEach(i->numbers[i]=sc.nextInt());
    Arrays.sort(numbers, Comparator.reverseOrder());
    int ans = numbers[0]*10 + numbers[1] + numbers[2];
    out.println(ans);
  }

  /*
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

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

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


Measured memory_bytes: 26196
#! usr/bin/env python
# -*- coding: utf-8 -*-

res = {}
dp = [[0 for j in range(80)] for i in range(30)]


def pf(n):
    c = 2
    while c * c <= n:
        while not n % c:
            res[c] = res.get(c, 0) + 1
            n //= c
        c += 1

    if n != 1:
        res[n] = res.get(n, 0) + 1


def main():
    n = int(input())

    for i in range(2, n+1):
        pf(i)

    a = [res[k] for k in res]
    for i in range(30):
        dp[i][1] = 1
    for i in range(len(a)):
        for j in range(80):
            dp[i+1][j] = dp[i][j]
            for k in range(1, min(a[i]+1, j+1)):
                if not j % (k+1):
                    dp[i+1][j] += dp[i][j//(k+1)]

    print(dp[len(a)][75])


if __name__ == '__main__':
    main()


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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int n,x[100];
  int ans = 1001001001;
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> x[i];
  for (int p=1; p<=100; p++){
    int t=0;
    for (int i=0; i<n; i++){
      t += (x[i]-p)*(x[i]-p);
    }
    ans = MIN(ans, t);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int dig;
        if((b / 100) >= 1){
            dig = 1000;
        }else  if(b / 10 >= 1){
            dig = 100;
        }else{
            dig = 10;
        }
        b = b + a * dig;

        for(int i = 1; i < 320; i++){
            if(b == i * i){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21712
#include<stdio.h>
#define LENGTH 20

int main(){
  int p[LENGTH];
  int n;
  int result;
  int i;
  
  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d",&p[i]);
  }
  for(i=0; i<n-2; i++){
    if((p[i+1] < p[i] && p[i+1] > p[i+2]) || (p[i+1] > p[i] && p[i+1] < p[i+2]))
      result ++;
  }
  
  printf("%d",result);
  
}
  

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int K;
	string S, ret;

	cin >> K >> S;

	if (S.length() <= K)
	{
		ret = S;
	}
	else
	{
		ret = S.substr(0, K) + "...";
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<map>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U; typedef pair<int,int > P; typedef long long ll;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	inp();
	return 0;
}
map<int ,int> mp;
void inp(){
	int n,m,x;
	scanf("%d",&n);for(int i=0;i<n;i++){ scanf("%d",&x);
		if(mp.count(x))mp[x]++;
		else mp[x]=1;
	}
	int s = 1;
	scanf("%d",&m);for(int i=0;i<m&&s;i++){ scanf("%d",&x);
		if(mp.count(x)){ 
			if(mp[x]>=1)mp[x]--;
			else s=0;
		}
		else s=0;
	}
	puts(s?"YES":"NO");
}
//tmp.cc by xsthunder at Sun Oct  8 20:05:04 2017


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mm(arr) memset(arr, 0, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
#define pb push_back
#define PI 3.141592653589793
#define MOD 1000000007

using namespace std;

int main(){
    FAST
    string s; cin >> s;
    if(s=="ABC"){
        cout << "ARC" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p;
  while(cin>>n>>p,n+p!=0){
    int winner=0;
    int stone=p;
    int candidate[n]={0};
    int now=0;
    while(1){
      if(stone==0){
	stone+=candidate[now];
	candidate[now]=0;
      }else{
      candidate[now]++;
      stone--;
      }
     if(candidate[now]==p){
	  winner=now;
	  break;
	}
      if(now==n-1)
	now=0;
      else
	now++;
    }
    cout<<winner<<endl;
  }
  return 0;
}

Measured memory_bytes: 3040
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
void solve(){
}
int main(){
    ll n;
    cin >> n;
    vector<ll>an(n);
    for(int i = 0; i < n; i++){
        cin >> an.at(i);
    }
    map<ll, ll>m;
    for(int i = 0; i < n; i++){
        if(m.count(an.at(i))){
            m.at(an.at(i))++;
        }
        else{
            m[an.at(i)] = 1;
        }
    }
    long long sum = 0;
    for (auto p : m) {
        auto k = p.first;
        auto v = p.second;
        sum += v * (v - 1) / 2;
    }
    for(int i = 0; i < n; i++){
        long long tmp = sum;
        tmp -= (m.at(an.at(i))) * (m.at(an.at(i)) - 1) / 2;
        tmp += (m.at(an.at(i)) - 1) * (m.at(an.at(i)) - 2) / 2;
        cout << tmp << endl;
    }
    solve();
    return 0;
}



Measured memory_bytes: 12800
package main

import "fmt"

func reversed(s string) string {
	var reversed []rune

	for i := len(s) - 1; i >= 0; i-- {
		reversed = append(reversed, rune(s[i]))
	}

	return string(reversed)
}

func isPalindrome(s string) bool {
	return s == reversed(s)
}

func isStrongPalindrome(s string) bool {
	sLength := len(s)

	leftPart := s[:((sLength - 1) / 2)]
	rightPart := s[((sLength+3)/2 - 1):]

	return isPalindrome(s) && isPalindrome(leftPart) && isPalindrome(rightPart)
}

func answer159B(s string) string {
	if isStrongPalindrome(s) {
		return "Yes"
	}
	return "No"
}

func main() {
  var s string
  fmt.Scan(&s)
  
  fmt.Println(answer159B(s))
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int k, x;
  cin >> k >> x;
  if (k * 500 >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  ll sum=0;
  cin>>n;
  vi A(n);
  ll hoge=0;
  ll ans=llINF;
  for(auto &aa:A){cin>>aa;sum+=aa;}
  for(int i=0;i<n;i++){
    hoge+=A[i];
    ans=min(ans,abs((sum-hoge)-hoge));
  }
  cout<<ans<<endl;
  return 0;
}


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


string s;
bool can_reach(int l, int r) {
    for (int i = l; i < r; i++) {
        if (s[i] == s[i+1] && s[i] == '#') {
            return false;
        }
    }
    return true;
}

void solve() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d >> s;
    a--;
    b--;
    c--;
    d--;

    // 1. a b c d: b -> d 間に岩が2個並んでいるところがない かつ、 a -> c ...
    // 2. a c b d: ..
    // 3. a b d c: a が b を追い越すことができる. 3連続の空きがあり、かつ、右端がb じゃない

    if (!can_reach(a,c) || !can_reach(b,d)) {
        cout << "No" << endl;
        return;
    }

    if (c > d) {
        int ok = 0;
        for (int i = b; i <= d; i++) {
            if (s[i-1] == s[i] && s[i] == s[i+1] && s[i] == '.') {
                ok = 1;
            }
            if (ok) break;
        }
        if (!ok) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;

}

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




Measured memory_bytes: 644
# Distance
from math import sqrt
def calc_distance(x, y):
    return (sqrt(x * x + y * y))


n, d = list(map(int, input().split()))
ans = 0
for i in range(n):
    x, y = list(map(int, input().split()))
    if calc_distance(x, y) <= d:
        ans += 1
print(ans)

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();

		in.close();

		for (int i = 0; i < 100; i++) {
			for(int j = 0; j < 100; ++j) {
				if(a * i - b * j == c) {
					System.out.println("YES");
					return;
				}
			}
		}
		System.out.println("NO");
	}

}


Measured memory_bytes: 21716
x = input()
n = len(x)
ret=[]
if x[n-1]=="1" or x[0]=="0" or x[:-1]!=x[-2::-1]:
    print (-1)
else:
    a=1
    for i in range(n-1):
        print ("{0} {1}".format(a, i+2))
        if x[i] == "1":
            a=i+2

Measured memory_bytes: 4556
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmin(a,b) a = min(a,b);

int dp[1005][10005];
const int INF = 1001001001;

int main() {
    int h, n;
    cin >> h >> n;
    rep(i,n+1)rep(j,h+1) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        rep(j,h+1) {    
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][j], dp[i+1][max(j-a,0)]+b);
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 42752
#include<stdio.h>
long long ll_abs(long long a){
  if(a < 0){
    return -a;
  }else{
    return a;
  }
}
    
int main(){
  long long n = 0;
  long long a[200000] = {};
  long long i = 0;
  long long sum = 0;
  long long lsum = 0;
  long long diff = 0;
  long long min = -1;
  
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    sum += a[i];
  }
  for(i=0;i<n-1;i++){
    lsum += a[i];
    diff = ll_abs(lsum - (sum - lsum));
    if(diff < min || min == -1){
      min = diff;
    }
  }
  printf("%lld",min);
  return 0;
}
      

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

const int INF = 1 << 30;

int N;
vector<int> a;
vector<vector<int>> G;
vector<int> dp, ans;

void dfs(int i, int prev = -1) {
    auto lb = lower_bound(dp.begin(), dp.end(), a[i]);
    int prev_dp = *lb;
    *lb = a[i];
    ans[i] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
    for (int nv : G[i]) {
        if (nv == prev) continue;
        dfs(nv, i);
    }
    *lb = prev_dp;
}

int main() {
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    G.resize(N, vector<int>());
    for (int i = 0; i < N - 1; ++i) {
        int u, v;  cin >> u >> v;
        --u;  --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    dp.resize(N);
    for (int i = 0; i < N; ++i) dp[i] = INF;
    ans.resize(N);
    dfs(0);

    for (int i = 0; i < N; ++i) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 27852
/* EVERYTHING STARTS AS NOTHING ! :) */
#include<bits/stdc++.h>
using namespace std;

#define ull unsigned long long
#define ll long long
#define null NULL
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int dp[100001] = {0} ;
vector <int> v ;

int rec (int n) {
	if (n == 1) return dp[1] = abs(v[1] - v[0]) ;
	if (n <= 0)return 0 ;

	if (dp[n] != -1)return dp[n] ;
	int a = abs(v[n] - v[n - 1]) + rec(n - 1) ;
	int b = abs(v[n] - v[n - 2]) + rec(n - 2) ;
	return dp[n] = min(a, b);
}

int main () {
	int n ;
	cin >> n ;
	v.resize(n) ;
	// vector <int> v(n) ;
	memset(dp, -1, sizeof dp) ;
	for (auto &it : v) cin >> it ;
	cout << rec(n - 1) ;
	return 0 ;
}


Measured memory_bytes: 10300
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int d, g;
    cin >> d >> g;
    g /= 100;
    vector<int> p(d), c(d);
    for (int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }
    int ans = INT_MAX;
    for (int i = 0; i < (1 << d); i++) {
        vector<bool> comp(d, false);
        int need = g;
        int q = 0;
        //コンプしたやつの処理
        for (int j = 0; j < d; j++) {
            if (i & (1 << j)) {
                need -= c[j] + p[j] * (j + 1);
                q += p[j];
                comp[j] = true;
            }
        }
        int now = d - 1;
        while (need > 0 && now >= 0) {
            if (!comp[now]) {
                int temp =
                    min((need + (now + 1) - 1) / ((now + 1)), p[now] - 1);
                q += temp;
                need -= temp * (now + 1);
            }
            now--;
        }
        if (need <= 0) {
            ans = min(ans, q);
        }
    }
    cout << ans << endl;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define pb push_back

using namespace std;

const int N = 1e5 + 10;

vector<int> G[N];
int n;
int dp[N];

void DFS(int o){
	vector<int> val;
	for(int v : G[o]) DFS(v), val.pb(dp[v] + 1);
	sort(val.begin(), val.end());

	int now = int(G[o].size()) - 1;
	for(int v : val) dp[o] = max(dp[o], v + now), --now;
}

int main(){
	scanf("%d", &n);
	For(i, 2, n){
		int x;
		scanf("%d", &x);
		G[x].pb(i);
	}

	DFS(1);
	printf("%d\n", dp[1]);
	return 0;
}

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

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

int main(void){
  int n;
  vector<int> a,l,r;
  cin>>n;
  a.resize(n);
  l.resize(n);
  r.resize(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  l[0]=a[0];
  for(int i=1;i<n;i++){
    l[i]=gcd(l[i-1],a[i]);
  }
  r[n-1]=a[n-1];
  for(int i=n-2;i>=0;i--){
    r[i]=gcd(r[i+1],a[i]);
  }
  int max=0;
  int g=0;
  for(int i=0;i<n;i++){
    if(i==0)g=gcd(0,r[i+1]);
    else if(i==n-1)g=gcd(l[i-1],0);
    else g=gcd(l[i-1],r[i+1]);
    
    if(g>max)max=g;
  }
  cout<<max;
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
using namespace std;
int n,a[100005][3],dp[100005][3];
int main() 
{
   cin>>n;
   for(int i=1;i<=n;i++)
    for(int h=0;h<3;h++)
      cin>>a[i][h];
   
   dp[0][0]=dp[0][1]=dp[0][2]=0;
   
  for(int i=1;i<=n;i++){
  	for(int h=0;h<3;h++){
  		if(h==0){
  			dp[i][h]=max(dp[i-1][1]+a[i][h],dp[i-1][2]+a[i][h]);
		  }
		else if(h==1){
			dp[i][h]=max(dp[i-1][0]+a[i][h],dp[i-1][2]+a[i][h]);
		}
		else
		 dp[i][h]=max(dp[i-1][0]+a[i][h],dp[i-1][1]+a[i][h]);
		  
	  }
  }
   int ans=0;
   for(int i=0;i<3;i++)
     ans=max(ans,dp[n][i]);
     
    cout<<ans; 
   
	return 0;
}

Measured memory_bytes: 5540
N, P = map(int, input().split())
Alist = list(map(int, input().split()))
guuki = [A%2 for A in Alist]
odd = guuki.count(1)
even = guuki.count(0)
if odd == 0:
    if P == 0:
        print(2**N)
    else:
        print(0)
else:
    print(2**(N-1))

Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,n;
  cin>>n;
  int a[n],b[n],c[n];
  int dp[n][3];
  for(i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  for(i=1;i<n;i++)
  {
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}
  

Measured memory_bytes: 2560
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int ans = 0;
		if (n <= 9)
			ans = n;
		else if (10 <= n && n <= 99)
			ans = 9;
		else if (100 <= n && n <= 999)
			ans = n - 90;
		else if (1000 <= n && n <= 9999)
			ans = 909;
		else if (10000 <= n && n <= 99999)
			ans = n - 9090;
		else if (100000 == n)
			ans = 90909;

		System.out.println(ans);

	}

}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
#define MAX 45

int fib[45];
void make_fib(){
	fib[0] = 1;
	fib[1] = 1;
	for (int i=2;i<MAX;i++) {
	fib[i] = fib[i-1] + fib[i-2];
	}
}

int main() {
	int n;
	cin >> n;
	make_fib();
	cout << fib[n] << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<int> A(5);
    for(int i = 0; i < 5; i++) cin >> A[i];
    int matsu = 9;
    int jun = 0;
    for(int i = 0; i < 5; i++){
        if(A[i] >= 100 && A[i] % 10 != 0){
            matsu = min(matsu,A[i] % 10);
            if(matsu == A[i] % 10) jun = i;
        }
        else if(A[i] < 100 && A[i] % 10 != 0){
            matsu = min(matsu,A[i] % 10);
            if(matsu == A[i] % 10) jun = i;
        }
    }
    //cout << matsu << " " << jun << endl;
    int jikan = 0;
    for(int i = 0; i < 5; i++){
        if(i == jun) jikan += A[i];
        else if(A[i] % 10 == 0) jikan += A[i];
        else jikan += A[i] /10 *10 +10;
    }
    cout << jikan << endl;
}


Measured memory_bytes: 256
//#pragma comment(linker,"/STACK:102400000,102400000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
const int INF=0x3f3f3f3f;
#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= b; ++i)
const int max_number=1000000;


struct points{
    double x, y;
};

// int main()
// {

//     points x, y;
//     scanf("%lf%lf%lf%lf", &x.x, &x.y, &y.x, &y.y);  //double

//     double distance;
//     double i = pow((x.x - y.x), 2);
//     double j = pow((x.y - y.y), 2);

//     distance = sqrt(i + j);

//     printf("%.8f", distance);
//     printf("\n");
//     return 0;
// }


int main()
{
    double a, b, c,other;
    double area, circumference, height;
    scanf("%lf%lf%lf", &a, &b, &c);

    area = a * b * 0.5 * sin(c*M_PI/180);  //sin参数是弧度而不是角度
    other = sqrt(a * a + b * b - 2 * a * b * cos(c * M_PI / 180));
    circumference = a + b + other;
    height = area * 2 / a;

    printf("%.20lf\n", area);
    printf("%.20lf\n", circumference);
    printf("%.20lf\n", height);

   
    return 0;
}


Measured memory_bytes: 3388
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>

using namespace std;
/** Problem0108 : Operation of Frequency of Appearance **/
int main()
{
	int s1[12], s2[12], n;
	map<int, int> f;
	
	while (cin >> n, n!= 0) {
		for (int i=0; i<n; i++)
			cin >> s1[i];
		
		for (int j=0; ; j++) {
			for (int i=0; i<n; i++)
				f[s1[i]]++;
		
			for (int i=0; i<n; i++)
				s2[i] = f[s1[i]];
			
			f.clear();
			
			bool flag=true;
			for (int i=0; i<n; i++)
				if (s1[i] != s2[i])
					flag=false;
			
			if (flag) {
				cout << j << endl;
				cout << s2[0];
				for (int k=1; k<n; k++)
					cout << " " << s2[k];
				cout << endl;
				goto end;
			}
			for (int i=0; i<n; i++)
				s1[i] = s2[i];
		}
	end: ;
	}
}

Measured memory_bytes: 1196
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#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)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    string s; cin >> s;
    if (s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a=0,b=0,sb=1,c,f=0;
	char ch;
	ch=getchar();
	while(isdigit(ch))
	{
		a=a*10+(ch-48);
		ch=getchar();
	}
	while(!isdigit(ch))
	{
		ch=getchar();
	}
	while(isdigit(ch))
	{
		sb*=10;
		b=b*10+(ch-48);
		ch=getchar();
	}
	c=a*sb+b;
	for(int i=1;i<=317;i++)
	{
		if(i*i==c)
		{
			f=1;
		}
	}
	if(f==1)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

using Q = pair<P,ll>;

struct edge{ll to; ll cost;};
int V;
vector<vector<ll>> d;
vector<vector<ll>> rem;
vector<vector<edge>> G;
ll l;

P pl(P p, ll c){
    if(p.second+c>0)return P(p.first+1,-l+c);
    else return P(p.first,p.second+c);
}

void dijkstra(ll s){
    priority_queue<Q,vector<Q>,greater<Q>> que;
    d[s] = vector<ll>(V,INF);
    rem[s]=vector<ll>(V,-INF);
    d[s][s]=0;
    rem[s][s]=-l;
    que.push(Q(P(0,-l),s));
    while(!que.empty()){
        Q q = que.top();que.pop();
        ll v = q.second;
        if(P(d[s][v],rem[s][v])<q.first)continue;
        for(edge e:G[v]){
            auto A = pl(P(d[s][v],rem[s][v]),e.cost);
            if(P(d[s][e.to],rem[s][e.to])>A){
                d[s][e.to]=A.first;
                rem[s][e.to]=A.second;
                que.push(Q(P(d[s][e.to],rem[s][e.to]),e.to));
            }
        }
    }
}


int main(){
    /*ios::sync_with_stdio(false);
    cin.tie(0);*/
    ll n,m;cin>>n>>m;
    cin>>l;
    V=n;
    G = vector<vector<edge>>(V,vector<edge>());
    rep(i,m){
        ll a,b,c;cin>>a>>b>>c;a--;b--;
        if(c>l) continue;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    d = vector<vector<ll>>(V);
    rem = vector<vector<ll>>(V);
    rep(i,n){dijkstra(i);}
    ll q;cin>>q;
    rep(i,q){
        ll s,t;cin>>s>>t;s--;t--;
        if(d[s][t]!=INF)cout<<d[s][t]<<endl;
        else cout<<-1<<endl;

    }


    
    return 0;
}

Measured memory_bytes: 4352