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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

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

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld EPS = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        string a; cin >> a;
        int L; cin >> L;
        if (L == 0) break;

        map<string,int> mp;
        while (a.size() < L) a = '0' + a;
        for (int k = 0;; ++k) {
            if (mp.count(a)) {
                cout << mp[a] << " " << stoi(a) << " " << k - mp[a] << endl;
                break;
            }
            mp[a] = k;
            string mi = a, ma = a;
            sort(mi.begin(),mi.end());
            sort(ma.rbegin(),ma.rend());
            a = to_string(stoi(ma) - stoi(mi));
            while (a.size() < L) a = '0' + a;
        }
    }

    return 0;
}



Measured memory_bytes: 3248
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 12:05:39
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    cout << min(a*n, b) << endl;

    return 0;
}


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

int main() {
  string a;
  cin>>a;
  map<char, int> m;
  for (char c: a) {
    ++m[c];
  }
  long long ans = 0;
  int n = a.length();
  for (int i=0; i<n; i++) {
    ans += n - i - m[a[i]];
    --m[a[i]];
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

int swp[MAXN], suf[MAXN];

int32_t main() {
    $
    int n, k;
    string ss, s = "1";
    cin >> n >> k >> ss;
    s += ss;
    if (count(all(s), '1') - 1 == 0) {
        return cout << n << '\n', 0;
    }
    queue<ii> q;
    ++n;
    suf[n] = 0;
    for (int i = n - 1; i >= 0; --i) {
        suf[i] = suf[i + 1] + (s[i] == '1');
    }
    int cur = 0, sum = 0, kp = n, ax;
    bool f = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == '1') {
            if (cur) {
                q.push({cur, kp});
                sum += cur;
            }
            if (q.size() > k) {
                sum -= q.front().F;
                q.pop();
            }
            if (q.size()) {
                ax = q.front().S + 1;
            } else {
                ax = n;
            }
            swp[i] = suf[i] - suf[ax] + sum;
            if (f) kp = i, f = 0;
            cur = 0;
        } else {
            f = 1;
            ++cur;
        }
    }
    int ans = swp[0] - 1;
    for (int i = 1; i < n; ++i) {
        if (s[i] == '1') {
            ans = max(ans, swp[i]);
        }
    }
    cout << ans << '\n';
}   



Measured memory_bytes: 1488
s = input()
li = {"dream": 5, "dreamer": 7, "erase": 5, "eraser": 6}
flag = 0
while len(s) > 0:
    ct = 0
    if flag == 1:
        break
    for key in li.keys():
        ct += 1
        if s.endswith(key):
            s = s[:-(li[key])]
            break
        if ct == 4:
            flag = 1
            print("NO")
            break
if flag == 0:
    print("YES")


Measured memory_bytes: 3188
# Problem: https://atcoder.jp/contests/abc042/tasks/abc042_b
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(str, sys.stdin.readline().split()))


def LS(): return list(map(str, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(allNumber, eachStringList):
    result = ""
    # algorithm
    eachStringList.sort(reverse=False)
    #    print("{}".format(eachStringList))
    result = result.join(eachStringList)
    return result


if __name__ == "__main__":
    N, _ = MI()
    SI = []
    for j in range(N):
        tmpList = LS()
        SI.append(tmpList[0])
    print("{}".format(solver(N, SI)))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()
int main()
{
  int N, t, ans, s;
  cin >> N >> t;
  int x[N];
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
  }
  ans = abs(t-x[0]);
  for (int i=0; i < N; ++i) {
    s = ans;
    ans = __gcd(s, abs(t-x[i]));
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;

const int MAXN = 1e5 + 7;
const long long mod = 1e9 + 7;

long long a[MAXN];

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

	long long n, k;

	cin >> n >> k;

	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}

	long long ans = 0;

	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			if(a[i] > a[j]){
				++ans;
			}
		}
	}

	ans *= k;
	ans %= mod;

	long long ans2 = 0;

	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if(a[i] > a[j]){
				++ans2;
			}
		}
	}

	ans2 *= (k * (k - 1ll) / 2ll) % mod;
	ans2 %= mod;

	cout << (ans + ans2) % mod << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
bool z[101];
int n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  z[0] = true;
  FOR(i, 0, 101-4) z[i+4] |= z[i];
  FOR(i, 0, 101-7) z[i+7] |= z[i];
  cin >> n;
  cout << (z[n] ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
const ll INF = 500005;
int main(void) {
  string s;
  cin >> s;
  int desc = 0;
  int n = s.size();
  int cptl = 0;
  ll ans = 0;
  int h = 0;
  rep(i, n) {
    if(s[i] == '>') {
      ++desc;
      if(h > 0) {
        h = 0;
        continue;
      }
      ans += desc - 1;
      if(desc > cptl) ans++;
    } else {
      ++h;
      ans += cptl = h;
      desc = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#define INF 1e9+7
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int lo;

lo n,k;
map <lo,bool> dislike;
bool cnt(string str){
    for(lo i = 0;i < str.size();i++) if(dislike[str[i]-'0']) return false;
    return true;
}
int main(){
    cin >> n >> k;
    for(lo i = 0;i < k;i++) {
        lo d;
        cin >> d;
        dislike[d] = true;
    }    
    
    while(true){
        if(cnt(to_string(n))){
            break;
        }
        else{
            n++;
        }
    }
    cout << n;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int E = sc.nextInt();
        int F = sc.nextInt();
        double ans = 0;
        int tmp[] = new int[2];
        tmp[0] = 0;
        tmp[1] = 0;
        for (int a = 0; a * A * 100 <= F; a++) {
            for (int b = 0; a * A * 100 + b * B * 100 <= F; b++) {
                for (int c = 0; a * A * 100 + b * 100 * B + c * C <= F; c++) {
                    for (int d = 0; a * A * 100 + b * B * 100 + c * C + d * D <= F; d++) {

                        if (c * C + d * D <= E * (a * A + b * B) && ans <= (double) (c * C + d * D) / (double) (a * A * 100 + b * B * 100 + c * C + d * D)) {
                            ans = (double) (c * C + d * D) / (double) (a * A * 100 + b * B * 100 + c * C + d * D);
                            tmp[0] = a * A * 100 + b * B * 100 + c * C + d * D;
                            tmp[1] = c * C + d * D;
                        }
                    }
                }
            }
        }
        System.out.println(tmp[0] + " " + tmp[1]);
    }
}

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

using namespace std;

string MapBefore[8], MapAfter[8];

void solve() {
	char tmp[9];

	for (int j = 0; j < 8; j++) {
		for (int i = 0; i < 8; i++) {
			tmp[7-i] = MapBefore[i][j];
		}
		tmp[8] = '\0';
		MapAfter[j] = tmp;
	}
}

int main() {

	for (int i = 0; i < 8; i++) {
		cin >> MapBefore[i];
	}

	for (int i = 1; i < 4; i++) {
		solve();
		cout << 90 * i << endl;
		for (int i = 0; i < 8; i++) {
			cout << MapAfter[i] << endl;
		}
		for (int i = 0; i < 8; i++) {
			MapBefore[i] = MapAfter[i];
		}
	}
	
	return 0;
}


Measured memory_bytes: 3048
def func(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3*n + 1

s = int(input())
data = set()
data.add(s)
for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val


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

string solve(int n, int m, int k);
string solve(int n, int m, int k) {
    for (int i = 0; i < n + 1; i++) {
        for (int j = 0; j < m + 1; j++) {
            if (i * m + j * n - 2 * i * j == k) {
                return "Yes";
            }
        }
    }
    return "No";
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    cout << solve(n, m, k) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#define ll long long int
#define ld long double
#define pi acos(-1)
#define pb push_back
using namespace std;

int main()
{
    ll i,j,a,k,b,c,n,t,m,p,q,d,e,f,y,g,z,h,r,l,x;
    ld aa,bb,ee,dd,ff,kk,gg;

    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

        cin>>n;
        cin>>bb;
        e = 0;
        for(i=0;i<n;i++){
            cin>>a>>b;
            c = (a*a)+(b*b);
          aa = sqrt(c);
            if(aa<=bb)e++;
        }
        cout<<e<<endl;
}


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

int main(){
    int H,W;
    cin >> H >> W;
    char G[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> G[i][j];
        }
    }
    for(int i=1;i<H-1;i++){
        for(int j=1;j<W-1;j++){
            if(G[i][j]=='#'){
                if(G[i-1][j]=='.'&&G[i+1][j]=='.'&&G[i][j-1]=='.'&&G[i][j+1]=='.'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
N = int(input())
mat = list()
for i in range(10):
    mat.append([0] * 10)

for i in range(N):
    A = int(str(i + 1)[0])
    B = int(str(i + 1)[-1])
    mat[A][B] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += mat[i][j] * mat[j][i]
print(ans)


Measured memory_bytes: 3060
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(bf.readLine());
        String S = bf.readLine();
        int min;
        int count = 0;
        for(int i = 0; i < N; i++){
            if(S.charAt(i) == '.'){
                count++;
            }
        }
        min = count;
        for(int i = 0; i < N && 0 < min; i++){
            if(S.charAt(i) == '#'){
                count++;
            } else{
                count--;
                if(count < min){
                    min = count;
                }
            }            
        }           
        System.out.println(min);
    }
}

Measured memory_bytes: 26972
#include<iostream>
using namespace std;
const int INF = 2e9;

int n, r[200000];
int ans = -INF;
int main()
{
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> r[i];

  int mn = r[0];
  for(int i = 1; i < n; i++){
    ans = max(ans, r[i] - mn);
    mn = min(mn, r[i]);
  }

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

Measured memory_bytes: 1940
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定

#define ll long long int
#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

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

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

//degree → radian
ll chg_DegRad(ll deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(ll rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

string s, t;



int main() {
	
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<random>
using namespace std;


int main(){

  string s;
  cin >> s;
  bool f = true;


  if( s.size()%2 == 1 ) f = false;

  if( s[0] == s[s.size()-1] ){
    if( f ) f = false;
    else f = true;
  }


  if( !f ) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}














// EOF


Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <climits>
using namespace std;

int main() {
    int n;
    cin >> n;
    long long a[3 * n + 1], l[3 * n + 1], r[3 * n + 1];
    for (int i = 1; i <= 3 * n; i++) {
        cin >> a[i];
    }
    priority_queue<int, vector<int>, greater<int>> q1;
    priority_queue<int> q2;
    long long sum = 0;
    for (int i = 1; i <= 3 * n; i++) {
        sum += a[i];
        q1.emplace(a[i]);
        while (q1.size() > n) {
            sum -= q1.top();
            q1.pop();
        }
        l[i] = sum;
    }
    sum = 0;
    for (int i = 3 * n; i > 0; i--) {
        sum += a[i];
        q2.emplace(a[i]);
        while (q2.size() > n) {
            sum -= q2.top();
            q2.pop();
        }
        r[i] = sum;
    }
    long long result = LLONG_MIN;
    for (int i = n; i <= 2 * n; i++) {
        result = max(result, l[i] - r[i + 1]);
    }
    cout << result;
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

int mpow(int a,int b){
    int ret=1;
    while(b){
        if(b&1)ret=ret*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}

int fact[111111];
int inv[111111];
int calc(int n,int k){
    return fact[k+n-1]*inv[k]%mod*inv[n-1]%mod;
}

signed main(){
    fact[0]=1;
    for(int i=1;i<111111;i++)fact[i]=fact[i-1]*i%mod;
    inv[111111-1]=mpow(fact[111111-1],mod-2);
    for(int i=111111-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

    int N,M;
    cin>>N>>M;
    int ans=1;
    for(int i=2;i*i<=M;i++){
        int cnt=0;
        while(M%i==0){
            M/=i;
            cnt++;
        }
        if(cnt>=1)ans=ans*calc(N,cnt)%mod;
    }
    if(M!=1)ans=ans*N%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <ll> ds;
    REP(i, n){
        ll d; cin >> d;
        ds.push_back(d);
    }
    ll ans = 0;
    for (ll i=0; i<n; i++){
        for (ll j=0; j<i; j++){
            ans += ds[i] * ds[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-8
#define inf 0x3f3f3f3f
#define mod 1000000009
using namespace std;

int main() {
	speed;
	int n, m, k;
	cin >> n >> m;
	vector<vector<int>>g(m);
	for (int i = 0; i < m; ++i) {
		cin >> k;
		int v;
		for (int j = 0; j < k; ++j) {
			cin >> v;
			--v;
			g[i].push_back(v);
		}
	}
	vector<int>p(m);
	for (int i = 0; i < m; ++i)
		cin >> p[i];
	int ans = 0;
	for (int i = 0; i < pow(2, n); ++i) {
		bitset<10> b = i;
		int cnt = 0;
		for (int j = 0; j < m; ++j) {
			int son = 0;
			for (int k = 0; k < g[j].size(); ++k)
				if (b[g[j][k]])
					++son;
			if (son % 2 == p[j])
				++cnt;
		}
		if (cnt == m)
			++ans;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ull a, b, c; cin>>a>>b>>c;
	/*
	a+b+2kökab < c
	2kökab < c-a-b
	(c > a+b)
	4ab <
	*/
	(c > a+b && 4*a*b < (c-a-b)*(c-a-b)) ? cout<<"Yes" : cout<<"No";
}

Measured memory_bytes: 256
import heapq
n, m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] *= -1
heapq.heapify(a)
while(m):
    heapq.heapreplace(a, -(-a[0] // 2))
    m -= 1
res = -sum(a)
print(res)

Measured memory_bytes: 14180
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec
import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, m) = in.readLine().split("\\s+").map(_.toInt)
    val as = mutable.PriorityQueue(in.readLine().split("\\s+").map(_.toInt): _*)(Ordering[Int].reverse)
    val bcs = mutable.PriorityQueue(Array.fill(m) {
      in.readLine().split("\\s+") match {
        case Array(b, c) => (b.toInt, c.toLong)
      }
    }: _*)(Ordering.by[(Int, Long), Long] {
      case (_, b) => b
    })

    @tailrec
    def max(sum: Long, i: Int): Long = {
      if (i == n) {
        sum
      } else if (bcs.isEmpty) {
        sum + as.foldLeft(0L)(_ + _)
      } else {
        val a = as.dequeue()
        val (b, c) = bcs.dequeue()
        if (a < c) {
          if (b > 1) {
            bcs.enqueue((b - 1, c))
          }
          max(sum + c, i + 1)
        } else {
          sum + a + as.foldLeft(0L)(_ + _)
        }
      }
    }

    out.println(max(0L, 0))

    out.flush()
  }
}


Measured memory_bytes: 124468
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, ki;
signed main() {
	cin >> n;
	rep(i, n) {
		int a; cin >> a;
		if (a % 2)ki++;
	}
	if (ki % 2)cout << "NO" << endl;
	else cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,m;
int32_t main(){
CODE_START;
cin>>n>>m;
cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<ll> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

int f(bool x) {
  return x ? -1 : 1;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VL x(n), y(n), z(n);
  rep(i, n) cin >> x[i] >> y[i] >> z[i];
  ll ans = 0;
  for(int i = 0; i < 1 << 3; ++i) {
    VL a;
    ll sum = 0;
    rep(j, n) a.push_back(f((i >> 0) & 1) * x[j] + f((i >> 1) & 1) * y[j] + f((i >> 2) & 1) * z[j]);
    sort(rall(a));
    rep(j, m) sum += a[j];
    ans = max(ans, sum);
  }
  out(ans);
  return 0;
}


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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())



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

	char c;
	cin >> c;
	if(c != 'z')
		cout << char(c + 1);
   	else
   		cout << 'z';
	return 0;
}

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

using namespace std;

int main() {

    int A, B, C;
    int asn = 0;

    cin >> A >> B >> C;

    while(B >= A) {
        
        if(asn == C) break;
        asn++;
        B -= A;
    }

    cout << asn << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
    long long int n, d;
    scanf("%lld%lld", &n, &d);
    long long int ans = 0;
    for(long long int i = 0; i < n; i++) {
        long long int x, y;
        scanf("%lld%lld", &x, &y);
        if(x * x + y * y <= d * d) {
            ans++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    if (k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        exit(0);
    }

    if (k % 7 == 0) k /= 7;

    if (k == 1) {
        cout << 1 << endl;
        exit(0);
    }

    k *= 9;

    int t = 1;
    for (int i = 0; i < k; i++) {
        t *= 10;
        t %= k;
        if (t == 1) {
            cout << i + 1 << endl;
            exit(0);
        }
    }

    return 0;
}

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

int main(){
  string s, t;
  cin >> s;
  cin >> t;
  int i, j;
  char temp;
  for(i = 0; i < s.length(); i++){
    for(j = 0; j < s.length(); j++){
      if(s[i] < s[j]){
	temp = s[i];
	s[i] = s[j];
	s[j] = temp;
      }
    }
  }
  
  for(i = 0; i < t.length(); i++){
    for(j = 0; j < t.length(); j++){
      if(t[i] > t[j]){
	temp = t[i];
	t[i] = t[j];
	t[j] = temp;
      }
    }
  }
  if(s.compare(t) < 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    
    string n;
    cin>>n;
    ll sz = n.length();
    ll val = 0;
    for(ll i =0;i<sz;i++)
    {
        val = (val+(n[i]-'0'))%9;
    }
    if(val==0) cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3676
N = int(input())
A = list(map(int, input().split()))
Mt = [0] * N

for i in range(N):
    Mt[0] += A[i] * (-1) ** i

for i in range(1, N):
    Mt[i] = 2 * A[i - 1] - Mt[i-1]

print(*Mt)


Measured memory_bytes: 14092
n = gets.to_i
a = []
n.times do
  s = gets.split
  case s[0]
  when 'insert'
    a.unshift s[1].to_i
  when 'delete'
    i = a.index s[1].to_i
    a.delete_at i if i
  when 'deleteFirst'
    a.shift
  when 'deleteLast'
    a.pop
  end
end

puts a * ' '



Measured memory_bytes: 21192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

vector<lint> bellman_ford(Edges<int> & edges,int V,int S)
{
  vector<lint> path(V,I64_MAX);
  path[S] = 0;

  for (int i = 0; i < V; i++)
  {
    for(auto &e :edges)
    {
      if(path[e.src] == I64_MAX) continue;
      path[e.to] = min(path[e.to],path[e.src] + e.cost);
    }
  }

  for(auto &e:edges)
  {
    if(path[e.src] == I64_MAX)continue;
    if(path[e.src] + e.cost < path[e.to]) return vector<lint>();
  }
  
  return path;
}

void solve()
{
  int V,E,r;
  cin>>V>>E>>r;
  WeightedGraph<lint> G(V);

  Edges<int> es;
  for (int i = 0; i < E; i++)
  {
    int a,b,c;
    cin>>a>>b>>c;
    es.emplace_back(a,b,c);
  }

  vector<lint> path = bellman_ford(es,V,r);
  if(path.empty()) cout<<"NEGATIVE CYCLE"<<endl;
  for(auto & p :path)
  {
    if(p == I64_MAX) cout<<"INF"<<endl;
    else cout<<p<<endl;
  }
  
  

  return;
}

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

  solve();

  return 0;
}



Measured memory_bytes: 3152
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, M;

	public static void main(String[] args) throws Exception {
		while (true) {
			N = sc.nextInt();
			M = sc.nextInt();
			if (N == 0) break;
			sc.nextLine();
			long[] c = new long[M];
			for (int i = 0; i < M; ++i) {
				c[i] = M - i;
			}
			for (int i = 0; i < N; ++i) {
				String line = sc.nextLine();
				for (int j = 0; j < M; ++j) {
					c[j] += ((long) (line.charAt(j * 2) - '0')) << 32;
				}
			}
			Arrays.sort(c);
			for (int i = M - 1; i >= 0; --i) {
				System.out.print(M + 1 - (int) c[i]);
				if (i != 0) System.out.print(' ');
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll x,y;
	cin>>x>>y;
	if(y%2==1){
		cout<<"No"<<endl;
	}
	else{
		if(x*4>=y&&2*x<=y){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}


}

Measured memory_bytes: 3128
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<ll> res, vec[210000];
ll n, m, a, b, d[210000];

void dfs1(ll x){
    d[x] = 1;
    res.push_back(x);
    for (ll i = 0; i < vec[x].size(); i++) {
        if (d[vec[x][i]] == 1) continue;
        dfs1(vec[x][i]);
        break;
    }
}

void dfs2(ll x){
    d[x] = 1;
    res.insert(res.begin(), x);
    for (ll i = 0; i < vec[x].size(); i++) {
        if (d[vec[x][i]] == 1) continue;
        dfs2(vec[x][i]);
        break;
    }
}

int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        cin >> a >> b;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    for (ll i = 1; i <= n; i++) {
        if (vec[i].size() == 0) continue;
        d[i] = 1;
        res.push_back(i);
        dfs1(vec[i][0]);
        for (ll j = 1; j < vec[i].size(); j++) {
            if (d[vec[i][j]] == 1) continue;
            dfs2(vec[i][j]);
            break;
        }
        break;
    }
    cout << res.size() << endl << res[0];
    for (ll i = 1; i < res.size(); i++) {
        cout << ' ' << res[i]; 
    }
}


Measured memory_bytes: 13428
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){  a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=2*1e5+3;
bool f[N];
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      int a[n];
      int s=0;
      for(int i=0;i<n;i++) 
      {
            cin>>a[i];
            s=s^a[i];
      }
      if(s==0)
      {
            cout<<"Yes\n";
      }
      else cout<<"No\n";
}     
// I never lose. I either win or I learn

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;

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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        a_vec: [usize; n],
    }

    let mut bmap: BTreeMap<usize, usize> = BTreeMap::new();
    
    for i in 0..n {
        *bmap.entry(a_vec[i]).or_insert(0) += 1;
    }

    let mut max = 0;
    for (&k, &v) in bmap.iter() {
        let mut t = v + bmap.get(&(k+1)).unwrap_or(&0);
        if k != 0 {
            t += bmap.get(&(k-1)).unwrap_or(&0);
        }

        max = std::cmp::max(max, t);
    }

    println!("{}", max);
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 4968
#include <stdio.h>
#include <string.h>
#define rep(i, n) for(int i=0; i<(int)(n); i++)

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

int M, N;
char f[512][512];

bool click(int x, int y, char target) {
    if(f[x][y]!='.') return false;
    int tx[4], ty[4];
    rep(d, 4) {
        tx[d] = x, ty[d] = y;
        while(f[tx[d]][ty[d]]=='.') {
            tx[d] += dx[d];
            ty[d] += dy[d];
        }
    }
    rep(i, 4) if(f[tx[i]][ty[i]]==target) {
        rep(j, i) if(f[tx[j]][ty[j]]==target) {
            f[tx[i]][ty[i]] = f[tx[j]][ty[j]] = '.';
            return true;
        }
    }
    return false;
}

int xof[32][2], yof[32][2];

int main() {
    scanf("%d%d", &M, &N);
    memset(f, '#', sizeof(f));
    rep(i, M) rep(j, N) scanf(" %c", f[i+1]+j+1);
    memset(xof, -1, sizeof(xof));
    memset(yof, -1, sizeof(yof));
    rep(i, M) rep(j, N) if(f[i+1][j+1]!='.') {
        const int ix = f[i+1][j+1]-'A';
        if(xof[ix][0]==-1) xof[ix][0]=i+1, yof[ix][0]=j+1;
        else xof[ix][1]=i+1, yof[ix][1]=j+1;
    }
    bool nothing = false;
    int ans = 0;
    while(!nothing) {
        nothing = true;
        rep(i, 32) if(xof[i][0]!=-1) {
            bool hit = false;
            if(xof[i][0]==xof[i][1]) {
                hit = click(xof[i][0], (yof[i][0]+yof[i][1])/2, i+'A');
            }
            else if(yof[i][0]==yof[i][1]) {
                hit = click((xof[i][0]+xof[i][1])/2, yof[i][0], i+'A');
            }
            else {
                hit |= click(xof[i][0], yof[i][1], i+'A');
                hit |= click(xof[i][1], yof[i][0], i+'A');
            }
            if(hit) {
                nothing = false;
                xof[i][0] = -1;
                ans += 2;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;  cin >> a >> b;
    cout << (a + b + 1) / 2 << '\n';

    return 0;
}


Measured memory_bytes: 256
s = input()
r = s[::-1]

if s != r:
  print('No')
  exit()
n = len(s)
s1 = s[:int((n-1)/2)]
r1 = s1[::-1]
if s1 != r1:
  print('No')
  exit()
s2 = s[int((n+3)/2)-1:]
r2 = s2[::-1]
if s2 != r2:
  print('No')
  exit()
print('Yes')

Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#include <vector>
#define ME(x , y) memset(x , y , sizeof(x))
#define SF(n) scanf("%d" , &n)
#define rep(i , n) for(int i = 0 ; i < n ; i ++)
#define INF  0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
using namespace std;
typedef long long ll ;
char s[29][29];
int vis[29][29];
int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int xx , yy ;

struct node{
    int x , y , cnt;
};

int bfs(int x , int y)
{
    int ans = 0 ;
    memset(vis , 0 , sizeof(vis));
    node a , b ;
    queue<node>q;
    a.x = x , a.y = y ,a.cnt = 0 ;
    vis[x][y] = 1 ;
    q.push(a);
    while(!q.empty())
    {
        a = q.front();
        q.pop();
        for(int i = 0 ; i < 4 ; i++)
        {
            b.x = a.x + dir[i][0] ;
            b.y = a.y + dir[i][1] ;
            b.cnt = a.cnt + 1 ;
            if(b.x < 0 || b.x >= xx || b.y < 0 || b.y >= yy || vis[b.x][b.y] || s[b.x][b.y] == '#')
                continue;
            vis[b.x][b.y] = 1;
            ans = max(ans , b.cnt);
            q.push(b);
        }
    }
    return ans ;
}


int main()
{

    scanf("%d%d" , &xx , &yy);
    for(int i = 0 ; i < xx ; i++)
    {
        for(int j = 0 ; j < yy ; j++)
        {
            cin >> s[i][j] ;
        }
    }
    int ma = 0 ;
    for(int i = 0 ; i < xx ; i++)
    {
        for(int j = 0 ; j < yy ; j++)
        {
            if(s[i][j] != '#')
            {
                //cout << bfs(i , j) << endl ;
                ma = max(ma , bfs(i , j));
            }
        }
    }
    cout << ma << endl ;
    return 0 ;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ma=max(a)
mi=min(a)
ans=10**9

for i in range(mi,ma+1):
    tm=0
    for j in a:
        tm+=(j-i)**2
    else:
        ans=min(ans,tm)

print(ans)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';

const ll MOD = 1e9 + 7;

int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &&a : A) cin >> a;
  ll sm = 0, ans = 0;
  for (int i = 0; i < N; i++) {
    ans = (ans + sm * A[i] % MOD) % MOD;
    sm = (sm + A[i]) % MOD;
  }
  cout << ans << nl;
  return 0;
}


Measured memory_bytes: 4756
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */


int main() {
    int a,b,k;
    cin >> a>> b >>k;
    vector<int> can;
    rreps(i,100){
        if(a % i ==  0 && b % i == 0) {
            if(!--k){
                cout << i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
import bisect


def main():
    n = int(input())
    a = [int(v) for v in input().split()]
    count = {}
    for i, v in enumerate(a):
        v = i - v
        if count.get(v) is None:
            count[v] = [i]
        else:
            count[v].append(i)

    ans = 0
    for i, v in enumerate(a):
        t = count.get(v+i)
        if t is None:
            continue
        idx = bisect.bisect_right(t, i)
        ans += len(t) - idx

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 123940