akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;

int main() {

  int a, b, c; cin >> a >> b >> c;
  rep(t, 1000000) {
    int just_over = (60 * t + c) / (a + b) + 1;
    int aright = just_over * (a + b) - b;
    int aleft = aright - a;
    int gesha = 60 * t + c;
    if(aleft <= gesha && gesha <= aright) {
      cout << 60 * t + c << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  
  return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  ll r, d, x;
  cin >> r >> d >> x;
  rep1 (i, 10) {
    x = r * x - d;
    cout << x << endl;
  }
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<bitset>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define MAXN 105
int rd()
{
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
int main()
{
	int x=rd(),a=rd();
	if(x<a) printf("0");
	else printf("10");
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_c
// https://atcoder.jp/contests/abc073/tasks/abc073_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, K, L;
    cin >> N >> M;
    UnionFind uf(N + M);
    REP(i, N) {
        cin >> K;
        REP(j, K) {
            cin >> L;
            uf.unite(L - 1, M + i);
        }
    }
    bool flag = true;
    FOR(i, 1, N) {
        if (!uf.same(M, M + i)) {
            flag = false;
            break;
        }
    }

    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


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

bool check(char **s, int h, int w) {
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
	if (i > 0 && s[i - 1][j] == '#')
	  continue;
	else if (i < h - 1 && s[i + 1][j] == '#')
	  continue;
	else if (j > 0 && s[i][j - 1] == '#')
	  continue;
	else if (j < w - 1 && s[i][j + 1] == '#')
	  continue;
	return false;
      }
    }
  }
  return true;
}

int main(){
  int h, w;
  cin >> h >> w;
  char** s;
  s = new char *[h];
  for (int i = 0; i < h; i++) {
    s[i] = new char[w];
    for (int j = 0; j < w; j++)
      cin >> s[i][j];
  }
  if (check(s, h, w))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<utility>	// 値入れ替えの関数 wrap
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

// 最大公約数（ユークリッドの互除法）
int GCD(int x, int y) {
	if (x > y) {
		swap(x, y);
	}
	int r = y % x;
	while (r != 0) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}

// 最小公倍数
int LCM(int x, int y) {
	ll gcd = GCD(x, y);
	return x * y / gcd;
}

// 素数判定(素数ならtrue,合成数ならfalse)
bool IsPrime(int num) {
	if (num < 2) return false; // 0,1
	else if (num == 2) return true;	// 2
	else if (num % 2 == 0) return false; // 偶数

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false; // 割り切れたら素数ではない
	}
	return true; // 全部通ったら素数
}

int main(void) {

	int n;
	cin >> n;
	vector<int> d(n);
	REP(i, n) cin >> d[i];

	sort(d.begin(), d.end());
	int m = n / 2;

	if (d[m - 1] == d[m]) {
		cout << 0 << endl;
	}
	else {
		cout << d[m] - d[m - 1] << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    //freopen("test.inp","r",stdin);
    int i, n, t = 0;
    int a[100001], b[100001], s[100001] = {0};
    cin >> n;
    for (i = 1; i <= n; i++) cin >> a[i];
    s[2] = abs(a[1]-a[2]);
    for (i = 3; i <= n; i++) s[i] = min(abs(a[i-1]-a[i])+s[i-1],abs(a[i-2]-a[i])+s[i-2]);
    cout << s[n];
    //for (i = t; i >= 1; i--) cout << b[i] <<" ";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> v;

int main() {
    int a, b, c;
    int sum = 0;
    cin >> a >> b >> c;

    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    sum = v[2] * 2 - v[0] - v[1];
    
    while(1) {
        if(sum % 2 == 0) {
            cout << sum / 2 << endl;
            break;
        }
        sum += 3;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<iostream>
int a[110], n;
long long sum, ans = 2147483647;
int main() {
    int i, j;
    scanf("%d", &n);
    for(i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }
    std::sort(a + 1, a + n + 1);
    for(i = 1; i <= a[n]; ++i) {
        sum = 0;
        for(j = 1; j <= n; ++j) sum += pow(abs(a[j] - i), 2);
        ans = std::min(ans, sum);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
list = [int(i) for i in input().split()]

ans = 1
flag = True
for i in range(n):
    ans *= list[i]
    if ans>10**18:
        flag = False
        ans = ans%(10**18)
    if list[i]==0:
        flag = True
        break

if flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
 
typedef long long int ll;
 
const ll INF=(ll)1e18;
 
int main(){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;;
 
  REP(i,ty-sy)cout << 'U';
  REP(i,tx-sx)cout << 'R';
  REP(i,ty-sy)cout << 'D';
  REP(i,tx-sx)cout << 'L';
  cout << 'L';
  REP(i,ty-sy+1)cout << 'U';
  REP(i,tx-sx+1)cout << 'R';
  cout << "DR";
  REP(i,ty-sy+1)cout << 'D';
  REP(i,tx-sx+1)cout << 'L';
  cout << 'U' << endl;;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	string s,t;
	cin>>s>>t;
	int n = s.length();
	int m = t.length();
	int ans = 0;
	for(int i=0;i<=n-m;i++){
		int cnt = 0;
		string a,b;
		for(int j=0;j<m;j++){
			if(s[i+j] == t[j])cnt++;
			a+=s[i+j];
			b+=t[j];
		}
	    //cout<<a<<'\n';
		//cout<<b<<'\n';
		ans = max(ans,cnt);
	}
	//cout<<ans<<'\n';
	cout<<m-ans;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define INF2 (1e18)
#define PI (acos(-1))
#define EPS (1e-7)

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

const long long mod = 998244353;
// auto mod int
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, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    vi cnt(n);
    rep(i, n) cnt[d[i]]++;
    bool ok = (cnt[0] == 1);
    if (ok) {
        bool zero = false;
        rep1(i, n-1) {
            if (zero && cnt[i]>0) ok = false;
            if (!zero && cnt[i]==0) zero = true;
            if (!ok) break;
        }
    }
    if (!ok) {
        cout << 0 << endl;
        return 0;
    }
    int md = -1;
    rep(i, n) {
        if (cnt[i] > 0) md = i;
        else break;
    }
    if (md == 0) {
        cout << 1 << endl;
        return 0;
    }
    mint ans = 1;
    rep1(i, md) {
        mint now = cnt[i-1];
        now = now.pow(cnt[i]);
        ans *= now;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

const int N = 200000;
int n, k, c;
string s;
int L[N];
int R[N];

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

    cin >> n >> k >> c;
    cin >> s;

    for (int i = 0, cnt = 1; i < n, cnt <= k;) {
      if (s[i] == 'o') {
        L[i] = cnt++;
        i += c;
      }
      ++i;
    }
    for (int i = n - 1, cnt = k; i >= 0, cnt > 0;) {
      if (s[i] == 'o') {
        R[i] = cnt--;
        i -= c;
      }
      --i;
    }
    for (int i = 0; i < n; ++i) {
      if (R[i] == L[i] && R[i] != 0) {
        cout << i + 1 << endl;
      }
    }

    return 0;
}


Measured memory_bytes: 3348
n,m = map(int,input().split())
L0, R0 = map(int,input().split())
for i in range(m-1):
    l, r = map(int,input().split())
    L0 = max(L0,l)
    R0 = min(R0,r)

if L0 <= R0:
    print(R0-L0+1)
else:
    print(0)

Measured memory_bytes: 3064
A,B,H,M=map(int, input().split())
import math

a=math.radians(M*0.5+H*30)
b=math.radians(6*M)


ans2=(A*math.cos(a)-B*math.cos(b))**2+(A*math.sin(a)-B*math.sin(b))**2
ans=math.sqrt(ans2)
print(ans)


Measured memory_bytes: 9560
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for (int i=(a-1);i>=(b);--i)
#define rrep(i,n) rrepd(i,n,0)
typedef long long ll;
typedef pair<int, int> P;


int main(int argc, const char * argv[]) {

  int n, k;
  cin >> n >> k;

  double ans = 0;
  rep(i, n){
    long now = i+1;
    double tmp = 1.0/n;
    while(now < k){
      now*=2;
      tmp/=2;
    }
    ans += tmp;
  }
  printf("%.12f\n",ans);
  return 0; 
}


Measured memory_bytes: 888
/**
 * File              : C.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 12.01.2020
 * Last Modified Date: 12.01.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

#include <bits/stdc++.h>
using namespace std;
int const MAXN = 1e5+999;

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> ac(n+1, false);
    vector<int> wa(n+1, false);
    int ac_cnt = 0;
    int wa_cnt = 0;
    for (int i = 0; i < m; i++) {
        int problem;
        string result;
        cin >> problem >> result;
        if (result == "WA") {
            wa[problem]++;
        } else {
            if (!ac[problem]) {
                ac[problem] = true;
                ac_cnt++;
                wa_cnt += wa[problem];
            }
        }
    }
    cout << ac_cnt << ' ' << wa_cnt;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

char c;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin >> c;
	
	c ++;
	
	cout << c << '\n';
	
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time

def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N = I()
    A = LI()
    plus_Ai_minus_i = defaultdict(int)
    minus_Aj_minus_j = defaultdict(int)

    for i in range(len(A)):
        plus_Ai_minus_i[A[i] - i] += 1
        minus_Aj_minus_j[-A[i] - i] += 1

    ans = 0

    for k, cnt1 in plus_Ai_minus_i.items():
        cnt2 = minus_Aj_minus_j[k]
        ans += cnt1 * cnt2

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
  int N, A[201];
  cin>>N;
  for(int i = 0; i < N; i++){
    cin>>A[i];
  }
  int counter = 0;
  while(true){
    bool exist_odd = false;
    for(int i = 0; i < N; i++){
      if(A[i] % 2 != 0) exist_odd = true;
    }
    if(exist_odd) break;
    for(int i = 0; i < N; i++){
      A[i] /= 2;
    }
  counter++;
  }
  cout<<counter<<"\n";
}

Measured memory_bytes: 256
from math import factorial
n, m = [int(x) for x in input().split()]
temp = abs(n - m)
if temp > 1:
    print(0)
    exit()
mod = 10 ** 9 + 7
f_n = factorial(n) % mod
f_m = factorial(m) % mod
ans = f_n * f_m % mod
if temp == 0:
    ans = ans * 2 % mod
print(ans)

Measured memory_bytes: 10092
#include <iostream>

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

ll power(ll x, ll n) {
	ll ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % MOD;
		}
		x = x * x % MOD;
		n >>= 1;
	}
	return ans;
}

int main() {
	ll N, a[60000]{};
	cin >> N;
	for (int i = 0; i < N; i++) {
		ll b;
		cin >> b;
		if (b % 2 != (N + 1) % 2) {
			cout << 0 << endl;
			return 0;
		}
		a[b / 2]++;
	}
	a[0] += N % 2;
	for (int i = 0; i <= (N-1) / 2; i++) {
		if (a[i] != 2) {
			cout << 0 << endl;
			return 0;
		}
	}
	cout << power(2, N / 2) << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
//~ #include <ext/pb_ds/assoc_container.hpp>
//~ #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//~ using namespace __gnu_pbds; 
#define mp make_pair
#define endl '\n'
typedef long long ll;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=2e5+5;
const int mod=1e9+7;	
const ll oo=1e18+5;

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

ll fac[N],inv_fac[N];

ll mul(ll a,ll b){
	return 1ll*a*b%mod;
}

ll poww(ll a,ll b){
	int r=1;
	while(b){
		if(b%2) r=mul(r,a);
		a=mul(a,a);
		b/=2;
	}
	return r;
} 

ll my_inv(ll a){
	return poww(a,mod-2);
} 

ll binomial(ll a,ll b){
	if(a<0||b<0||a<b) return 0;
	return mul(fac[a],mul(inv_fac[b],inv_fac[a-b]));
}

void init(){
	fac[0]=inv_fac[0]=1;
	for(int i=1;i<N;++i){
		fac[i]=mul(fac[i-1],i);
		inv_fac[i]=my_inv(fac[i]);
	}
}

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

void sub_self(ll& a,ll b){
	a=(a-b%mod+mod)%mod;
} 

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	init();
	//~ cout<<f(2,1)<<endl;
	int h,w,n;
	cin>>h>>w>>n;
	vector<pair<ll,ll>> in(n);
	for(int i=0;i<n;++i) cin>>in[i].first>>in[i].second;
	sort(in.begin(),in.end(),[&](pair<ll,ll> a,pair<ll,ll> b){
		return a.first+a.second<b.first+b.second;
	});
	in.emplace_back(h,w);
	vector<ll> dp(n+1);
	for(int i=0;i<=n;++i){
		dp[i]=f(in[i].first-1,in[i].second-1);
		for(int j=0;j<i;++j){
			if(in[i].second>=in[j].second){
				sub_self(dp[i],dp[j]*f(in[i].first-in[j].first,in[i].second-in[j].second));
			}
		}
	}
	cout<<dp[n]<<endl;
	return 0;	
}


Measured memory_bytes: 3456
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

void print_dp(int dp[1001],int paragraph_len,int p1,int p2){
  for(int i=0;i<=paragraph_len;i++){
    printf("i:=%d j:=%d dp[%d]:=%d\n",p1,p2,i,dp[i]);
  }
  printf("\n");
}

int main(){
  int paragraph_len,paper_width;
  
  int case_num = 1;
  while(~scanf("%d %d",&paragraph_len,&paper_width)){
    if(paragraph_len == 0 && paper_width == 0) break;

    int a[1001];
    int sum[1001][1001];
    memset(a,0,sizeof(a));
    
    for(int i=0;i<paragraph_len;i++){
      scanf("%d",a+i);
    }

    for(int i=0;i<paragraph_len;i++){
      int tmp = 0;
      for(int j=i;j<paragraph_len;j++){
	tmp += a[j];
	sum[i][j] = tmp;
      }
    }
    
    int dp[1001];
    for(int i=0;i<paragraph_len;i++){
      dp[i] = abs(sum[0][i] - paper_width);
      for(int j=0;j<i;j++){
	dp[i] = min(dp[i],dp[j]+abs(sum[j+1][i]-paper_width));
	// print_dp(dp,paragraph_len,i,j);
      }
    }
    
    dp[paragraph_len-1] = min(dp[paragraph_len-1],max(0,sum[0][paragraph_len-1]-paper_width));
    for(int i=0;i<paragraph_len;i++){
      dp[paragraph_len-1]
	= min(dp[paragraph_len-1],
	      dp[i] + max(0,sum[i+1][paragraph_len-1]-paper_width)
	);
    }
    
    printf("Case %d: %d\n",case_num++,dp[paragraph_len-1]);
  }
}

Measured memory_bytes: 5108
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#define _CRT_DISABLE_PERFCRIT_LOCKS

#include <iostream>
#include <cstdio>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>	
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <thread>
#include <cassert>

using namespace std;

#define ll long long
#define ull unsigned long long
typedef int hv;
#define double long double
#define make(type, x) type x; cin>>x	
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
#define VI vector<int>
#define VVI vector<vector<int>>
#define PII pair<int, int>
#define PPII pair<PII, int>
#define M7 1000000007ll
#define M9 1000000009ll
#define MFFT 998244353ll 
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define outv(a) for(auto& x: a) cout << x << ' ';

void Solve() {
	make3(int, a, b, c);
	cout << max(0, c + b - a);
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef _SUPER_DEFINE
	auto F1 = freopen("input.txt", "r", stdin);
	auto F2 = freopen("output.txt", "w", stdout);
	if (F1 == NULL || F2 == NULL) return 0;
	if (sizeof(int) != 8) cout << "NO LONG!!!\n";
	Solve();
	fflush(stdout);
	while (!cin.eof()) {
		string s = "_";
		do getline(cin, s);
		while (!cin.eof() && !s.empty());
		if (cin.eof()) break;
		FOR(2) cout << endl;
		Solve();
		fflush(stdout);
	}
	fclose(F1), fclose(F2);
#else
	Solve();
#endif
	return 0;
}

Measured memory_bytes: 256
def calc():
    x, n, *p = map(int, open(0).read().split())
    h = set(p)
    for i in range(0, n+1):
        a = x - i
        b = x + i
        if a not in h:
            return a
        if b not in h:
            return b
    return x

print(calc())

Measured memory_bytes: 9184
import math

N = int(input())
A = [int(i) for i in input().split()]

left = [0] * (N+1)
for i in range(1, N+1):
    left[i] = math.gcd(left[i-1], A[i-1])
    
right = [0] * (N+1)
right[N-1] = A[N-1]
for i in range(N-2, -1, -1):
    right[i] = math.gcd(right[i+1], A[i])
    
output = 0
for i in range(N):
    output = max(output, math.gcd(left[i], right[i+1]))
    
print(output)

Measured memory_bytes: 21284
using System;
using System.Collections.Generic;

namespace ALDS1_3
{
    class Program
    {
        static int Calc(string[] a)
        {
            var stack = new List<int>();
            var symbol = "+-*/";
            foreach(var e in a)
            {
                if (symbol.Contains(e))
                {
                    var l = stack.Count - 1;
                    var x = stack[l - 1];
                    var y = stack[l];
                    stack.RemoveRange(l - 1, 2);
                    int aque = 0;
                    switch (e)
                    {
                        case "+":
                            aque = x + y;
                            break;
                        case "-":
                            aque = x - y;
                            break;
                        case "*":
                            aque = x * y;
                            break;
                        case "/":
                            aque = x / y;
                            break;
                    }
                    stack.Add(aque);
                }
                else
                    stack.Add(int.Parse(e));
            }
            return stack[0];
        }
        static void Main()
        {
            Console.WriteLine(Calc(Console.ReadLine().Split()));
        }
    }
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl

using namespace std;

typedef long long ll;
typedef string str;

const ll MAXN = 1e5 + 10;
const ll MOD = 1000000000000037;

ll n, a[MAXN], ps[MAXN];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll a, b;
	cin >> a >> b;
	if(a % 3 == b % 3) cout << (a == b ? "Brown" : "Alice") << '\n';
	else cout << (abs(a - b) < 2 ? "Brown" : "Alice") << '\n';
	return 0;
}


Measured memory_bytes: 256
/*
wxy.

*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
namespace wxy{
	int n;const int maxn=50+9;
	ll len[maxn],pp[maxn];
}
using namespace wxy;
ll rs(ll x,int lv){
	if(x==len[lv]) return pp[lv];
	if(x<=1)
		return 0;
	if(x<=len[lv-1]+1)
		return rs(x-1,lv-1);
	if(x==len[lv-1]+2)
		return pp[lv-1]+1;
	if(x<=len[lv]-1)
		return pp[lv-1]+1+rs(x-len[lv-1]-2,lv-1);
}
int main(){
	cin>>n;
	len[0]=1;pp[0]=1;
	for(int i=1;i<=n;++i){
		len[i]=len[i-1]*2+3;
		pp[i]=pp[i-1]*2+1;
		//printf("i=%d len=%lld pp=%lld\n",i,len[i],pp[i]);
	}
	ll x;cin>>x;
	printf("%lld\n",rs(x,n));
	return 0;
}

Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
# mod = 998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"
INF = 1<<32-1
# INF = 10**18

def main():
    s = input()
    if s[-1] == "s":
        print(s+"es")
    else:
        print(s+"s")

    return None

if __name__ == '__main__':
    main()


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    ll X = tx-sx;
    ll Y = ty-sy;

    REP(i, X){
        cout << 'R';
    }
    REP(i, Y+1){
        cout << 'U';
    }
    REP(i, X+1){
        cout << 'L';
    }
    REP(i, Y+1){
        cout << 'D';
    }

    cout << "RD";

    REP(i, X+1){
        cout << 'R';
    }
    REP(i, Y+1){
        cout << 'U';
    }
    REP(i, X+1){
        cout << 'L';
    }
    REP(i, Y){
        cout << 'D';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3668
n=int(input())
x=list(map(int, input().split()))
x1=reversed(x)
sum_list=[]

for i in range(min(x),max(x)+1):
    sum=0
    for k in range(len(x)):
        sum+=(x[k]-i)**2
    sum_list.append(sum)

min_sum=min(sum_list)
print(min_sum)

Measured memory_bytes: 3064
/**
 * Title: A - Coffee
 * Url: https://atcoder.jp/contests/abc160/tasks/abc160_a
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <set>
#include <tuple>

using namespace std;
typedef vector<int>VI;
typedef long long LL;

#define IOSWORK ios::sync_with_stdio(0); cin.tie(0)
#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define VAR(v, n) typeof(n) v = (n)
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define SCAN_INT(n) scanf("%i",&n)
#define SCAN_P_INT(n,m) scanf("%i %i",&n,&m)
#define PRINT_P_INT(n,m) printf("%i %i\n",n,m);
#define PRINT_INT(n) printf("%i\n",n)

#define PB push_back
#define ST first
#define ND second
#define INF 1000000000


#define MAXSIZE 210
int n,m,r;
int suma = INF;
int odleglosci[MAXSIZE][MAXSIZE];
VI wierzcholki;
int zajete[10];

void permutacje(VI &ciag, int i){

    if(i==r-1){
        int temp_sum=0;
        REP(j,SIZE(ciag)-1)
          temp_sum+=odleglosci[ciag[j]][ciag[j+1]];//printf("%i ",odleglosci[wierzcholki[ciag[j]]] [wierzcholki[ciag[j+1]]]);

        suma=min(temp_sum,suma);
    }
    else{
        FOR(j,i,r-1){
            swap(ciag[i],ciag[j]);
            permutacje(ciag,i+1);
            swap(ciag[i],ciag[j]);
        }
    }

}

int main(){
    SCAN_P_INT(n,m);
    SCAN_INT(r);

    REP(i,r){
        int temp;
        SCAN_INT(temp);
        wierzcholki.PB(temp);
    }

    FOR(i,1,n)
        FOR(j,1,n){
            if(i==j)
                odleglosci[i][j]=0;
            else
                odleglosci[i][j]=INF;
        }

    REP(i,m){
        int a,b,c;
        scanf("%i %i %i",&a,&b,&c);
        odleglosci[a][b]=c;
        odleglosci[b][a]=c;
    }

    FOR(i,1,n)
        FOR(j,1,n)
            FOR(k,1,n){
                odleglosci[j][k]=min(odleglosci[j][k],odleglosci[j][i]+odleglosci[i][k]);
        }

    permutacje(wierzcholki,0);


    PRINT_INT(suma);
    return 0;
}


Measured memory_bytes: 384
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var ans = xArray(0,n);
  for(var x = 1; x*x <= n; x++){
    for(var y = 1; y*y <= n; y++){
      var xy = x*x + y*y + x*y;
      if(xy > n)break;
      for(var z = 1; z*z <= n; z++){
        var f = xy + z*z + y*z + z*x;
        if(f > n)break;
        ans[f-1]++;
      }
    }
  }
  return ans.join("\n");
}

Measured memory_bytes: 33156
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
for i in range(1,int(n**.5)+1):
  if n % i == 0:
    mans = min(mans, i + n //i)
print(mans-2)

Measured memory_bytes: 40556
l=[input() for i in range(5)]
a=[0, 0, 0, 0, "9"]

for i in range(5):
  if int(a[4][-1]) >= int(l[i][-1]) and not(int(l[i][-1]) == 0):
      a[4] = l[i]

if a[4] is "9":
  a[4] = l[0]

l.remove(a[4])
l = [int(i) for i in l]
l.sort()
for j in range(4):
  while(not(int(l[j]) % 10 is 0)):
    l[j]+=1
  a[j] = int(l[j])
  
a[4] = int(a[4])
print(sum(a))


Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public final static long MOD = 1000000007;

    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int N = reader.nextInt();
        int K = reader.nextInt();
        PriorityQueue<Long> q = new PriorityQueue<Long>();
        for (int i=0; i<N; i++) q.add(reader.nextLong());
        long ans = 0;
        for (int i=0; i<N-K; i++)ans += q.poll();
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 30512
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()

int main() {
	ll a, b, ans;
	cin >> a >> b;
	if (a == 1 or b == 1) {
		if (a == 1 and b == 1) cout << "1" << endl;
		else cout << max(a,b) - 2 << endl;
	}
	else cout << (a - 2) * (b - 2) << endl;
}



Measured memory_bytes: 256
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

const SPLIT_DELIMITER: char = ' ';
#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
    let i: usize;
    input!(i);

    let mut left: usize = 0;
    let mut right: usize = 1_000_000;

    loop {
        let mid = (right - left) / 2 + left;
        if right - left == 1 {
            break;
        } else if mid * mid < i {
            left = mid;
        } else if mid * mid > i {
            right = mid;
        } else {
            left = mid;
            break;
        }
    }
    p(left * left);
}

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

using namespace std;
typedef long long ll;

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

  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (i & 1) ans += (s[i] == 'g');
    else ans -= (s[i] == 'p');
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
 
int main(){
    ll N;
    string S;
    cin>>N>>S;
    ll ans=0;
    rep(i,0,N){
        map<char,ll> mp1,mp2;
        rep(j,0,i) mp1[S[j]]++;
        rep(j,i,N) mp2[S[j]]++;
        ll cnt=0;
        for(char c='a'; c<='z'; c++){
            if(mp1.count(c)>0 && mp2.count(c)>0)cnt++;
        }
        ans=max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int h, w;
	cin>>h>>w;
	vector<string> s(h);
	rep(i, h) cin>>s[i];
	vector<string> res[2];
	rep(k, 2){
		res[k] = vector<string>(s);
		rep(i, h){
			res[k][i][k==0?0:w-1] = '#';
			if(i%2==k) rep(j, w-2) res[k][i][j+1] = '#';
		}
		rep(i, h) cout<<res[k][i]<<endl;
		if(k==0) cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main(void) {
    while(true) {
        vector<int> key;
        for(int r = 0; r < 8; r++) {
            int input; cin >> input;
            if(input != 0) key.push_back(input);
        }
        if(cin.eof()) break;
        int height = (int)key.size();
        switch(height) {
            case 1:cout << "C" << endl; break;
            case 2:
                if(key[0] == key[1]) cout << "A" << endl;
                else if(key[0] > key[1]) cout << "E" << endl;
                else                     cout << "G" << endl;
                break;
            case 3:
                if(key[0] < key[2]) cout << "D" << endl;
                else                cout << "F" << endl;
                break;
            default: cout << "B" << endl;
        }
    }
    return(0);
}

Measured memory_bytes: 1204
from fractions import gcd

A, B, C, D = map(int, input().split())

C_num = B // C - (A - 1) // C
D_num = B // D - (A - 1) // D
CD = (C * D) // gcd(C, D)
CD_num = B // CD - (A - 1) // CD
print(int(B - A + 1 - C_num - D_num + CD_num))


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

const int N = 1e5+1;
int cnt[N];

int main()
{
  fastio;
  int n; cin >> n;
  long ans = 0;
  for (int i = 1; i <= n; i++){
    int x; cin >> x;
    cnt[x]++; ans += x;
  }
  int Q; cin >> Q;
  while (Q--){
    long x, y; cin >> x >> y;
    long cur = cnt[x]; cnt[x] = 0;
    cnt[y] += cur; ans = ans - cur * x + cur * y;
    cout << ans << '\n';   
  }
  return 0;
}

Measured memory_bytes: 4032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner in = new Scanner(System.in);

		while(true){

			int H = in.nextInt();
			int W = in.nextInt();

			if(H == 0 && W == 0){break;}

			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					System.out.print("#");
				}
			System.out.println();
			}
		System.out.println();
		}
	}
}



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

int N;
string S;

int main(void) {
	cin >> S;
	N = S.length();

	int sum = 0;
	for (int i = 0; i < N; ++i)
		sum += (int)(S[i] - '0');

	string ans = "No\n";
	if (sum % 9 == 0)
		ans = "Yes\n";

	cout << ans;
	return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n_animals, n_legs,c,t;
  scanf("%d %d", &n_animals, &n_legs);
  bool found = false;
  for(c = 0; c<=n_animals; c++){
  	t = n_animals  - c;
    if (c*2 + t*4 == n_legs){
    	found = true;
      	break;
    }
  }
  if ( found == true){
  	printf("Yes\n");
  }
  else{
    printf("No\n");
  }
 
  
 return 0; 
}

Measured memory_bytes: 3708
//たぶん下の桁からDPすればよさそう。
//全ての石を移すことはできないことに注意する。
#include <iostream>
#include <algorithm>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

void chmin(int &a, int b) { a = min(a, b); }

int n;
int a[300];
int dp[41][2][2][2];	//dp[keta][a[0]繰り下がり？][a[1]繰り上がり？][山0の石が0個以上？] = minCost

signed main() {
	int i, j, k, l, m;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int Xor = 0;
	for (i = 2; i < n; i++) Xor ^= a[i];
	
	int INF = 1e+15;
	rep(i, 41) rep(j, 2) rep(k, 2) rep(l, 2) dp[i][j][k][l] = INF;
	
	dp[0][0][0][0] = 0;
	rep(i, 40) {
		rep(j, 2) {
			rep(k, 2) {
				rep(l, 2) {
					if (dp[i][j][k][l] == INF) continue;
					//2^iの位からm(=0, 1)だけ貰う
					rep(m, 2) {
						int x = (a[0] >> i) % 2 - j - m;
						int y = (a[1] >> i) % 2 + k + m;
						int nj = 0;
						int nk = 0;
						int cst = m * (1LL << i);
						if (x < 0) { x += 2; nj = 1; }
						if (y >= 2) { y -= 2; nk = 1; }
						int nl = (l || (x > 0));
						if ((x ^ y) != (Xor >> i) % 2) continue;
						chmin(dp[i + 1][nj][nk][nl], dp[i][j][k][l] + cst);
					}
				}
			}
		}
	}
	
	if (dp[40][0][0][1] >= INF) cout << "-1" << endl;
	else cout << dp[40][0][0][1] << endl;
	return 0;
}

Measured memory_bytes: 3596