akhauriyash/Code-Regression huggingface dataset:
/**
*    created: 05.05.2020 09:17:33
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int main() {
    ll h, w;
    cin >> h >> w;
    ll x = (h + 1LL) / 2LL;
    ll y = (w + 1LL) / 2LL;
    ll xx = h  / 2LL;
    ll yy = w  / 2LL;
    if(h==1||w==1){
        x = 0, y = 0, xx = 1, yy = 1;
    }
    cout << x*y+xx*yy << endl;
}

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

bool comp(const int &r, const int &l) {
    return r % 10 > l % 10;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int food;
    vector<int> div_ten, div_not;
    for (int i = 0; i < 5; i++) {
        cin >> food;
        if (food % 10 == 0) div_ten.push_back(food);
        else div_not.push_back(food);
    }
    int ans = 0;
    for (int i = 0; i < div_ten.size(); i++) {
        ans += div_ten[i];
    }
    if (div_ten.size() == 5) {
        cout << ans << endl;
        return 0;
    }
    sort(div_not.begin(), div_not.end(), comp);
    for (int i = 0; i < div_not.size() - 1; i++) {
        ans += ((div_not[i] + 9) / 10) * 10;
    }
    ans += div_not[div_not.size() - 1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((10 * g + b) % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
  // fail in first test
 int main() {
    int n;
    cin >> n;
    ll x = 1;
    vector<ll> f;
    for(int i = 0; i < n; i++){
       ll m;
       cin >> m;
       f.push_back(m);
    }
    sort(f.begin(), f.end());
    for(auto y : f){
       
       if(static_cast<double>(x) > 1000000000000000000.00/static_cast<double>(y)) {
          cout << -1;
          return 0;
       }
       x *= y;
       if(x > 1000000000000000000){
          cout << -1;
          return 0;
       }
    }
    cout << x;
    return 0;
 }

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

int main(){
  int n, a[105];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  for(int i = 0; i < n-1; i++){
    for (int j = n - 1; j > i; j--){
      if(a[j] > a[j - 1]){
        int x = a[j];
        a[j] = a[j - 1];
        a[j - 1] = x;
      }
    }
  }
  
  int bob = 0, alice = 0;
  for(int i = 0; i < n; i++){
    if(i % 2 == 0){
      alice += a[i];
    }else{
      bob += a[i];
    }
  }
  
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] imos = new int[100003];
        for (int i = 0; i < n; i++) {
            imos[sc.nextInt()]++;
            imos[sc.nextInt() + 1]--;
        }
        int max = 0;
        for (int i = 1; i < imos.length; i++) {
            imos[i] += imos[i - 1];
            if (imos[i] >= i - 1) {
                max = Math.max(max, i - 1);
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 100756
#include <stdio.h>

int main(){
  int n,i,count=0;
  int a[20];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=1;i<n-1;i++){
    if(a[i-1] < a[i] && a[i+1] < a[i]);
    else if(a[i-1] > a[i] && a[i+1] > a[i]);
    else count++;
  }
  printf("%d\n",count);
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<long long> h(n);
  int ans = 0, count = 0;
  for(int i = 0; i < n; i++){
    cin >> h[i];
  }
  for(int i = 0; i < n - 1; i++){
    if(h[i] >= h[i + 1]) count++;
    else{
      ans = max(ans, count);
      count = 0;
    }
  }
  cout << max(ans, count) << endl;
}

Measured memory_bytes: 4044
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        long x=nl();
        long a=100l;
        int c=0;
        while(a<x)
        {
            a=a+(a/100);
            c++;
        }
        pn(c);
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

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

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 32768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int R;
  cin>>R;
  if(R<1200){
    cout<<"ABC"<<endl;
  }
  else if(R<2800){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"AGC"<<endl;
  }
}

Measured memory_bytes: 256
n,m,a,b = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.sort()
y.sort()
if x[-1]<y[0]:
    for i in range(x[-1]+1,y[0]+1):
        if a<i<b:
            print("No War")
            break
    else:
        print("War")
else:
    print("War")

Measured memory_bytes: 9140
# Knapsack問題

# input
N,W = map(int, input().split())
w = []
v = []
for _ in range(N):
    a,b = map(int ,input().split())
    w.append(a)
    v.append(b)

# calc
dp = [[0 for _ in range(W+1)] for _ in range(N+2)]

for i in range(N):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])


Measured memory_bytes: 171656
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	
		int X = sc.nextInt();
      	if(X==7 || X==5|X==3){
        	System.out.println("YES");	
        }else{
          	System.out.println("NO");
        }
      
    }
}

Measured memory_bytes: 22608
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
R = sorted(L)
ans = 0
diff = [L[i] - L[i+1] for i in range(N-1)]

for i in range(N):
    d = 0
    for j in range(i+1, N):
        d += diff[j-1]
        k = bisect.bisect_left(R, d+1)
        ans += max(N-k-1 - j, 0)

print(ans)


Measured memory_bytes: 44380
#include <bits/stdc++.h>  
using namespace std;  
const int maxn=2005;
struct Edge
{
	int	fr,
	    to,  
		next;
}e[2*maxn];
int tot,last[2*maxn];
inline void add(int u, int v)
{
	tot++;
	e[tot].fr=u;
	e[tot].to=v;
	e[tot].next=last[u];
	last[u]=tot;
}

int n,k;
int begin=0,end=0;
int d;
int a[2*maxn];
int ans=0x7fffffff;

inline int dfs(int now,int fa,int deep)
{
    int re=1;
    if(deep==d)
        return 1;
    for(int i=last[now];i;i=e[i].next)
        if(e[i].to!=fa)
            re+=dfs(e[i].to,now,deep+1);
    return re;
}
int main()  
{  
    int x,y;
    cin>>n>>k;
    for(int i=1;i<n;i++)
    {
        cin>>x>>y;
        add(x,y);
        add(y,x);
    }
    d=k/2;   
    
    if(k&1)
        for(int i=1;i<=tot;i++)
            a[i]=dfs(e[i].fr,e[i].to,0)+dfs(e[i].to,e[i].fr,0);
    else
        for(int i=1;i<=n;i++)
            a[i]+=dfs(i,0,0);
    if(k&1)
        for(int i=1;i<=tot;i++)
            ans=min(ans,n-a[i]);
    else
        for(int i=1;i<=n;i++)
            ans=min(ans,n-a[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    int a,b,c,d,e,f,g,i,j,k,l,w,h;
    cin>>h>>w;
    string s[h],t;
    for(a=0;a<h;a++){
        c=1;
        cin>>s[a];
        for(b=0;b<w;b++){
            if(s[a][b]=='#'){
                c=0;
            }
        }
        if(c==1){
            for(d=0;d<w;d++){
                s[a][d]='!';
            }
        }
    }
    for(e=0;e<w;e++){
        c=1;
        for(f=0;f<h;f++){
            if(s[f][e]=='#'){
                c=0;
            }
        }
        if(c==1){
            for(g=0;g<h;g++){
                s[g][e]='!';
            }
        }
    }
    for(i=0;i<h;i++){
        l=0;
        for(j=0;j<w;j++){
            if(s[i][j]!='!'){
                cout<<s[i][j];
                l=1;
            }
        }
        if(l==1){
            cout<<endl;
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

void no(){
	printf("0\n");
	exit(0);
}

#define N 112345
ll a[N];

int main(){
	int n; ll m; scanf("%d%lld", &n, &m);
	REP(i, n) scanf("%lld", a+i);
	
	REP(i, n) if(__builtin_ctz(a[0]) != __builtin_ctz(a[i])) no();
	ll x = 1;
	REP(i, n){
		a[i] /= 2;
		x = x * a[i] / __gcd(x, a[i]);
		if(x > m) no();
	}
	DEBUG("%lld\n", x);

	printf("%lld\n", (m / x + 1) / 2);
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i+=2){
        k--;
        if(k==0){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3+10;
int n, k , cnt[maxn][2], h[maxn],ans=1e9;
bool mark[maxn];
vector<int> veci[maxn];
void dfs(int a){
	for(auto x : veci[a])
		if(mark[x] == 0){
			mark[x]=1;
			h[x]=h[a]+1;
			if(h[x] > k/2)
				cnt[x][0]+=1;
			if(h[x] > (k+1)/2)
				cnt[x][1]+=1;
			dfs(x);
			cnt[a][0]+=cnt[x][0];
			cnt[a][1]+=cnt[x][1];
		}
}
int  check ( int a){
	fill_n(mark , maxn , 0);
	memset(cnt , 0 , sizeof cnt);
	mark[a]=1;
	h[a]=0;
	dfs(a);
	if(k%2 == 0 ){
		int  sum=0;
		for(auto x : veci[a ]){
			sum+= cnt[x][0];
		}
		return sum ;
	}
	int sum =0, maxi =0;
	for(auto x : veci[a]){
		sum+= cnt[x][0];
		maxi= max ( maxi , cnt[x][0] - cnt[x][1]);
	}
	return sum - maxi ; 
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n-1;i++){
		int a, b;cin>>a>>b;
		veci[a].push_back(b);
		veci[b].push_back(a);
	}
	for(int i =1 ;i<= n;i++)
		ans = min ( ans , check(i)  );
	cout<<ans;
}

Measured memory_bytes: 512
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  while(1) {
    int n;
    cin >> n;
    if(!n) break;
    vector<int> v(n);
    for(auto &e: v) cin >> e;
    sort(begin(v), end(v));
    ll sum = 0;
    for(int i = 1; i < n - 1; i++) sum += v[i];
    cout << sum / (n - 2) << "\n";
  }
  return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

//struct edge {
//    int to;
//    int cost;
//};
//
//int dijkstra ( int l, int r, vector<vector<edge>> &g, int n ) {
//    vector<int> cost(n, 1e8);
//    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
//    cost[l] = 0;
//    que.push(make_pair(0, l));
//    bool ok = false;
//    while(!que.empty()) {
//        pair<int, int> now = que.top();
//        cout << now.first << " " << now.second << endl;
//        que.pop();
//        int v = now.second;
//        if ( cost[v] < now.first ) continue;
//        for ( auto u : g[v] ) {
//            if ( u.cost + cost[v] < cost[u.to] ) {
//                cost[u.to] = u.cost + cost[v];
//                que.push(make_pair(cost[u.to], u.to));
//            }
//        }
//    }
//    return cost[r];
//}

const int N = 1000002;
int n, m;
vector<bool> mark(N);
vector<vector<pair<ll, ll>>> g(N);
vector<ll> cost(N, 1e18);

//void dfs ( ll v, vector<bool> mark, vector<vector<pair<ll, ll>>> &g, vector<ll> &cost ) {
void dfs ( ll v ) {
    mark[v] = true;
//    for ( auto u : g[v] ) {
    for ( int i = 0; i < g[v].size(); ++i ) {
//        ll to = u.first;
//        ll len = u.second;
        ll to = g[v][i].first;
        ll len = g[v][i].second;
        if ( cost[to] == 1e18 ) {
            cost[to] = cost[v] + len;
        }
        if ( cost[to] != cost[v] + len ) {
            cout << "No" << endl;
            exit(0);
        }
        if ( !mark[to] ) {
//            dfs(to, mark, g, cost);
            dfs(to);
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
//    vector<vector<pair<ll, ll>>> g(n);
//    vector<bool> mark(n+1, false);
//    vector<ll> cost(n+1, 1e18);
    rep(i, m) {
        ll l, r, d;
        cin >> l >> r >> d;
//        --l, --r;
        g[l].push_back({r, d});
        g[r].push_back({l, -d});
    }
//    rep(i, n) {
    for ( int i = 1; i <= n; ++i ) {
        if ( !mark[i] ) {
            cost[i] = 0LL;
//            dfs(i, mark, g, cost);
            dfs(i);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 45696
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x;
    cin>>n>>d>>x;
    int sum=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        sum+=(d-1)/a+1;
    }
    cout<<sum+x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define BIGINT_LEN 420
using ll=long long;
using ull=unsigned long long;
struct BigInt{
  ull a[BIGINT_LEN]={};
  BigInt lshift(ll n){
    BigInt result{};
    ll ashift=n/64;
    ll shift=n%64;
    for(int i=BIGINT_LEN-1;i>=0;i--){
      if(i+ashift>=BIGINT_LEN)continue;
      result.a[i+ashift]|=a[i]<<shift;
      if(shift!=0&&i+ashift+1<BIGINT_LEN){
	result.a[i+ashift+1]|=a[i]>>(64-shift);
      }
    }
    return result;
  }
  BigInt rshift(ll n){
    BigInt result{};
    ll ashift=n/64;
    ll shift=n%64;
    for(int i=0;i<BIGINT_LEN;i++){
      if (i-ashift<0)continue;
      result.a[i-ashift]|=a[i]>>shift;
      if(shift!=0&&i-ashift-1>=0){
	result.a[i-ashift-1]|=a[i]<<(64-shift);
      }
    }
    return result;
  }
  void OR(BigInt rhs){
    for(int i=0;i<BIGINT_LEN;i++){
      a[i]|=rhs.a[i];
    }
  }
  int minBit(){
    for(int i=BIGINT_LEN/2;i<BIGINT_LEN;i++){
      for(int j=0;j<64;j++){
	if(a[i]&(1<<j)){
	  return (i-BIGINT_LEN/2)*64+j;
	}
      }
    }
    return -1;
  }
};

BigInt dp[80][80];


void solve(ll H, ll W, std::vector<std::vector<ll>> A, std::vector<std::vector<ll>> B){
  {
    BigInt bi;
    bi.a[BIGINT_LEN/2]=1;
    ll s=abs(A[0][0]-B[0][0]);
    dp[0][0].OR(bi.lshift(abs(s)));
    dp[0][0].OR(bi.rshift(abs(s)));
  }
  for(int i=1;i<H;i++){
    ll s=abs(A[i][0]-B[i][0]);
    dp[i][0].OR(dp[i-1][0].lshift(s));
    dp[i][0].OR(dp[i-1][0].rshift(s));
  }
  for(int j=1;j<W;j++){
    ll s=abs(A[0][j]-B[0][j]);
    dp[0][j].OR(dp[0][j-1].lshift(s));
    dp[0][j].OR(dp[0][j-1].rshift(s));
  }
  for(int i=1;i<H;i++){
    for(int j=1;j<W;j++){
      ll s=abs(A[i][j]-B[i][j]);
      dp[i][j].OR(dp[i-1][j].lshift(s));
      dp[i][j].OR(dp[i-1][j].rshift(s));
      dp[i][j].OR(dp[i][j-1].lshift(s));
      dp[i][j].OR(dp[i][j-1].rshift(s));
    }
  }
  cout<<dp[H-1][W-1].minBit()<<endl;
}

int main(){
  ll H;
  scanf("%lld",&H);
  ll W;
  scanf("%lld",&W);
  std::vector<std::vector<ll>> A(H, std::vector<ll>(W));
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      scanf("%lld",&A[i][j]);
    }
  }
  std::vector<std::vector<ll>> B(H, std::vector<ll>(W));
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      scanf("%lld",&B[i][j]);
    }
  }
  solve(H, W, std::move(A), std::move(B));
  return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  
  string a_ij;
  vector<string> line(W+2,"#");
  
  for (int i=0;i<W+2;i++)
    cout << line.at(i); cout << endl;
  
  for (int i=0;i<H;i++){
    cout << "#";
    cin >> a_ij;
    for (int j=0;j<W;j++){
      cout << a_ij.at(j);
    }
    cout << "#" << endl;
  }
  for (int i=0;i<W+2;i++)
    cout << line.at(i); cout << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>
#include<stdlib.h>
 
struct P{
  int key;
  struct P *prev,*next;
};
typedef struct P* node;
node F,L;
 
void insert(int x) {
  node z=F->next;
  node v=malloc(sizeof(struct P));
  v->key=x;
  F->next=v;
  v->prev=F;
  v->next=z;
  z->prev=v;
}
 
void delete(int x) {
  node z=F;
  while(z->key!=x && z!=L) z=z->next;
  node l=z->prev,r=z->next;
  l->next=r;
  r->prev=l;
}
 
void deleteF() {
  node z=F->next->next;
  F->next=z;
  z->prev=F;
}
 
void deleteL() {
  node z=L->prev->prev;
  L->prev=z;
  z->next=L;
}
 
int main() {
  int n;
  scanf("%d",&n);
  char c[10];
  int x;
  F=malloc(sizeof(struct P));
  L=malloc(sizeof(struct P));
  F->next=L;F->prev=F;
  L->prev=F;L->next=L;
  while(n--) {
    scanf("%s",c);
    if(c[0]=='i') {
      scanf("%d",&x);
      insert(x);
    } else if(c[6]=='F') deleteF();
    else if(c[6]=='L') deleteL();
    else {
      scanf("%d",&x);
      delete(x);
    }
  }
  node z=F->next;
  while(z!=L) {
    if(z!=F->next) printf(" ");
    printf("%d",z->key);
    z=z->next;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 36088
N = int(input())
h = list(map(int,input().split()))
h = [0] + h
ans = 0

while(sum(h)>0):
    for i in range(N):     
        if h[i] == 0 and h[i+1] > 0:
            ans += 1
    for i in range(N+1):
        if h[i] > 0:
            h[i] -= 1
print(ans)  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long A, long long B, long long K){
	ll res = 0;
	ll i = 100;
	ll c = 0;
	while(c<K) {
		if (A%i==0 && B%i==0) {
			res = i;
			c++;
		}
		i--;
	}
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
import queue
import numpy as np
import math

N, M = map(int, input().split())
a2 = list(map(int, input().split()))
a = []
for i in a2:
    a.append(i//2)

lcm = a[0]

for i in a:
    lcm *= i // math.gcd(lcm, i)

hasAns = True
for i in a:
    if (lcm // i) % 2 == 0:
        hasAns = False
        break

ans = 0

if hasAns:
    ans = ((M // lcm) + 1 )// 2

print(ans)

Measured memory_bytes: 38388
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  vector<int> x(5); REP(i, 5) cin >> x[i];
  cout << find(ALL(x), 0) - x.begin() + 1 << '\n';
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>

#define ll long long
using namespace std;

const ll M = 998244353;
const ll N = (ll)(1e7+5);

ll fac[N];
ll ifac[N];

ll pow(ll b, ll p) {
  if (!p) return 1;
  if (p%2) return (b*pow(b,p-1))% M;
  ll a = pow(b, p/2);
  return (a*a)%M;
}

void work() {
  fac[0] = 1;
  for (ll i = 1; i < N; i++) {
    fac[i] = (fac[i-1] * i) % M;
  }
  ifac[N-1] = pow(fac[N-1], M-2);
  for (ll i = N-2; i >= 0; i--) {
    ifac[i] = (ifac[i+1] * (i+1)) % M;
  }
}

ll nCk(ll n, ll k) {
  return (((fac[n]*ifac[k]) % M) * ifac[n-k]) % M;
}


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

  ll ret = 0;
  ll p2 = 1;
  for (ll i = n; i >= n/2 + 1; i--) {
    ret = (ret + 2*nCk(n, i) * p2) % M;
    p2 = (p2+p2)%M;
  }
  ret = (pow(3, n) - ret + M) % M;
  cout << ret << endl;
}

Measured memory_bytes: 156544
import sys
HAND=["null","one pair","two pair","three card","straight","full house","four card"]
for line in sys.stdin.readlines():
    cards=sorted(map(int,line.strip().split(",")))
    switch=len(set(cards))
    ma=cards.count(max(cards,key=lambda c:cards.count(c)))
    if switch==4:print HAND[1]
    elif switch==3:
        if ma==2:print HAND[2]
        else:print HAND[3]
    elif switch==2:
        if ma==4:print HAND[6]
        else:print HAND[5]
    else:
        if cards==[1,10,11,12,13] or len(set([cards[i+1]-cards[i] for i in xrange(4)]))==1:print HAND[4]
        else:print HAND[0]

Measured memory_bytes: 23000
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846

void solve()
{
    int h,w;cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++)
        cin>>s[i];
    int dp[h][w];
    memset(dp,0,sizeof(dp));
    bool f=false;
    for(int i=0;i<w;i++)
    {
        if(s[0][i]=='.' && f==false)
            dp[0][i]=1;
        else
        {
            f=true;
            dp[0][i]=0;
        }
    }
    f=false;
    for(int i=0;i<h;i++)
    {
        if(s[i][0]=='.' && f==false)
            dp[i][0]=1;
        else
        {
            f=true;
            dp[i][0]=0;
        }
    }
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(s[i][j]=='.')
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%div;
            else
                dp[i][j]=0;
        }
    }
    cout<<dp[h-1][w-1]<<nl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 9088
#include<iostream>
using namespace std;
int main(){

    int W,H,x,y,r,a = 0;
    
    cin >> W >> H >> x >> y >> r;
    
    if(x-r >= 0){
        if(y-r >= 0){
            if(W-x >= r){
                if(H-y >= r){
                    cout <<"Yes\n";
                    a = 1;
                }
            }
        }
    }
    if(a == 0)
        cout <<"No\n";
    
    return 0;

}



Measured memory_bytes: 3092
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}



lint N, A[100010];

void isno() {
	puts("NO");
	exit(0);
}

void isyes() {
	puts("YES");
	exit(0);
}

void solve() {
	lint div = (N + 1) * N / 2;
	lint sum = accumulate(A, A + (int)N, lint());
	
	if (sum % div > 0) isno();
	
	lint k = sum / div;
	lint minA = *min_element(A, A + (int)N);
	lint maxA = *max_element(A, A + (int)N);
	
	if (minA < k || maxA < N) {
		puts("NO");
		exit(0);
	}
	
	vector< lint > sub;
	for_(i,0,N) sub.push_back(A[(i + 1) % N] - A[i]);
	
	lint sum_k = 0;
	for_(i,0,N) {
		lint poyo = k - sub[i];
		if (poyo % N > 0) isno();
		sum_k += poyo / N;
	}
	
	if (sum_k != k) isno();
	isyes();
}

int main() {
	cin >> N;
	for_(i,0,N) cin >> A[i];
	solve();
}

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


int main(){
  int n, ans = 0;
  cin >> n;
  for(int a = 1; a < n; a++){
    for(int b = 1; b <= n / a; b++){
      if(1 <= a * b && a * b <= n - 1){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int a,b; cin >> a >> b;
  string x = to_string(a);
  string y = to_string(b);

  string xx = "";
  string yy = "";

  for(int i=1;i<=b;i++) xx+=x;
  for(int i=1;i<=a;i++) yy+=y;

  if(xx<yy) cout << xx;
  else cout << yy;


  

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
int main(){

    int h,n;
    cin>>h>>n;
    int arr[n];
    fo(i,n) cin>>arr[i];
    fo(i,n){
        h-=arr[i];
        if(h<=0) {cout<<"Yes"; return 0;}
    }
    cout<<"No"<<endl;

}

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


int main(){
  while(1){
    int H,W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;


  for(int i=0;i<H;i++){
   for(int j=0;j<W;j++){
   cout<<"#";
   }
  cout<<endl;
  }
 cout<<endl;
 }


  return 0;
}


Measured memory_bytes: 3080
import java.util.*;

class Graph1 {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	private int[] discover = new int[totalVertex];
	private int time;
	private boolean[] visit = new boolean[totalVertex];
	private int[] finish = new int[totalVertex];
	//adjacency list of edges
	public Graph1() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		discover = new int[totalVertex];
		time = 0;
		visit = new boolean[totalVertex];
		finish = new int[totalVertex];
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void dfs(int cur) {
	    discover[cur] = ++time;
	    visit[cur] = true;
	    int size = adjList.get(cur).size();
	    for (int i = 0; i < size;i++) {
	        int v = adjList.get(cur).get(i);
	        if (visit[v] == false) {
	            dfs(v);
	        }
	      }
	    finish[cur] = ++time;

	}
	
	public void print() {
		for (int i = 0; i < totalVertex;i++) {
            if(!visit[i]) {
            	dfs(i);
            }
        } 
        for (int i = 1; i <= totalVertex;i++) {
        	System.out.println(i + " " + discover[i-1] + " " + finish[i-1]);
        }
	}
}


public class Main {
	
	public static void main(String argv[]) {
		Graph1 g = new Graph1();
		g.loadAdjList();
		g.print();
	}

}



Measured memory_bytes: 28340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll h;
	cin >> h;

	ll cnt = 0;
	while(h > 0){
		cnt++;
		h /= 2;
	}
	cout << (1ll<<cnt)-1 << endl;

	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.container.rbtree;

class Heap(T) {
  private:
    T [] a;
    int [] h;
    int [] g;
    int n;
    int size;
  final void heapifyFront (int k) pure nothrow @nogc {
    immutable he = h[k];
    int i = k;
    int j = i << 1;
    while (j <= size) {
      if (j < size && a[h[j+1]] < a[h[j]]) {
        j++;
      }
      if (a[h[j]] >= a[he]) {
        break;
      }
      h[i] = h[j];
      g[h[i]] = i;
      i = j;
      j = i << 1;
    }
    if (i != k) {
      h[i] = he;
      g[he] = i;
    }
  }
  final void heapifyBack (int k) pure nothrow @nogc {
    immutable he = h[k];
    int i = k;
    while (i > 1) {
      int j = i >> 1;
      if (a[he] >= a[h[j]]) {
        break;
      }
      h[i] = h[j];
      g[h[i]] = i;
      i = j;
    }
    if (i != k) {
      h[i] = he;
      g[he] = i;
    }
  }
  final void insert (int i) pure nothrow @nogc {
    h[++size] = i;
    g[i] = size;
    heapifyBack (size);
  }
  public:
  final void decreaseKey (int k, T value) pure nothrow @nogc in {
    assert (k >= 0 && k < n);
    assert (value < a[k]);
  } body {
    a[k] = value;
    immutable pos = g[k];
    if (!pos) {
      insert (k);
    } else {
      heapifyBack (pos);
    }
  }
  final void update (int k, T value) pure nothrow @nogc in {
    assert (k >= 0 && k < n);
  } body {
    immutable pos = g[k];
    if (!pos) {
      a[k] = value;
      insert (k);
    } else if (value < a[k]) {
      a[k] = value;
      heapifyBack (pos);
    } else if (value > a[k]) {
      a[k] = value;
      heapifyFront (pos);
    }
  }
  final int extractMin () pure nothrow @nogc {
    assert (size > 0);
    immutable he = h[1];
    g[he] = 0;
    if (--size) {
      h[1] = h[size+1];
      g[h[1]] = 1;
      heapifyFront (1);
    }
    return he;
  }

  inout(T) opIndex (size_t index) pure nothrow @nogc inout {
    return a[index];
  }

  @property
  bool empty () const pure nothrow @nogc { return size == 0; }

  this (int n_, T default_value = T.init) {
    n = n_;
    size = 0;
    a = uninitializedArray! (T[]) (n);
    a[] = default_value;
    h = new int[n+1];
    g = new int[n];
  }
}

void main() {
  int n;
  readf (" %d", &n);
  auto c = new int[n];
  auto d = new int[n];
  auto edges = new RedBlackTree!int[n];
  foreach (i; 0 .. n) {
    edges[i] = new RedBlackTree!int ();
  }
  foreach (edgeId; 1 .. n) {
    int i, j;
    readf (" %d %d", &i, &j);
    --i; --j;
    d[i]++;
    d[j]++;
    edges[i].insert(j);
    edges[j].insert(i);
  }
  foreach (i; 0 .. n) {
    readf (" %d", &c[i]);
  }
  c.sort ();
  auto h = new Heap!int (n, int.max); 
  foreach (i; 0 .. n) {
    h.decreaseKey (i, d[i]);
  }
  long r;
  auto color = new int[n];
  foreach (cost; c) {
    immutable i = h.extractMin ();
    color[i] = cost;
    immutable j = edges[i].front;
    edges[j].removeKey (i);
    h.decreaseKey (j, h[j] - 1);
    r += cost;
  }
  writeln (r - c.back);
  writefln ("%(%s %)", color);
}



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

int main()
{
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> costs(n);
    vector<vector<int>> vec(n,vector<int>(m));
    for(int i = 0; i < n; ++i)
    {
        cin >> costs[i];
        for(int j = 0; j < m; ++j)
        {
            cin >> vec[i][j];
        }
    }

    int lim = pow(2,n);
    int cost = 12000000;
    for(int i = 0; i < lim; ++i)
    {
        int t = i;
        vector<int> checker(m);
        int idx = 0;
        int tcost = 0;
        while(t > 0)
        {
            int tt = t%2;
            t /= 2;
            if(tt!=1)
            {
                ++idx;
                continue;
            }
            for(int j = 0; j < m; ++j)
            {
                checker[j] += vec[idx][j];
            }
            tcost += costs[idx];
            ++idx;
        }
        bool result = true;
        for(int j : checker)
        {
            if(j < x)
            {
                result = false;
            }
        }
        if(result)
        {
            cost = min(cost, tcost);
        }
    }
    if(cost == 12000000)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << cost << endl;
    }
}

Measured memory_bytes: 4112
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    if(b-a+1<=k*2)rep(i,a,b+1)cout<<i<<"\n";
    else{
        rep(i,a,a+k)cout<<i<<"\n";
        rep(i,b-k+1,b+1)cout<<i<<"\n";
    }
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;
const int m=100010;

int t[m],x[m],y[m];

int main(){

  int n;cin>>n;
  rep(i,0,n)cin>>t[i]>>x[i]>>y[i];

  if(n==1){

    if(t[0]>=x[0]+y[0]&&t[0]%2==(x[0]+y[0])%2)out("Yes")
    else out("No")

    return 0;
  }

  bool e=true;

  rep(i,0,n-1){
    int dift=abs(t[i+1]-t[i]);
    int dis=abs(x[i+1]-x[i]+y[i+1]-y[i]);

    if(dift>=dis){
      if(dift%2!=dis%2){
        e=false;
        break;
      }
    }else {
      e=false;
      break;
    }
  }
  if(e)out("Yes")
  else out("No")

  return 0;
}


Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
N = int(input())

counter = 0
for number in range(1, N + 1):
    if len(str(number)) % 2 != 0:
        counter += 1

print(counter)



# def main():

# if __name__ == '__main__':
#     main()


Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(200000)

H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(input())


dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]

used = [[False for _ in range(W)] for _ in range(H)]


def dfs(x, y):
    global nb, nw
    if S[y][x] == '#':
        nb += 1
    if S[y][x] == '.':
        nw += 1
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if nx < 0 or nx >= W or ny < 0 or ny >= H:
            continue
        if used[ny][nx]:
            continue
        if S[y][x] == '#' and S[ny][nx] == '#':
            continue
        if S[y][x] == '.' and S[ny][nx] == '.':
            continue
        used[ny][nx] = True
        dfs(nx, ny)

ans = 0
for i in range(H):
    for j in range(W):
        if not used[i][j]:
            used[i][j] = True
            nb = 0
            nw = 0
            dfs(j, i)
            ans += nb*nw
print(ans)


Measured memory_bytes: 148212
sx, sy, tx, ty = map(int, input().split())
h, w = (ty-sy), (tx-sx)
inner_route = "U"*h+"R"*w+"D"*h+"L"*w
outer_route = "L"+"U"*(h+1)+"R"*(w+1)+"D"
outer_route += "R"+"D"*(h+1)+"L"*(w+1)+"U"
print(inner_route+outer_route)


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

int n;
LL A[200005], B[200005];

int main(){
  scanf("%d",&n);
  for ( int i = 0; i < n; i++ ) scanf("%lld %lld",&A[i],&B[i]);
  sort(A,A+n);
  sort(B,B+n);
  if ( n & 1 ){
    printf("%lld\n",B[n/2] - A[n/2] + 1 );
  } else {
    LL a = (A[n/2-1] + A[n/2]);
    LL b = (B[n/2-1] + B[n/2]);
    printf("%lld\n",b-a+1);
  }
  return 0;
}







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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9 + 7)

ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for (ll m = MOD - 2; m > 0; m /= 2)
    {
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}

ll N, K;
ll A[30];
ll dp[22][1010], dp2[22][1010];
ll Fa[20202],iFa[20202];
ll i, j, k, ans;

ll C(const ll& a,const ll& b){
    return Fa[a] * iFa[b] % MOD * iFa[a - b] % MOD;
}

int main(){
    scanf("%lld%lld", &N, &K);
    fornum(i,0,K){
        scanf("%lld", &A[i]);
    }

    Fa[0] = iFa[0] = 1;
    fornum(i,0,20002){
        Fa[i + 1] = Fa[i] * (i + 1) % MOD;
        iFa[i + 1] = moddiv(1, Fa[i + 1]);
    }

    dp[0][0] = 1;
    fornum(i,0,K){
        fornum(j,0,N+1){
            fornum(k,0,N+1){
                if(j+k>N)
                    break;
                if(k>A[i])
                    break;
                dp[i + 1][j + k] += dp[i][j] * C(N-j, k) % MOD * C(N - k, A[i] - k) % MOD;
                dp[i + 1][j + k] %= MOD;
            }
        }
    }
    printf("%lld", dp[K][N]);

    return 0;
}

Measured memory_bytes: 768
def check(n, k, W, P):
    i = 0
    for _ in range(k):
        capacity = 0
        while capacity + W[i] <= P:
            capacity += W[i]
            i += 1
            if i == n:
                return n
    return i

def solve(n, k, W):
    left = 0
    right = (10 ** 5) * (10 ** 5)
    mid = 0
    while (right - left) > 1:
        mid = (right + left) // 2
        v = check(n, k, W, mid)
        if v >= n:
            right = mid
        else:
            left = mid
    return right

n, k = map(int, input().split())
W = [int(input()) for _ in range(n)]
print(solve(n, k, W))



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

int32_t main(){
    int a,b,c,k;cin>>a>>b>>c>>k;
    int ans=0;
    if(k<=a){
        ans+=k;
        cout<<ans<<"\n";
        exit(0);
    }
    else ans=a,k-=a;

    if(k<=b){
        cout<<ans<<"\n";
        exit(0);
    }
    else k-=b;

    ans-=k;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3636
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    println(problem148e(n))
}

fun problem148e(n: Long): String {
    if (n % 2 != 0L) return "0"
    var n = n / 2L
    var res = 0L
    while (n != 0L) {
        res += n / 5
        n /= 5
    }
    return res.toString()
}

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

using namespace std;

const long long mod = 1e9 + 7;

long long fact[2000006];
long long revfact[2000006];

long long Bin(long long a, long long n) {
	if (n == 0) return 1;
	long long l = Bin(a, n / 2);
	l = l * l % mod * ((n & 1) ? a : 1) % mod;
	return l;
}

long long rev(long long n) {
	return Bin(n, mod - 2);
}

long long C(long long k, long long n) {
	//if (k == 0) return n;
	long long res = fact[n] * revfact[k] % mod * revfact[n - k] % mod;
	return res;
}

long long f(long long n, long long m) {
	//cout<<n<<" "<<m<<"\n";
	if (n < 0 || m < 0) return 0LL;
	/*vector < long long > s(m);
	s[1] = (n * (n + 3) / 2 ) % mod;
	
	for (int i = 2; i < m; i++)
		s[i] = (2 * s[i - 1] + 1 - C(i, n + i) + 5 * mod) % mod;
		
	long long sum = 0;
	for (int i = 1; i < m; i++)
		sum = (sum + s[i]) % mod;
	//*/
	
	long long ans = 0;
	for (long long i = 1; i <= m + 1; i++)
		ans = (ans + C(n, n + i)) % mod;
	
	ans = (ans + mod - m - 1) % mod;
	return ans;
}

void solve(long long r1, long long c1, long long r2, long long c2) {
	//r2++;
	//c2++;
	//c1++;
	//r1++;
	long long res = f(r2, c2) + f(r1 - 1, c1 - 1) - f(r1 - 1 , c2) - f(r2, c1 - 1);
	res = (res + 5 * mod) % mod;
	cout<<res<<"\n";
	//cout<<f(r2, c2)<<" "<<f(r1 - 1, c1 - 1)<<" "<<f(r1 - 1, c2)<<" "<<f(r2, c1 - 1)<<"\n";
}

void Calc_fact() {
	fact[0] = 1;
	for (int i = 1; i <= 2000004; i++)
		fact[i] = (fact[i - 1] * i) % mod;
	for (int i = 0; i <= 2000004; i++)
		revfact[i] = rev(fact[i]);
}

int main() {
	ios::sync_with_stdio(false);
	Calc_fact();
	long long r1, r2, c1, c2;
	cin>>r1>>c1>>r2>>c2;
	
	solve(r1, c1, r2, c2);
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int r,g,b,k;
  cin>>r>>g>>b>>k;
  int R,G,B;
  bool can=false;
  rep2(x,1,8) {
    rep2(y,1,8) {
      rep2(z,1,8) {
        R=r*pow(2,x-1);
        G=g*pow(2,y-1);
        B=b*pow(2,z-1);
        if(B>G&&G>R&&x+y+z<=k+3) {
          can=true;
        }
      }
    }
  }
  if(can) cout<<"Yes\n";
  else cout<<"No\n";
}


Measured memory_bytes: 4060
fun main(args: Array<String>) {
    val a = readLine()!!.split("")
    var r = mutableListOf<String>()
    a.forEach{
        when(it){
            "0" -> r.add("0")
            "1" -> r.add("1")
            "B" -> if (r.count() > 0) r = r.dropLast(1).toMutableList()
        }
    }
    println(r.reduce{x, y -> x + y})
}

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

#define ll long long
#define pb push_back
#define int ll

const int maxn = 1e5 + 20;

int p[maxn] , x[maxn] , b[maxn];

bool visited[maxn];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> x[i] , p[i] = i;

	int m;
	ll k;
	cin >> m >> k;

	for(int i = 0; i < m; i++)
	{
		int t;
		cin >> t;
		t--;

		swap(p[t] , p[t - 1]);
	}

	for(int i = 0; i + 1 < n; i++)
		if(!visited[i])
		{
			vector<int> cycle;
			while(!visited[i])
			{
				visited[i] = 1;
				cycle.pb(i);
				i = p[i];
			}

			int sz = cycle.size();

			int tmp = k % sz;

			for(int j = 0; j < sz; j++)
				p[cycle[j]] = cycle[(j + tmp) % sz];
		}

	cout << x[0] << endl;
	b[0] = x[0];
	for(int i = 0; i + 1 < n; i++)
	{
		int ind = p[i];
		b[i + 1] = b[i] + (x[ind + 1] - x[ind]);
		cout << b[i + 1] << endl;
	}
}










Measured memory_bytes: 3812