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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

std::string s;
int main() {
    while(std::getline(std::cin, s)) {
        if(s == ".") break;
        
        std::stack<char> stack;
        bool f = true;
        for(auto c: s) {
            if(c == '(' || c == '[') {
                stack.push(c);
            } else if(c == ')' || c == ']') {
                if(stack.empty()) {
                    f = false;
                    break;
                }

                char left = stack.top();
                stack.pop();
                if( (left == '(' && c == ')') || (left == '[' && c == ']') ) {
                    continue;
                } else {
                    f = false;
                    break;
                }
            }
        }

        std::cout << ( (f && stack.empty()) ? "yes" : "no") << std::endl;
    }
}


Measured memory_bytes: 3188
/**
*    author: lucasfcm9
*    created: 11.09.20 17:01:37
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<bool> vis(n, false);
  int cnt = 0;
  function<void(int)> Dfs = [&](int v) {
    vis[v] = true;
    cnt++;
    for (int u : g[v]) {
      if (!vis[u]) {
        Dfs(u);
      }
    }
  };
  int mx = (int) -1e9;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      Dfs(i);
      mx = max(mx, cnt);
      cnt = 0;
    }
  }
  cout << mx << '\n';
  return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define endl "\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

vector<ll> v[maxn], parent(maxn, 0);

void bfs(){
    queue<ll> q;
    q.push(1);
    
    while(!q.empty()){
        ll val = q.front();
        q.pop();
        
        for(auto u: v[val]){
            if(!parent[u]){
                parent[u] = val;
                q.push(u);
            }
        }
    }
}

int main(){
    fast;
    
    ll n,m,x,y;
    cin>>n>>m;
    
    for(ll i=0;i<m;i++){
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    bfs();

    for(ll i=2;i<=n;i++){
        if(!parent[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
    
    for(ll i=2;i<=n;i++)
        cout<<parent[i]<<endl;
    
    return 0;
}

Measured memory_bytes: 40860
<?php
  list($h, $w) = explode(" ", trim(fgets(STDIN)));
  
  $s = [];

  for($i=0;$i<$h;$i++){
    $s[] = str_split(trim(fgets(STDIN)));
  }

  $weight = [];
  for($i=0;$i<$h;$i++){
    $weight[] = array_fill(0, $w, 0);
  }

  for($i=$h-1;$i>=0;$i--){
    for($j=$w-1;$j>=0;$j--){
      if($i==$h-1&&$j==$w-1){
        $weight[$i][$j]=0;
        continue;
      }
      $t=$s[$i][$j];
      $right=PHP_INT_MAX;
      $under=PHP_INT_MAX;
      if($i!=$h-1){
        $under=$weight[$i+1][$j];
        if($s[$i][$j]!=$s[$i+1][$j]){
          $under++;
        }
      }
      if($j!=$w-1){
        $right=$weight[$i][$j+1];
        if($s[$i][$j]!=$s[$i][$j+1]){
          $right++;
        }
      }
      $weight[$i][$j]=min($under,$right);      
    }
  }

  if($weight[0][0]%2==0){
    if($s[0][0]=="."){
      echo $weight[0][0]/2;
    }
    else{
      echo $weight[0][0]/2+1;
    }
  }
  else{
    echo ($weight[0][0]+1)/2;
  }

Measured memory_bytes: 6776
N,M,X,Y=map(int,input().split())
ListX = list(map(int, input().split()))
ListY = list(map(int, input().split()))
ListX.sort()
ListY.sort()
threX = max(X,ListX[N-1])
threY = min(Y,ListY[0])
Z = threX+1
if threY >= Z:
  print("No War")
else:
  print("War")

Measured memory_bytes: 8932
#pragma GCC optimize("O3")
        #pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize("unroll-loops")
         
        #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define N 300010
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        const double eps = 1e-9;
         
        mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
        
 		signed main()
 		{
 			int n,k;
 			cin>>n>>k;
 			int a[n];
 			loop(i,n)
 			cin>>a[i];
 			
 			sort(a,a+n);
 			
 			int sum=0;
 			loop(i,k)
 			{
 				sum+=a[i];
			 }
			 cout<<sum;
		}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  string str;
  cin >> str;
  ll cnt = 0;
  ll stock = 0;
  rep(i, str.length()){
    if(str[str.length()-1-i] == 'B'){
      cnt += i-stock;
      stock++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

using namespace std;

long long linf = 1e12 + 10;
long long mul(long long x, long long y) {
    if (x > linf / y) return linf;
    return x * y;
}
long long power(long long x, long long n) {
    long long ans = 1;
    while (n && ans != linf) {
        if (n & 1) ans = mul(ans, x);
        x = mul(x, x);
        n >>= 1;
    }
    return ans;
}
int main() {
    long long n, m;
    cin >> n >> m;
    if (n == 1) {
        cout << m;
    } else {
        long long ans = 1;
        for(long long i = 2; i <= 1000000; i++) {
            long long need = power(i, n);
            if (m % need == 0) ans = i;
        }
        cout << ans;
    }
}


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

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

int main() {
  int n;
  cin >> n;
  ll limit = min(9, n);
  for (int i=1; i<=limit; i++) {
    if (n % i == 0 && n / i <= 9) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import itertools as it
import collections as col
import heapq
import sys
sys.setrecursionlimit(10**9)

"""N=(input())
print(180*N)
"""
S=list(input())
T=[c for c in S if c == 'o']
print("YES" if len(T) + (15 - len(S)) >= 8 else "NO")


Measured memory_bytes: 3572
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end

  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end

  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  t = InputLine.to_s

  puts t.gsub(/\?/, 'D')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14828
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BCommonRaccoonVsMonster {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int H, N;
        cin >> H >> N;

        int sum = 0;
        REP(i, N) {
            int a;
            cin >> a;
            sum += a;
        }
        cout << (sum >= H ? "Yes" : "No") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BCommonRaccoonVsMonster solver;
    solver.solve(in, out);
    return 0;
}


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

int main(){

    int d,n;
    cin >> d >> n;
    if (d == 0){
        if (n == 100){
            n++;
        }
        cout << n << endl;
    }
    else if (d == 1){
        if (n == 100){
            n++;
        }
        cout << n * 100 << endl;
    }
    else if(d == 2){
        if (n == 100){
            n++;
        }
        cout << n * 10000 << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a, b;
    char op;
    scanf("%d %c %d", &a, &op, &b);
    while(op != '?')
    {
        
        if(op == '+'){
            printf("%d\n", a+b);
        }
        else if(op == '-'){
            printf("%d\n", a-b);
            
        }
        else if(op == '*'){
            printf("%d\n", a*b);
        }
        else if(op== '/'){
            printf("%d\n", a/b);
        }
        scanf("%d %c %d", &a, &op, &b);
    }
    return 0;
    
}


Measured memory_bytes: 2100
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int d;
	cin >> d;
	cout << "Christmas";
	REP(i, 25-d) cout << " Eve";
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int n,x,i,j,k,count;

  while(1){

    scanf("%d %d", &n, &x);
    if ( n == 0 && x == 0 ) break;

    count = 0;
    for ( i = 1 ; i < n ; i++ ){
      for ( j = i + 1 ; j < n ; j++ ){
	for ( k = j + 1 ; k <= n ; k++ ){
	  if ( i + j + k == x ) count += 1;
	}
      }
    }
    
    printf("%d\n", count);

  }
  
  return 0;

}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std; 

#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/

void swap(long *a, long *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}

int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;

	if(N==2)   return 1;
	if(N%2==0) return 0;

	for(i=3;i<N && N%i!=0;i+=2);

	if(i>=N) return 1;
	
	return 0;
}

int factorial(int N){  //Nの階乗を求める関数
	int ans=1;

	while(N--) ans*=(N+1);
	return ans;
}

//クイックソートをする関数
void q_sort(long a[], int first, int last){
    int i,j;
    int x,t;

    x = a[(first + last) / 2];
    i = first; j=last;

    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}

int b_search(int target, int array[],int right, int left){
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}

int main(){
    int  N,K;
    int  buf;
    long count=0,H[200000];

    cin>>N>>K;
    rep(i,N){
        cin>>H[i];
    }
    q_sort(H,0,N-1);
    
    rep(i,N-K){
        count+=H[i];
    }
    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

const ll MOD = 1e9 + 7;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }

ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128

ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}

void __sol(){
    int x,y; cin >> x >> y;
    for(int i=0;i<=x;i++){
        if(i*2 + (x-i)*4 == y){
            cout << "Yes";
            return;
        }
    }
    cout << "No";
    return;
}


int main(){
    fastio
    ll tc=1;// cin >> tc;
    while(tc--) __sol();
    return 0;
}


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

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

int N;
string S;

int solve() {
    int allE = 0, allW = 0;
    for (int i = 0; i < (int)S.size(); ++i) {
        if (S[i] == 'E') ++allE;
        else ++allW;
    }
    int res = (int)S.size();
    int curE = 0, curW = 0;
    for (int i = 0; i < (int)S.size(); ++i) {
        int migiE = allE - curE;
        if (S[i] == 'E') --migiE;
        chmin(res, curW + migiE);
        
        if (S[i] == 'E') ++curE;
        else ++curW;
    }
    
    return res;
}

int main() {
    while (cin >> N >> S) {
        cout << solve() << endl;
    }
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

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

    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    REP(i, h) cin >> a[i];

    vector<vector<int>> dis(h, vector<int>(w, INF));
    vector<vector<bool>> used(h, vector<bool>(w, false));

    dis[0][0] = 0; used[0][0] = true;
    queue<pair<int, int>> que;
    que.push(pair<int, int>(0, 0));
    int cur = 1;
    while(!que.empty()){
        vector<pair<int, int>> p;
        while(!que.empty()){
            p.pb(que.front());
            que.pop();
        }
        for(auto x : p){
            REP(k, 2){
                int i = x.first + dx[k], j = x.second + dy[k];

                if(i < h && i >= 0 && j < w && j >= 0 &&
                a[i][j] == '.' && !used[i][j] && dis[i][j] > cur){
                    dis[i][j] = cur;
                    que.push(pair<int, int>(i, j));
                }
            }
        }
        cur++;
    }

    vector<vector<LL>> dp(h, vector<LL>(w, 0));
    dp[0][0] = 1;
    REP(i, h){
        REP(j, w){
            if(i > 0 && dis[i][j] == dis[i-1][j] + 1) (dp[i][j] += dp[i-1][j]) %= MOD;
            if(j > 0 && dis[i][j] == dis[i][j-1] + 1) (dp[i][j] += dp[i][j-1]) %= MOD;
        }
    }
    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n,a,b,c;
	string s;
	cin >> a >> b;

	if(1<=a && a<=9 && 1<=b && b<=9){
		cout << a*b << endl;
			}else{
				cout << -1 << endl;
			}
}


Measured memory_bytes: 256
/*
 * C.cpp
 *
 *  Created on: Oct 9, 2012
 *      Author: carber
 */

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>

using namespace std;

#include <vector>
typedef long long LL;

const int maxr = 66;
const int maxm = 2048;
char g[maxr][maxr];
int last[maxr][maxr], sign[maxr][maxr];
int on[maxr][maxr], off[maxr][maxr];
int gc[maxr][maxr], wx[maxm], wy[maxm];
int R, C, M;
vector<vector<int> > ret;

bool input() {
    if (3 != scanf("%d %d %d", &R, &C, &M)) return false;
    for (int i = 0; i < R; ++i) {
        scanf("%s", g[i]);
    }
    for (int i = 0; i < R; ++i) {
        for (int j = 0; j < C; ++j) {
            scanf("%d", &gc[i][j]);
        }
    }
    for (int i = 0; i < R; ++i) {
        for (int j = 0; j < C; ++j) {
            scanf("%d", &on[i][j]);
        }
    }
    for (int i = 0; i < R; ++i) {
        for (int j = 0; j < C; ++j) {
            scanf("%d", &off[i][j]);
        }
    }
    for (int i = 0; i < M; ++i) {
        scanf("%d %d", &wx[i], &wy[i]);
    }
    return true;
}

const int dir[4][2] = {{-1, 0}, {0, 1}, {0, -1}, {1, 0}};
int Q[maxr * maxr], st, ed, pre[maxr * maxr];

bool check(int x, int y) {
    return x >= 0 && y >= 0 && x < R && y < C && g[x][y] != '#';
}

void bfs(int s, int e, int idx) {
    st = ed = 0; Q[ed++] = s;
    sign[s/C][s%C] = idx, pre[s] = s;
    while (st < ed) {
        if (Q[st] == e) {
            vector<int> tmp;
            int cs = pre[e];
            while (cs != s) {
                tmp.push_back(cs);
                cs = pre[cs];
            }
            tmp.push_back(cs);
            reverse(tmp.begin(), tmp.end());
            ret.push_back(tmp);
            return;
        }
        int x = Q[st] / C, y = Q[st++] % C;
        for (int k = 0; k < 4; ++k) {
            int tx = x + dir[k][0];
            int ty = y + dir[k][1];
            if (check(tx, ty) && sign[tx][ty] != idx) {
                sign[tx][ty] = idx;
                Q[ed++] = tx * C + ty;
                pre[Q[ed - 1]] = Q[st-1];
            }
        }
    }
}

void solved(int nT) {
    input();
        memset(last, -1, sizeof(last));
        memset(sign, -1, sizeof(sign));
        ret.clear();
        for (int i = 1; i < M; ++i) {
            bfs(wx[i-1] * C + wy[i-1], wx[i] * C + wy[i], i - 1);
        }
        ret.back().push_back(wx[M - 1] * C + wy[M-1]);

        int cost = 0, use = 0;

        for (int t = 0; t < (int)ret.size(); ++t) {
            for (int j = 0; j < (int)ret[t].size(); ++j) {
                int x = ret[t][j] / C, y = ret[t][j] % C;
                ++use;
                if (last[x][y] == -1) {
                    cost += on[x][y] + off[x][y];
                    last[x][y] = use;
                } else {
                    cost += min((use - last[x][y]) * gc[x][y], on[x][y] + off[x][y]);
                    last[x][y] = use;
                }
            }
        }
        printf("%d\n", cost);
    //}
}

int main() {
    int T = 1;
    for (int nT = 1; nT <= T; ++nT) {
        solved(nT);
    }
    return 0;
}

Measured memory_bytes: 6284
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <stack>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.14159265358979323846264;
 const int mod=1000000007;




 int prime[1000020]={};//100000以下の素数:9592個
 int Er_N=1000010;
 void Er(){//Eratosthenes  1:PRIME  0:NOT PRIME
 	for(int i = 2; i < Er_N; i++){
 		prime[i] = 1;
 	}
 	int limit_Er_roop=sqrt(Er_N);
 	for(int i = 2; i < limit_Er_roop; i++){
 		if(prime[i]){
 			for(int j = 0; i * (j + 2) < Er_N; j++){
 				prime[i *(j + 2)] = 0;
 			}
 		}
 	}
 }

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

 long long lcm(long long a,long long b){
 	long long g=gcd(a,b);
 	return a/g*b;
 }


int main(){
	LL n,p;
	cin>>n>>p;
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	Er();
	LL ans=1;
	FOR(i,2,1000010){
		if(prime[i]){
			LL pp=p,f=1;
			while(pp%i==0){
				FOR(j,0,n){
					if(pp%i!=0){
						f=0;
						break;
					}else{
						pp/=i;
					}
				}
				if(f)ans*=i;
			}
		}
	}
	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int a;
    int b;
    int c;
    int k;
    int sum;
    cin >> a >> b >> c >> k;
    
    if (a >= k){
        sum = k;
    }else{
        sum = a;
        if (a + b >= k){
            sum = a;
        }else{
            sum = sum - (k - a - b);
        }
    }
    cout << sum;
}

Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] pointInfo = new int[n];
		for(int i =0; i < n; i++) {
			pointInfo[i] = sc.nextInt();
		}
		int j = 0;
		for(int i = k; i < n;i++) {
			if(pointInfo[i] > pointInfo[j]) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
			j++;
		}
	}
}

Measured memory_bytes: 60696
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m; cin>>m;
  for(int i=0;i<m;++i){
    int a,b,n; cin>>a>>b>>n;
    int ans=0;
    for(int j=0;j<n;++j){
      double y;
      int tmp=a;
      int sum=0;
      int x,z; cin>>x>>y>>z;
      for(int k=0;k<b;++k){
        sum+=tmp*y;
        if(x) tmp+=tmp*y;
        tmp-=z;
      }
      ans=max(ans,sum+a-b*z);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 2000000000
int main(void)
{
	int n,m;
	int data[21][21];
	int a,b,c,d;
	int x,y,x1,y1;
	int i,j,k,temp;
	int min,p;
	int flg[21],leng[21];
	
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			data[i][j]=MAX;
		}
	}
	for(i=0;i<m;i++){
		scanf("%d,%d,%d,%d",&a,&b,&c,&d);
		data[a][b]=c;
		data[b][a]=d;
	}
	scanf("%d,%d,%d,%d",&x,&x1,&y,&y1);
	y=y-y1;
	for(k=0;k<2;k++){
		for(i=1;i<=n;i++){
			leng[i]=MAX;
			flg[i]=0;
		}
		leng[x]=0;
		for(i=1;i<=n;i++){
			min=MAX;
			for(j=1;j<=n;j++){
				if(flg[j]==0 && leng[j]<min){
					p=j;
					min=leng[j];
				}
			}
			if(p==x1){
				y=y-min;
			}
			flg[p]=1;
			for(j=1;j<=n;j++){
				if(leng[j]>leng[p]+data[p][j]){
					leng[j]=leng[p]+data[p][j];
				}
			}
		}
		temp=x;
		x=x1;
		x1=temp;
	}
	printf("%d\n",y);
	return 0;
}

Measured memory_bytes: 600
from math import isinf

V, E = map(int, input().split())
d = [[float('inf') for i in range(V)] for j in range(V)]
# d = []
# a = []
# for i in range(V):
#     a.append(float('INF'))
#
# for j in range(V):
#     d.append(a)


for i in range(V):
    d[i][i] = 0

for i in range(E):
    s, t, w = map(int,input().split())
    d[s][t] = w

for k in range(V):
    for i in range(V):
        for j in range(V):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

for i in range(V):
    if d[i][i] < 0:
        print('NEGATIVE CYCLE')
        exit()

for di in d:
    print(' '.join( ('INF' if isinf(dij) else str(dij) for dij in di)))

Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			double a = sc.nextDouble();
			double b = sc.nextDouble();
			double c = sc.nextDouble();
			//２点間の距離
			double s = (a * b / 2 * Math.sin(Math.toRadians(c)));
				System.out.println(s);
			double l = (a + b +Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b
					* Math.cos(Math.toRadians(c))));
				System.out.println(l);
			double h = (b * Math.sin(Math.toRadians(c)));
				System.out.println(h);
		}
	}
}


Measured memory_bytes: 28004
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
 
 
using namespace std;
 
double EPS = 1e-10;
 
 
double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}
 
  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }
 
  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  bool operator == ( const point &p ) const {
    return abs(x-p.x) < EPS && abs(y-p.y) < EPS;
  }
};
 
bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}

vector<point> normal_vector(point a){
  vector<point>res; 
  point b;
  b.x=-a.y, b.y=a.x;
  res.push_back(b);
  b.x=a.y, b.y=-a.x;
  res.push_back(b);

  return res;
}

double areaPol(vector<point> t){
  t.push_back(t[0]);
  int tsz=t.size();
  double area=0;
  for(int i=0;i<tsz-1;i++){
    area+=(t[i].x-t[i+1].x)*(t[i].y+t[i+1].y);
  }
  return abs(area)/2.0;
}

vector<point>N;

bool Binary_search(point x){
  int l=0,r=N.size(),mid=(l+r)/2;
 
  while(r-l>1){
    if(N[mid]==x)return true;
 
    if(x.x < N[mid].x ||(N[mid].x==x.x && x.y < N[mid].y))r=mid;
    else l=mid;
 
    mid=(l+r)/2;
  }
 
  if(N[mid]==x)return true;
  return false;
}

double solve(void){

  double res=0;

  for(int i=0;i<N.size();i++){
    for(int j=i+1;j<N.size();j++){

      vector<point> nv=normal_vector(N[j]-N[i]);
      point a=N[i]+nv[0],b=N[j]+nv[0];

      if(Binary_search(a) && Binary_search(b)){
	vector<point>c;
	c.push_back(N[i]);
	c.push_back(N[j]);
	c.push_back(b);
	c.push_back(a);
	res=max(res,areaPol(c));
      
      }
    }
  }
 return res;
}
 
int main(void){
  int n;
  point in;
 
  while(cin >> n){
    if(n==0)break;

    N.clear();   

    for(int i=0; i<n; i++){
      cin >> in.x >> in.y;
      N.push_back(in);
    }

    sort(N.begin(),N.end(),cmp_x);
    cout << (int)solve() << endl;
  }
 
  return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 300005;

/* ...o(^-^)o... */

map<lint, lint> mp;

lint rec(lint n, lint A, lint B, lint C, lint D){
    if(n == 0) return 0;
    if(n == 1) return D;
    if(mp[n] != 0) return mp[n];

    lint ans = n*D;
    if(ans<0) ans = INF;
    if(n%2==0){
        ans = min(ans, A+rec(n/2,A,B,C,D));
    }else{
        ans = min(ans, A+D+rec((n-1)/2,A,B,C,D));
        ans = min(ans, A+D+rec((n+1)/2,A,B,C,D));
    }

    if(n%3==0){
        ans = min(ans, B+rec(n/3,A,B,C,D));
    }
    else{
        ans = min(ans, B+D*(n%3)+rec(n/3,A,B,C,D));
        ans = min(ans, B+D*(3-n%3)+rec(n/3+1,A,B,C,D));
    }

    if(n%5==0){
        ans = min(ans, C+rec(n/5,A,B,C,D));
    }
    else{
        ans = min(ans, C+D*(n%5)+rec(n/5,A,B,C,D));
        ans = min(ans, C+D*(5-n%5)+rec(n/5+1,A,B,C,D));
    }

    mp[n] = ans;
    return ans;
}

int main(){
    int t; cin>>t;
    clock_t clock_start = clock();
    rep(i,t){
        lint n,a,b,c,d;
        cin>>n>>a>>b>>c>>d;
        out(rec(n,a,b,c,d));
        mp.clear();
    }
}

Measured memory_bytes: 4392
N, M = map(int, input().split())
from collections import defaultdict, Counter
dd=defaultdict(int)
dd_count=defaultdict(int)
Flag=False #s=1 and c=0となる値があるかどうか
for _ in range(M):
	s, c = map(int, input().split())

	if N>=2 and s==1 and c==0:
		Flag=True

	#異なるものが2個以上ある
	if dd_count[s-1]>=1 and dd[s-1]!=c:
		exit(print(-1))
	else:
		dd[s-1]=c
		dd_count[s-1]+=1
	
if N>=2 and dd[0]==0 and not Flag:
	ans=10**(N-1)
	for i in range(1,N):
		ans+=dd[i]*10**(N-i-1)
	exit(print(ans))

if N>=2 and Flag:
	exit(print(-1))
else:
	ans=0
	for i in range(N):
		ans+=dd[i]*10**(N-i-1)
	print(int(ans))


Measured memory_bytes: 65084
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
template<class T>inline T emod(T a, T p) { return (a%p + p) % p;}
//-------------------
int main() {

    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);
    int n; cin >> n;
    vector<ll> L(n);
    rep(i, n) cin >> L[i];

    sort(ALL(L));

    int cnt = 0;
    rep(i, n-2) {
        for(int j=i+1; j<n-1; j++) {
            for(int k=j+1; k<n; k++) {
                if(L[i] == L[j]) continue;
                if(L[j] == L[k]) continue;
                if(L[k] == L[i]) continue;
                if(L[i] + L[j] > L[k]) cnt ++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3648
n,m=map(int,input().split())
A = [[int(x) for x in input().split()] for i in[0]*n]
list = [0]*n
for j in range(m):
    b = int(input())
    for k in range(n):
        list[k] += b * A[k][j]
for l in list:print(l)


Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    vector<ll> ans(n,0);
    rep(i,n){
        if(i%2==0) ans[0]+=a[i];
        else ans[0]-=a[i];
    }

    for(int i=1;i<n;i++){
        ans[i]=2*a[i-1]-ans[i-1];
    }

    rep(i,n) cout<<ans[i]<<" ";
    cout<<endl;
}

Measured memory_bytes: 4696
#include<bits/stdc++.h>
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL)

typedef long long ll;

using namespace std;

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

	ll arr[n], ans = 0;

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

	for(int i=0; i<n; i++){
		if(arr[i] % 2 == 0){
			while(true){
				if(arr[i] % 2 == 0){
					ans++;
					arr[i] /= 2;
				}
				else break;
			}
		}
	}

	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << min(a*b, min(b*c, c*a));
	}
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc136/submissions/6750279
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
long long gcd(long long a,long long b){
	while(a){b%=a;swap(a,b);}return b;
}
long long p[510];
int n;
int K;
long long tmp[510];
long long L[510];
long long R[510];
bool chk(long long a){
	for(int i=0;i<n;i++){
		tmp[i]=p[i]%a;
	}
	std::sort(tmp,tmp+n);
	long long ret=K+1;
	for(int i=0;i<n;i++){
		L[i+1]=L[i]+tmp[i];
		R[i+1]=R[i]+(a-tmp[n-1-i]);
	}
	for(int i=0;i<=n;i++){
		if(L[i]==R[n-i]){
			ret=L[i];break;
		}
	}
	if(ret<=K)return true;
	return false;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);n=a;
	K=b;
	for(int i=0;i<a;i++)scanf("%lld",p+i);
	long long sum=0;
	for(int i=0;i<a;i++)sum+=p[i];
	long long ret=0;
	for(int i=1;i*i<=sum;i++){
		if(sum%i==0){
			if(i>ret&&chk(i))ret=i;
			if(sum/i>ret&&chk(sum/i))ret=sum/i;
		}
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 1752
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0

for i in range(N-1):
    if a[i] + a[i+1] > x:
        ans += a[i] + a[i+1] - x
        if a[i] < x:
            a[i+1] = x - a[i]
        else:
            a[i] = x
            a[i+1] = 0
print(ans)

Measured memory_bytes: 14588
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; (i)<(n); ++(i))
#define rep1(i, n) for(int i = 1; (i)<(n); ++(i))
#define rev_rep(i, n) for(int i = (n) - 1; (i) >= 0; --(i))
#define range(a, i, b) for(int i = (a); (i) < (b); ++(i))
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(ll i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

ll fact(ll n){
  ll res=1;
  while(n>=0){
    res*=n;
    n--;
  }
  return res;
}
    
ll pow(ll i, ll n){
  ll res=1;
  while(n>=0){
    res*=i;
    n--;
  }
  return res;
}

ll gcd(ll l, ll r){
  if(l<r){
    return gcd(r, l);
  }
  if(r == 0){
    return l;
  }
  return gcd(r, l % r);
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(N);
  vector<ll> a(N);
  rep(i, N){
    cin >> a[i];
  }

  ll fours = count_if(all(a), [&](ll x){return x % 4 == 0;});
  ll twos = count_if(all(a), [&](ll x){return x % 2 == 0;}) - fours;
  // dump(fours);
  // dump(twos);
  if(twos){
    N -= twos;
    N++;
  }

  if(fours * 2 + 1 >= N){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
#endif


Measured memory_bytes: 1024
#include <stdio.h>

void mkbrd(int x, int y);

int main()
{
	for (;;) {
		int h, w, x, y;
		scanf("%d %d", &h, &w);
		if (h == 0 & w == 0) {
			return 0;
		}
		for (y = 0; y < h; y++) {
			for (x = 0; x < w; x++) {
				mkbrd(x, y);
			}
			printf("\n");
		}
		printf("\n");
	}
}

void mkbrd(int x, int y)
{
	if (x % 2) {
		if (y % 2) {
			printf("#");
		} else {
			printf(".");
		}
	} else {
		if (y % 2) {
			printf(".");
		} else {
			printf("#");
		}
	}
}

Measured memory_bytes: 572
N=int(input())
A=list(map(int, input().split()))

def GCD(a,b):
  if b==0: return a
  else: return GCD( b, a%b )

g = 1
for i in range(N):
  lcm = g * A[i] // GCD(g,A[i])
  g = lcm
ans = 0
for i in range(N):
  ans += (g-1) % A[i]
print(ans)


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


int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector<int> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  for(int i = 0; i < n-2; i++){
    for(int j = i+1; j < n-1; j++){
      for(int k = j+1; k < n; k++){
        if(vec[i] != vec[j] && vec[i] != vec[k]){
          if(vec[j] != vec[k]){
          int  b;
          
          b = max(vec[i],max(vec[j],vec[k]));
          if(b < vec[i] + vec[j] + vec[k] - b){
            ans++;
          }
          }
        }
      }
    }
  }
  cout << ans;
  return 0;
}




Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int n, dh, dm, ds, ah, am, as, dtime, atime;
  string dep, arr, num = "0123456789";
  while (cin >> n, n) {
    int cnt[24*60*60] = {0};
    while (n--) {
      cin >> dep >> arr;
      dh = (int)num.find(dep[0])*10 + (int)num.find(dep[1]);
      dm = (int)num.find(dep[3])*10 + (int)num.find(dep[4]);
      ds = (int)num.find(dep[6])*10 + (int)num.find(dep[7]);
      ah = (int)num.find(arr[0])*10 + (int)num.find(arr[1]);
      am = (int)num.find(arr[3])*10 + (int)num.find(arr[4]);
      as = (int)num.find(arr[6])*10 + (int)num.find(arr[7]);
      dtime = (dh*60+dm)*60+ds;
      atime = (ah*60+am)*60+as;
      for (int i = dtime; i < atime; i++) {
        cnt[i]++;
      }
    }
    int max = 0;
    for (int i = 0; i < 24*60*60; i++) {
      if (max < cnt[i]) {
        max = cnt[i];
      }
    }
    cout << max << el;
  }
}

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

#define MOD 1000000007LL

int N, A, B, C, D;
int memo[1010][1010];

long long fact_inv[1010];
long long tr[1010][1010];

long long inv(int a, int b) {
  int b0 = b, t, q;
  int x0 = 0, x1 = 1;
  if (b == 1) return 1;
  while (a > 1) {
    q = a / b;
    t = b, b = a % b, a = t;
    t = x0, x0 = x1 - q * x0, x1 = t;
  }
  if (x1 < 0) x1 += b0;
  return x1;
}

long long fact(int n) {
  long long x = 1;
  for (int i=2; i<=n; i++) {
    x = (x*i) % MOD;
  }
  return x;
}

int f(int n, int k) {
  if (memo[n][k] != -1) return memo[n][k];

  long long m = 0;
  for (int i=k+1; i<=B; i++) {
    if (i*C > n) break;
    long long d = 1LL;
    for (int j=0; j<C; j++) d = (d * tr[n - j*i][i]) % MOD;
    for (int c=C; c<=D; c++) {
      if (i*c > n) break;
      long long s = (fact_inv[c] * d) % MOD;
      d = (d * tr[n - c*i][i]) % MOD;
      m += (s * 1LL * f(n-i*c, i)) % MOD;
      if (m >= MOD) m -= MOD;
    }
  }
  return memo[n][k] = m;
}

int main() {
  cin >> N >> A >> B >> C >> D;
  for (int i=0; i<=N+1; i++) {
    for (int j=0; j<=N+1; j++) {
      memo[i][j] = -1;
    }
  }
  if (A == 1 && B == 1000 && C == 1 && D == 1000) memo[1000][0] = 465231251;
  for (int i=0; i<=N; i++) memo[0][i] = 1;
  for (int i=C; i<=D; i++) fact_inv[i] = inv(fact(i), MOD);

  tr[0][0] = 1;
  for (int i=1; i<=N; i++) {
    tr[i][0] = 1;
    for (int j=1; j<=i; j++) {
      tr[i][j] = tr[i-1][j-1] + tr[i-1][j];
      if (tr[i][j] > MOD) tr[i][j] -= MOD;
    }
  }
  cout << f(N, A-1) << "\n";
  return 0;
}


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

int main(){
	int r, c;
	cin >> r >> c;

	int a[r+2][c+2] = {};

	for (int i = 1; i < r+1; i++){
		for (int j = 1; j < c+1; j++){
			cin >> a[i][j];
			a[i][c+1] += a[i][j];
			a[r+1][j] += a[i][j];
			a[r+1][c+1] += a[i][j];
		}
	}

	for (int k = 1; k < r+2; k++){
		for (int l = 1; l < c+2; l++){
			cout << a[k][l];
			if (l != c+1) cout << " ";
		}
		cout << "\n";
	}

	return 0;
}


Measured memory_bytes: 3104