akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;

const int INF = 2e9;
const double pi = 3.141592653589793238;

int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double s = h*30 + m*0.5;
    double t = m*6;
    double x = min(abs(s-t),(360 - abs(s-t)));
    double c = cos(x/180.0*pi);
    double y = a*a + b*b - 2*a*b*c;
    double ans = pow(y,0.5);
    cout << fixed << setprecision(10) << ans << endl; 
}


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

def rec(x, y, used, TILE):
    if not(0<=x<W) or not(0<=y<H):
        return
    elif used[y][x]==1 or TILE[y][x]=='#':
        return
    else:
        used[y][x] = 1
        rec(x-1, y, used, TILE)
        rec(x+1, y, used, TILE)
        rec(x, y-1, used, TILE)
        rec(x, y+1, used, TILE)

(W, H) = map(int, raw_input().split())
while W!=0:
    used = [[0]*W for i in range(H)]
    TILE = []
    s = []
    for i in range(H):
        TILE.append(raw_input())
    for i in range(H):
        for j in range(W):
            if TILE[i][j] == '@':
                s = [i, j]

    #print s[0], s[1]
    #print used
    #print TILE
    rec(s[1], s[0], used, TILE)
    Sum = 0
    for i in range(H):
        Sum += used[i].count(1)
    print Sum
    #print used.count(1)

    (W, H) = map(int, raw_input().split())

Measured memory_bytes: 4368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

struct state{
	ll d,x,y,dir;
};

bool operator<(const state &a,const state &b){
	return b.d<a.d;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll h,w,k;
	cin>>h>>w>>k;
	ll x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	x1--,y1--,x2--,y2--;
	vector<string> g(h);
	rep(i,h){
		cin>>g[i];
	}
	vector dist(h,vector<vector<ll>>(w,vector<ll>(4,inf)));
	priority_queue<state> que;
	rep(dir,4){
		dist[x1][y1][dir]=0;
		que.push({0,x1,y1,dir});
	}
	vector<int> dx={1,-1,0,0},dy={0,0,1,-1};
	while(!que.empty()){
		auto hoge=que.top();
		que.pop();
		ll d=hoge.d,x=hoge.x,y=hoge.y,dir=hoge.dir;
		if(dist[x][y][dir]<d) continue;
		ll nx=x+dx[dir],ny=y+dy[dir];
		if(0<=nx && nx<h && 0<=ny && ny<w && g[nx][ny]!='@'){
			if(chmin(dist[nx][ny][dir],d+1)){
				que.push({dist[nx][ny][dir],nx,ny,dir});
			}
		}
		rep(ndir,4){
			if(ndir==dir) continue;
			if(chmin(dist[x][y][ndir],(d+k-1)/k*k)){
				que.push({dist[x][y][ndir],x,y,ndir});
			}
		}
	}
	ll ans=inf;
	rep(dir,4){
		chmin(ans,dist[x2][y2][dir]);
	}
	if(ans==inf) cout<<-1<<endl;
	else cout<<(ans+k-1)/k<<endl;
}

Measured memory_bytes: 144940
#include <iostream>

using namespace std;

int main(void){
  int vacation, n;
  int homework = 0;

  cin >> vacation >> n;
  for (int i = 0; i < n; i++)
  {
    int tmp; cin >> tmp;
    homework += tmp;
  }
  
  vacation -= homework;

  if(vacation < 0){
    cout << -1 << endl;
  }else {
    cout << vacation << endl;
  }

  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vc vector
#define a first
#define b second
#define pb push_back
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)

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

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

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

void Main(){
  int a, b, c; cin >> a >> b >> c;
  if((a == b && b != c) || (b == c && a != b) || a == c && a != b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

void change(char *str){
    int len=strlen(str);
    int i;
    for(i=0;i<len;i++){
        if('a'<=str[i]&&str[i]<='z'){
            str[i]-=32;
        }
    }
}

int main(){
    char t[10000];
    char key[10000];
    char eofstr[]={"END_OF_TEXT"};
    int ans=0;

    scanf("%s",key);
    change(key);

    while(1){
        scanf("%s",t);
        if(strcmp(t,eofstr)==0){
            break;
        }
        change(t);
        if(strcmp(t,key)==0){
            ans++;
        }
    }

printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 2040
R,G,B,N = (int(x) for x in input().split())
ans = 0

for i in range(int(N/R)+1):
    a = N-R*i
    for j in range(int(a/G)+1):
        if (a - G*j) % B == 0:
            ans += 1 

print(ans)

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

// 正の数の桁数を取得
int GetDigit( const long long iNum )
{
	// 入力チェック
	if( iNum < 0 )
		return - 1;		// エラー
	else if( iNum == 0 )
		return 0;
	else if( iNum < 10 )
		return 1;
	else if( iNum < 100 )
		return 2;
	else if( iNum < 1000 )
		return 3;
	else if( iNum < 10000 )
		return 4;
	else if( iNum < 100000 )
		return 5;
	else if( iNum < 1000000 )
		return 6;
	else if( iNum < 10000000 )
		return 7;
	else if( iNum < 100000000 )
		return 8;
	else if( iNum < 1000000000 )
		return 9;
	else if( iNum < 10000000000 )
		return 10;
	else if( iNum < 100000000000 )
		return 11;
	else if( iNum < 1000000000000 )
		return 12;
	else if( iNum < 10000000000000 )
		return 13;
	else if( iNum < 100000000000000 )
		return 14;
	else if( iNum < 1000000000000000 )
		return 15;
	else if( iNum < 10000000000000000 )
		return 16;
	else if( iNum < 100000000000000000 )
		return 17;
	else if( iNum < 1000000000000000000 )
		return 18;
	else if( iNum < 1000000000000000000 )
		return 19;
	else
		return 20;
}

int main( int argc, char *argv[] )
{
long long i;
long long N;
double dblRoot;	// 平方根
long long iVal;	// 平方根以上の値である最小の約数

	// N を取得
	cin >> N;
	if( N < 1 || N > 10000000000 ) return 0;

	// 平方根
	dblRoot = sqrt( N );

	// Ti を取得
	iVal = 0;
	for( i = (int) dblRoot; i > 1; i-- )
	{
		if( N % i == 0 )
		{
			iVal = N / i;

			break;
		}
	}

	// 素数の場合
	if( iVal == 0 ) iVal = N;

	// 表示
	cout << GetDigit( iVal ) << endl;

	return 0;
}


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

int main() {
  int N, M, k, a1, a2, b1, b2, c1, c2, d1, d2, e1, e2;
  cin >> N;
  while ( N > 1000) {
    N = N - 1000;
  }
  N = 1000 - N;
  cout << N << endl;
}

Measured memory_bytes: 3652
a,b,c,d = map(int,input().split())

if a >= d or b <= c:
    e = 0
elif a <= c <= b <= d:
    e = b - c
elif c <= a <= d <= b:
    e = d - a
elif a <= c <= d <= b:
    e = d - c
elif c <= a <= b <= d:
    e = b - a

print(e)

Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
X=int(input().rstrip())
maxX=10**6

def resolve():
    check,table=sieve(maxX)

    for a in table:
        if a>=X:
            print(a)
            return

def sieve(n):#n以下の素数を返す, is_prime[i]:iが素数ならtrue、table[i]:小さい順に素数入る
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [ i for i in range(1, n+1) if is_prime[i-1]]
    is_prime=[False]+is_prime ##[False]は勝手につけた、累積和をするときはこの影響で[0]+いらない
    return is_prime, table


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """20"""
        output = """23"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """99992"""
        output = """100003"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 25372
N,K = map(int,input().split())
H = list(map(int,input().split()))
 
def main(N,K,H):
    dp = [0]*N
    for i in range(1,N):
        L = [dp[j]+abs(H[i]-H[j]) for j in range(max(0,i-K),i)]
        dp[i] = min(L)
    print(dp[-1])
main(N,K,H)

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
const int maxm=1e5+5;
const int mod=1e9+7;
int d[maxm][13];
char s[maxm];
int n;
signed main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    if(s[1]!='?'){
        d[1][s[1]-'0']=1;
    }else{//d[1]=='?'
        for(int j=0;j<10;j++){
            d[1][j]=1;
        }
    }
    for(int i=2;i<=n;i++){
        if(s[i]!='?'){
            int x=s[i]-'0';
            for(int j=0;j<13;j++){
                int t=(j*10+x)%13;
                d[i][t]+=d[i-1][j];
                d[i][t]%=mod;
            }
        }else{
            for(int x=0;x<10;x++){
                for(int j=0;j<13;j++){
                    int t=(j*10+x)%13;
                    d[i][t]+=d[i-1][j];
                    d[i][t]%=mod;
                }
            }
        }
    }
    cout<<d[n][5]<<endl;
    return 0;
}
/*

*/


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

 int main() {
   int N, cnt = 0;
   ll sum = 0, mn = 1000000000;

   cin >> N;

   vector<ll> A(N);

   rep(i, 0, N) {
     cin >> A.at(i);
     sum += abs(A.at(i));
     mn = min(mn, abs(A.at(i)));
     if (A.at(i) < 0) cnt++;
   }

   if (cnt % 2 == 0) cout << sum << endl;
   else cout << sum - 2 * mn;
 }


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    int a,b=1;
    for(int i=0;i<n;i++){
         if(i>0)b=a;
         a=min(b*2,b+k);
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc118/tasks/abc118_c
 
// http://ctylim.hatenablog.com/entry/2015/08/30/191553
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstdio>
 
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end()))
#define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end()))
#define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl;
#define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl;
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
 
#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;
 
 
void print() { std::cout << std::endl; }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail){
  std::cout << head << ",";
  print(std::forward<Tail>(tail)...);
}
 
using namespace std;
 
 
int main(int argc, char **argv)
{
  int64_t N;
  int64_t m = 1000000007;
  scanf("%lld", &N);
  char *s1 = new char [N];
  char *s2 = new char [N];
  getc(stdin);
  FOR(i, 0, N){
      s1[i] = getc(stdin);
  }
  getc(stdin);
  FOR(i, 0, N){
      s2[i] = getc(stdin);
  }
 
  int64_t lut[2][2] = {{2,2},{1,3}};
 
  int64_t pre = s1[0] != s2[0];  // 0 : |, 1: =
  int64_t s = pre ? 6 : 3;
  int index = pre ? 2 : 1;
  // print(0, pre, s);
  for(int i=index;i<N;i=i+index){
    int64_t cur = s1[i] != s2[i];
    s = s * lut[pre][cur];
    pre = cur;
    index = cur ? 2 : 1;
    //s = (s > (1ll<<50)) ? s%m : s;
  }
 
  cout << s % m << endl;
 
  free(s1); free(s2);
  return 0;
  }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int check(int n) {
    int sum = 0;
    rep(i, 1000) {
        sum += i;
        if (sum == n) return i;
    }
    return -1;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int k = check(N);
    if (k == -1) {
        cout << "No" << endl;
        return 0;
    }
    vector<int> v[1010];
    int num = 1;
    rep(i, k) {
        REP(j, i, k - 1) {
            v[i].push_back(num);
            num++;
        }
    }
    num = 1;
    REP(i, 1, k) {
        REP(j, i, k) {
            v[j].push_back(num);
            num++;
        }
    }
    cout << "Yes" << endl;
    cout << k + 1 << endl;
    rep(i, k + 1) {
        cout << v[i].size();
        rep(j, k) {
            cout << " " << v[i][j];
        }
        cout << endl;
    }
    
    


    return 0;
}


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

#define MN 1001000

using namespace std;
typedef long long ll;

ll n, ans, a[MN];
vector<pair<int, int>> ff[2];
map<int, int> f[2];

int main() {
    scanf("%lld", &n);

    for(int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        f[i%2][a[i]]++;
    }
    ans = n;

    for(int i = 0; i < 2; i++)
        for(auto tt : f[i])
            ff[i].push_back({tt.second, tt.first});

    ff[0].emplace_back(0, -1);
    ff[1].emplace_back(0, -2);
    sort(ff[0].begin(), ff[0].end(), greater<pair<int, int>>());
    sort(ff[1].begin(), ff[1].end(), greater<pair<int, int>>());

    for(int i = 0; i < 2; i++)
        for(int j = 0; j < 2; j++)
            if(ff[0][i].second != ff[1][j].second)
                ans = min(ans, n - ff[0][i].first - ff[1][j].first);

    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()

int main() {
    set<int> a, b, c;
    int n; cin >> n;
    while (n--) {
        int x; cin >> x; a.insert(x);
    }
    int m; cin >> m;
    while (m--) {
        int x; cin >> x; b.insert(x);
    }
    set_symmetric_difference(all(a), all(b), inserter(c, c.begin()));
    for (auto& x : c) {
        cout << x << endl;
    }
}


Measured memory_bytes: 40596
#include<cstdio>
#include<algorithm>

int main(){
  int n,s,r[20200];
  while(scanf("%d%d",&n,&s),n){
    for(int i=0;i<n;i++)scanf("%d",r+i);
    std::sort(r,r+n);
    int ans = 0;
    for(int i=0;i<n;i++)ans += n - (std::upper_bound(r+i+1,r+n,s-r[i]) - r);
    printf("%d\n",ans);
  }
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n, m;
	while(cin >> n >> m, n+m){
		int idx = 0;

		int r;
		cin >> r;
		vector<vector<int> > v1, v2;
		rep(i, r){
			vector<int> vv(4);
			cin >> vv[2] >> vv[0] >> vv[1] >> vv[3];
			if(vv[3] == 1) v1.push_back(vv);
			else v2.push_back(vv);
		}
		sort(all(v1));
		sort(all(v2));

		int q; cin >> q;
		rep(qq, q){
			bool student[1300]; rep(j, 1300) student[j] = false;
			int a, b, c;
			cin >> a >> b >> c;
			int ret = 0;

			for(int i=0; i< v1.size(); i++){
				if(v1[i][1] == c){
					for(int j = v1[i][2]; j < v2[i][2]; j++) student[j] = true;
				}
			}
			for(int i = a; i < b; i++) if(student[i]) ret++;
			cout << ret << endl;
		}
	}
}

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

using namespace std;

typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define forn(n) for(int i = 0; i < n; i++)
#define print(n) cout << n << "\n"
#define fprint(n) fout << n << "\n"

/*
ID: argnowillac
TASK:
LANG: C++
*/

int a,b,c;
int main()
{
	cin>>a>>b>>c;
  	if(c-(a-b)<0) cout<<0<<endl;
  	else cout<<c-(a-b)<<endl;
    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
a = [[] for _ in range(h)]
for i in range(h):
    a[i] = list(map(int,input().split()))
    for j in range(w):
        a[i][j] %= 2
        
z = []
for i in range(h):
    for j in range(w):
        if i%2 == 0:
            k = j
        else:
            k = (w-1)-j
        z.append((i,k))
        
coin = 0
ans = []
for i in range(h*w-1):
    y,x = z[i]
    yy,xx = z[i+1]
    
    if a[y][x] == 1:
        if coin == 0:
            coin = 1
        else:
            coin = 0
            
    if coin == 1:
        ans.append((y+1,x+1,yy+1,xx+1))
        
print(len(ans))
for i in ans:
    print(*i)

Measured memory_bytes: 85532
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <limits>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

int main(){
    ll n;
    cin >> n;
    ll a[n+1];
    ll a_max = -1;
    rep1(i,n){
        cin >> a[i];
        a_max = max(a[i], a_max);
    }
    ll tmp = 1;
    ll mod = 1e9 + 7;
    ll count = 0;
    rep0(i, 60){
        ll count1 = 0;
        rep1(j, n){
            if((a[j] >> i) & 1) count1++;
        }
        ll tmp_expo =  tmp % mod;
        ll tmp_count1 = (count1*(n-count1)) % mod;
        count += (tmp_expo*tmp_count1) % mod;
        tmp *= 2;
    }
    count %= mod;
    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 5492
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N, long long x, std::vector<long long> a){
  sort(all(a));
  for (int i = 0; i < N; i++) {
    ll n = min(x,a[i]);
    a[i] -= n;
    x -= n;
  }
  if(x > 0)a[N-1] -= x;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if(a[i] == 0)ans++;
  }
  cout << ans << endl;  
}

int main(){
    long long N;
	scanf("%lld",&N);
	long long x;
	scanf("%lld",&x);
	std::vector<long long> a(N);
	for(int i = 0 ; i < N ; i++){
		scanf("%lld",&a[i]);
	}
    solve(N, x, std::move(a));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int MOD = 1e9 + 7;

ll N,M,K,H,W;

int main(){
    cin >> N;
    vector<ll> v(N);
    for(int i = 0; i < N; ++i){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < N-1; ++i){
        if(v[i] == v[i+1]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    rep(i,s.size()) {
        if(s.substr(i,3) == "ABC") {
            cnt++;
        }
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 1000000
using namespace std;
LL read(){
	LL nm=0,fh=1;char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
LL n,m,ans;
char ch[M];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",ch+1),n=strlen(ch+1);
	for(int i=1;i<=n;i++){
		if(ch[i]=='B') m++;
		else ans+=m;
	}
	printf("%lld\n",ans); 
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string str;
    cin >> str;
    while(str.length() > 0){
        str.erase(str.end()-2, str.end());
        string s = str.substr(0,str.length()/2);
        string t = str.substr(str.length()/2);
        if(s == t){
            break;
        }
    }
    cout << str.length() << endl;
    return 0;
}

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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
ll a[3];
                    
int main()
{                                  
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  for (int i = 0; i < 3; i++)
    cin >> a[i];
  ll k; cin >> k;     
                  
  if (k % 2 == 0)
    cout << a[0] - a[1];
  else
    cout << a[1] - a[0];




  return 0;
}






// Coded by Z..



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n";
typedef long long ll;
using namespace std;
void solve(){
    
}
int  main(){
	fastio;
	int n;
	cin>>n;
	char a[4];
	int ac=0;
	int wa=0;
	int tle=0;
	int re=0;
	int i=0;
	while(n--){
		cin>>a;
		if(a[i]=='A'||a[i]=='a'){
			ac++;
		}
		if(a[i]=='w'||a[i]=='W'){
			wa++;
		}
		if(a[i]=='T'||a[i]=='t'){
			tle++;
		}
		if(a[i]=='R'|| a[i]=='r'){
			re++;
		}
	}
	cout<<" AC x "<<ac<<endl;
    cout<<" WA x "<<wa<<endl;	
    cout<<" TLE x "<<tle<<endl;
    cout<<" RE x "<<re<<endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
    int k;
    cin >> k;
    vector<ll> n;
    for (int i = 1;i<10;++i) n.push_back(i);

    for (int i=0;i<n.size();++i){
        for (int j=-1;j<=+1;++j){
            if (n[i]%10 == 0 && j ==-1) continue;
            if (n[i]%10 == 9 && j ==+1) continue;
            n.push_back(n[i]*10+n[i]%10+j);
        }
        if (n.size() > k){
            break;
        }
    }
    cout << n[k-1];
    return 0;
}

Measured memory_bytes: 1400
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int hp = sc.nextInt();
        int kind = sc.nextInt();
        int deathblow[] = new int[kind]; 
        for(int i = 0; i < kind; i++){
        	deathblow[i] = sc.nextInt();
        }
        int offensive = 0;
        for(int i = 0; i < kind; i++){
        	offensive += deathblow[i];
        }
        if(offensive >= hp){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 59556
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            if (Read().Contains('9'))
                Println("Yes");
            else
                Println("No");
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


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

const ll mod=1000000007;

int N;
ll A[200000];
ll T;


ll pw(ll x,int y){
	ll a=1;
	while(y){
		if(y&1){
			a*=x;
			a%=mod;
		}
		x=x*x%mod;
		y/=2;
	}
	return a;
}

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<N;i++){
		T+=A[i];
		T%=mod;
	}
	T*=T;
	T%=mod;
	for(int i=0;i<N;i++){
		T-=A[i]*A[i]%mod;
		T+=mod;
		T%=mod;
	}
	T*=pw(2,mod-2);
	T%=mod;
	cout<<T<<endl;
}


Measured memory_bytes: 5108
import java.util.Scanner;

class Main {
	static int n;
	static int[][] m;
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(true){
			n = scan.nextInt();
			if(n == 0)break;
			m = new int[n][n];
			put(n / 2 + 1, n / 2, 1);
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					System.out.printf("%4d", m[i][j]);
				}
				System.out.println();
			}
		}
	}
	
	static void put(int i, int j, int k){
		if(k > n * n)return;
		if(j == n){
			put(i, 0, k);return;
		}
		if(j < 0){
			put(i, n - 1,k);return;
		}
		if(i == n){
			put(0, j, k);return;
		}
		if(m[i][j] == 0){
			m[i][j] = k;
			put(i + 1, j + 1, k + 1);
		}
		else put(i + 1, j - 1, k);
	}
}

Measured memory_bytes: 27848
#include <cstdio>
#include <cmath>

#include <vector>
#include <queue>
#include <utility>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;
double x[1002], y[1002], r[1002];


std::vector<std::pair<int, double>> vec[1002];
double dist[1002];

template<typename Cost> void dijkstra(int start, std::vector<std::pair<int, Cost>> v[], Cost dist[]) {
	typedef std::pair<int, Cost> PC;
	std::priority_queue<PC, std::vector<PC>, std::greater<PC>> q;
	
	dist[start] = 0;
	q.push(std::make_pair(start, dist[start]));
	while(! q.empty()) {
		PC pc = q.top();
		q.pop();
		if(pc.second != dist[pc.first]) { continue; }
		for(auto && e : v[pc.first]) {
			if(setmin(dist[e.first], dist[pc.first] + e.second)) {
				q.push(std::make_pair(e.first, dist[e.first]));
			}
		}
	}
	
	return;
}

int main() {
	double xs, ys, xt, yt;
	scanf("%lf%lf%lf%lf%d", &xs, &ys, &xt, &yt, &n);
	inc(i, n) { scanf("%lf%lf%lf", &x[i], &y[i], &r[i]); }
	x[n] = xs;
	y[n] = ys;
	r[n] = 0.0;
	x[n + 1] = xt;
	y[n + 1] = yt;
	r[n + 1] = 0.0;
	
	inc(i, n + 2) {
	inc(j, n + 2) {
		double d = max(sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])) - r[i] - r[j], 0.0);
		vec[i].push_back(std::make_pair(j, d));
	}
	}
	
	inc(i, n + 2) { dist[i] = 4e9; }
	dijkstra(n, vec, dist);
	
	printf("%.12f\n", dist[n + 1]);
	
	return 0;
}


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

using namespace std;

int n,k,x[110000],z,mi,hoge,an = 300000000;

int main() {
    cin >> n >> k;
    for (z=0 ; z<n ; z++) {
        cin >> x[z];
        if (x[z] == 0) {
            n--;
            k--;
            z--;
        }else if (x[z] < 0) {
            mi++;
            x[z] *= -1;
        }
    }

    if (mi >= k) {
        an = x[mi-k];
        z = mi-k+1;
    }else z = 0;

    k--;

    if (n-mi > k) an = x[mi+k];
    while (mi > z && z+k < n) {
        if (x[z] >= x[z+k] && an > x[z]+x[z+k]*2) an = x[z]+x[z+k]*2;
        else if(x[z+k] >= x[z] && an > x[z]*2+x[z+k]) an = x[z]*2+x[z+k];

        z++;
    }


    cout << an << "\n";



}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    if(a[0]==b[2] && a[2]==b[0] && a[1]==b[1])
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;


void solve(){
    int n;
    cin >> n;
    int d,x;
    cin >> d >> x;
    int a[n+10];
    rep(i,n){
        cin >> a[i];
    }
    int sum=x;
    rep(i,n){
        if(d%a[i]!=0) sum += d/a[i]+1;
        else sum += d/a[i];
    }
    cout << sum << endl;

}

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


Measured memory_bytes: 256
import numpy as np

N, M = map(int,input().split())

box = np.array([1]*N)#個数
pos = np.array([0]*N)#ありえるか
pos[0] = 1

for i in range(M):
    x, y = map(lambda x:int(x)-1,input().split())
    box[x] -= 1
    box[y] += 1
    if pos[x]:
        pos[y] = 1
        if box[x] == 0:
            pos[x] = 0

#print(box)
#print(pos)

box = np.where(box > 0, 1, 0)
print(sum(pos*box))

Measured memory_bytes: 29744
#include<bits/stdc++.h>
using namespace std;
int main(){
	int i,c,n;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	c=0;
	for(i=1;i<n-1;i++){
		if((a[i+1]<a[i] && a[i-1]>a[i]) || (a[i+1]>a[i] && a[i-1]<a[i])){
			c++;
		}
	}
	cout << c;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n, m, c = sc.nextInt

  val B = (1 to m).map(_ => sc.nextInt)

  val ans = (1 to n)
    .map(_ => (1 to m).map(_ => sc.nextInt))
    .count(A => A.zip(B).foldLeft(0) {case (sum, (a, b)) => sum + a * b} + c > 0 )

  println(ans)

}


Measured memory_bytes: 27460
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
const int mod = 1000000007;
 
int main() {
    int s,w;
    cin >> s >> w;
    if(s-w>0) {
        cout << "safe" << endl;
        return 0;
    } else {
        cout << "unsafe" << endl; 
    }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

bool chmax(ll& a,ll b){if(a<b){a=b;return true;}return false;}

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

  ll N=in<ll>(),K=in<ll>();
  vector<ll> A(N);
  for(auto& x:A) x=in<ll>();
  ll dp[100][2];
  for(auto& x:dp){
     for(auto& y:x) y = -1;
  }
  dp[0][0]=0;
  
  for(int i=0;i<50;i++){
    ll mask = 1LL<<(50-1-i);
    int num=0;
    for(auto& x:A) if(x&mask) num++;
    
    ll cost0 = mask*num;
    ll cost1 = mask*(N-num);
    
    if(dp[i][1]!=-1){
      chmax(dp[i+1][1],dp[i][1]+max(cost0,cost1));
    }
    if(dp[i][0]!=-1){
      if(K&mask){
        chmax(dp[i+1][1],dp[i][0]+cost0);
        chmax(dp[i+1][0],dp[i][0]+cost1);
      }
      else{
        chmax(dp[i+1][0],dp[i][0]+cost0);
      }
    }
  }
  
  cout << max(dp[50][0],dp[50][1]) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
char s[N];
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	scanf("%s",s+1);
	int len=strlen(s+1);
	if(len==2&&s[1]==s[2]){
		printf("1 2\n");
		return 0;
	}
	int l=-1,r=-1;
	for(int i=1;i<len-1;i++){
		if(s[i]==s[i+1]||s[i]==s[i+2]||s[i+1]==s[i+2]){
			l=i,r=i+2;
			break;
		}
	}
	printf("%d %d\n",l,r);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		char c[] = S.toCharArray();
		int a = N;
		sc.close();

		for (int i = 0; i < N - 1; i++) {
			if (c[i] == c[i + 1]) {
				a--;
			}
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 26572
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int n;
    scan(n);

    int pmax = 0;
    int ps = 0;

    foreach (i ; 0 .. n) {
        int pi;
        scan(pi);
        ps += pi;
        pmax = max(pmax, pi);
    }

    ps -= pmax / 2;

    writeln(ps);
}


















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define FASTER ios_base::sync_with_stdio(false); cin.tie(0);
using namespace std;

int main()
{
    FASTER;

    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s < t) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
// finish date: 2018/02/24

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0;
    rep(i, N) {
        ans += A[i] / 2;
        A[i] %= 2;
        if (i != N - 1) {
            if (A[i] && A[i + 1]) {
                ans++;
                A[i]--;
                A[i + 1]--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 640
import sys
import queue
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

d = [[-1,0],[1,0],[0,-1],[0,1]]

H,W = LI()
S = [list(input()) for _ in range(H)]

def bfs(s):
    dist = [[-1]*W for _ in range(H)]
    h,w = s
    dist[h][w] = 0
    que = queue.Queue()
    que.put(s)
    while(not(que.empty())):
        h,w = que.get_nowait()
        for dh,dw in d:
            nh,nw = h+dh,w+dw
            if 0<=nh<H and 0<=nw<W and dist[nh][nw]==-1 and S[nh][nw]=='.':
                dist[nh][nw] = dist[h][w] + 1
                que.put([nh,nw])
    return dist[h][w]

def main():
    ans = 0
    for h in range(H):
        for w in range(W):
            if S[h][w] == '.':
                ans = max(ans,bfs([h,w]))
#                if (((h==0 or S[h-1][w]=='#') or (h==H-1 or S[h+1][w]=='#')) and 
#                        ((w==0 or S[h][w-1]=='#') or (w==W-1 or S[h][w+1]=='#'))):
#                    ans = max(ans,bfs([h,w]))
    print(ans)

if __name__ == "__main__":
    main()



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

#define vi vector<int>
#define pb push_back

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

Measured memory_bytes: 256
main = getLine >>= putStrLn . solve . map read . words

solve (a:b:_)
  | b < 10 = issquare $ 10 * a + b
  | b < 100 = issquare $ 100 * a + b
  | otherwise = issquare $ 1000 * a + b

issquare n = if round (sqrt (fromIntegral n)) ^ 2 == n then "Yes" else "No"

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define SORTA(v,n) sort(v, v + n)
#define SZ(v) (int) v.size()
#define sc(x) scanf("%d",&x)

void open(){
	freopen("D:/Code/in.txt","r",stdin);
	freopen("D:/Code/out.txt", "w", stdout);
}

int wt[120];
int v[120];
int n;
map<ii, int> mapper;
int dp(int idx, int w_left){
	if(idx == n)return 0;
	ii p = ii(idx, w_left);
	if(mapper.find(p) != mapper.end())return mapper[p];

	int ans = dp(idx + 1, w_left);
	if(w_left >= wt[idx]){
		ans = max(ans, dp(idx + 1, w_left - wt[idx]) + v[idx]);
	}

	return mapper[p] = ans;
}

int main(void){
	int w;
	sc(n);sc(w);
	FOR(i,n){
		sc(wt[i]);
		sc(v[i]);
	}

	cout << dp(0, w);
    return 0;
}

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

int main() {
  string input, result;
  cin >> input;
  for(int i = 0; i < input.size(); i++) {
    char c = input.at(i);
    try {
      if(c == 'B') {
      	result.pop_back();
      }
      else {
      	result.push_back(c);
      }
    }
    catch(...) {
      
    }
  }
  cout << result;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){

  int x, y; //総数　足の数
  cin >> x >> y;

  int turu, kame;
  // if(x == 1){
  //   if(2*)
  // }

  REP(i,x+1){
    turu = i;
    kame = x - i;
    if(turu*2+kame*4 == y){
      cout << "Yes" << endl;
      return 0;
    }

  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
 
using namespace std;
 
/* template */
 
using ll = long long;
 
void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
 
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;

vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};
 
/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    vector<ll> a(2),b(2);
    rep(i,0,2){
        cin >> a[i];
    }
    rep(i,0,2){
        cin >> b[i];
    }
    ll ans = a[0]*b[0];
    rep(i,0,2){
        rep(j,0,2){
            chmax(ans,a[i]*b[j]);
        }
    }
    if(a[0]*a[1]<=0 || b[0]*b[1]<0){
        chmax(ans,0ll);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652