akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    int H, W; cin >> H >> W;
    char s[H][W];
    rep(i,H) {
        rep(j,W) cin >> s[i][j];
    }

    int d[H][W];
    bool used[H][W];
    int ans = 0;

    int dir_x[4] = {0, 1, 0, -1};
    int dir_y[4] = {1, 0, -1, 0};
    
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {

            if (s[i][j] == '#') continue;
            
            for (int k = 0; k < H; ++k) {
                for (int l = 0; l < W; ++l) {
                    d[k][l] = INF;
                    used[k][l] = false;
                }
            }
            d[i][j] = 0;

            while (true) {

                int v_x = -1; int v_y = -1; int d_tmp = INF;
                for (int k = 0; k < H; ++k) {
                    for (int l = 0; l < W; ++l) {
                        if (used[k][l] || s[k][l] == '#') continue;
                        if (d[k][l] < d_tmp) {
                            d_tmp = d[k][l];
                            v_x = k;
                            v_y = l;
                        }
                    }
                }
                if (v_x == -1 && v_y == -1) break;
                used[v_x][v_y] = true;

                for (int dir = 0; dir < 4; ++dir) {
                    int n_x = v_x + dir_x[dir];
                    int n_y = v_y + dir_y[dir];
                    if (0 <= n_x && n_x < H && 0 <= n_y && n_y < W && s[v_x][v_y] == '.') {
                        if (d[v_x][v_y] != INF) {
                            d[n_x][n_y] = min(d[n_x][n_y], d[v_x][v_y] + 1);
                        } 
                    } 
                }
            }

            for (int k = 0; k < H; ++k) {
                for (int l = 0; l < W; ++l) {
                    if (s[k][l] == '.') {
                        ans = max(ans, d[k][l]);
                    }
                }
            }
        }
    }

    cout << ans << endl;


    
    return 0;
}









Measured memory_bytes: 3644
n, m = map(int, input().split())
List1 = [[0 for i in range(m)] for i in range(n)]
for x in range(n):
    List1[x] = list(map(int, input().split()))
List2 = [int(input()) for i in range(m)]
sum = [0 for i in range(n)]
for x in range(n):
    for y in range(m):
        sum[x] += List1[x][y] * List2[y]
for x in range(n):
    print(sum[x])


Measured memory_bytes: 6028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
	int n;cin>>n;
	vector<int> v(n+2);
	v[0]=0;v.back()=0;
	for(int i=1;i<=n;i++)cin>>v[i];
	vector<int> d(n+2);
	for(int i=0;i<=n;i++)d[i]=abs(v[i+1]-v[i]);
	int sum=accumulate(d.begin(),d.end(),0);
	for(int i=1;i<=n;i++){
	    cout<<sum-d[i-1]-d[i]+abs(v[i-1]-v[i+1])<<endl;
	}
	
}

Measured memory_bytes: 2048
#include <stdio.h>

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	
	if(a < b)
	{
		printf("a < b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

int main() {
    // input
    ll N;
    cin >> N;
    
    // calculation
    if (N < 1200) {
        cout << "ABC" << "\n";
    } else if (N < 2800) {
        cout << "ARC" << "\n";
    } else {
        cout << "AGC" << "\n";
    }
    
    return 0;
}


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

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

  int sum = 0;
  for (int i = 0; i < n.length(); i++) {
    sum += n.at(i) - '0';
  }

  if (stoi(n) % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll res = N/(A+B)*A;
    N %= A + B;
    res += min(A, N);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    long long s;
    std::cin >> s;

    if (s == 1e18) {
        std::cout << "0 0 1000000000 0 0 1000000000" << std::endl;
        return 0;
    }

    std::cout << "0 0 1000000000 1 " << 1000000000 - s % 1000000000 << " " << s / 1000000000 + 1 << std::endl;
}


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

using namespace std;

int A, B, C;

int main() {
	int X[3];
	cin >> X[0] >> X[1] >> X[2];

	sort(X, X + 3);
	int cnt = 0;
	cnt = X[2] - X[1];
	if ((X[2] - X[0] - cnt) % 2 == 0)
		cnt += (X[2] - X[0] - cnt) / 2;
	else
		cnt += ceil((X[2] - X[0] - cnt) / 2.0) + 1;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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

ll modpow(ll p,ll q){
    if(q == 0) return 1;
    if(q%2 == 0){
        ll x = modpow(p,q/2);
        return x*x%mod;
    }else{
        return modpow(p,q-1)*p%mod;
    }
}


int main(void){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll h,w,m;
    cin >> h >> w >> m;
    vector<ll>hr(h),wr(w);
    set<pair<ll,ll>>pl;
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        --x;--y;
        ++hr[x];
        ++wr[y];
        pl.insert(make_pair(x,y));
    }
    ll max_x=0,max_y=0;
    rep(i,h){
        max_x = max(max_x,hr[i]);
    }
    rep(i,w){
        max_y = max(max_y,wr[i]);
    }
    vector<ll>li_x,li_y;
    rep(i,h){
        if(hr[i] == max_x)li_x.pb(i);
    }
    rep(i,w){
        if(wr[i] == max_y)li_y.pb(i);
    }
    bool flag = false;
    for(auto x : li_x){
        for(auto y : li_y){
            if(pl.find(make_pair(x,y)) == pl.end()){
                flag = true;
                break;
            }
        }
        if(flag)break;
    }

    ll ans;
    if(flag)ans = max_x + max_y;
    else ans = max_x + max_y -1;
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 34980
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          Console.WriteLine($"ABC{Input.ScanInt()}");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
# include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
	int N;
  	cin >> N;
	int A[N+1];
 	int i;
  	for (int i = 0; i < N; ++i) { cin >> A[i]; }
  
    string ans = "APPROVED"; 
  	for (int i = 0; i < N; ++i) {
    	if (A[i] % 2 == 1) continue;
		if (A[i] % 3 == 0) continue;
		if (A[i] % 5 == 0) continue;
      
        ans = "DENIED";
        break;
    }
  
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,d,x;
  cin >> n >> d >> x;
  ll a[n];
  rep(i,n) cin >> a[i];
  rep(i,n) {
    ll t=1;
    while(t<=d) {
      x++;
      t+=a[i];
    }
  }
  pr(x);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <vector>
#include <functional>
#include <queue>
using namespace std;

struct edge_base {
  int from;
  int to;
};

template<class E>
struct graph_base {
  virtual void add_edge(E e) = 0;
  virtual const vector<E>& operator[](int i) const = 0;
  virtual int N() const = 0;
};

template<class E, class W>
vector<E> prim(const graph_base<E>& g, function<W(E)> sel) {
  int n = g.N();
  vector<E> ans;
  vector<bool> vis(n, false);
  using P = pair<W, E>;
  struct cmp {
    bool operator()(const P& a,const P& b){ 
      return a.first > b.first;
    }
  };
  priority_queue<P, vector<P>, cmp> que;
  vis[0] = true;
  for(auto & e : g[0]) {
    que.push({sel(e) , e});
  }
  for(int c = 0;c < n - 1;) {
    auto e = que.top().second;
    que.pop();
    if(vis[e.to]) continue;
    vis[e.to] = true;
    ans.push_back(e);
    for(auto & ee : g[e.to]) {
      if(!vis[ee.to])
        que.push({sel(ee) , ee});
    }
    c++;
  }
  return std::move(ans);
}

template<class E>
struct graph : graph_base<E> {
  vector<vector<E>> G;
  graph(int n) : G(n) {}
  void add_edge(E e) {
    G[e.from].push_back(e);
  }
  const vector<E>& operator[](int i) const { return G[i]; }
  int N() const { return G.size(); }
};

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

struct edge : edge_base {
  i64 cost;
  edge(int f,int t, i64 c) {
    from = f;
    to = t;
    cost = c;
  }
};

int main() {
  int n,m;
  cin >> n >> m;
  graph<edge> g(n);
  rep(i,0,m - 1) {
    int s,t;
    i64 w;
    cin >> s >> t >> w;
    g.add_edge(edge(s,t,w));
    g.add_edge(edge(t,s,w));
  }
  function<i64(edge e)> ff = [](edge e){ return e.cost; };
  auto res = prim(g, ff);
  i64 ans = 0;
  for(auto& x : res) {
    ans += x.cost;
  }
  cout << ans << endl;
}



Measured memory_bytes: 11668
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

struct BiMatch{
  Int L,R;
  vector<vector<Int> > G;
  vector<Int> match,level;
  
  BiMatch(){}
  BiMatch(Int L,Int R):L(L),R(R),G(L+R),match(L+R,-1),level(L){}
  
  void add_edge(Int u,Int v){
    G[u].push_back(v+L);
    G[v+L].push_back(u);
  }
  
  bool bfs(){
    queue<Int> q;
    for(Int i=0;i<L;i++){
      level[i]=-1;
      if(match[i]<0){
	level[i]=0;
	q.emplace(i);
      }
    }
    while(!q.empty()){
      Int v=q.front();q.pop();
      for(Int u:G[v]){
	Int w=match[u];
	if(w<0) return true;
	if(level[w]<0){
	  level[w]=level[v]+1;
	  q.emplace(w);
	}
      }
    }
    return false;
  }

  bool dfs(Int v){
    for(Int u:G[v]){
      Int w=match[u];
      if(w<0||(level[w]>level[v]&&dfs(w))){
	match[v]=u;
	match[u]=v;
	return true;
      }
    }
    return false;
  }
  
  Int build(){
    Int res=0;
    while(bfs())
      for(Int i=0;i<L;i++)
	if(match[i]<0&&dfs(i))
	  res++;
    return res;
  }
  
};

//INSERT ABOVE HERE
signed main(){
  Int n,x,y;
  cin>>n>>x>>y;
  
  vector<Int> cn,cp;
  auto check=[&](Int c){
    return (abs(c)<=x||(y<=abs(c)&&abs(c)<=x*2));
  };
  
  Int ans=0;
  for(Int i=0;i<n;i++){
    Int a,b;
    cin>>a>>b;
    Int c=a-b;
    if(check(c)){
      ans++;
      continue;
    }
    if(c<0) cn.emplace_back(c);
    if(c>0) cp.emplace_back(c);
  }

  
  Int p=cn.size(),q=cp.size();
  BiMatch bm(p,q);
  for(Int i=0;i<p;i++)
    for(Int j=0;j<q;j++)
      if(check(cn[i]+cp[j]))
	bm.add_edge(i,j);
  
  ans+=bm.build();
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3916
def triangle a, b, c
  if a < b+c
    if b < a+c
      if c < a+b
        return true
      end
    end
  end
  return false
end

n = gets.to_i
arr = gets.split.map(&:to_i)

x = 0
hash = { }

n.times do |i|
  n.times do |j|
    next if arr[i] == arr[j]
    n.times do |k|
      next if arr[i] == arr[k]
      next if arr[j] == arr[k]
      str = [i,j,k].sort.map(&:succ).to_s
      unless hash.has_key? str
        hash[str] = triangle arr[i], arr[j], arr[k]
        if hash[str]
          x += 1
        end
      end
    end
  end
end

puts x


Measured memory_bytes: 38728
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
using namespace std;

const int M=1e5+10;
char a[M];

int main(){
    while(scanf("%s",a)!=EOF){
        getchar();
        int flag=0;
        for(int i=1;a[i];i++){
           if(a[i]==a[i-1]){
                /*if(a[i+1]&&a[i]!=a[i+1]){
                    printf("%d %d\n",i,i+2);
                    flag=1;
                    break;
                }

                else
                    if(i-2>=0&&a[i-2]!=a[i-1]){
                        printf("%d %d\n",i-1,i+1);
                        flag=1;
                        break;
                    }*/
                printf("%d %d\n",i,i+1);
                 flag=1;
                break;
            }
            else
                if(a[i-1]==a[i+1]){
                    printf("%d %d\n",i,i+2);
                    flag=1;
                    break;
                }
        }
        if(!flag)
            printf("-1 -1\n");
    }
    return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d;
int x, y;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  rep(i, 3) cin >> v[i];
  sort(v.begin(), v.end());
  rep(i, 2)
  {
    if (v[i] == v[i + 1])
      ans++;
  }

  pr(3 - ans);
}

Measured memory_bytes: 3636
n = int(input())
num_list = list(map(int,input().split()))
sum_cnt = sum(num_list)
sunuke = 0
arai = 0
tmp = 0
tmp_list = []
for i in range(len(num_list)-1):
    if i == 0:
        sunuke += num_list[i]
        arai = (sum_cnt - sunuke)
        tmp = abs(arai - sunuke)
        tmp_list.append(tmp)
    else:
        sunuke += num_list[i]
        arai = (sum_cnt - sunuke)
        tmp = abs(arai - sunuke)
        tmp_list.append(tmp)
print(min(tmp_list))

Measured memory_bytes: 24832
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a[100005]={},cnt=0;
  map<int,int> m;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  for(auto p:m) {
    if(p.second>1) {
      cnt+=p.second-1;
    }
  }
  if(cnt%2==0) {
    cout << n-cnt << endl;
  }
  else {
    cout << n-cnt-1 << endl;
  }
}




Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int n,l;
    cin >> n >> l;
    
    vector<int> a(n);
    int b = 10000;
    int tmp = 0;
    bool flag =0;
    for (int i = 0; i < n; i++)
    {
        a[i] = l + i;
        tmp = min(abs(a[i]),abs(b));
        if (a[i]<0 || b<0)
        {
            flag =1;
        }
        
        b = tmp;
        // cout << tmp << endl;
    }

    int ans =0;
    for (int i = 0; i < n; i++)
    {
        ans += a[i];
    }
    if (flag)
    {
        cout << ans + tmp << endl;
    }else
    {
        cout << ans - tmp << endl;
    }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int dev(int[] a,int an){
		boolean flg = false;
		for(int i = 0;i < a.length;i++){
			if(a[i]%2 == 0){
				flg = true;
				while(a[i]%2 == 0){
				a[i] /= 2;
				an++;
				}
				break;
			}
		}
		if(flg)
			return dev(a,an);
		else
			return an;
	}
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		int na[] = new int[n];
		for(int i = 0; i < n; i++)
			na[i] = sc.nextInt();

		System.out.println(dev(na,0));

	}
}


Measured memory_bytes: 35716
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7;//998244353 ;

int main(){
  char c;
  cin >> c;
  if('a'<=c && c<='z'){
    cout << 'a' << endl;
  }else cout << "A" << endl;
return 0;}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int L[200];
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    int ans=0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            for(int k=j+1; k<N; k++){
                if(L[i]!=L[j] and L[i]!=L[k] and L[j]!=L[k]){
                    if( L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[k]+L[j]>L[i] ){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#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>;

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

const ll INF = 1LL << 60;

ll dp[100010];


int main(){
    int N, K; cin >> N >> K;
    vector<int> H(N);
    rep(i, N) cin >> H[i];

    rep(i, 100010) dp[i] = INF;

    dp[0] = 0;
    for(int i = 0; i < N; ++i){
        for(int k = 1; k<=K && i+k<N; ++k){
            chmin(dp[i+k], dp[i] + abs(H[i+k] - H[i]));
        }
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 4388
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
int n,m;
int s[111111],c[111111];
int num[111111];
signed main(){
	rep(i,111111)num[i]=-1;
	cin>>n>>m;
	rep(i,m)cin>>s[i]>>c[i];
	rep(i,m){
	    if(num[s[i]]==-1){
	        num[s[i]]=c[i];
	    }
	    else{
	        if(num[s[i]]!=c[i]){
	            cout<<-1<<endl;
	            return 0;
	        }
	    }
	}
	if(num[1]==0 && n!=1){
	    cout<<-1<<endl;
	    return 0;
	}
	if(n==1 && m==0){
	    cout<<0<<endl;
	    return 0;
	}
	rep(i,n){
	    if(num[i+1]==-1){
	        if(i==0)cout<<1;
	        else cout<<0;
	    }
	    else cout<<num[i+1];
	}
	cout<<endl;
}

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

def solve():
    n, m = map(int, input().strip().split())
    am = set([int(input().strip()) for i in range(m)])
    ans = [0] * (n + 1000)
    ans[0] = 1
    md = (10 ** 9) + 7
    for i in range(n):
        if (i + 1) not in am:
            ans[i + 1] = (ans[i] + ans[i + 1]) % md
        if (i + 2) not in am:
            ans[i + 2] = (ans[i] + ans[i + 2]) % md
    print(ans[n])

if __name__ == "__main__":
    solve()


Measured memory_bytes: 56664
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
int main() {

	int t;
	int i,j,n;

	cin>>n;

	vector<ll> v(n);
	ll br=0;
	for (i=0;i<n;i++) {
		cin>>v[i];
	}

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

	br=v[n-1];

	int pati = n-2;
	i=n-2;
	while (pati) {

		if (pati>=2) {
			
			br+=v[i]*2;
			pati-=2;
		} else {
			br+=v[i];
			pati--;
		}
		i--;

	}



	cout<<br<<"\n";


	return 0;
}

Measured memory_bytes: 4764
a = input().split()
b = input().split()

H = int(a[0])
W = int(a[1])
h = int(b[0])
w = int(b[1])

gridAll = H*W
gridRemain = gridAll

gridRemain -= h*W
gridRemain -= w*H
gridRemain += h*w

print(gridRemain)

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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const int matches[10] = {1<<30, 2, 5, 5, 4, 5, 6, 3, 7, 6};

vector<int> a(9);
int n, m;
vector<string> dp(10001, "");

string chmax(string s, string t) {
    if(s.length() < t.length()) {
        return t;
    } else if(s.length() > t.length()) {
        return s;
    } else {
        return max(s, t);
    }
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    a.resize(m);
    for(int i=0;i<m;++i) cin >> a[i];

    for(int i=0;i<m;++i) {
        for(int j=0;j<=n-matches[a[i]];++j) {
            if(j && dp[j].empty()) continue;
            dp[j+matches[a[i]]] = chmax(
                dp[j+matches[a[i]]], 
                chmax(dp[j] + char('0'+a[i]), char('0'+a[i]) + dp[j])
            );
            // cerr << j+matches[a[i]] << ": " << dp[j+matches[a[i]]] << endl;
        }
    }
    cout << dp[n] << "\n";
}


Measured memory_bytes: 35584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] list = str.split(" ");
		String answer = "";
		for(int i=0; i<3; i++){
			answer = answer +  list[i].substring(0, 1).toUpperCase();
		}
		System.out.println(answer);

	}

}


Measured memory_bytes: 22868
#!/usr/bin/env python3


def main():
    N = int(input())
    C = [None] * (N-1)
    S = [None] * (N-1)
    F = [None] * (N-1)
    for i in range(N-1):
        C[i], S[i], F[i] = map(int, input().split())
    
    for i in range(N-1):
        ans = S[i]
        for j in range(i,N-1):
            if j > i:
                if ans <= S[j]:
                    ans = S[j]
                else:
                    if (ans - S[j]) % F[j] > 0:
                        ans += F[j] - (ans - S[j]) % F[j]
            ans += C[j]
        print(ans)
    print(0)


if __name__ == "__main__":
    main()


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



int main(){
    string s;cin>>s;
    ll i=0;
    string ss="";
    while(i<s.size()){
        if(i!=s.size()-1&&s[i]=='B'&&s[i+1]=='C'){ss+='D';i++;}
        else if(s[i]=='B'||s[i]=='C')ss+='E';
        else ss+='A';
        i++;
    }
    ll cn=0,an=0;    
    for(int i=ss.size()-1;i>=0;i--){
        if(ss[i]=='E')cn=0;
        else if(ss[i]=='D')cn++;
        else if(ss[i]=='A')an+=cn;
    }
    cout<<an<<endl;
    
}







Measured memory_bytes: 776
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    minA = min(A)
    if (N - A.count(minA)) % (K - 1) == 0:
        print((N - A.count(minA)) // (K - 1))
    else:
        print((N - A.count(minA)) // (K - 1) + 1)


main()


Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int K, X;


signed main(){
    cin >> K >> X;

    if(500*K >= X) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint N,K;
    cin >> N >> K;
    lint base=0;
    lint sum=0;
    lint save[1000000]={};
    rep(i,1000000){
        save[i]=N/(i+1)-N/(i+2);
        sum+=save[i];
        if(save[i]==0) break;
        base++;
    }
    base+=N-sum;
    rep(i,100000) save[i]=max(1LL,save[i]);
    lint mul[base];
    rep(i,base){
        if(i==0) mul[i]=save[base-1-i];
        else{
            mul[i]=mul[i-1]+save[base-1-i];
        }
    }
    lint dp[K+10][base+10]={};
    rep(i,base) dp[1][i+1]=save[base-1-i];
    for(int i=2;i<=K;i++){
        lint befo[base+1]={};
        befo[1]=dp[i-1][1];
        for(int j=2;j<=base;j++) befo[j]=(befo[j-1]+dp[i-1][j])%MOD;
        for(int j=1;j<=base;j++) dp[i][j]=(befo[base+1-j]*dp[1][j])%MOD;
    }
    lint ans=0;
    rep(i,base) ans=(ans+dp[K][i+1])%MOD;
    cout << ans << endl;
}

Measured memory_bytes: 63360
using System;

namespace AtCoder.ABC089
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            Console.WriteLine(a/3);
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC089.A.Solve();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N,M,C;
	cin >> N >> M >> C;
	vl B(M);
	FOR(i,0,M)cin >> B[i];
	vector<vl> A(N,vl(M));
	FOR(i,0,N)FOR(j,0,M)cin >> A[i][j];
	ll ans = 0;
	FOR(i,0,N){
		ll SUM = C;
		FOR(j,0,M)SUM += A[i][j] * B[j];
		if(SUM > 0)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int max(int a,int b){
  if(a<b)return b;
  else return a;
}

int main(void){
  char x[1005]={0};
  char y[1005]={0};
  int set=0;
  int dp[1005][1005]={0};
  /*dp[i][j]は、xのi文字目とyのj文字目での最長部分列*/
  scanf("%d",&set);
  int p=0,i=0,j=0;;
  for(p=0;p<set;p++){
    scanf("%s%s",x,y);
    int xl,yl;
    xl=strlen(x);yl=strlen(y);
    int ma,mb,mc;
    for(i=1;i<xl+1;i++){
      for(j=1;j<yl+1;j++){
	ma=dp[i][j-1];
	mb=dp[i-1][j];
	mc=dp[i-1][j-1];
	if(x[i-1]==y[j-1])mc++;
	//dp[i][j]= ma<mb ? (mb<mc ? mc : mb) : ma;
	dp[i][j]= max(ma,max(mb,mc));
      }
    }
    printf("%d\n",dp[xl][yl]);
  }
  return 0;
}

Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    vector<llll> X(N); //A+B と index
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        X[i].first = A[i] + B[i];
        X[i].second = i;
    }

    sort(ALL(X), greater<llll>());
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if(i%2 == 0){
            ans += A[X[i].second];
        }
        else{
            ans -= B[X[i].second];
        }
    }
    printf("%lld\n", ans);
}


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

using namespace std;

typedef pair<int, int> point;
#define x first
#define y second

int n;
vector<point> vp;

int gcd(int a, int b) {
  return a ? gcd(b % a, a) : b;
}
int tmp[1 << 16];
void process(vector<point> idx) {
  int nmask = 1 << n;
  for (int i = 0; i < nmask; ++i)
    tmp[i] = 0;
  tmp[0] = 1;
  for (int i = 0; i < nmask; ++i) {
    if (!tmp[i]) continue;
    for (auto it : idx) {
      int cur = (1 << it.first) | (1 << it.second);
      if (cur & i) continue;
      cur |= i;
      tmp[cur] = 1;
    }
  }
}

int tra[1 << 16], dp[1 << 16];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    vp.emplace_back(x, y);
  }
  vector<pair<point, point> > sorted;
  for (int i = 0; i < n; ++i)
    for (int j = i+1; j < n; ++j) {
      int dx = vp[i].x - vp[j].x, dy = vp[i].y - vp[j].y;
      if (dx < 0)
        dx *= -1, dy *= -1;
      int gd = gcd(dx, dy);
      if (gd)
        dx /= gd, dy /= gd;
      sorted.emplace_back(point(dx, dy), point(i, j));
    }
  sort(sorted.begin(), sorted.end());
  int nmask = 1 << n;
  for (int i = 0; i < sorted.size(); ) {
    vector<point> cur;
    point val = sorted[i].x;
    for (; i < sorted.size() && sorted[i].first == val; ++i)
      cur.push_back(sorted[i].y);
    process(cur);
    for (int j = 0; j < nmask; ++j)
      tra[j] |= tmp[j];
  }
  int ans = 0;
  for (int i = 0; i < nmask; ++i) {
    dp[i] = 0;
    if (tra[i]) {
      int cnt = __builtin_popcount(i)/2;
      dp[i] = cnt * (cnt-1)/2;
    }
    for (int j = (i-1) & i; j > 0; j = (j-1) & i) {
      if (tra[j]) {
        int cnt = __builtin_popcount(j)/2;
        dp[i] = max(dp[i], dp[i^j] + cnt * (cnt-1) / 2);
      }
    }
    ans = max(ans, dp[i]);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 3996
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
    if 500*i > X:
        break
    for j in range(B+1):
        if 500*i + 100*j > X:
            break
        for k in range(C+1):
            if 500*i + 100*j + 50*k > X:
                break
            if 500*i + 100*j + 50*k == X:
                ans += 1

print(ans)

Measured memory_bytes: 68148
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
ll inf = 1e18+7;
//LLONG_MIN

/*

*/

ll h,w,k,dp[110][10],dp2[100][2],dp3[110],dx[3]={-1,0,1},dy[3]={1,1,1},mod=1e9+7;//h,w

//累乗法
ll mod_pow(ll x,ll n){
	ll res=1;
	while(n){
		if(n&1) (res*=x)%=mod;
		(x*=x)%=mod;
		n>>=1;
	}
	return res;
}

ll f(ll x,ll y){
	if(dp[y][x]!=-1)return dp[y][x];
	if(y==h+1){
		if(x==k){
			return 1;
		}else{
			return 0;
		}
	}
	ll sum=0;
	rep(i,3){
		if(1<=x+dx[i] && x+dx[i]<=w){
			ll left=min(x,x+dx[i]),right=max(x,x+dx[i]);
			ll tmp = (dp3[max(abs(left-1)-1,(ll)0)] * dp3[max(abs(w-right)-1,(ll)0)])%mod;
			sum=(sum+( f(x+dx[i],y+dy[i])*tmp )%mod)%mod;
		}
	}
	return dp[y][x]=sum;
}

int main(void){
	rep(i,100)rep(j,2)dp2[i][j]=0;
	dp2[1][0]=1;
	dp2[1][1]=1;
	reg(i,1,20){
		dp2[i+1][0]+=dp2[i][0];
		dp2[i+1][0]+=dp2[i][1];
		dp2[i+1][1]+=dp2[i][0];
	}
	dp3[0]=1;
	reg(i,1,20)dp3[i]=dp2[i][0]+dp2[i][1];
	rep(i,110)rep(j,10)dp[i][j]=-1;
	cin>>h>>w>>k;
	cout<<f(1,1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second 
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define pp pair<ll,ll> 
#define sz(v) int(v.size())
#define hell (ll)1000000007
#define hell1 (ll)100000009
#define hell2 (ll)998244353
ll t = 1 ;
void solve()
{
    ll a , b ;
    cin >> a >> b ;
    cout << max(a+b,max(a-b,a*b));
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin>>t ;
    while(t--){
        solve();
    }
    return 0 ;
}


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

int main() {
  long long x,d,i,j,k,ans=2e15;
  cin >> x >> k >> d;
  
  if(x<0){
    x=-x;
  }
  if(x/d>=k){
    cout << x-k*d << endl; return 0;
  }
  
  if(k%2==1){
    k--;
    if(x<d){
      x=d-x;
    }else{
      x=x-d;
    }
  }
  ans=x;
  
  i=x/(2*d);
  ans=min(ans,abs(x-(2*d*i)));
  ans=min(ans,abs(2*d-ans));
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

bool palindrome(string s)
{
    bool ok = true;
    rep(i, s.size() / 2)
    {
        ok = ok && s.at(i) == s.at(s.size() - i - 1);
        if (!ok)
            break;
    }
    return ok;
}

int main()
{
    string s;
    cin >> s;
    int n = s.size(), k = (n + 3) / 2 - 1;
    string f = s.substr(0, (n - 1) / 2),
           b = s.substr(k, n - k);

    bool ans = palindrome(s) && palindrome(f) && palindrome(b);

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
def cnt_factor(n):
    if (n ** 0.5) % 1 == 0:
        return 0
    c = 0
    for d in range(1, int(n ** 0.5) + 1):
        if n % d == 0:
            c += 1
    return c * 2


n = int(input())
cnt = 0
for i in range(1, n + 1, 2):
    if cnt_factor(i) == 8:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
/*input
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
*/

#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility> 
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

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

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}
/********************* MODULAR ARITHMETIC *******************************/

ll MOD = 1000000007;

void mod(ll &a){ if(a > MOD) a %= MOD; }
ll add(ll a, ll b) { a += b; mod(a); return a; }
ll mul(ll a, ll b) { mod(a); mod(b); a *= b; mod(a); return a; }
ll sub(ll a, ll b) { mod(a); mod(b); a -= b; a += MOD; mod(a); return a; }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

ll inv(ll a) { return powr(a, (MOD - 2)); }

/************************************************************************/

/******************************** START *********************************/
const int N = 1001;
int dp[N][N];

int main()
{
  ifalse;
  int n, m;
  cin >> n >> m;
  string s[n];
  for(int i = 0; i < n; i ++) {
    cin >> s[i];
  }

  
  dp[1][1] = 1;
  for(int i = 1; i <= n; i ++) {
    for(int j = 1; j <= m; j ++) {
      if(i == 1 and j == 1) continue;
      if(s[i - 1][j - 1] == '.') {
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
      }
    }
  }
  cout << dp[n][m];
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
struct Card {
  ll a;
  int n; // aがn枚
};

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;

  vector<Card> deck;
  deck.reserve(N);
  for (int i=0; i<N; i++) {
    Card c;
    c.n = 1;
    cin >> c.a;
    deck.push_back(c);
  }

  for (int i=0; i<M; i++) {
    Card c;
    cin >> c.n >> c.a;
    deck.push_back(c);
  }

  sort(begin(deck), end(deck),
       [](const Card& lhs, const Card& rhs) {
         return lhs.a > rhs.a;
       });

  int count = 0;
  ll sum = 0;
  for(auto c : deck) {
    for (int i=0; i<c.n; i++) {
      if (count == N) {
        cout << sum << endl;
	return 0;
      }
      sum += c.a;
      count++;
    }
  }


  return 0;
}


Measured memory_bytes: 7392