akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


template<typename IntType>
struct mat2d_t {
    mat2d_t(size_t h, size_t w) : h(h), w(w) {
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, 0));
    }
    mat2d_t(size_t h, size_t w, IntType init) : h(h), w(w){
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, init));
    }

    std::vector<IntType>& operator[](size_t p) {
        return mat[p];
    }

    const std::vector<IntType>& operator[](size_t p) const {
        return mat[p];
    }
    size_t height() const {
        return h;
    }
    size_t width() const {
        return w;
    }

private:
    std::vector<std::vector<IntType>> mat;
    size_t h;
    size_t w;
};

bool count(const mat2d_t<i64>& mt, const vector<i64>& cost, i64 flag, i64 x, i64& total) {
    total=0;
    int i=0;
    int m=mt.width();
    vector<i64> val(m, 0);
    while (flag) {
        bool use = flag & 1;
        if (use) {
            for (int j=0; j<m; ++j) {
                val[j] += mt[i][j];
            }
            total+=cost[i];
        }
        ++i;
        flag >>= 1;
    }
    bool ret{true};
    for (auto v: val) {
        if (v < x) ret = false;
    }
    return ret;
}

int main(int argc, char **argv) {
    i64 n,m,x;
    cin >> n >> m >> x;
    mat2d_t<i64> mt(n, m, 0);
    vector<i64> cost(n, 0);

    for (int i=0; i<n; ++i) {
        i64 c;
        cin >> c;
        cost[i]=c;
        for (int j=0; j<m; ++j) {
            i64 a;
            cin >>a;
            mt[i][j] = a;
        }
    }
    i64 ans{-1};
    for (int i=(1<<n) - 1; i>0; --i) {
        i64 tot;
        if (count(mt, cost, i, x, tot)) {
            if (ans == -1)
                ans = tot;
            else
                ans = min(ans, tot);
        }
    }

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

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

using namespace std;

int root(int idx, vector<int> &parent){
    if(parent[idx] == idx) return idx;
    return parent[idx] = root(parent[idx], parent);
}

int main(void){
    int N, M;
    cin >> N >> M;
    vector<int> parent(N), s(N);
    for(int i = 0; i < N; i++){
        parent[i] = i;
        s[i] = 1;
    }
    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        int ra = root(A, parent);
        int rb = root(B, parent);
        if(ra != rb){
            parent[rb] = ra;
            s[ra] += s[rb];
        }

    }
    // for(int i = 0; i < N; i++) cout << i << " " << root(i, parent) << endl;
    cout << *max_element(s.begin(), s.end()) << endl;
    return 0;
}


Measured memory_bytes: 4828
def colorful_leaderboard(N: int, A: list)->tuple:
    rates = {
        '0001-0399': False,
        '0400-0799': False,
        '0800-1199': False,
        '1200-1599': False,
        '1600-1999': False,
        '2000-2399': False,
        '2400-2799': False,
        '2800-3199': False,
    }
    wildcard = 0

    for a in A:
        if a < 400:
            rates['0001-0399'] = True
        elif a < 800:
            rates['0400-0799'] = True
        elif a < 1200:
            rates['0800-1199'] = True
        elif a < 1600:
            rates['1200-1599'] = True
        elif a < 2000:
            rates['1600-1999'] = True
        elif a < 2400:
            rates['2000-2399'] = True
        elif a < 2800:
            rates['2400-2799'] = True
        elif a < 3200:
            rates['2800-3299'] = True
        else:
            wildcard += 1

    rated_colors = sum(rates.values())
    return rated_colors if rated_colors > 0 else 1, rated_colors + wildcard


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]
    min_c, max_c = colorful_leaderboard(N, A)
    print(min_c, max_c)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const int MAX = 100005;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i,n-1) {
        string a = s.substr(0,i+1);
        string b = s.substr(i+1);
        sort(all(a)); sort(all(b));
        a.erase(unique(all(a)),a.end());
        b.erase(unique(all(b)),b.end());
        int ct = 0;
        rep(i,a.size()) {
            rep(j,b.size()) {
                if (a[i] == b[j]) ct++;
            }
        }
        ans = max(ans,ct);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  string s,t;
  cin>>s>>t;
  
  vector<int> A(26,-1),B(26,-1);
  
  bool b=true;
  rep(i,s.size()){
    if(A[s[i]-'a']==-1) A[s[i]-'a']=t[i]-'a';
    else if(A[s[i]-'a']!=t[i]-'a'){
      b=false;
      break;
    }
  }
  rep(i,t.size()){
    if(B[t[i]-'a']==-1) B[t[i]-'a']=s[i]-'a';
    else if(B[t[i]-'a']!=s[i]-'a'){
      b=false;
      break;
    }
  }
  if(b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 3904
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

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

	int n,m;
	cin>>n>>m;
	vvi in(n,vi(2));
	rep(i,n)rep(j,2)cin>>in[i][j];

	vi dp(m+1);
	
	rep(i,n)for(int j=m;j>=0;j--)if(j+in[i][0]<=m)
		cmax(dp[j+in[i][0]],dp[j]+in[i][1]);

	cout<<dp[m]<<endl;
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
struct tree{
  vector<vector<int>> G,son,ancestor;
  vector<int> depth,parent;
  queue<int> que;
  int root=-1;
  bool made_lca=false;

  tree(int n):G(n),son(n),parent(n,-1),depth(n,-1),ancestor(n){
    for(int i=0;i<n;i++)ancestor[i].resize(30);
  }

  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  inline void reset_root(){
    root=-1;
    fill(depth.begin(),depth.end(),-1);
    fill(parent.begin(),parent.end(),-1);
    for(auto &p:ancestor)for(int &q:p)q=-1;
    for(auto &p:son)p.resize(0);
    made_lca=false;
  }

  void have_root(int r){
    reset_root();
    root=r;
    que.push(r);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:G[p]){
        if(parent[p]==q)continue;
        son[p].push_back(q);
        parent[q]=p;
        que.push(q);
      }
    }
  }

  void set_depth(){
    assert(~root);
    depth[root]=0;
    que.push(root);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:son[p]){
        depth[q]=depth[p]+1;
        que.push(q);
      }
    }
  }

  inline void make_lca(){
    assert(~root);
    if(depth[root]<0)set_depth();
    for(int i=0;i<G.size();i++)ancestor[i][0]=parent[i];
    for(int j=1;j<30;j++)
      for(int i=0;i<G.size();i++)
        if(~ancestor[i][j-1])
          ancestor[i][j]=ancestor[ancestor[i][j-1]][j-1];
    made_lca=1;
  }

  int lca(int u,int v){
    if(!made_lca)make_lca();
    if(depth[u]>depth[v])swap(u,v);
    int diff=depth[v]-depth[u],cnt=0;
    while(diff){
      if(diff&1)v=ancestor[v][cnt];
      cnt++;
      diff>>=1;
    }
    if(u==v)return u;
    for(int k=28;k>=0;k--)
      if(ancestor[u][k]!=ancestor[v][k])
        u=ancestor[u][k],v=ancestor[v][k];
    return ancestor[u][0];
  }
};
int ans[223456];
int now1=0,now2=0,now3=0,one,two;

signed main(){
  int n;cin>>n;
  tree t(n);
  vector<int> edge[n];
  for(int i=0;i<n-1;i++){
    int u,v;cin>>u>>v;u--;v--;
    t.add_edge(u,v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  vector<int> three[n];
  t.have_root(0);
  t.set_depth();
  for(int i=0;i<n;i++)(t.depth[i]&1?one:two)++;
  if(one<=n/3){
    for(int i=0;i<n;i++){
      if(t.depth[i]&1)cout<<now3++*3+3<<" ";
      else if(now1*3+1<=n)cout<<now1++*3+1<<" ";
      else if(now2*3+2<=n)cout<<now2++*3+2<<" ";
      else cout<<now3++*3+3<<" ";
    }
  }
  else if(two<=n/3){
    for(int i=0;i<n;i++){
      if(!(t.depth[i]&1))cout<<now3++*3+3<<" ";
      else if(now1*3+1<=n)cout<<now1++*3+1<<" ";
      else if(now2*3+2<=n)cout<<now2++*3+2<<" ";
      else cout<<now3++*3+3<<" ";
    }
  }
  else{
    for(int i=0;i<n;i++){
      if(t.depth[i]&1){
        if(now1*3+1<=n)cout<<now1++*3+1<<" ";
        else cout<<now3++*3+3<<" ";
      }
      else{
        if(now2*3+2<=n)cout<<now2++*3+2<<" ";
        else cout<<now3++*3+3<<" ";
      }
    }
  }
  cout<<endl;
}


Measured memory_bytes: 67968
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  long long ans=0,p=0;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='p'){
      p++;
    }
  }
  ans+=s.size()/2-p;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
from itertools import product
import operator
import unittest

def solution(n, v, c):

    value, cost, ans = [0, 0, 0]
    for x in product([0, 1], repeat=n):
        value = sum(map(operator.mul, v, x))
        cost = sum(map(operator.mul, c, x))
        ans = max(ans, value - cost)

    return ans

class Test(unittest.TestCase):
    def test1(self):
        self.assertEqual(solution(3, [10, 2, 5], [6, 3, 4]), 5)

if __name__ == '__main__':

    n = int(input())
    v = list(map(int, input().split()))
    c = list(map(int, input().split()))
    print(solution(n, v, c))
    
    unittest.main()

Measured memory_bytes: 57816
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
int main(){
  int i, j, n, ans=0;
  cin >> n;
  int a[n];
  for(i=0; i<n; i++)
    cin >> a[i];
  for(i=1; i<n; i++)
    if(a[i]==a[i-1]) {
      ans++;
      i++;
    }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    inl(n);
 
    out(A[n-1]);
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

//-----------------------------------------------------------------------------

int n,a[100000];
ll sum1,sum2,ans1,ans2;

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

	cin>>n;
	REP(i,n) cin>>a[i];

	REP(i,n) {
		sum1+=a[i];
		if(i&1) {
			if(sum1>=0) ans1+=sum1+1,sum1=-1;
		}
		else {
			if(sum1<=0) ans1+=1-sum1,sum1=1;
		}
	}

	REP(i,n) {
		sum2+=a[i];
		if(i&1) {
			if(sum2<=0) ans2+=1-sum2,sum2=1;
		}
		else {
			if(sum2>=0) ans2+=sum2+1,sum2=-1;
		}
	}

	cout<<min(ans1,ans2)<<endl;

	return 0;
}


Measured memory_bytes: 640
use std::io::{self, Read};

#[allow(dead_code)]
fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}

#[allow(dead_code)]
struct UnionFind{
    par: Vec<usize>,
    size: Vec<u32>,
}

#[allow(dead_code)]
impl UnionFind{
    fn new(n: usize) -> Self {
        let mut uf = UnionFind{par: Vec::with_capacity(n), size: vec![1; n]};
        for i in 0..n {
            uf.par.push(i);
        }
        return uf;
    }
    fn find(&mut self, u:usize) -> usize {
        if self.par[u] != u  {
            let p = self.par[u] ;
            self.par[u] = self.find(p);
            return  self.par[u];
        }
        return u;
    }
    fn size(&mut self, u:usize) -> u32 {
        let u = self.find(u);
        return self.size[u];
    }
    fn same(&mut self, u:usize, v:usize) -> bool {
        return self.find(u) == self.find(v);
    }
    fn unite(&mut self, u:usize, v:usize){
        let u = self.find(u);
        let v = self.find(v);
        if(u == v){
            return;
        }
        if self.size[u] < self.size[v] {
            self.par[u] = v;
            self.size[v] += self.size[u];
        }else{
            self.par[v] = u;
            self.size[u] += self.size[v];
        }
    }
}


fn main() {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).unwrap();
    let mut iter = buffer.split_whitespace();

    let n:usize  = iter.next().unwrap().parse().unwrap();
    let m:usize  = iter.next().unwrap().parse().unwrap();

    let mut edge: Vec<(usize,usize)> = Vec::with_capacity(m);
    for _ in 0..m{
        let a:usize  = iter.next().unwrap().parse().unwrap();
        let b:usize  = iter.next().unwrap().parse().unwrap();
        edge.push((a-1, b-1));
    }

    let mut vans: Vec<(i64)> = Vec::with_capacity(m);
    let mut ans:i64 =  n as i64 * (n as i64 -1) / 2;
    let mut uf:UnionFind = UnionFind::new(n);

    for i in (0..m).rev() {
        vans.push(ans);
        let e = edge[i];
        if !uf.same(e.0, e.1) {
            ans -= uf.size(e.0) as i64 *  uf.size(e.1) as i64;
            uf.unite(e.0, e.1);
        }
    }
    vans.reverse();
    for x in vans{
        println!("{}", x);
    }
}


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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}


int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin >> n >> k;
    int a[n+1];
    rep(i,1,n+1) cin>> a[i];
    for(int i=k+1; i<=n; i++){
        if(a[i]>a[i-k]){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }
        //cout << i << " " <<  i-k << "\n";
    }
    return 0;
}


Measured memory_bytes: 5204
def main():
    foods_list = get_params()
    print(count_common(foods_list))


def get_params():
    n, _ = map(int, input().split())
    return [
        {a for a in input().split()[1:]}
        for _ in range(n)
    ]


def count_common(foods_list):
    return len(set.intersection(*foods_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
if __name__ == "__main__":
    H, W = map(lambda x: int(x), input().split())
    dp = [list(map(int, input().split())) for _ in range(H)]

    for h in range(H):
        for w in range(W):
            dp[h][w] ^= 1  # 0 -> 1, 1 -> 0

    for h in range(1, H):
        for w in range(1, W):
            if dp[h][w]:
                dp[h][w] = min(dp[h - 1][w - 1], dp[h - 1][w], dp[h][w - 1])
                dp[h][w] += 1

    print(max(w for h in dp for w in h) ** 2)  # type: ignore



Measured memory_bytes: 43844
def main():
    a, b, c = map(int, input().split())

    ans = 0
    if a == b and b == c:
        ans = 1
    elif a == b or b == c or c == a:
        ans = 2
    else:
        ans = 3

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <stdio.h>

int main (){
    int n,k;
    scanf("%d", &n);
    scanf("%d", &k);
    int ans=1;

    for(int i=0;i<n;i++){
        if(ans<k){
            ans*=2;
        } else {
            ans+=k;
        }
    }

    /* int i = 0;
    while(i<n){
        if(ans<k){
            ans*=2;
        } else {
            ans+=k;
        }
        ++i;
    }
    */
    printf("%d\n", ans);
}

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

using namespace std;

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

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

  int sum = 1;

  string ans = "Yes";
  for (int i = 0; i < w.size(); i++) {
    char c = w[i];

    int num = count(w.begin(), w.end(), c);

    if (num % 2 != 0) {
      ans = "No";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
void bulk(){}template<class H,class...T>void bulk(H&h,T&...t){cin>>h;bulk(t...);}
#define rep(i,n) for(int i=0;i<n;i++)
#define all(i) i.begin(),i.end()
vs ss;
int b,n;
map<vi,int> memo;

int search(vi &index){
    if(index.size()<=1) return 0;
    if(memo.find(index)!=memo.end()) return memo[index];
    int ans=INT_MAX;
    rep(i,b){
        vvi next(2,vi());
        for(auto j:index){
            next[ss[j][i]=='1'].push_back(j);
        }
        if(next[0].size()!=0 && next[1].size()!=0){
            ans=min(max(search(next[0]),search(next[1]))+1,ans);
        }
    }
    return memo[index]=ans;
}

int main(void){
    while(cin>>b>>n,b){
        memo.clear();
        ss.resize(n);
        for(auto &s:ss) cin>>s;
        vi index(n);
        iota(all(index),0);
        cout<<search(index)<<endl;
    }
}

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

long long n, x, t, a[100001];
int main(){
	cin >> n >> x;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++){
		if((a[i-1]+a[i]) > x){
			t += a[i-1]+a[i]-x;
			a[i] = x-a[i-1];
		}
	}
	cout << t;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <sstream>
#include <functional>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

typedef pair<int, int> PII;
typedef pair<PII, int> PIII;

int f ( int a, int b )
{
	return a*a + b*b;
}

int main ( void )
{
	int h, w;
	vector<PIII> vp;
	for (int i = 1; i <= 200; ++i) {
		for (int j = i+1; j <= 200; ++j) {
			vp.push_back(PIII(PII(f(i, j), i), j));
		}
	}
	sort(vp.begin(), vp.end());

	while (cin >> h >> w, h|w) {
		for (int i = 0; i < vp.size(); ++i) {
			PIII pp = vp[i];
			PII p = vp[i].first;
			int hh = p.second;
			int ww = vp[i].second;
			if (hh == h && ww == w) {
				PIII nx = vp[i+1];
				cout << nx.first.second << ' ' << nx.second << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1540
use std::io;


/// https://beta.atcoder.jp/contests/abc078/tasks/abc078_b
fn main() {
    let (x, y, z) = {
        let i = read::<usize>();
        (i[0], i[1], i[2])
    };

    println!("{}", (x - z) / (y + z));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>	
#include <utility>
#include <cinttypes>
#include <string>
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int n,k;
    string s;
    cin >> n;
    cin >> k;
    cin >> s;
    s[k-1] = s[k-1] + 'a' - 'A';
    cout << s << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main{
	
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		List <Data> L = new ArrayList<Data>();
		
		for(int i = 0 ; i < m ;i++) {
			int p = Integer.parseInt(sc.next());
			int y = Integer.parseInt(sc.next());
			L.add(new Data(i,p,y));
		}
		
		String []s = new String [m];
		int []num = new int [n];
		Arrays.fill(num, 1);
		Collections.sort(L);
		
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0 ; i < m ;i++) {
			int id = L.get(i).getId();
			int pref = L.get(i).getPref();
			String t1 = String.format("%06d", pref);
			String t2 = String.format("%06d", num[pref-1]);
			sb.append(t1).append(t2);
			s[id] = sb.toString();
			sb.setLength(0);
			num[pref-1]++;
		}
		
		for(int i = 0 ; i < m ;i++) {
			System.out.println(s[i]);
		}

	}

}
class Data implements Comparable<Data>{
	private int id;
	private int pref;
	private int year;
	
	public Data(int id,int pref ,int year) {
		this.id = id;
		this.pref = pref;
		this.year = year;
	}
	public int getId() {
		return id;
	}
	public int getPref() {
		return pref;
	}
	public int getYear() {
		return year;
	}

	@Override
	public int compareTo(Data o) {
		return Integer.compare(this.year, o.getYear());
	}
	
	
}


Measured memory_bytes: 123484
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <chrono>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s;
    cin >> s;

    string t;
    t = s;
    reverse(t.begin(), t.end());

    int ans = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) ans++;
    }

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


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import math
import statistics


def get_average_score(scores):
    return math.floor(statistics.mean(sorted(scores)[1: -1]))


if __name__ == "__main__":
    while True:
        n = int(input())
        if n == 0:
            break
        else:
            print(get_average_score(int(input()) for i in range(n)))

Measured memory_bytes: 10136
import sys
#input = sys.stdin.readline

def main():
    h,w=map(int,input().split())
    s=[list(input()) for _ in range(h)]
    ans=[[0]*w for _ in range(h)]
    if s[0][0]=='#':
        ans[0][0]=1
    for i in range(h):
        for j in range(w):
            if i==0:
                if j==0:
                    continue
                else:
                    if s[i][j]==s[i][j-1]:
                        ans[i][j]=ans[i][j-1]
                    else:
                        ans[i][j]=ans[i][j-1]+1
            else:
                if j==0:
                    if s[i][j]==s[i-1][j]:
                        ans[i][j]=ans[i-1][j]
                    else:
                        ans[i][j]=ans[i-1][j]+1
                else:
                    if s[i][j]==s[i][j-1]:
                        a=ans[i][j-1]
                    else:
                        a=ans[i][j-1]+1
                    if s[i][j]==s[i-1][j]:
                        b=ans[i-1][j]
                    else:
                        b=ans[i-1][j]+1
                    ans[i][j]=min(a,b)
    A=ans[h-1][w-1]
    if A%2==1:
        print(A//2+1)
    else:
        print(A//2)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

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

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

template<typename T>
void dump_line(T *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

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

	int n,goal[3];
	cin >> n >> goal[0] >> goal[1] >> goal[2];
	int l[n];
	rep(i,n) cin >> l[i];

	int ans=INF,abc;
	for(int bit=0;bit<(1<<(n*2));bit++){
		int nums[3]={};
		int sums[3]={};
		int tmp=0;
		rep(i,n){
			if((abc=((bit>>(2*i))%4)) == 3) continue;	

			nums[abc]++;
			sums[abc]+=l[i];
		}
		if(!nums[0] || !nums[1] || !nums[2]) continue;
		
		tmp = 10*(nums[0]+nums[1]+nums[2]-3);
		rep(i,3) tmp+=abs(goal[i]-sums[i]);
		
		ans=min(ans,tmp);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N,D,X;
	cin >> N;
	cin >> D >> X;
	vi A(N);
	for(int i=0; i<N;i++ ){
		cin >> A[i];
	}

	int ans=X;
	for(int i=0; i<N; i++){
		int j=0;
		while(j*A[i]+1<=D){
			ans++;
			j++;
		}
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    int a[n],sum=0,p=0,q=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=abs(a[i]);
        if(a[i]>=0)p++;
        else q++;
    }
    sort(a,a+n);
    if(p==0){
        cout<<sum+2*a[n-1]<<endl;
        p=1;q=n-1;
    }else if(q==0){
        cout<<sum-2*a[0]<<endl;
        p=n-1;q=1;
    }else{
        cout<<sum<<endl;
    }
    for(int i=q;i<n-1;i++){
        cout<<a[0]<<" "<<a[i]<<endl;
        a[0]-=a[i];
    }
    for(int i=0;i<q;i++){
        cout<<a[n-1]<<" "<<a[i]<<endl;
        a[n-1]-=a[i];
    }
}


Measured memory_bytes: 2304
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s1, s2, s3;

        sc.useDelimiter(",");
        s1 = sc.next();
        s2 = sc.next();
        s3 = sc.next();

        System.out.println(s1 + " " + s2 + " " + s3);
        sc.close();
    }
}

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

/* -128 ~ 127 */
using i8  = int8_t;
/* 0 ~ 255 */
using u8  = uint8_t;
/* -32,768 ~ 32,767 */
using i16 = int16_t;
/* 0 ~ 65,535 */
using u16 = uint16_t;
/* -2,147,483,648 ~ 2,147,483,647 */
using i32 = int32_t;
/* 0 ~ 4,294,967,295 */
using u32 = uint32_t;
/* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using i64 = int64_t;
/* 0 ~ 18,446,744,073,709,551,615 */
using u64 = uint64_t;
/* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f32 = float;
/* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f64 = double;
using f80 = __float80;

template <class T>
using Vec = vector<T>;

template <typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1000000007;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

void Main() {
    string S;
    cin >> S;
    u32 m = 0;
    u32 acgt = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            acgt++;
            m = max(m, acgt);
        } else {
            acgt = 0;
        }
    }
    cout << m << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}




Measured memory_bytes: 256
n,m = map(int,input().split())
dum = list(map(int,input().split()))
ans = dum[1:dum[0]+1]
#print(ans)
dum = []
for i in range(n-1):
    li = list(map(int,input().split()))
    for j in range(li[0]):
        if ans.count(li[j+1]) == 1:
            dum.append(li[j+1])
    ans = dum
    dum = []
print(len(ans))

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

using namespace std;
using ll = long long;

int main() {
  ll X, Y;
  cin >> X >> Y;
  int ans = 1;
  ll a = X;
  while (1) {
    a = a * 2;
    if (a > Y) break;
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


int main() {
  int n;
  cin>>n;
  vector<int> ans(n+2);
  rep(x,sqrt(n)){
    rep(y,x+1){
      rep(z,y+1){
        if(x*y*z==0)continue;
        ll xyz=x*x+y*y+z*z+x*y+y*z+z*x;
        if(xyz>n)continue;
        if(x==y && y==z)ans[xyz]++;
        else if(x==y && y!=z || x==z && y!=z || y==z && x!=z){
          ans[xyz]+=3;
        }else ans[xyz]+=6;
      }
    }
  }
  int a=0;
  for(int i=1;i<=n;i++){
    //a++;
    cout<<ans[i]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 3612
from math import (pi,cos,sqrt,radians)

def main():
    A,B,H,M = map(int, input().split())

    # 長針、短針の0時0分からの角度を求める
    HTheta = H/12 * 360 + 1/12 * (M/60) *  360
    MTheta = M/60 * 360
    # |長針-短針|で角度θを求める
    Theta = abs(HTheta - MTheta) 
    # θ=180ならA+Bを出力して終了
    if Theta == 180:
        print(A + B)
        return
    # 予言定理を求める
    print(sqrt(A*A + B*B - 2*A*B*cos(radians(Theta))))

main()

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

using namespace std;

#define int long long

const int N = 105;
const int INF = 1e15;
const int W = 1e5 + 10;
int dp[N][W], n, w, weight[N], value[N];

int sol(int idx, int wt) {
    if (idx == n + 1) return 0;
    int &ans = dp[idx][wt];
    if (ans != -1) return ans;
    ans = max(sol(idx + 1, wt), (wt + weight[idx] <= w) ? (sol(idx + 1, wt + weight[idx]) + value[idx]) : -INF);
    return ans;
}

void solve() {
    cin >> n >> w;
    for (int i = 1; i <= n; i++) cin >> weight[i] >> value[i];
    memset(dp, -1, sizeof(dp));
    cout << sol(1, 0) << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin>>t;
    while (t--) {
        solve();
    }
}

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

signed main() {
	int a, b;
	cin >> a >> b;
	if (a * b % 2  == 0) cout << "Even" << endl;
	else cout << "Odd" << endl;

	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

vector<vi> f(vi a, vi b){ // 転倒数を求める
    int n = a.size();
    vector<vi> ret(n,vi(n+1));
    rep(i,n)rep(j,n){
        ret[i][j+1] = ret[i][j] + (a[i] < b[j]);
    }
    return ret;
}

int main(void) {
    int n;
    cin >> n;
    vi a(n),b(n);
    rep(t,n*2){
        string s;
        cin >> s;
        int i;
        cin >> i;
        i--;
        if(s == "W") a[i] = t;
        else b[i] = t;
    }

    vector<vi> aa = f(a,a), ab = f(a,b), ba = f(b,a), bb = f(b,b);
    vector<vi> dp(n+1, vi(n+1, INF));
    dp[0][0] = 0;
    rep(i,n+1) rep(j,n+1){
        if(i<n) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + aa[i][i] + ab[i][j]);
        if(j<n) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + bb[j][j] + ba[j][i]);
    }
    cout << dp[n][n] << endl;
}


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

int main()
{
    string n;
    cin >> n;
    if (n[0] == '7' || n[1] == '7' || n[2] == '7')
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
}

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

long long solve(long long n) {
    long long x, k;
    long long min{n};
    x = sqrt(n);
    for (long long i = 1; i <= x; i++) {
        if (n % i == 0) {
            k = n / i;
            min = ((k + i - 2 < min) ? k + i - 2 : min);
        }
    }
    return min;
}

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

    cout << solve(n);
    return 0;
}

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

signed main(){
	int n,m;
	cin>>n>>m;
	if(n>=2&&m>=2)cout<<(n-2)*(m-2)<<endl;
	else if(n<2&&m<2)cout<<1<<endl;
	else{cout<<max(n,m)-2<<endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}

char s[120000];
char t[120000];
int prs[120000];
int prt[123000];

int main() {
    scanf("%s %s", s, t);
    int n = strlen(s);
    int m = strlen(t);
    for (int i = 0; i < n; ++i)
        prs[i + 1] = prs[i] + (s[i] == 'A' ? 1 : 2);
    for (int i = 0; i < m; ++i)
        prt[i + 1] = prt[i] + (t[i] == 'A' ? 1 : 2);
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; ++i) {
        int a, b, c, d;
        scanf("%d%d%d%d", &a, &b, &c, &d);
        --a;
        --c;
        int x = (prs[b] - prs[a]) % 3;
        int y = (prt[d] - prt[c]) % 3;
        if (x == y) {
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }
	return 0;
}




Measured memory_bytes: 1536
import           Control.Monad
import qualified Data.ByteString.Char8         as B
import qualified Data.Vector                   as V
import           Data.Char

main = do
  [h, w] <- map read . words <$> getLine
  s      <- V.replicateM h B.getLine
  V.mapM_ B.putStrLn $solve h w s
solve h w s = V.generate h f where
  f i = B.pack $map g [0 .. w - 1]   where
    g j = if B.index (s V.! i) j == '#'
      then '#'
      else intToDigit $ length
        [ ()
        | di <- [-1 .. 1]
        , dj <- [-1 .. 1]
        , let (i', j') = (i + di, j + dj)
        , 0 <= i'
        , i' < h
        , 0 <= j'
        , j' < w
        , B.index (s V.! i') j' == '#'
        ]


Measured memory_bytes: 1020
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
	long long int h=0;
	long long int w=0;
	cin>>h>>w;

	if(h==1||w==1)
	{
		cout<<1<<endl;
	}
	else
	{
		cout<<(h*w+1)/2<<endl;
	}
	return 0;
}

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

int main(void) {
	int n;
	cin >> n;
	int a[n];
	rep (i, n) cin >> a[i];

	vector<int> b;
	if (n % 2 == 0) {
		for (int i = n - 1; i > 0; i -= 2) {
			b.push_back(a[i]);
		}
		for (int i = 0; i < n; i += 2) {
			b.push_back(a[i]);
		}
	}
	else {
		for (int i = n - 1; i >= 0; i -= 2) {
			b.push_back(a[i]);
		}
		for (int i = 1; i < n; i += 2) {
			b.push_back(a[i]);
		}
	}
	rep (i, n) cout << b[i] << endl;

	return 0;
}


Measured memory_bytes: 3828
# ABC 116 D - Various Sushi
N, K = map(int,input().split())

# S[k] := ネタkのおいしさのリスト
S = [[-float("inf")] for k in range(N)]
for k in range(N):
    t, d = map(int,input().split())
    S[t-1].append(d)

# 各種類のおいしさの最大を入れた配列がtop、それ以外がhoka
# それらを降順にソートして、k=1,2,..Kについて、topから大きい順にk個、hokaから同様にN-k個取ると、種類はk以上になる
# hokaからの要素で合計の種類がkより大きくなるばあい、その要素以上の大きさで同じ種類のものがtopに入っているため、
# あとでその種類からもtopを取る場合に、合計点がより大きい組み合わせになる
top = []
hoka = []
for k in range(N):
    S[k].sort()
    top.append(S[k].pop())
    hoka += S[k]

top.sort(reverse=True)
hoka.sort(reverse=True)

# 毎回sum(top[:k])とかやっていると間に合わないので累積和
# hokaから一つも取らないときは0を返すようにする
T = [0 for k in range(N+1)]
H = [0 for k in range(N+1)]
T[1], H[1] = top[0], hoka[0]
for k in range(2,N):
    T[k] = T[k-1] + top[k-1]
    H[k] = H[k-1] + hoka[k-1]

ans = 0
for k in range(1,K+1):
    ans = max(ans,T[k]+H[K-k]+k**2)
print(ans)

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






const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    int n;
    int zero = 0;
    map<pair<ll,ll>,P> mp;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(x == 0 && y == 0)
        {
            zero++;
            continue;
        }
        ll g = gcd(x,y);
        x /= g;
        y /= g;
        if(y<0)x = -x,y = -y;
        if(y == 0 && x < 0)x = -x,y = -y;
        bool rot90 = (x <= 0);
        if(rot90)
        {
            ll temp = x;
            x = y;y = -temp;
        }
        if(rot90)mp[{x,y}].first++;
        else mp[{x,y}].second++;
    }
    mint ans = 1;
    for(auto p : mp)
    {
        int s = p.second.first;
        int t = p.second.second;
        mint now = 1;
        now += mint(2).pow(s)-1;
        now += mint(2).pow(t)-1;
        ans *= now;
    }
    ans -= 1;

    ans += zero;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16112
#include<iostream>
#include<vector>

using namespace std;

int main(){
int N, M; cin >> N >> M;
  vector<int>a(N);
  for(int i = 0; i < M; i++){
    int k ; cin >> k;
    for(int j = 0; j < k ; j++){
      int s; cin >> s; s--; a[s] |= 1 << i;}}
  
   int ans = 0; int p = 0;
  
  for(int i = 0; i < M; i++){
    int x; cin >> x;  p |= x << i;}
  
  for(int s = 0; s < ( 1 << N) ; s++){
    int t = 0;
    for(int i = 0; i < N; i++){
    if( s >> i & 1){ t ^= a[i];}}
    
    if( t == p){ ans++;}}
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 3000001
#define MINI -1
int parent(int);
int left(int);
int right(int);
void maxHeapify(int*, int);
void buildMaxHeap(int*);
void insert(int*, int);
void heapIncreaseKey(int*, int);
int extractMax(int*);
int n=0;
int main(){
  int *T, key;
  char func[7];
  T = (int*)malloc(sizeof(int) * MAX);
  while(1){
    scanf("%s",func);
    if(func[2] == 'd') break;
    else if(func[0] == 'i'){
      scanf("%d",&key);
      insert(T, key);
    }
    else if(func[0] == 'e') printf("%d\n",extractMax(T));
  }
  return 0;
}
int parent(int x){
  return x/2;
}
int left(int x){
  return 2*x;
}
int right(int x){
  return 2*x+1;
}
  void maxHeapify(int *A, int i){
    int l=left(i), r=right(i), largest, temp;
    if(l <= n && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= n && A[r] > A[largest]) largest = r;
    if(largest != i){
      temp = A[i];
      A[i] = A[largest];
      A[largest] = temp;
      maxHeapify(A,largest);
    }
  }
  void buildMaxHeap(int *A){
    int i;
    for(i=n/2; i>0; i--) maxHeapify(A,i);
  }
  void insert(int *A, int key){
    n++;
    A[n] = MINI;
    heapIncreaseKey(A, key);
  }
  void heapIncreaseKey(int *A, int key){
    int temp, i=n;
    if(key < A[i]) printf("Error\n");
    A[i] = key;
    while(i > 1 && A[parent(i)] < A[i]){
      temp = A[i];
      A[i] = A[parent(i)];
      A[parent(i)] = temp;
      i = parent(i);
    }
  }
  int extractMax(int *A){
    int max;
    if(n < 1) printf("Error\n");
    max = A[1];
    A[1] = A[n];
    n--;
    maxHeapify(A,1);
    return max;
  }



Measured memory_bytes: 5628
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;



int main(){
	int a,b;
	cin>>a>>b;
	vector<int>c(1000000);
	c[0]=0;
	for(int i=10000;i<100000;i++){
		if(i/10000==i%10&&(i-(i/10000)*10000)/1000==(i%100)/10){
			c[i-9999]=1+c[i-10000];
		}
		else{
			c[i-9999]=c[i-10000];
		}
	}
	cout<<c[b-9999]-c[a-10000]<<endl;
    return 0;
}

Measured memory_bytes: 4096
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long*)b)return 1;
    return -1;
}
long long Max(long long a,long long  b){
    if(a>b )return a;
    return b;
}
long long Min(long long  a,long long  b){
    if(a<b )return a;
    return b;
}
int main()
{   int a,b,c,n,k,i,m,x,y;
    scanf("%d%d%d",&a,&b,&c);
    if(b/a>=c)
    printf("%d",c);
    else printf("%d",b/a);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   string s, t;
   cin>>s>>t;
   int a, b;
   cin>>a>>b;
   string u;
   cin>>u;

   if(s==u) a--;
   else b--;

   cout<<a<<" "<<b<<endl;
   return 0;
}


Measured memory_bytes: 3620