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

int main()
{
    long long int N, sum;
    cin >> N;
    long long int d[N];
    for(int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    sum = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            sum += d[i] * d[j];
        }
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

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

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

    int a[n];
    int temp = 0;
    rep(i, n) {
        cin >> a[i];
        temp ^= a[i];
    }

    rep(i, n) cout << (temp^a[i]) << ' ';
    cout << endl;

    return 0;
}

Measured memory_bytes: 4260
#include<stdio.h>
int main()
{   long n,a,b;
long blue=0;
scanf("%ld%ld%ld",&n,&a,&b);
long m=n/(a+b);
long d=n%(a+b);
if(a!=0)
{   if(b==0||a>=n)printf("%ld\n",n);
	else if(a+b<=n) {
			if(a<d) blue=a*m+a;
			else blue=a*m+d;
			printf("%ld\n",blue);
				}
		else printf("%ld\n",a);
}

else printf("0\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
// head
int n,ans,res;
int a[101][2];

int main() {
	scanf("%d",&n);
  rep(j,0,2){rep(i,0,n){cin >> a[i][j];}
  }
  rep(i,0,n){
    res = 0;
    rep(j,0,i+1){
    res += a[j][0];}
    rep(j,i,n){
    res += a[j][1];}
    ans = max(ans,res);
  }
  printf("%d",ans);
}

Measured memory_bytes: 256
import sys

X, N = map(int, input().split())
if N ==0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))

if (X in p) == False:
    print(X)
    sys.exit()

for i in range(N+1):
    if (X - i in p) == False:
        print(X - i)
        sys.exit()
    elif (X + i in p) == False:
        print(X+i)
        sys.exit()

Measured memory_bytes: 9204
a=int(input())
ct=1
if a==1:
  print(4)
  exit()
elif a==2:
  print(4)
  exit()
while a!=1:
  ct+=1
  if a%2==0:
    a=a//2
  else:
    a=3*a+1
else:
  ct+=1
  print(ct)


Measured memory_bytes: 61920
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  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{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=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{
    mint res(*this);
    return res/=a;
  }
};
const int M = 100010;
mint pow2[M];
void make_pow2() {
  pow2[0].x = 1;
  rep(i,M-1) {
    pow2[i+1] = pow2[i] * (mint)2;
  }
}
int main()
{
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  make_pow2();
  
  if(n % 2 == 0) {
    map<int,int> mp;
    rep(i,n) mp[a[i]]++;
    bool f = true;
    rep(i,n/2) {
      if(mp[ i*2 + 1 ] != 2) f = false;
    }
    if(!f) cout << 0 << "\n";
    else {
      cout << pow2[n/2].x << "\n";
    }
  }
  else {
    map<int,int> mp;
    rep(i,n) mp[a[i]]++;
    bool f = true;
    if(mp[0] != 1) f = false;
    rep1(i,n/2) {
      if(mp[ i*2 ] != 2) f = false;
    }
    if(!f) cout << 0 << "\n";
    else {
      cout << pow2[n/2].x << "\n";
    }
  }  
  return 0;
}


Measured memory_bytes: 5248
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair< ll, ll > P;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(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 ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

struct Point
{
  double x;
  double y;
  Point(double _x, double _y) : x(_x), y(_y) {}
};

double abs(Point p1, Point p2)
{
  return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}

signed main()
{
  ll a, b;
  ll h, m;
  cin >> a >> b >> h >> m;

  double a_ang = (double(h) / 12.0 + ((double(m) / 60.0) / 12.0)) * M_PI * 2.0;
  double b_ang = (double(m) / 60.0) * M_PI * 2.0;

  // cout << a_ang << ", " << b_ang << endl;

  Point a_p = Point(double(a) * cos(a_ang), double(a) * sin(a_ang));
  Point b_p = Point(double(b) * cos(b_ang), double(b) * sin(b_ang));

  cout << std::fixed << std::setprecision(15) << abs(a_p, b_p) << endl;
}


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

string osero;
char flag;
int answer = 0;

int main(){
	cin >> osero;
	flag = osero[0];
	for (int i = 1; i < osero.size(); ++i){
		if (osero[i] != flag){
			answer++;
			flag = osero[i];
		}
	}
	printf("%d\n", answer);
	return  0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define ll long long
#define sz size()
#define ft front
#define pu push
#define ty empty
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int m5=100042;
int main(void)
{
	const float pie=3.1415926;
	float r;
	cin>>r;
	cout<<(r*2*pie);
	return 0;
    return 0;
}



Measured memory_bytes: 3788
#include <cstdio>
using namespace std;

int main(void) {
    int a[3][3], f[3][3], n, *b, y=0;
    
    int i, j, k;
    for(i=0; i<3; i++) {
        scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
    }
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) {
            f[i][j] = 0;
        }
    }

    scanf("%d", &n);

    b = new int[n];
    for(i=0; i<n; i++) {
        scanf("%d", &b[i]);
    }

    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) {
            for(k=0; k<n; k++) {
                if(a[i][j] == b[k]){
                    f[i][j] = 1;
                }
            }
        }
    }

    for(i=0; i<3; i++) {
        if(f[i][0] && f[i][1] && f[i][2])   y=1;
    }
    for(i=0; i<3; i++) {
        if(f[0][i] && f[1][i] && f[2][i])   y=1;
    }
    if(f[0][0] && f[1][1] && f[2][2])   y=1;
    if(f[0][2] && f[1][1] && f[2][0])   y=1;

    if(y)   printf("Yes");
    else    printf("No");

    delete[] b;

    return 0;
}

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

long long distant(int p){
    long long d=0;
    rep(i,x.size())d += (p-x.at(i))*(p-x.at(i));
    return d;
}

long long find(int p){
    long long now=INF,next=INF,back=INF;
    now = distant(p);
    if(p!=100)next=distant(p+1);
    if(p!=1)back=distant(p-1);
    if(now > next)find(p+1);
    else if(now > back)find(p-1);
    else return now;
}

int main(){
    long long n;
    cin >> n;
    rep(i,n){
        int X;
        cin >> X;
        x.emplace_back(X);
    }
    sort(x.begin(),x.end());
    long long ans = INF;
    int p = (x.at(0)+x.at(n-1)+1)/2;
    cout << find(p) << endl;
}

Measured memory_bytes: 256
n, k = gets.chomp.split(' ').map(&:to_i)

if n % 2 == 0
  if n / 2 >= k
    puts 'YES'
  else
    puts 'NO'
  end

else
  if (n + 1) / 2 >= k
    puts 'YES'
  else
    puts 'NO'
  end
end

Measured memory_bytes: 3836
#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(){
    vector<int> s(3);
    rep(i,3){
        cin>>s[i];
    }
    int cnt=0;
    sort(s.begin(),s.end());
    if(s[0]%2==s[1]%2 && s[1]%2==s[2]%2){

        cnt=(s[1]-s[0])/2+s[2]-s[1];
    }else{
        if(s[0]%2==s[1]%2){
            cnt=(s[1]-s[0])/2+s[2]-s[1];
        }else if(s[1]%2==s[2]%2){
            s[2]++;s[1]++;
            cnt=(s[1]-s[0])/2+s[2]-s[1]+1;
        }else if(s[0]%2==s[2]%2){
            s[0]++;s[2]++;
            cnt=(s[1]-s[0])/2+s[2]-s[1]+1;
        }

    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct SegTree{
	vector<ll> data;
	int size;
	SegTree(int _size){
		for(int i=1;;i<<=1)
			if(i>=_size){
				size=i;
				break;
			}
		data.assign(2*size,0);
	}
	void Update(int i,ll n){
		data[size+i]=n;
		for(int j=size+i;j;j>>=1)
			data[j]=max(data[j],n);
	}
	ll Query(int a,int b,int i,int l,int r){
		if(b<=l || r<=a) return 0;
		if(a<=l && r<=b) return data[i];
		ll res=0;
		int m=(l+r)/2;
		if(a<m) res=max(res,Query(a,b,i*2+0,l,m));
		if(m<b) res=max(res,Query(a,b,i*2+1,m,r));
		return res;
	}
	ll Query(int a,int b){
		return Query(a,b,1,0,size);
	}
};

int main()
{
	for(int n;cin>>n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		
		vi b(n);
		rep(i,n) b[a[i]-1]=i;
		
		SegTree st(n);
		ll mx=0;
		rep(i,n){
			st.Update(b[i],st.Query(0,b[i])+i+1);
			mx=max<ll>(mx,st.Query(0,b[i]+1));
		}
		cout<<(ll)n*(n+1)/2-mx<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3908
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  char s[n];
  // Aがゴールのパターン、Bがゴールのパターン
  bool flag = true;

  for (int i = 1; i <= n; i++) {
    cin >> s[i];

    //岩が二連続のパターン
    if (i >= a && i <= max(c, d)) {
      if (s[i] == '#' && s[i] == s[i - 1]) flag = false;
    }
  }

  // c>dならb動かしてa動かして終わり
  if (d < c) {

    for (int i = b; i <= d; i++) {
      // 途中の道で.が3連続であるとき
      if (s[i] == s[i + 1] && s[i] == s[i - 1] && s[i] == '.') {
        flag = true;
        break;
      }else{
        flag=false;
      }
    }

  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

class fraction {
    ll numel;                  // ??????
    ll denom;                  // ??????

    map<ll, ll> prime_factor(ll n) {
        map<ll, ll> res;
        for (ll i = 2; i*i <= n; i++) {
            while (n%i == 0) {
                ++res[i];
                n /= i;
            }
        }
        if (n != 1) res[n] = 1;
        return res;
    }

    pair<ll, ll> reduce(ll n, ll d) {
        map<ll, ll> pfs = prime_factor(d);
        for (auto it = pfs.begin(); it != pfs.end(); it++) {
            while ((*it).second > 0 && n%(*it).first == 0) {
                n /= (*it).first;
                d /= (*it).first;
                (*it).second--;
            }
        }
        return pair<ll, ll>(n, d);
    }

public:
    fraction() {
        this->numel = 0;
        this->denom = 1;
    }
    fraction(string s) {
        int pos = 0;
        while (s[pos] != '/') pos++;
        ll n = stoi(string(s.begin(), s.begin()+pos));
        ll d = stoi(string(s.begin()+pos+1, s.end()));

        pair<ll, ll> ret = reduce(n, d);
        this->numel = ret.first;
        this->denom = ret.second;
    }
    fraction (ll n, ll d) {
        pair<ll, ll> ret = reduce(n, d);
        this->numel = ret.first;
        this->denom = ret.second;
    }

    friend ostream& operator << (ostream &os, const fraction& fr);

    fraction operator + (const fraction& fr) const {
        ll n = this->numel*fr.denom + fr.numel*this->denom;
        ll d = this->denom * fr.denom;
        return fraction(n, d);
    }
    fraction operator - (const fraction& fr) const {
        ll n = this->numel*fr.denom - fr.numel*this->denom;
        ll d = this->denom * fr.denom;
        return fraction(n, d);
    }
};

ostream& operator << (ostream& os, const fraction& fr) {
    os << to_string(fr.numel);
    if (fr.denom != 1) os << "/" + to_string(fr.denom);
    return os;
}

fraction calc_dir(const vector<int>& dirs, int pos) {
    if (pos == dirs.size()-1) return fraction(dirs[pos], 1);

    int denom = pow(2, dirs.size() - pos - 1);
    if (dirs[pos] == 0) {
        return calc_dir(dirs, pos+1) - fraction(90, denom);
    }

    return calc_dir(dirs, pos+1) + fraction(90, denom);
}

int main(void) {

    string s;
    while (cin >> s) {
        if (s == "#") break;

        int pos = 0;
        vector<int> dirs;
        while (pos < s.size()) {
            if (s.substr(pos, 5) == "north") {
                dirs.push_back(0);
                pos += 5;
            } else {
                // west
                dirs.push_back(90);
                pos += 4;
            }
        }

        fraction ret = calc_dir(dirs, 0);
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 3424
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

int main() {
    int n;
    
    cin >> n;
    
    vector<int> l(n);
    rep(i, n) cin>>l[i];
    Sort(l);
    
    int ans = 0;
    for(int i = 0; i<n-1;i++){
        for(int j = i+1; j<n;j++){
            int h = (lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin());
            ans += max(0, h - (j + 1));
        }
    }

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


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

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


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

// 3数以上の最大公約数
// a, b, c の最小公約数は a, b の最小公約数と c の最小公約数に等しいことを利用
template <typename T=long long>
T gcd(std::vector<T>& a, int i = 0)  // a[i] と a[i+1] ~ a[end] の最大公約数を返す
{
    if( a.size() < 2 ) return 0;  // 必要に応じて変える
    if( i == (int) a.size() - 2 ) return gcd( a[i], a[i+1] );
    return gcd( a[i], gcd(a, i+1) );
}

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

    long long ans = 0;
    FOR(a, 1, K+1){
        FOR(b, 1, K+1){
            FOR(c, 1, K+1){
                vector<long long> x = {a, b, c};
                ans += gcd(x);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define ll long long
#define F(i,m,n) for(ll i=m;i<n;i++)
#define Fr(j,n,m) for(ll j=n;j>=m;j--)
#define vll vector<ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpll vector< pll >
#define tlll tuple < ll ,ll,ll >
/*-------------------------------------*---------------------------------------*/

#define godspeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl
#define cout_array(a) cout<<#a<<"=";for(auto x: a){ cout<<x<<" ";}cout<<endl

ll gcd(ll a,ll b){
    return (b?gcd(b,a%b):a);
}
const ll MAX_PRIME = 1e9+7;
const ll INF = 1e18;


/*I NEED YOU TO WORK FOR TWO HOURS ON THIS NO MATTER WHAT....THE RESULT DOESN'T MATTER.....ITS ALL ABOUT YOUR EFFORTS.
---------------------------------------------------------------------------------------------------------------------*/

ll fast_pow(ll x,ll y,ll z){
    if(y==0)return 1%z;
    else if(y==1)return x%z;
    if(y%2==0){
        ll res = fast_pow(x,y/2,z);
        return (res*res)%z;
    }
    else{
        ll res = fast_pow(x,y/2,z);
        ll temp = (res*res)%z;
        return ((x%z)*temp)%z;
    }
}
int main() {
    godspeed
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
    return 0;
}


Measured memory_bytes: 3648
N = int(input())
A = list(map(int,input().split()))
A.sort()
count = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if A[i] + A[j] > A[k] and A[i]!=A[j] and A[j]!= A[k]:
                count += 1
print(count)

Measured memory_bytes: 9152
{-# LANGUAGE BangPatterns          #-}

import Control.Monad
import Control.Applicative
import Data.Array.IO

maxNum :: Int
maxNum = 100000

main :: IO()
main = do
    n <- readLn :: IO Int
    a <- map read .words <$> getLine :: IO [Int]
    count <- newArray (0, maxNum + 1) 0 :: IO (IOUArray Int Int)
    forM_ a $ \v -> do
        inc count v
        when (v > 0) (inc count (v - 1))
        when (v < maxNum) (inc count (v + 1))
    elems <- getElems count
    print $ maximum elems

    where
        inc arr i = do
            c <- readArray arr i
            writeArray arr i (c + 1)

Measured memory_bytes: 16764
#include<iostream>

using namespace std;

struct ST {
	int a;
	int b;
	int c;

	int an;
};

int reset(int, int */*[100 + 10]*/);

int main()
{
	int ans[1000 + 10];

	ST res[1000 + 10];

	int an, bn, cn, n;

	int ml;

	int ln;

	int i, j;
	int af, bf, cf;

	while (1)
	{
		cin >> an >> bn >> cn;
		if (an == 0 && bn == 0 && cn == 0)
		{
			return 0;
		}

		cin >> n;

		ln = n;

		ml = an + bn + cn;

		reset(ml, ans);

		for (i = 1; i <= ln; i++)
		{
			cin >> res[i].a >> res[i].b >> res[i].c >> res[i].an;

			if (res[i].an == 1)
			{
				ans[res[i].a] = 1;
				ans[res[i].b] = 1;
				ans[res[i].c] = 1;

				i--;
				ln--;
			}
		}

		for (i = 1; i <= ln; i++)
		{
			af = bf = cf = 0;

			if (ans[res[i].a] == 1) af = 1;
			if (ans[res[i].b] == 1) bf = 1;
			if (ans[res[i].c] == 1) cf = 1;

			if (af + bf + cf == 2)
			{
				if (af == 0)
				{
					ans[res[i].a] = 0;
				}
				if (bf == 0)
				{
					ans[res[i].b] = 0;
				}
				if (cf == 0)
				{
					ans[res[i].c] = 0;
				}
			}
		}

		for (i = 1; i <= ml; i++)
		{
			cout << ans[i] << endl;
		}
	}

	return 0;
}

int reset(int n, int *le)
{
	int i;
	for (i = 0; i < n; i++)
	{
		le[i] = 2;
	}
	return 0;
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,l;
  l=1;
  cin >> N;
  cin >> K;
  for(int i=0;i<N;i++){
    if(l<K){
      l = 2*l;
    }else{
      l = l+K;
    }
  }
  cout << l << endl;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
import math
# N = 4
# K = 5

L = math.ceil(math.log(K,2))
#print(L)

S = 0.0
if N >= K:
	S += (N-K+1)/N
for i in range(L):
	T = math.ceil(K/2**i)
	B = math.ceil(K/2**(i+1))
#	print(i,"N",N,"T",T,"B",B,"T-B",(T-B),"1/2**(i+1)",2**(i+1))
	if N >= T:
		S += (1/N)*(T-B)/2.0**(i+1)
#		print("N>T",(1/N)*(T-B)/2.0**(i+1))
	elif T > N >=B:
		S += (1/N)*(N+1-B)/2.0**(i+1)
#		print("T>N>=B",(1/N)*(N+1-B)/2.0**(i+1))
	elif N==B:
		S += (1/N)*(N+1-B)/2.0**(i+1)
#		print("T>N>=B",(1/N)*(N+1-B)/2.0**(i+1))
print(S)


Measured memory_bytes: 3064
//y12-2
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    a = 100 * a + 10 * b + c;
    switch(a){
        case 100:
        cout << "Close" << endl;
        break;
        case 10:
        cout << "Close" << endl;
        break;
        case 110:
        cout << "Open" << endl;
        break;
        case 1:
        cout << "Open" << endl;
        break;
        case 0:
        cout << "Close" << endl;
        break;
    }

    return 0;
}


Measured memory_bytes: 3104
//If you are trying to hack me I wish you can get it, Good Luck :D.
#include <bits/stdc++.h>
using namespace std;

#define debug(args...) fprintf (stderr,args)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX = 1123;
const ll  MOD = 1000000007;
int crivo[MAX];
int n;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    
    for (int i = 2; i < MAX; i++) {
        if (crivo[i] == 0) {
            for (int k = i * i; k < MAX; k += i) crivo[k] = i;
        }        
    }

    map<int, int> factors;
    ll ans = 1;
    
    cin >> n;

    for (int i = 1; i <= n; i++) {
        int num = i;
        while (num > 1) {
            if (crivo[num] > 0) {
                factors[crivo[num]]++;
                num /= crivo[num];
            } else {
                factors[num]++;
                num = 1;
            }
        }
    }

    for (auto e : factors) {
        ans = (ans * ((ll)e.second + 1LL)) % MOD;
    }

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


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;


signed main() {
  ll N;
  cin >> N;
  vector<string> s(N*4, string(N*4, '#'));

  rep(i,N) {
    string x;
    cin>>x;
    rep(j,N){
      s[i][j]=x[j];
      s[i+N][j]=x[j];
      s[i][j+N]=x[j];
      s[i+N][j+N]=x[j];
    }
  }
  //rep(i,2*N){
  //  rep(j,2*N){
  //    cout<<s[i][j];
  //  }
  //  cout<<endl;
  //}

  ll ans = 0;
  rep(dx,N) {
    bool ok = true;
    ll ox = N-dx, oy = N;
    rep(x,N) rep(y,N) {
      if (s[x+ox][y+oy] != s[y+ox][x+oy]){
        ok = false;
      }
    }
    if (ok)
      ans++;
  }
  ans *= N;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N % 10;
  b = (N - a) % 100;
  c = (N - a - b * 10) % 1000;
  d = N -(a + b * 10 + c * 100);
  
  if (a - b == 0 && c - d == 0){
    cout << "Yes" << endl;
  }
  else if (a == b && b == c ){
    cout << "Yes" << endl;
  }
  else if (a == b && b == d){
    cout << "Yes" << endl;
  }
  else if (a== c && c == d){
    cout << "Yes" << endl;
  }
  else if (b == c &&  c == d){
    cout << "Yes" << endl;
  }

 else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
x1,y1,x2,y2 = map(int,input().split())
v1 = x2-x1
v2 = y1-y2
x3 = x2 + v2;
y3 = y2 + v1;
x4 = x3 - v1;
y4 = y3 + v2;
print(str(x3)+" "+str(y3)+" "+str(x4)+" "+str(y4))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
map<long long,int> M;
int main()
{
	int N;
	cin>>N;
	long long Sum=0;
	long long Res=0;
	M[Sum]=1;
	while(N--)
	{
		long long A;
		cin>>A;
		Sum+=A;
		Res+=M[Sum];
		M[Sum]++;
	}
	cout<<Res<<endl;
	return 0;
}

Measured memory_bytes: 12800
N = int(input())

V = dict()
for i in range(N):
	s = ''.join(sorted(input()))
	if s not in V.keys():
		V[s]=1
	else:
		V[s]+=1

result = 0
for key in V.keys():
	result += ((V[key]-1)*(1+V[key]-1))//2

print(result)

Measured memory_bytes: 17852
#include <cstdio>
int main(){
    int n;
    scanf("%d", &n);
    if (n == 0){printf("2\n"); return 0;}
    if (n == 1){printf("1\n"); return 0;}
    long long t1 = 2, t2 = 1, temp;
    for (int i = 2; i <= n; i++){
        temp = t1 + t2, t1 = t2, t2 = temp;
    }
    printf("%lld\n", temp);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    private static int MOD = 1_000_000_007;

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


    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int N = scanner.nextInt(), M = scanner.nextInt();
        scanner.nextLine();
        List<List<Integer>> pay = new ArrayList<>();
        for (int i = 0; i <= M; i++) {
            pay.add(new ArrayList<>());
        }
        for (int i = 0; i < N; i++) {
            int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            if (n[0] <= M) {
                pay.get(n[0]).add(n[1]);
            }
        }

        int ans = 0;
        Queue<Integer> q = new PriorityQueue<>(Comparator.comparingInt(x -> -x));
        for (int i = 1; i <= M; i++) {
            q.addAll(pay.get(i));
            if (!q.isEmpty()) {
                ans += q.poll();
            }
        }
        System.out.println(ans);
    }

}


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

using namespace std;

#define fou(i,a,n) for(int i=a;i<n;i++)
#define elif(c) else if(c)

int main() {
    int a, b, ans=0;
    string tmp_0, tmp_1;
    cin >> a >> b;
    fou(i, a, b+1){
        tmp_0 = to_string(i);
        tmp_1 = tmp_0;
        reverse(tmp_0.begin(), tmp_0.end());
        if (tmp_0 == tmp_1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n,a,b = (int(i) for i in input().split())
res_sum = 0

for nn in range(1, n + 1):
  keta_sum = 0
  
  for i in (str(nn)):
    keta_sum += int(i)
  
  if keta_sum >= a and keta_sum <= b:
    res_sum += nn
    
print(res_sum)

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

#define pi 3.14159265358979323846
#define ll long long


int main()
{
    double a,c;
    cin>>a;
    c=3.1415926535897932384626*a*2;
    cout<<fixed<<showpoint;
    cout<<setprecision(20);
    cout<<c<<endl;


}



Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define int long long
#define ll int 
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
    x = 0;char c = getchar();bool f = 0;
    for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
    for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if(f) x = -x;
}
const int N = 210;
int n, a[N], sum = 0, Min_Num = -1 ;
main() {
    read(n);
    for(int i = 1; i <= n; i ++) {
        read(a[i]);
    	sum += a[i];
    	if(a[i] % 10 && (Min_Num > a[i] ||  ! ~ Min_Num)) {
    		Min_Num = a[i];
		}
	}
//	cout << sum << " " << Min_Num << "\n";
	if(! ~ Min_Num && sum % 10 == 0) {
		cout << "0\n" ;
	}
	else {
		cout << (sum % 10 ? sum : sum - Min_Num);
	}
    
}

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

unsigned long long gcd(unsigned int a, unsigned int b) {
    return (b==0) ? a : gcd(b, a % b);
}

unsigned long long lcm(unsigned int const a, unsigned int const b) {
    unsigned long long h = gcd(a, b);
    return h ? (a * (b/h)) : 0;
}

int main() {
    int A, B;

    cin >> A >> B;

    long long ans = 0;

    ans = lcm(A, B);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	cout << max({a, b, c}) * 9 + a + b + c << endl;
}

Measured memory_bytes: 256
MAX_X = 10 ** 5 + 100

def main():
    N, M = [int(i) for i in input().split()]
    X = [0] * (MAX_X + 1)
    for i in map(int, input().split()):
        X[i] += 1
    Y = [sum(X[i::M]) for i in range(min(M, MAX_X))]
    # Mの倍数    
    ans = Y[0] // 2
    Y[0] = 0
    # M%2==0のM/2
    try:
        if M % 2 == 0:
            ans += Y[M//2] // 2
            Y[M//2] = 0    
        for i in range(1, M//2+1):
            j = M - i
            tmp = min(Y[i], Y[j])
            ans += tmp
            Y[i] -= tmp
            Y[j] -= tmp
    except IndexError:
        print(-1)
    for i, n in enumerate(X):
        j = i % M
        if Y[j] < 2 or n < 2:
            continue
        tmp = min(Y[j]-Y[j]%2, n-n%2)
        ans += tmp // 2
        Y[j] -= tmp
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 54252
N,M=list(map(int,input().split()))
S=input()
T=input()

if N>=M:
	x=N
	y=M
else:
	x=M
	y=N
while y!=0:
	a=y
	y=x%y
	x=a
G=x


L = (N*M)//G
cycle = L//G

flag=0

if G==1: 
	if S[0]==T[0]: print(L)
	else: print("-1")
else:
	for i in range(G):
		if S[cycle*i*N//L]!=T[cycle*i*M//L]:
			flag=1
			break
	if flag==0: print(L)
	else: print("-1")



Measured memory_bytes: 3316
#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
#include <cstdio>
using namespace std;
#define MAX_V 10240
//#define LOCAL
// 从?点from指向?点to的???cost的?
typedef struct edge
{
	int to, distance, cost;
	edge(){}
	edge(int to, int distance, int cost) : to(to), distance(distance), cost(cost){}
};

// first 当前最短路径?度，second当前?点?号
typedef pair<int, int> P;

// ?
vector<edge> G[MAX_V];

// 最短距?
int d[MAX_V];
// V是?点数
int V;

// 求解从?点s出?到所有点的最短距?（并非最小花?）
void dijkstra(int s)
{
	priority_queue<P, vector<P>, greater<P> > que;
	memset(d, 0x3f, sizeof(d));
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.distance)
			{
				d[e.to] = d[v] + e.distance;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
#ifdef	LOCAL
	freopen("data.in", "r", stdin);
	//freopen("data.out", "w", stdout);
#endif // LOCAL
	int /*N = V,*/ M;
	while (cin >> V >> M && V)
	{
		for (int i = 0; i < V; ++i)
		{
			G[i].clear();
		}
		for (int i = 0; i < M; ++i)
		{
			int u, v, d, c;
			cin >> u >> v >> d >> c;
			--u, --v;
			G[u].push_back(edge(v, d, c));
			G[v].push_back(edge(u, d, c));
		}
		// 首都是0号
  		dijkstra(0);
		int ans = 0;
		for (int i = 1; i < V; ++i)
		{
			int min_cost = 0x3f3f3f3f;
			// 找??足?先距?最短，然后?用最低的那个最低?用
			for (int j = 0; j < G[i].size(); ++j)
			{
				if (d[G[i][j].to] + G[i][j].distance == d[i] && G[i][j].cost < min_cost)
				{
					min_cost = G[i][j].cost;
				}
			}
			ans += min_cost;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 4920
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N,K;
	cin>>N>>K;
	int D[10];
	
	REP(i,K)cin>>D[i];
	FOR(i,N,10000000){
		int f=0;
		if(10000<=i){
			REP(j,K){
				if(i/10000==D[j]){f=1; break;}
				if((i/1000)%10==D[j]){f=1; break;}
				if((i/100)%10==D[j]){f=1; break;}
				if((i/10)%10==D[j]){f=1; break;}
				if(i%10==D[j]){f=1; break;}
			}
			if(f==1)continue;
		}
		else if(i<10000 && i>=1000){
			REP(j,K){
				if(i/1000==D[j]){f=1; break;}
				if((i/100)%10==D[j]){f=1; break;}
				if((i/10)%10==D[j]){f=1; break;}
				if(i%10==D[j]){f=1; break;}
			}
			if(f==1)continue;
		}
		else if(i<1000 && i>=100){
			REP(j,K){
				if(i/100==D[j]){f=1; break;}
				if((i/10)%10==D[j]){f=1; break;}
				if(i%10==D[j]){f=1; break;}
			}
			if(f==1)continue;
		}
		else if(i<100 && i>=10){
			REP(j,K){
				if(i/10==D[j]){f=1; break;}
				if(i%10==D[j]){f=1; break;}
			}
			if(f==1)continue;
		}
		else{
			REP(j,K){
				if(i==D[j]){f=1; break;}
			}
			if(f==1)continue;
		}
	
		cout<<i<<endl;
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<int, int> P;

const int inf = 114514810;
int H, W, white;
std::string S[51];
int d[51][51];

int main()
{
	in >> H >> W;
	rep(i, H) in >> S[i];
	int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };
	std::queue<P>que;
	memset(d, -1, sizeof(d));
	que.push({ 0,0 });
	d[0][0] = 0;
	while (que.size() > 0)
	{
		auto pos = que.front(); que.pop();
		if (pos.first == H - 1 && pos.second == W - 1) { break; }
		rep(i, 4)
		{
			auto toY = pos.second + dy[i], toX = pos.first + dx[i];
			if (0 <= toY && toY < W && 0 <= toX && toX < H && S[toX][toY] != '#' && d[toX][toY] == -1)
			{
				que.push({ toX,toY });
				d[toX][toY] = d[pos.first][pos.second] + 1;
			}
		}
	}
	if (d[H - 1][W - 1] == -1)
	{
		out << -1 << std::endl;
		return 0;
	}
	rep(i, H)
	{
		rep(j, W)
		{
			if (S[i][j] == '.') ++white;
		}
	}
	out << white - d[H - 1][W - 1] - 1 << std::endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
# m1,d1=map(int,input().split())
hl = list(map(int, input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
hc = [0 for i in range(N)]
mx = max(hl)
count = 0
for k in range(mx):
    i = 0
    while i < N:
        if hl[i] > hc[i]:
            count += 1
            while i < N and hl[i] > hc[i]:
                hc[i] = hc[i] + 1
                i += 1
        else:
            i += 1
print(count)


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
struct Node;
vector<Node> F;
int N;
int maxd = 9;
lint calc = 0;
struct Node {
  int idx;
  int v;
  int w;
  int d = 0;
  vector<int> dp;
  void calcd() {
      int tmp = 2;
      while(idx >= tmp) {
          tmp *= 2;
          d++;
      }
  }
  void precalc(vector<int> dpt) {
      if(d > maxd) return;
      IREP(i, 100001) if(i-w >= 0) dpt[i] = max(dpt[i], dpt[i-w]+v);
      FOR(i, 1, 100001) dpt[i] = max(dpt[i], dpt[i-1]);
      calc += 200000;
      dp = dpt;
      if(idx*2-1 < N) F[idx*2-1].precalc(dp);
      if(idx*2 < N) F[idx*2].precalc(dp);
  }
};
int solve(int x, int L){
    if(F[x-1].d <= maxd){
        return F[x-1].dp[L];
    }
    return max(solve(x/2, L), (L - F[x-1].w >= 0 ? solve(x/2, L - F[x-1].w) + F[x-1].v : 0));
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    REP(i, N) {
        F.emplace_back();
        F[i].idx = i+1;
        cin >> F[i].v >> F[i].w;
        //F[i].v = 1; F[i].w = 1;
        F[i].calcd();
    }
    vector<int> dp(100001);
    F[0].precalc(dp);

    //cout << calc << endl;

    int Q;
    cin >> Q;
    REP(q, Q) {
        int v, L;
        cin >> v >> L;
        //v = 249999; L = 100000;

        int ans = solve(v, L);

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

    //cout << calc << endl;
    

}

Measured memory_bytes: 417824
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define mod 1000000007
#define INF 1000000000000000000
/****************************/
ll ans=0;
int main()
{
	int h,w;
	cin>>h>>w;
	int x=w/2+w%2;
	rep(i,h)
	{
		ans+=x-i%2;
		if(w%2==0)
		{
			ans+=i%2;
		}
	}
	if(h==1||w==1)
	{
		ans=1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int n,k;
string s;

int main(){
    cin >> n >> k;
    cin >> s;

    if(s[k-1] == 'A') s[k-1] = 'a';
    if(s[k-1] == 'B') s[k-1] = 'b';
    if(s[k-1] == 'C') s[k-1] = 'c';

    dunk(s);
}


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

class UnionFind{
	public:
		vector<int> Parent;
		vector<int> Rank;
		UnionFind(int n){
			++n;
			Parent.resize(n, 0);
			Rank.resize(n, 0);
			for(int i=0; i<n; ++i){
				Parent[i] = i;
				Rank[i] = 0;
			}
		}

		int find(int x){
			if(Parent[x] == x) return x;
			return Parent[x] = find(Parent[x]);
		}

		void unite(int x, int y){
			x = find(x);
			y = find(y);
			if(x == y) return;
			if(Rank[x] < Rank[y]) Parent[x] = y;
			else{
				Parent[y] = x;
				if(Rank[x] == Rank[y]) ++Rank[x];
			}
		}

		bool same(int x, int y){
			return find(x) == find(y);
		}
};

int main(){
	int n, q;
//	cin >> n >> q;
	scanf("%d %d", &n, &q);
	UnionFind uf(n);
	for(int i=0; i<q; ++i){
		int c, x, y;
//		cin >> c >> x >> y;
		scanf("%d %d %d", &c, &x, &y);
		if(c == 0) uf.unite(x, y);
//		else cout << (uf.same(x, y) ? 1 : 0) << endl;
		else printf("%d\n", uf.same(x, y) ? 1 : 0);
	}
}


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

int main() {
	ll k;
	cin >> k;
	ll sum = 0;
	for (ll i = 0; i <= 1e7; ++i) {
		sum = (sum * 10 + 7) % k;
		if (sum == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 3596
N, Y= map(int, input().split())
flag = False
for i in range(N+1):
	for j in range(N+1-i):
		k = N - i - j
		if(10000*i+5000*j+1000*k == Y):
			flag = True
			print(i, j, k)
			break
	if flag is True:
		break
if flag is False:
	print(-1,-1,-1)

Measured memory_bytes: 3064
n, m = list(map(int,input().split()))
a = []
for i in range(m):
  a.append(int(input()))
c = [0] * (n+2) #combination
for i in a:
  c[i] = -1
c[0] = 1

for i in range(n):
    if c[i] < 0:
      continue
    if c[i+1] >= 0:
        c[i+1] = c[i] + c[i+1]
    if c[i+2] >= 0:
        c[i+2] = c[i] + c[i+2]
    c[i] = c[i] % 10**9+7
print(c[n]%(10**9+7))

Measured memory_bytes: 8948
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int n; cin >> n;
	vector<vector<pair<int, int> > > xy(n);
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		for (int j = 0; j < a; ++j) {
			int x, y; cin >> x >> y;
			xy[i].push_back(make_pair(x - 1, y));
		}
	}
	int ans = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {
		vector<int> tmp(n, -1);
		int cnt = 0;
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				++cnt;
				if (tmp[i] == 0) goto fal;
				tmp[i] = 1;
				for (auto e : xy[i]) {
					if (tmp[e.first] == (1 - e.second)) goto fal;
					tmp[e.first] = e.second;
				}
			} else {
				if (tmp[i] == 1) goto fal;
				tmp[i] = 0;
			}
		}
		ans = max(ans, cnt);
	fal:;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  int YUNI;
  cin >> a;
  
  size_t KYR = a.length();
  
  while(YUNI < KYR){
    if(a.at(YUNI) == '?'){
      a.at(YUNI) = 'D';
    }
    YUNI ++;
  }
    
  cout << a << endl;
  
}
  

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

typedef long long ll;
#define fi first
#define se second

const ll mod = 1000000007;
//              123456789

using namespace std;

////////////////////////////////
//
//
////////////////////////////////

///////////////////////////////
//////////////////////////////

ll solve( ll x ){
	ll i;
	ll ans = 1;
	for( i = 1; i <= x; i++ ){
		ans *= i;
		ans %= mod;
	}

	return ans;
}

int N;
int M;

int main(){
  
  cin>>N>>M;
  
  if( N - M < 2 && N - M > -2 ){
  	if( N == M ){
  		cout<<((solve( N )*solve( M )*2)%mod)<<endl;
  	}
  	else{
  		cout<<(solve( N )*solve( M )%mod)<<endl;	
  	}
  }
  else{
  	puts("0");
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using ll = long long;

int main(){
    ll n;
    std::cin >> n;
    std::vector<ll> a(n);
    std::map<ll, ll> mp;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        mp[a[i]]++;
        sum += a[i];
    }

    ll q;
    std::cin >> q;
    for(int i = 0; i < q; i++){
        ll b, c;
        std::cin >> b >> c;
        // mp[b]個のbをcに変える
        sum -= mp[b] * b;
        sum += mp[b] * c;
        mp[c] += mp[b];
        mp[b] = 0;
        std::cout << sum << std::endl;
    }
    return 0;
}


Measured memory_bytes: 10068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b;
    cin>>a>>b;
    vi ans;
    FOR(i,1,max(a,b)+1){
        if(a%i==0&&b%i==0){
            ans.pb(i);
        }
    }
    reverse(all(ans));
    int k;
    cin>>k;
    cout<<ans[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
open Str;;

type set_of_values = {w: int; h: int; x: int; y: int; r: int}

let decompose list =
  match list with
  | w :: h :: x :: y :: r :: [] -> {w = w; h = h; x = x; y = y; r = r}
  | _ -> failwith "Error";;

let yes_no_of_bool b =
  match b with
  | true -> "Yes"
  | false -> "No";;

read_line()
|> Str.split (Str.regexp " ")
|> List.map int_of_string
|> decompose
|> fun vals -> [(vals.x - vals.r) >= 0;
                (vals.y + vals.r) <= vals.h; 
                (vals.x + vals.r) <= vals.w;
                (vals.y - vals.r) >= 0];
|> List.for_all (fun x -> x)
|> yes_no_of_bool
|> print_endline



Measured memory_bytes: 2128
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n, m;
    cin >> n >> m;
    int s = 0;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a; 
        s += a;
    }
    if (s > n) cout << -1;
    else cout << n - s << endl;
    return 0;
}

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

struct RollingHash {
  const int h = 1000000007;
  const int b = 10007;
  vector<int> ha;
  vector<int> po;
  RollingHash(const string &s) {
    int n = (int) s.size();
    ha.assign(n + 1, 0);
    po.assign(n + 1, 1);
    for (int i = 0; i < n; i++) {
      ha[i + 1] = ((long long) ha[i] * b + s[i]) % h;
      po[i + 1] = ((long long) po[i] * b) % h;
    }
  }
  int get(int l, int r) {
    return (ha[r] + h - ((long long) ha[l] * po[r - l]) % h) % h;
  }
};

struct UnionFind {
  vector<int> par;
  vector<int> siz;
  UnionFind(int n) {
    par = vector<int>(n);
    siz = vector<int>(n, 1);
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
    siz[y] += siz[x];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return siz[root(x)];
  }
};

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  string ss = s;
  while (ss.size() < t.size()) {
    ss += s;
  }
  ss += ss;
  RollingHash sh(ss), th(t);
  auto uf = UnionFind(n);
  for (int i = 0; i < n; i++) {
    if (sh.get(i, i + t.size()) == th.get(0, t.size())) {
      int x = i % n;
      int y = (i + t.size()) % n;
      if (uf.same(x, y)) {
        cout << -1 << endl;
        return 0;
      }
      uf.unite(x, y);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i) - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31412
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        char a = reader.readLine().charAt (0);
        System.out.println (a <= 'Z' ? "A" : "a");
        return;
    }
}

Measured memory_bytes: 32488