akhauriyash/Code-Regression huggingface dataset:
N,W = map(int,input().split())
w = [-1]
v = [-1]
for i in range(N):
    x,y = map(int,input().split())
    w.append(x)
    v.append(y)
INF = 10**11+1
dp = [[INF]*(10**5+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(1,N+1):
    for j in range(0,10**5+1):
        if (j-v[i]>=0):
            dp[i][j] =min(dp[i-1][j],dp[i-1][j-v[i]]+w[i])
        else:
            dp[i][j] = dp[i-1][j]
ans = 10**5
while dp[N][ans]>W:
    ans -= 1
print(ans)

Measured memory_bytes: 147744
#include <stdio.h>
#define LL long long
int st[20],top;
int main(){
	LL n;
	int i;
	scanf("%lld",&n);
	while(n){
		st[++top]=(n-1)%26;
		n--;
		n/=26;
	}
	for(i=top;i>=1;i--)printf("%c",'a'+st[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 1644
def find(A,B,M):
    ans=0
    sofar=0
    C=sorted(zip(A,B))
    #print(C)
    for i in range(len(C)):
        yen,num=C[i]
        if sofar+num<=M:
            ans+=yen*num
            sofar+=num
        else:
            need=M-sofar
            ans+=yen*need
            break
    return ans
A=[]
B=[]
N,M=list(map(int,input().strip().split(' ')))
for _ in range(N):
    a,b=list(map(int,input().strip().split(' ')))
    A+=[a]
    B+=[b]
print(find(A,B,M))

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

int main() {
	vector<string> c;
	for (int i = 0; i < 3; i++) {
		string tmp; cin >> tmp;
		c.push_back(tmp);
	}
	cout << c[0][0] << c[1][1] << c[2][2] << endl;

	return 0;
}

Measured memory_bytes: 256
//テンプレ：

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  ll n;
  cin>>n;
  vector<ll>v1(n);
  vector<ll>v2(n);
  ll count=0;
  for(ll i=0;i<n;i++){
    cin>>v1[i];
    count+=v1[i];
    count%=mod;
    v2[i]=count;
  }
  ll ans=0;
  for(ll j=1;j<n;j++){
    ll  x=(v1[j])*(v2[j-1]);
    x%=mod;
    ans+=x;
    ans%=mod;
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 6372
S_hatena = input()
T_hint = input()

N = len(S_hatena)
ans_list = []

for i in range(N):
    index_init = i
    index_end = i + len(T_hint) - 1
    
    s = S_hatena[index_init:index_end + 1]
    FLAG = True
    
    if (index_end < N):
        for j in range(len(T_hint)):
            if (s[j] != T_hint[j] and s[j] != '?'):
                FLAG = False
                break
    else:
        FLAG = False
    
    if (FLAG):
        tmp_ans = S_hatena[:index_init] + T_hint + S_hatena[index_init + len(T_hint):]
        tmp_ans = tmp_ans.replace('?', 'a')
        ans_list.append(tmp_ans)

ans_list.sort()

if (len(ans_list) > 0):
    print(ans_list[0])

else:
    print('UNRESTORABLE')

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

using namespace std;

typedef long long ll;
ll INF=1e18;

int N,M;
int flg[100005],f[100005];
ll a[100005];
ll r[100005];

int rk[100005];
int cnt[100005];
int prt[100005];

vector<int> rt;

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

void unite(int x,int y){
  int X=find(x); 
  int Y=find(y);
  if(rk[X]<rk[Y]){
    rk[X]=rk[Y];
    prt[X]=Y;
    cnt[Y]++;
  }
  else if(rk[X]>rk[Y]){
    rk[Y]=rk[X];
    prt[Y]=X;
    cnt[X]++;
  }
  else{
    rk[X]++;
    prt[Y]=X;
    cnt[X]++;
  }
}

bool same(int x,int y){
  if(find(x)==find(y)) return 1;
  else return 0;
}

int main() {

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>M;

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

for(int i=0; i<N; i++){
  rk[i]=1;
  cnt[i]=1;
  prt[i]=i;
}

for(int i=0; i<M; i++){
  int x,y;
  cin>>x>>y;
  unite(x,y);
}

for(int i=0; i<N; i++){
  int root=find(i);
  if(!flg[root]){
    flg[root]=1;
    rt.push_back(root);
  }
}

int num=rt.size(); 

if(num==1){
  cout<<0<<endl;
  return 0;
}

if(N<2*(N-1-M)){
  cout<<"Impossible"<<endl;
  return 0;
}

for(int i=0; i<num; i++){
  r[rt[i]]=INF;
}

for(int i=0; i<N; i++){
  int x=find(i);
  if(a[i]<r[x]){
    r[x]=a[i];
    f[x]=i;
  }
}

ll ans=0L;
for(int i=0; i<num; i++){
  ans+=r[rt[i]];
  a[f[rt[i]]]=INF;
}

int n=2*(N-1-M)-num;

sort(a,a+N);

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

cout<<ans<<endl;

}


Measured memory_bytes: 4092
O = input()
E = input()

ans = ''

if len(O)==len(E):
    for i in range(len(O)):
        ans=ans+O[i]
        ans=ans+E[i]
else:
    for i in range(len(O)-1):
        ans=ans+O[i]
        ans=ans+E[i]
    ans=ans+O[len(O)-1]


print(ans)

Measured memory_bytes: 38256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    int n;
    ll y;
    cin >> n >> y;
    int aa = -1, ab = -1, ac = -1;
    forin(a, 0, n + 1) {
        forin(b, 0, n - a + 1) {
            auto c = n - a - b;
            if (a * 10000 + b * 5000 + c * 1000 == y) {
                aa = a;
                ab = b;
                ac = c;
                break;
            }
        }
        if (aa != -1) break;
    }
    cout << aa << ' ' << ab << ' ' << ac << endl;
}



Measured memory_bytes: 256
n, p = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0] * 2 for _ in range(n + 1)]
dp[0][0] = 1

for i, e in enumerate(a, 1):
    for j in range(2):
        r = e % 2
        dp[i][j] = dp[i-1][j] + dp[i-1][(j-r)%2]

print(dp[n][p])


Measured memory_bytes: 3060
#include <iostream>
#include <string>

int h, w;
std::string s[2501];

int main(){

  std::cin >> h >> w;
  for(int i=0; i<h; i++) std::cin >> s[i];

  const int dx[4] = {1, 0, 0,-1,};
  const int dy[4] = {0, 1,-1, 0,};
  std::string ans = "Yes";
  int can = 0;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(s[i][j]=='.') continue;
      can = 0;
      for(int d=0; d<4; d++){

        const int ni = i + dy[d];
        const int nj = j + dx[d];

        if(ni<0 or h<=ni) continue;
        if(nj<0 or w<=nj) continue;
        if(s[ni][nj]=='#') can++;

      }
      if(can==0) {
        ans = "No"; break;
      }
    }
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main()
{
	int n;
	int t = 0;

	cin >> n;
	vector<int> w(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> w[i];
		t += w[i];
	}

	int t2 = t;
	int score;
	for (size_t i = 0; i < n; i++)
	{
		t2 -= w[i];
		if (t2 < (t - t2))
		{
			score = min(t - t2 * 2, (t2 + w[i]) * 2 - t);
			break;
		}
	}
	cout << score << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
int main()
{
	int n;
	cin >> n;
	cout << lcm(n, 2) << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations
MOD = 10**9+7
nn, m = map(int, input().split())
def nCr(n, r, mod):
	r = min(r, n-r)
	numer = denom = 1
	for i in range(1, r+1):
		numer = numer * (n+1-i) % mod
		denom = denom * i % mod
	return numer * pow(denom, mod-2, mod) % mod
ansn = 0
if nn < 2:
	ansn = 0
else:
	ansn = nCr(nn,2,MOD)
if m < 2:
	ansm = 0
else:
	ansm = nCr(m,2,MOD)

print (ansn + ansm)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long a;
  int ans;
  cin >> s >> a;
  bool flag = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '1' && i < a) {
      flag = true;
      cout << s[i] << endl;
      break;
    }
  }
  if (!flag) cout << 1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#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>
#include <climits>
#include <cstring>

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

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

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

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        int a, b;
        cin >> a >> b;
        vector<int> c;
        c.push_back(a + b);
        c.push_back(a - b);
        c.push_back(a * b);

        cout << *max_element(all(c)) << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>

using namespace std;

pair<int, int> solve(string S)
{
    int a = 0, b = 0;
    
    for(int i = 1; i < S.size(); i++)
    {
        if(S[i] == 'A')
        {
            a++;
        }
        else
        {
            b++;
        }
    }
    
    if(a == 10 && a > b) { a++; }
    else if(b == 10 && b < a) { b++; }
    else if(a > b) { a++; }
    else if(a < b) { b++; }
    
    return make_pair(a, b);
}

int main()
{
    while(true)
    {
        string S1, S2, S3;
        
        cin >> S1;
        
        if(S1 == "0") { break; }
        
        cin >> S2 >> S3;
        
        cout << solve(S1).first << ' ' << solve(S1).second << endl;
        cout << solve(S2).first << ' ' << solve(S2).second << endl;
        cout << solve(S3).first << ' ' << solve(S3).second << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3196
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
ans = 0
for i in range(3):
  for j in range(3):
    for k in B:
      if A[i][j] == k:
        A[i][j] = 1
for i in range(3):
  if A[i].count(1) == 3:
    ans += 1
  elif A[0][i] == 1 and A[1][i] == 1 and A[2][i] == 1:
    ans += 1
  elif A[0][0] == 1 and A[1][1] == 1 and A[2][2] == 1:
    ans += 1
  elif A[0][2] == 1 and A[1][1] == 1 and A[2][0] == 1:
    ans += 1
if ans > 0:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    int A[3][3], N, b;
    rep(i, 3){
        rep(j, 3) cin >> A[i][j];
    }
    cin >> N;
    
    rep(k, N){
        cin >> b;
        rep(i, 3){
            rep(j, 3){
                if(A[i][j]==b) A[i][j]=-1;
            }
        }
    }

    bool ans = false;
    rep(i, 3){
        if(A[i][0]+A[i][1]+A[i][2]==-3) ans=true;
    }

    rep(j, 3){
        if(A[0][j]+A[1][j]+A[2][j]==-3) ans=true;
    }
    
    if(A[0][0]+A[1][1]+A[2][2]==-3) ans=true;
    if(A[0][2]+A[1][1]+A[2][0]==-3) ans=true;

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


    return 0;
}

Measured memory_bytes: 256
#include <iostream>

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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())

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

const int FAC = pow(10, 9) + 7;

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

    VI primes;
    map<int, long> prime_count;

    FOR(i, 2, n + 1)
    {
        bool is_prime = true;
        EACH(prime, primes)
        {
            if (i % *prime == 0)
            {
                is_prime = false;
                int incr = 0;
                int I = i;
                while (I % *prime == 0)
                {
                    incr++;
                    I = I / *prime;
                }
                prime_count[*prime] = prime_count[*prime] + incr;
            }
        }
        if (is_prime)
        {
            primes.push_back(i);
            prime_count[i] = 1;
        }
    }

    long ans = 1;
    EACH(p_count, prime_count)
    {
        ans = (ans * ((*p_count).second + 1)) % FAC;
    }

    cout
        << ans << endl;
}

Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#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 CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int tb;
	int ta;
	int sb;
	int ans;
	while (cin>>tb>>ta>>sb,tb){
		ans = 0;
		FOR(i, 1, 1000){
			if (i*(100 + tb) / 100 >= sb)
				break;
			FOR(j, i, 1000){
				if (i*(100 + tb) / 100 + j*(100 + tb) / 100 == sb)
					ans = max(ans, i*(100 + ta) / 100 + j*(100 + ta) / 100);
				if (i*(100 + tb) / 100 + j*(100 + tb) / 100 >= sb)
					break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3076
#include <stdio.h>

int main(){

  int ori,n,j,i,a[1000],l,key;

  scanf("%d",&n); 

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

  for(l=0;l<n-1;l++){
    printf("%d ",a[l]);
  }
  printf("%d\n",a[l]);
   
  for(j=1;j<n;j++){
    key=a[j];
    i=j-1;
    
    while(i>=0 && a[i]>key){
      a[i+1]=a[i];
      i--;
    }
      a[i+1]=key;

      for(l=0;l<n-1;l++){
	printf("%d ",a[l]);
      }
      printf("%d\n",a[l]);  
  }
 
  return 0;
}


    



Measured memory_bytes: 2104
#include<iostream>
#include<utility>
#include<queue>
using namespace std;
typedef pair<int, int> P;

bool is_checked[1001][1001];
char grid[1001][1001];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    queue<pair<P, int> > Q;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == '#') {
                Q.push(make_pair(P(i, j), 0));
                is_checked[i][j] = true;
            }
        }
    }
    int ans = 0;
    while (!Q.empty()) {
        pair<P, int> now = Q.front();
        Q.pop();
        P pos = now.first;
        int num = now.second;
        ans = max(ans, num);
        int dh[4] = {0, 1, 0, -1}, dw[4] = {-1, 0, 1, 0};
        for (int i = 0; i < 4; i++) {
            int now_h = pos.first + dh[i], now_w = pos.second + dw[i];
            if (now_h >= 0 && now_h < H && now_w >= 0 && now_w < W && grid[now_h][now_w] == '.' && !is_checked[now_h][now_w]) {
                Q.push(make_pair(P(now_h, now_w), num + 1));
                is_checked[now_h][now_w] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14352
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}
		
		int[] ans = new int[n];
		for(int i=n-1; 0<=i; i--){
			int total = 0;
			int count = 2;
			int j = (i+1)*count;
			while(j<=ans.length){
				total += ans[j-1];
				count++;
				j = (i+1)*count;
			}
			if(total%2 == 0){
				if(a[i] == 0) ans[i] = 0;
				else ans[i] = 1;
			} else {
				if(a[i] == 0) ans[i] = 1;
				else ans[i] = 0;
			}
		}
		int ansC = 0;
		List<Integer> ansA = new ArrayList<>();
		for(int i=0; i<ans.length; i++){
			if(ans[i] == 1) {
				ansC++;
				ansA.add(i);
			}
		}
		System.out.println(ansC);
		for(int i: ansA){
			System.out.print((i+1)+" ");
		}

	}
}


Measured memory_bytes: 72552
n = int(input())
A = list(map(int,input().split()))
for i in range(1,n):
    print(" ".join(map(str,A)))
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
        
print(" ".join(map(str,A)))
        
            


Measured memory_bytes: 5596
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
const int maxn = 1e5 + 5;

int n, a, b;
ll h[maxn];

bool judge(ll mid) {
	ll midt = mid;
	for (int i = 1; i <= n; i++) {
		ll res = h[i] - mid * b;
		if (res <= 0) continue;
		midt -= res % (a - b) ? res / (a - b) + 1 : res / (a - b);
		if (midt < 0) return false;
	}
	return true;
}


int main() {
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	ll low = 0, high = 1e9;
	while (high > low + 1) {
		ll mid = (low + high) / 2;
		if (judge(mid)) high = mid;
		else low = mid;
	}
	cout << high << endl;
}

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

int main(){
    int n,i,x;
    cin >> n;
    for(i=1;i<=n;i++){
        if(i%3==0){
            cout << " " << i;
        }else{
            x = i;
            while(1){
                if(x%10==3){
                    cout << " " << i;
                    break;
                }
                if(x<10) break;
                x /= 10;

            }

        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3088
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
set<int> s;

int main()
{
    fast;

    int n,m,c,cnt = 0;
    cin >> n >> m >> c;
    vector<int>b(m);
    vector< vector<int> >a(n,vector<int>(m));

    for(int i = 0; i < m; i++)
        cin >> b[i];
    for(int i = 0; i < n; i++)
    {
        int sum = 0;
        for(int j = 0; j < m; j++)
        {
            cin >> a[i][j];
            sum += a[i][j]*b[j];
        }
        if(sum>c*-1)cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int A,B;
  scanf("%d%d",&A,&B);

  if(((A%3)) == 0 | ((B%3)) == 0 | (((A+B)%3) == 0)){
    printf("Possible\n");
  }else{
    printf("Impossible\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (2000L)
#define INF (1000000000000000000L)

using namespace std;

long min_slime_costs[MAX_N][MAX_N];

int main() {
  // read inputs
  long N, x, as[MAX_N];
  scanf("%ld %ld", &N, &x);
  for (long i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }

  // min_slime_costs[k][i] = min(as[i], ..., as[(i - k) mod N])
  for (long i = 0; i < N; i++) {
    min_slime_costs[0][i] = as[i];
  }
  for (long k = 1; k < N; k++) {
    for (long i = 0; i < N; i++) {
      min_slime_costs[k][i] =
          min(as[(N + i - k) % N], min_slime_costs[k - 1][i]);
    }
  }

  // calculate answer
  long ans = INF;
  for (long k = 0; k < N; k++) {
    long ans_k = k * x;
    for (long i = 0; i < N; i++) {
      ans_k += min_slime_costs[k][i];
    }
    ans = min(ans, ans_k);
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 31488
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
	cin>>n;
	m=n/1.08;
	if((int)m*1.08==n) cout<<m<<endl;
	else if((int)((m+1)*1.08)==n) cout<<m+1<<endl;
	else cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
vector<vector<i64>> g;
int main() {
  cin >> n >> m;
  init_n(g, n + 1);
  for (i64 i = 0; i < m; ++i) {
    i64 a, b; cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  set<i64> s;
  for (i64 v : g[1]) s.insert(v);
  for (i64 v : g[n]) {
    if (s.count(v) > 0) {
      cout << "POSSIBLE\n";
      return 0;
    }
  }
  cout << "IMPOSSIBLE\n";
  return 0;
}



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


int main(){
  string A;
  cin >> A;
  int tmp1=A.size(),tmp2=0;
    
  for(int i=0;i<A.size();i++){
    if(A[i] == 'A'){
      if (tmp1>i) tmp1=i;
    }else if(A[i] == 'Z'){
      if(tmp2<i) tmp2=i;
    }else{
      continue;
    }
  }
  tmp1 = tmp2 - tmp1 +1;
    cout << tmp1;

}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static int N = scan.nextInt();
	static int M = scan.nextInt();
	static int dp[]=new int[N];//メモ化
	static int count;







	public static void paint(int v,int c,V vs[]){
		if(dp[v]>=count){return;}//来たことがあってより深くまで塗れないなら帰る
		if(vs[v].color==0){
			vs[v].color=c;
		}
		dp[v]=count;
		if(count>0){
			count--;
			for(int j=0;j<vs[v].size();j++){
				paint(vs[v].get(j),c,vs);
		}
			count++;
		}



	}

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

		V vs[] = new V[N];
		for(int i =0;i<N;i++){
			vs[i] = new V(i);
		}


		int a;
		int b;

		for(int i =0;i<M;i++){
			a=scan.nextInt()-1;
			b=scan.nextInt()-1;

			vs[a].add(b);
			vs[b].add(a);
		}

		int Q = scan.nextInt();
		int v[] = new int[Q];
		int d[] = new int[Q];
		int c[] = new int[Q];

		for(int i =0;i<Q;i++){
			v[i]=scan.nextInt() - 1;
			d[i]=scan.nextInt();
			c[i]=scan.nextInt();
		}

		Arrays.fill(dp, -1);
		//ここから塗りつぶし動作
		for(int i =Q-1;i>=0;i--){
			count = d[i];
					paint(v[i],c[i],vs);

			}

		for(int i=0;i<N;i++){
			System.out.println(vs[i].color);
		}

		}

	static class V extends ArrayList<Integer>{
		int id;
		int color = 0;
		V(int _id){
			id = _id;
		}
	}



	}


Measured memory_bytes: 175576
#include<cstdio>

int main(){
    long long sum;
    int a,b,n,min,max,i;
    sum = 0;
    scanf ("%d",&n);
    scanf("%d\n",&a);
    max = a;
    min = a;
    sum = sum + a;
    for (i = 0;i < n - 1;i++){
    scanf("%d",&b);
        if (max < b){
            max = b;
        }
        if(min > b){
            min = b;
        }
    sum = sum + b;
    }
printf("%d %d %lld\n",min,max,sum);
}



Measured memory_bytes: 2740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll s,c;
    cin >> s >> c;
    if(2*s<=c){//cからsを作れるとき
        cout<< (2*s+c)/4 << endl;
    }else{//Cが足りないとき
        cout << c/2 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    cout << (N + 1) / 2 << endl;
    return 0;
}

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

long long n;
int	dp[19][2];

int main(){
	
	cin>>n;

	long long kk=1e17;

	for(int i=17;i>=0;i--){
		if(kk>n)
			dp[i][0]=-9;
		if(kk<=n)
			dp[i][0]=max(dp[i+1][0]+9,dp[i+1][1]+(int)((n/kk)%10)-1);
		dp[i][1]=dp[i+1][1]+((n/kk)%10);
		kk=kk/10;
	}

	cout<<max(dp[0][1],dp[0][0])<<endl;

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n, m = list(map(int, input().split()))

graph = defaultdict(set)

for _ in range(m):
    a, b = list(map(int, input().split()))
    graph[a].add(b)
    graph[b].add(a)

# 幅優先探索
# https://qiita.com/drken/items/4a7869c5e304883f539b
seen = [False for _ in range(n + 1)]  # 既に道しるべを設置したか? # idx 0 は使わない
todo = set()  # 検知したけどまだ探索してない
ans = defaultdict(int)
seen[1] = True
todo.update(graph[1])
for d in graph[1]:
    ans[d] = 1  # 1と繋がってる部屋の道しるべは1
    seen[d] = True
# 出発ノード
while len(todo) > 0:
    todo_next = set()
    for v in todo:
        for d in graph[v]:
            if seen[d]:
                continue
            seen[d] = True
            todo_next.add(d)
            ans[d] = v
    todo = todo_next

if not all(seen[1:]):
    print("No")
    exit()

print("Yes")
for i in range(2, n + 1):
    print(ans[i])


Measured memory_bytes: 79564
#include<bits/stdc++.h>
using namespace std;
#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
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }



int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  if (s[0] == '7' || s[1] == '7' || s[2] == '7'){
    puts("Yes");
  }
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, m := scanInt(), scanInt()

	a := make([]int, m)
	c := make([]int, m)

	for i := 0; i < m; i++ {
		a[i] = scanInt()
		b := scanInt()
		for j := 0; j < b; j++ {
			in := scanInt()-1
			c[i] += (1<<uint(in))
		}
	}

	dp := make([][]int, m+1)

	for i := 0; i < m+1; i++ {
		dp[i] = make([]int, (1<<uint(n)))
		for j := 0; j < len(dp[i]); j++ {
			dp[i][j] = -1
		}
	}

	dp[0][0] = 0

	for i := 0; i < m; i++ {
		for j := 0; j < (1<<uint(n)); j++ {
			if dp[i][j] == -1 {
				continue
			} else {
				if dp[i+1][j] == -1 {
					dp[i+1][j] = dp[i][j]
				} else {
					dp[i+1][j] = min(dp[i+1][j], dp[i][j])
				}
			}

			if dp[i+1][j|c[i]] == -1 {
				dp[i+1][j|c[i]] = dp[i][j]+a[i]
			} else {
				dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], dp[i][j]+a[i])
			}
		}
	}

	// for i := 0; i < m+1; i++ {
	// 	fmt.Println(dp[i])
	// }

	fmt.Println(dp[m][(1<<uint(n)-1)])
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] { res = a[i] }
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] { res = a[i] }
	}
	return res
}


Measured memory_bytes: 36120
const main = (N,A,B) => {
    if(N*A>B) {
        return B
    }else{
        return N*A
    }
}


const input = require('fs').readFileSync('/dev/stdin','utf8').split("\n")[0]
const lst = input.split(" ").map(x => Number(x))
console.log(main(lst[0],lst[1],lst[2]))

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

char s[2005][2005];
int l[2005][2005],r[2005][2005],o[2005][2005];
int n,m,q,a,b,c,d,A,B,C,D;

int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			o[i][j]=o[i][j-1]+o[i-1][j]-o[i-1][j-1];
			l[i][j]=l[i][j-1]+l[i-1][j]-l[i-1][j-1];
			r[j][i]=r[j][i-1]+r[j-1][i]-r[j-1][i-1];
			if(s[i][j]=='1'){
				o[i][j]++;
				if(s[i][j-1]=='1')++l[i][j];
				if(s[i-1][j]=='1')++r[j][i];
			}
		}
	}
	for(int i=1;i<=q;i++){
		scanf("%d%d%d%d",&A,&B,&C,&D);
		a=min(A,C),b=min(B,D);
		c=max(A,C),d=max(B,D);
		int node=0,line=0;
		node+=o[c][d]-o[c][b-1]-o[a-1][d]+o[a-1][b-1];
		line+=l[c][d]-l[c][b]-l[a-1][d]+l[a-1][b];
		line+=r[d][c]-r[b-1][c]-r[d][a]+r[b-1][a];
		printf("%d\n",node-line);
	}
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int k;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>k;
  int e=(k+1)/2;
  int o=k-e;
  int ans=o*e;
  cout<<ans<<endl;
  

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){
  int N,t,c = 0;
  cin >> N;
  t = N;
  c = t % 10;
  for (int i = 1;i < 9;++i){
    t /= 10;
    c += t % 10;
  }
  if (N % c == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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


signed main(){
    int n;
    cin>>n;
    vector<double>a(n);
    rep(i,0,n)cin>>a[i];
    double ave=accumulate(a.begin(),a.end(),double(0))/n;
    rep(i,0,n)a[i]=abs(a[i]-ave);
  	cout<<min_element(a.begin(),a.end())-a.begin();
}


Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let list_of_string str = range 0 (String.length str) |> List.map (fun i -> str.[i])
let array_of_string str = Array.init (String.length str) (fun i -> str.[i])

let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let lcm a b = a / (gcd a b) * b

let () = read_int () |> read_ints |> List.fold_left lcm 1 |> printf "%d\n"


Measured memory_bytes: 384
#include <stdio.h>

void sort_xy(int x, int y) {
  int n;
  n = x;
  x = y;
  y = n;
}

int main(void) {
  int x, y;
  int v;

  scanf("%d %d", &x, &y);

  if (x < y)
    sort_xy(x, y);
  
  while(x % y != 0) {
    v = x % y;
    x = y;
    y = v;
  }

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



Measured memory_bytes: 2148
_sa = gets.chomp
_sb = gets.chomp
_sc = gets.chomp

$sa = Array.new
$sb = Array.new
$sc = Array.new
(_sa.size).times do |i|
  $sa.push(_sa[i])
end
(_sb.size).times do |i|
  $sb.push(_sb[i])
end
(_sc.size).times do |i|
  $sc.push(_sc[i])
end

turn = "a"
while(true)do
  if(turn=="a")then
    card = $sa[0]
    $sa = $sa[1..-1]
  elsif(turn=="b")then
    card = $sb[0]
    $sb = $sb[1..-1]
  else
    card = $sc[0]
    $sc = $sc[1..-1]
  end

  if(card=="a")then
    if($sa.size==0)then
      puts "A"
      break
    end
  elsif(card=="b")then
    if($sb.size==0)then
      puts "B"
      break
    end
  else
    if($sc.size==0)then
      puts "C"
      break
    end
  end
  turn = card
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e3+2;
vector<int> adj[MX];
int seen[MX], depth[MX];
int prv[MX], st, anslen = 10000;
vector<int> ans;
bool ok;
void dfs(int i) {
	seen[i] = 1;
	for(int a: adj[i]) {
		if(!seen[a]) {
			prv[a] = i;
			depth[a] = depth[i] + 1;
			dfs(a);
		} else if(seen[a] == 1) {
			if(depth[i] - depth[a] < anslen) {
				anslen = depth[i] - depth[a];
				ans = {};
				int cur = i;
				while(cur != a) {
					ans.push_back(cur);
					cur = prv[cur];
				}
				ans.push_back(a);
			}
		}
	}
	seen[i] = 2;
}
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i=0; i<m; i++) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
	}
	for(int i=1; i<=n; i++) {
		st = i;
		memset(seen, 0, sizeof seen);
		memset(depth, 0, sizeof depth);
		dfs(st);
	}
	if(anslen == 10000)
		return !(cout << -1);
	cout << ans.size() << '\n';
	for(int a: ans)
		cout << a << ' ';
}

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

int main() {

	double N,sum=0; cin>>N;
  vector<double> A(N); 
  for(int i=0; i<N; i++){
    cin>>A.at(i);}
  for(int i=0; i<N;i++){
    sum+=1/(A.at(i));}
  
  cout<<1/sum<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mx 100005
vector<vector<int>>v(mx);
vector<bool>vis(mx,0);
map<int,int>mm;
vector<int>dist(mx,0);
void dfs(int root)
{
    if(vis[root]==1)return ;
    vis[root]=1;
    for(int i=0;i<v[root].size();i++)
    {
        mm[v[root][i]]--;dist[v[root][i]]=max(dist[v[root][i]],dist[root]+1);
        if(mm[v[root][i]]==0)
        {
            dfs(v[root][i]);
        }
    }
    
}

int main()
{
    int n,m;cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        int x,y;cin>>x>>y;
        v[x].push_back(y);
        mm[y]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(!vis[i]&&mm[i]==0)
        dfs(i);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
 ans=max(ans,dist[i]); 
 cout<<ans;
}

Measured memory_bytes: 18560
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  string s;
  cin >> s;
  int len = s.length();
  int P = 0;
  REP(i,len) if(s[i] == 'p') P++;
  cout << len/2 - P << endl;
  return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s1,s2,u;
    int g1,g2;
    cin >> s1 >> s2;
    cin >> g1 >> g2;
    cin >> u;
    if(s1==u)
        g1--;
    if(s2==u)
        g2--;
    cout << g1 << " " << g2;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int A,B;
    cin >> A >> B;
    if(A == B) cout << "Draw" << endl;
    else if((A > B  && B != 1) || A == 1) cout << "Alice" << endl;
    else if((A < B && A != 1) || B == 1) cout << "Bob" << endl;
}


Measured memory_bytes: 256
import math
LI = lambda: list(map(int,input().split()) )
MI = lambda: map(int,input().split())
SI = lambda: input()
II = lambda: int(input())
n = II()
a = LI()
count = 0
for i in range(n):
    if a[i]%2 == 1 and i%2 == 0:
        count+=1
print(count)

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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

double f(int x) {
  if(x&1) return (x+1)/2;
  return 0.5+x/2;
}

int main(int argc, char const* argv[])
{
  int n,k;
  cin>>n>>k;
  double sum_ = 0;

  vector<double> ps;
  REP(i,k) {
    int p;
    cin>>p;
    double fp = f(p);
    sum_ += fp;
    ps.push_back(fp);
  }

  double ans = sum_;

  REP(i,n-k) {
    int pos = i%k;
    int p;
    cin>>p;
    double fp = f(p);
    sum_ -= ps[pos];
    ps[pos] = fp;
    sum_ += fp;
    if(ans<sum_) ans = sum_;
  }

  printf("%.10f\n", ans);

  return 0;
}


Measured memory_bytes: 2420
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <iterator>
#include <set>
#include <cmath>
#include <algorithm>
#include <locale>

//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define For(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define F first
#define S second
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define ELM 100001 //問題によっては1000000001に変更

//限定
using namespace std;

signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    incin(n);
    vector<string> a(n);
    int c[5]={0};
    For(n, i){
        cin >> a.at(i);
        if (a[i][0]=='M') {
            c[0]++;
        }else if (a[i][0]=='A') {
            c[1]++;
        }else if (a[i][0]=='R') {
            c[2]++;
        }else if (a[i][0]=='C') {
            c[3]++;
        }else if (a[i][0]=='H') {
            c[4]++;
        }
    }
    int ans=0;
    For(5, i){
        For(5, j){
            For(5, k){
                if (k>j && j>i) {
                    ans+=c[i]*c[j]*c[k];
                }
            }
        }
    }
    Pr(ans);
    return 0;
}



Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N+1);
  for( int i = 0; i < N; i++ ){
    cin >> A.at(i);
    B.at(i+1) = B.at(i) + A.at(i);
  }
  
  int sa = 100000000000000000;
  for( int i = 0; i < N+1; i++ ){
    //cout << sa << endl;
    if( abs( (B.at(N)-B.at(i)) - B.at(i) ) < sa ){
      sa = abs( (B.at(N)-B.at(i)) - B.at(i) );
    }
  }
  cout << sa << endl;
    
    
}

Measured memory_bytes: 3328
<?php
 
fscanf(STDIN, '%d %d', $N, $M);
$point = array_map('intVal', explode(' ', trim(fgets(STDIN))));
 
if ($N >= $M) {
    echo 0;
} else {
    rsort($point);
    $distance = [];
    for ($i = 0; $i < $M-1; ++$i) {
        $distance[] = $point[$i] - $point[$i+1];
    }
    rsort($distance);
    array_splice($distance, 0, $N-1);
    
    echo array_sum($distance);
}

Measured memory_bytes: 19700
#include<iostream>

using namespace std;

int main(void) {
  int a, b;
  cin >> a >> b;
  if (a >= 13) {
    cout << b << endl;
    return 0;
  } else if (a >= 6) {
    cout << b / 2 << endl;
    return 0;
  } else {
    cout << 0 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
import sys
n = int(input())
l = list(map(int,input().split()))
for i in range(n):
    if l[i]==0:
        print(0)
        sys.exit()
ans = 1
for i in range(n):
    ans *= l[i]
    if ans > 1e18:
        print(-1)
        sys.exit()
print(ans)

Measured memory_bytes: 21792
/*=======================================
 * Author : ylsoi
 * Time : 2019.3.4
 * Problem : run
 * E-mail : ylsoi@foxmail.com
 * ====================================*/
#include<bits/stdc++.h>

#define REP(i,a,b) for(int i=a,i##_end_=b;i<=i##_end_;++i)
#define DREP(i,a,b) for(int i=a,i##_end_=b;i>=i##_end_;--i)
#define debug(x) cout<<#x<<"="<<x<<" "
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;

using namespace std;

void File(){
	freopen("run.in","r",stdin);
	freopen("run.out","w",stdout);
}

template<typename T>void read(T &_){
	_=0; T f=1; char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())_=(_<<1)+(_<<3)+(c^'0');
	_*=f;
}

const int maxn=2e6+10;
const int mod=1e9+7;
int n,f[maxn],sum[maxn];
pii a[maxn],b[maxn];
vector<int>t,pos[maxn];

void inc(int &x,int y){
	x+=y;
	if(x>=mod)x-=mod;
	else if(x<0)x+=mod;
}

void work(){
	REP(i,1,n)pos[b[i].se].pb(i);
	f[0]=sum[0]=1;
	REP(i,1,n){
		for(int id:pos[i]){
			inc(f[i],f[i]);
			if(b[id].fi==1)inc(f[i],sum[i-1]);
			else inc(f[i],(sum[i-1]-sum[b[id].fi-2])%mod);
		}
		inc(sum[i]=sum[i-1],f[i]);
	}
	printf("%d\n",f[n]);
}

int main(){
	//File();
	read(n);
	REP(i,1,n){
		read(a[i].fi);
		read(a[i].se),t.pb(a[i].se);
	}

	sort(t.begin(),t.end());
	t.erase(unique(t.begin(),t.end()),t.end());
	REP(i,1,n)a[i].se=lower_bound(t.begin(),t.end(),a[i].se)-t.begin()+1;

	sort(a+1,a+n+1);
	REP(i,1,n)b[i].se=(i==1 ? a[i].se : max(a[i].se,b[i-1].se));
	DREP(i,n,1)b[i].fi=(i==n ? a[i].se : min(a[i].se,b[i+1].fi));
	//REP(i,1,n)printf("%d %d\n",b[i].fi,b[i].se);

	work();

	return 0;
}

Measured memory_bytes: 66676
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int n,k;
  cin>>n>>k;
  if(2 * k - 1 <= n) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[100000];
	rep(i, N) cin >> A[i];

	ll np[100001];
	np[1] = -A[0];
	rep1(i, N - 1) {
		if (i & 1) np[i + 1] = np[i] + A[i];
		else np[i + 1] = np[i] - A[i];
	}
	ll pn[100001];
	pn[1] = A[0];
	rep1(i, N - 1) {
		if (i & 1) pn[i + 1] = pn[i] - A[i];
		else pn[i + 1] = pn[i] + A[i];
	}

	rep(i, N) {
		if (i & 1) {
			ll mae = pn[i];
			ll ato = np[N] - np[i + 1];
			co(mae + ato + A[i]);
		}
		else {
			ll mae = np[i];
			ll ato = pn[N] - pn[i + 1];
			co(mae + ato + A[i]);
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 3328