akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC70(void);
void ABC71(void);
void ABC72(void);
void ABC73(void);
void ABC74(void);
void ABC75(void);
void ABC76(void);
void ABC77(void);
void ABC78(void);
void ABC79(void);

int main(void){
    ABC73();
}

void ABC73(){
    int i,l,r,n,sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>l>>r;
        sum+=(r-l)+1;
    }
    if(sum>=100000)cout<<100000<<endl;
    else cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <tuple>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 100

using namespace std;
typedef pair<int, int> ipair;

int N;
int x[MAX_N], y[MAX_N], h[MAX_N];

tuple<int, int, int> solve(int i_init) {
    for(int i = 0; i <= MAX_N; ++i)
        for(int j = 0; j <= MAX_N; ++j) {
            
            int height = h[i_init] + abs(x[i_init] - i) + abs(y[i_init] - j);

            for(int k = 0; k < N; ++k) {
                int cur_h = h[k] + abs(x[k] - i) + abs(y[k] - j);
                
                if(h[k] == 0) {
                    if(height > cur_h)
                        goto nextpoint;
                } else if(height == -1)
                    height = cur_h;
                else if(height != cur_h)
                    goto nextpoint;
            }

            if(height != -1)
                return make_tuple(i, j, height);

            nextpoint: ;

        }

}

int main(int argc, char **argv) {
    cin >> N;
    int i_init = -1;
    for(int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0)
            i_init = i;
    }

    tuple<int, int, int> res = solve(i_init);

    cout << get<0>(res) << " " << get<1>(res) << " " << get<2>(res) << endl;
}

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

int main() {

    long long A,B,C,D;
    cin >> A >> B >> C >> D;

    long long num = 0;
    int altC = C,altD = D;

    while(altC != altD) {
        if(altC > altD) {
            altC -= altD;
        }else {
            altD -= altC;
        }
    }

    long long S = (C * D) / altC;
    long long numC = B / C - (A - 1) / C;
    long long numD = B / D - (A - 1) / D;
    long long numCD = B / S - (A - 1) / S;

    cout << B - A + 1 - (numC + numD - numCD) << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_163_CirclePond
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long R = long.Parse(Console.ReadLine());
            Console.WriteLine(R * 2 * Math.PI);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27580
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

string s;
int ans = inf;

int f(char c){

  int res=0,t=0;
  FOR(i,0,s.size()){
    if(s[i]!=c) t++;
    else t=0;
    res = max(res,t);
  }

  return res;
}

int main(){
  cin>>s;

  FOR(i,'a','z'+1){
    ans = min(ans,f(i));
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;

  if(l<=H && A[l]>A[i])
    largest=l;
  else
    largest=i;

  if(r<=H && A[r]>A[largest])
    largest=r;

  if(largest!=i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1)
    return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  if(key <A[i])
    return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    swap(A[i],A[i/2]);
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e' && com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",extract());
    }
  }

  return 0;
}



Measured memory_bytes: 6536
while True:
    height, width = [int(x) for x in input().split(" ")]
    if height == width == 0:
        break
    col1 = "#." * 150
    col2 = ".#" * 150
    col_set = col1[:width] + "\n" + col2[:width] + "\n"
    print(col_set * (height // 2) + (col1[:width] + "\n") * (height % 2))

Measured memory_bytes: 7660
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int MAX_N = 50;

int main(int argc, char const *argv[])
{
    int n, m, c;
    int b[MAX_N];
    cin >> n >> m >> c;
    for (int i = 0; i < m; ++i) {
        scanf("%d", &b[i]);
    }

    int ans = 0;

    for (int i = 0; i < n; ++i) {
        int sum = c;
        for (int j = 0; j < m; ++j) {
            int a;
            scanf("%d", &a);
            sum += a*b[j];
        }
        if (sum >0 ) ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;

int n;
ll a[2005];
P p[2005];
ll dp[2][2005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		p[i]=P(a[i],i);
	}
	sort(p,p+n);
	reverse(p,p+n);
	memset(dp,-1,sizeof(dp));
	int cur=0,nxt=1;
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		//printf("%lld %d\n",p[i].first,p[i].second);
		for(int j=0;j<=i;j++){
			if(dp[cur][j]==-1)continue;
			dp[nxt][j+1]=max(dp[nxt][j+1],dp[cur][j]+p[i].first*abs(p[i].second-j));
			dp[nxt][j]=max(dp[nxt][j],dp[cur][j]+p[i].first*abs(p[i].second-(n-1-(i-j))));
		}
		swap(cur,nxt);
		memset(dp[nxt],0,sizeof(dp[nxt]));
	}
	ll mx=0;
	for(int i=0;i<=n;i++){
		mx=max(mx,dp[cur][i]);
	}
	printf("%lld\n",mx);
	return 0;
}


Measured memory_bytes: 3912
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll N;
ll A[100000];
ll nega=0;
ll ans=0;
ll minimum=1'000'000'000;

int main(){
    cin>>N;
    rep(i,N){
        cin>>A[i];
        nega+=A[i]<0;
        minimum=min(minimum,abs(A[i]));
    }

    rep(i,N) ans+=abs(A[i]);
    if(nega%2==1) ans-=minimum*2;

    cout<<ans<<endl;
}

Measured memory_bytes: 1024
H,W,M = gets.split.map(&:to_i)
A = readlines.map {|s| s.split.map(&:to_i) }

ob = Array.new(H+1) { [] }
bh = Array.new(H+1, 0)
bw = Array.new(W+1, 0)
mh = 0
mw = 0
A.each do |y,x|
  ob[y] << x
  bh[y] += 1
  bw[x] += 1
  mh = bh[y] if mh < bh[y]
  mw = bw[x] if mw < bw[x]
end

a = bh.each_with_index.inject([]) {|r,(n,i)| n == mh ? r << i : r }
b = bw.each_with_index.inject([]) {|r,(n,i)| n == mw ? r << i : r }
puts mh + mw + (a.all? {|y| (b - ob[y]).empty? } ? -1 : 0)

Measured memory_bytes: 83716
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int long long
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl "\n"
const int oo = INT_MAX;
const int MOD = 1e9 + 7;
const int sz = 1e5 + 5;

int32_t main() {
    IOS;
   
    int tc = 1;
    //cin >> tc;
    while(tc--) {
        int x; cin >> x;
        if(x) cout << "0";
        else cout << "1";

    }
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,h,a[101010]={},b[101010]={},c=0;
	cin>>n>>h;
	FOR(i,0,n){
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	int idx=n-1;
	while(1){
		if(h<=0){
			cout<<c<<endl;
			return 0;
		}
		if(idx==-1)break;
		if(a[n-1]>=b[idx])break;
		h-=b[idx];
		idx--;
		c++;
	}
	int t=a[n-1];
	c+=(h+t-1)/t;
	cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int c[150][150];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	int N; scanf("%d", &N);
	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) scanf("%d", &c[i][j]);
    ll res = 0;
	for (int i = 0; i < N; i++)for (int j = i + 1; j < N; j++) res += 1LL * min(c[i][j], c[j][i]);
	printf("%lld\n", res);
	return 0;
}


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n){
    cin>>a[i];a[i]--;
  }
  rep(i,0,n)if(a[a[i]]==i)res++;
  cout<<res/2<<endl;
  return 0;
}

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

#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) a/__gcd(a,b)*b

typedef long long ll;

int main() { 
    ll a,b;
    cin>>a>>b;
    cout<<LCM(a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdint>
#include <vector>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
i64 p5(i64 x){return x * x * x * x * x;}

int main(void){
    i64 x;
    cin >> x;
    vi P5(120);
    for(i64 i=1; i<120; i++) P5[i] = p5(i);
    for(i64 a=1; true; a++){
        i64 a5 = P5[a];
        for(i64 b=-a; b<a; b++){
            i64 b5 = (b<0 ? -P5[-b] : P5[b]);
            if(a5-b5 == x){
                cout << a << ' ' << b << '\n';
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3580
import java.util.*;
public class Main {
    public static void main(String args[]) {
      Scanner in = new Scanner(System.in);
      int n = in.nextInt(); long d = in.nextLong();
      int count = 0;
      while(n > 0){
          n--;
          long x = in.nextLong();
          long y = in.nextLong();
          if(x*x + y*y <= d*d) count++;
      }
      System.out.println(count);
    }
}

Measured memory_bytes: 59096
N, P = map(int, input().split())
S = list(map(int, input()))
ans = 0
if P == 2:
    for i in range(N):
        if S[i]%2 == 0:
            ans +=i+1
    print(ans)

elif P ==5:
    for i in range(N):
        if S[i]%5 == 0:
            ans +=i+1
    print(ans)
else:
    data =[0]*P
    tens = 1
    k = 0
    for i in range(N-1,-1,-1):
        k += S[i] *tens %P
        k = k%P
        data[k] += 1
        tens *=10
        tens %=P

    for i in data:
        ans += i*(i-1)/2
    ans +=data[0]
    print(int(ans))

Measured memory_bytes: 5220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
vector<int> p,q;
int main(){
	int i,n,a = -1,b = -1;
	cin >> n;
	int k = 1;
	for(i=0;i<n;i++){
		int x; cin >> x;
		p.push_back(x);
	}
	for(i=0;i<n;i++){
		int x; cin >> x;
		q.push_back(x);
	}
	for(i=0;i<n;i++){
		if(p[i]!=q[i]){
			if(p[i]>q[i]){
				swap(p,q);
			}
			break;
		}
		if(i==n - 1){
			cout << 0 << endl;
			return 0;
		}
	}
	int cnt = 1;
	while(next_permutation(p.begin(),p.end())){
		for(i=0;i<n;i++){
			if(p[i]!=q[i]) break;
			if(i==n - 1){
				cout << cnt << endl;
				return 0;
			}
		}
		cnt++;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int n, m; cin >> n >> m;
	vector<int> vm(m+1,0);
	int x,z;
	rep(i, n) {
		cin >> x;
		rep(wi, x) {
			cin >> z;
			vm[z]++;
		}
	}
	int res = 0;
	rep(i,m+1)
		if (vm[i] == n)res++;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
ref = "SCHD"
first = 0
while 1:
	try:
		n = input()
		if first: print
		first = 1
	except:
		break
	P = [map(int,raw_input().split()) for i in range(4)]
	H = map(int,raw_input().split())
	for _ in range(n):
		hand = raw_input().replace("A","1").replace("T","10").replace("J","11").replace("Q","12").replace("K","13").split()
		num  = [int(i[:-1]) for i in hand]
		suit = [ref.index(i[-1]) for i in hand]
		ans  = sum(P[suit[i]][num[i]-1] for i in range(5))
		if len(set(suit)) == 1:
			if sorted(num) == [1,10,11,12,13]:
				ans *= H[8]
			elif sorted([i - min(num) for i in num]) == [0,1,2,3,4]:
				ans *= H[7]
			else:
				ans *= H[4]
		elif sorted([i - min(num) for i in num]) == [0,1,2,3,4] or sorted(num) == [1,10,11,12,13]:
			ans *= H[3]
		elif max(num.count(i) for i in set(num)) == 4:
			ans *= H[6]
		elif max(num.count(i) for i in set(num)) == 3:
			if len(set(num)) == 2:
				ans *= H[5]
			else:
				ans *= H[2]
		elif max(num.count(i) for i in set(num)) == 2:
			if len(set(num)) == 3:
				ans *= H[1]
			else:
				ans *= H[0]
		else:
			ans = 0
		print ans

Measured memory_bytes: 4368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderProject
{
    public static class Program
    {
        public static void Main()
        {
            var str = Console.ReadLine().Split(' ');
            var n = int.Parse(str[0]);
            var k = long.Parse(str[1]);

            var q = int.Parse(str[2]);
            var list = new List<int>();

            var sankasha = new List<long>();

            for (int i = 0; i < n; i++)
            {
                sankasha.Add(k - q);
            }

            for (int i = 0; i < q; i++)
            {
                list.Add(int.Parse(Console.ReadLine()));
            }

            foreach(var genten in list)
            {
                sankasha[genten - 1]++;
            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(sankasha[i] <= 0 ? "No" : "Yes");
            }
        }

        private static List<int> ReadArgsAsInt()
        {
            var str = Console.ReadLine().Split(' ');
            return str.Select(x => int.Parse(x)).ToList();
        }

        private static List<long> ReadArgsAsLong()
        {
            var str = Console.ReadLine().Split(' ');
            return str.Select(x => long.Parse(x)).ToList();
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back


int main() {
	string s;
	cin >> s;
	
	int a = 0, b = 0;
	rep(i, s.size()) {
	    if(i%2 == 0 && s[i]=='0') a += 1;
	    if(i%2 == 1 && s[i]=='1') a += 1;
	    if(i%2 == 0 && s[i]=='1') b += 1;
	    if(i%2 == 1 && s[i]=='0') b += 1;
	}
	
	cout << min(s.size()-a, s.size()-b) << endl;
}


Measured memory_bytes: 512
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n;
		int cnt=0;
		cin >> n;
		int a[MAX];
		for (int i=0 ; i<n ; i++) cin >> a[i];
		for (int i=0 ; i<n ; i+=2)
		{
			if(a[i]%2)
			cnt++;
			
		}
		cout << cnt << endl;
		return 0;  
}  


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    i32 H = input(), W = input();
    auto a = make_vector(H + 1, W + 1, 0);
    range(i, 1, H + 1) range(j, 1, W + 1) cin >> a[i][j];

    vector< pair< pair< i32, i32 >, pair< i32, i32 > > > ans;
    range(i, 1, H + 1) {
        range(j, 1, W) {
            if (a[i][j] & 1) {
                ans.emplace_back(make_pair(i, j), make_pair(i, j + 1));
                a[i][j] -= 1;
                a[i][j + 1] += 1;
            }
        }
    }

    range(i, 1, H) {
        if (a[i][W] & 1) {
            ans.emplace_back(make_pair(i, W), make_pair(i + 1, W));
            a[i][W] -= 1;
            a[i + 1][W] += 1;
        }
    }

    cout << ans.size() << endl;
    for (auto p : ans) {
        int a, b, c, d;
        tie(a, b) = p.first;
        tie(c, d) = p.second;
        cout << a << " " << b << " " << c << " " << d << endl;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 5236
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        System.out.println((sc.nextInt() - 1) * (sc.nextInt() - 1));
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 21844
n=int(input())
a=input().strip()
x=0
b=[]
for ai in [i for i in list(a)]:
  if ai=='(':
    x+=1
  else:
    x-=1
  b.append(x)
l=b[len(b)-1]	
if min(b)< 0:
  a = '(' * abs(min(b)) + a
  l+=abs(min(b))
a=a+')'*l
    
print(a)

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

using namespace std;
using lli = long long int;

vector<lli> input(int N) { vector<lli> r(N); for (int i = 0; i < N; i++)cin >> r[i]; return r; }

int main() {
	lli N;
	cin >> N;
	vector<vector<lli>> abc(N, vector<lli>(3));
	for (int i = 0; i < N; i++)
		for (int j = 0; j < 3; j++)cin >> abc[i][j];
	vector<vector<lli>> dp(N + 10, vector<lli>(3));
	for (int i = 0; i < N; i++)dp[i][0] = dp[i][1] = dp[i][2] = 0;
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	for (int i = 0; i < N; i++) {
		dp[i + 1][0] = max(dp[i][1], dp[i][2]) + abc[i][0];
		dp[i + 1][1] = max(dp[i][0], dp[i][2]) + abc[i][1];
		dp[i + 1][2] = max(dp[i][0], dp[i][1]) + abc[i][2];
	}

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


Measured memory_bytes: 11136
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

struct UnionFind {
    vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> siz;

    // 最初は全てが根であるとして初期化
    UnionFind(int N) : par(N), siz(N, 1) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    // xとyの木を併合
    void unite(int x, int y) {
        int rx = root(x);  // xの根をrx
        int ry = root(y);  // yの根をry

        // xとyの根が同じ(=同じ木にある)時はそのまま
        if (rx == ry) return;

        // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        par[rx] = ry;
        siz[ry] += siz[rx];
    }

    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) { return siz[root(x)]; }
};

int main() {
    INIT;

    ll N, M, K;
    cin >> N >> M >> K;

    UnionFind tree(N);
    vector<set<ll>> avoids(N);

    rep(i, M) {
        ll s, t;
        cin >> s >> t;
        s--;
        t--;

        avoids[s].insert(t);
        avoids[t].insert(s);

        tree.unite(s, t);
    }

    rep(i, K) {
        ll s, t;
        cin >> s >> t;
        s--;
        t--;

        if (!tree.same(s, t)) continue;
        avoids[s].insert(t);
        avoids[t].insert(s);
    }

    rep(i, N) {
        ll res = tree.size(i) - 1;
        res -= avoids[i].size();
        cout << res << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 28728
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

vector<int> a,f;

int chk(int lim,int n){
   int res = 0;
   f(i,0,n){
      int xa = lim/f[i];
      res += max(0ll,a[i]-xa);
   }
   return res;
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   a.resize(n);
   f.resize(n);
   f(i,0,n){
      cin >> a[i];
   }
   f(i,0,n){
      cin >> f[i];
   }
   sort(all(a));
   sort(all(f),greater<int>());
   int lo = 0,hi = 1e18;
   while(lo<hi){
      int mid = (lo+hi)/2;
      if(chk(mid,n) <= k){
         hi = mid;
      }else{
         lo = mid+1;
      }
   }
   cout << lo << '\n';
   return 0;
}

Measured memory_bytes: 3328
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
string s1,s2;
int dp[3001][3001];
vector<char> ans;
void print(int i,int j){
	if(i == 0 || j == 0){
		return ;
	}
	if((s1[i-1] == s2[j-1])){
		ans.pb(s1[i-1]);
		print(i-1,j-1);
	}else if(dp[i-1][j] > dp[i][j-1]){
		print(i-1,j);
	}else{
		print(i,j-1);
	}
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>s1>>s2;
	n = s1.length();
	m = s2.length();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s1[i-1] == s2[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}else{
				dp[i][j] = max({dp[i-1][j],dp[i][j-1]});
			}
		}
	}
	print(n,m);
	reverse(all(ans));
	for(auto x : ans){
		cout<<x;
	}
	return 0;
}
//.........

Measured memory_bytes: 70656
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];
int k[MAX]={};
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
        signed main() {
            COMinit();
        int n,t;
        cin>>n;
       int a[n],ma=0,mb;
       for(int i=0;i<n;i++){cin>>a[i];}
       
      //  int t;
        for(int i=0;i<n;i++){
            ma=a[i];
            for(int j=2;j<=sqrt(ma);j++){
                t=0;
                
                while(a[i]%j==0){
                    t++;
                    a[i]/=j;
                }
                k[j]=max(k[j],t);
            }
            if(a[i]!=1)k[a[i]]=max(k[a[i]],1ll);
            a[i]=ma;
        }
       // cerr<<'u';
       int ans1=0,ans2=1;
       for(int i=0;i<n;i++){
           ans1=(ans1+inv[a[i]])%MOD;
       }
       for(int i=2;i<MAX;i++){
           if(k[i])ans2=(ans2*modpow(i,k[i],MOD))%MOD;
       }
       cout<<ans1*ans2%MOD;
       // cerr<<ans2;
      
         return 0;

        }


Measured memory_bytes: 31360
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#define ll long long

using namespace std;

const long long mod = 1e9+7;

int main(){
    int n;
    ll* a, *b;
    cin >> n;
    a = new ll[n+1];
    b = new ll[n];

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

    ll sum = 0;
    ll dif = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        a[i] -= dif;
        if(a[i] < 0) a[i] = 0;
        dif = b[i] - a[i];
        if(dif < 0){
            sum += dif;
            dif = 0;
        }
    }

    ll last = a[n] - dif;
    if(last < 0) sum += a[n];
    else sum += dif;

    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int mod = 1e9 + 7;

const int maxn = 100100;
int a[maxn];

int p[maxn];
int s[maxn];
int n;

bool check() {
    int mx = 0;
    forn (i, n) {
        mx = max(mx, a[i]);
        if (mx != p[i])
            return false;
    }
    mx = 0;
    for (int i = n - 1; i >= 0; --i) {
        mx = max(mx, a[i]);
        if (mx != s[i])
            return false;
    }
    return true;
}

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    cin >> n;
    forn (i, n)
        a[i] = -1;
    forn (i, n) {
        cin >> p[i];
    }
    forn (i, n) {
        cin >> s[i];
    }
    a[0] = p[0];
    a[n - 1] = s[n - 1];
    forn (i, n - 1) {
        if (p[i] != p[i + 1])
            a[i + 1] = p[i + 1];
        if (s[i] != s[i + 1])
            a[i] = s[i];
    }
    if (!check()) {
        cout << 0 << '\n';
    } else {
        ll res = 1;
        forn (i, n) {
            if (a[i] == -1)
                res *= min(p[i], s[i]);
            res %= mod;
        }
        cout << res << '\n';
    }
}


Measured memory_bytes: 1408
#include <queue>
#include <iostream>
#include <sstream>
#include <cstring>

using namespace std;

/*
林檎が A 個、林檎の欠片が P 個あります。
林檎 1 個は、砕くことで林檎の欠片 3 個になります。
また、林檎の欠片 2 個を鍋で煮込むことで、アップルパイが 1 個作れます。

今ある材料で作れるアップルパイの最大数を求めてください。
*/
int main(void) {

    int a, p;
    cin >> a >> p;

    p += a*3;

    cout << (p /2) << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque

fun main() {
    fun readString():String{return readLine()!!}
    fun readIntList():List<Int>{return readLine()!!.split(" ").map { it.toInt() }}
    val (h,w)=readIntList()
    val grid=Array(h){readString().toCharArray()}
    var que=ArrayDeque<List<Int>>()
    que.add(listOf(0,0,1))
    var visited=Array(h){BooleanArray(w){false}}
    visited[0][0]=true
    var ng=0
    grid.forEach { i->i.forEach { j->if (j=='#'){ng++} } }
    var road=-1
    val around= listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)
    loop@while (!que.isEmpty()){
        val now=que.poll()
        for ((dx, dy) in around){
            val tmp= listOf(now[0]+dx, now[1]+dy)
            if (tmp[0] in 0 until h && tmp[1] in 0 until w && !visited[tmp[0]][tmp[1]] && grid[tmp[0]][tmp[1]]=='.'){
                if (tmp[0]==h-1&&tmp[1]==w-1){road=now[2]+1; break@loop}
                que.add(listOf(tmp[0], tmp[1], now[2]+1))
                visited[tmp[0]][tmp[1]]=true
            }
        }
    }
    if (road==-1){println(-1)}
    else{println(w*h-ng-road)}
}

Measured memory_bytes: 41148
package main

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

func main() {
	defer writer.Flush()
	n, q := ReadInt(), ReadInt()
	t := NewSegTree(n)
	for ; q > 0; q-- {
		if ReadInt() == 0 {
			t.Update(ReadInt(), ReadInt()+1, ReadInt())
		} else {
			Println(t.Find(ReadInt()))
		}
	}
}

// Segment Tree for Range Update Query (RUQ)
type SegTree struct {
	nodes    []int
	versions []int
	version  int
}

const Inf = 1<<31 - 1

func NewSegTree(n_ int) *SegTree {
	n := 1
	for n < n_ {
		n <<= 1
	}
	t := &SegTree{
		nodes:    make([]int, n*2),
		versions: make([]int, n*2),
	}
	for i := 1; i < len(t.nodes); i++ {
		t.nodes[i] = Inf
	}
	return t
}

func (t *SegTree) Update(a, b, x int) {
	t.version++
	t.UpdateRecur(a, b, x, 1, 0, len(t.nodes)>>1)
}

func (t *SegTree) UpdateRecur(a, b, x, k, l, r int) {
	if b <= l || r <= a {
		return
	}
	if a <= l && r <= b {
		t.nodes[k] = x
		t.versions[k] = t.version
		return
	}
	t.UpdateRecur(a, b, x, k*2, l, (l+r)>>1)
	t.UpdateRecur(a, b, x, k*2+1, (l+r)>>1, r)
}

func (t *SegTree) Find(i int) int {
	i += len(t.nodes) >> 1
	k := i
	for i > 0 {
		if t.versions[i] > t.versions[k] {
			k = i
		}
		i >>= 1
	}
	return t.nodes[k]
}

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Buffer(make([]byte, 256), 1e9)
	scanner.Split(bufio.ScanWords)
}
func ReadString() string { scanner.Scan(); return scanner.Text() }
func ReadInt() int {
	a, err := strconv.Atoi(ReadString())
	if err != nil {
		panic(err)
	}
	return a
}

var writer = bufio.NewWriter(os.Stdout)

func Println(a ...interface{}) { fmt.Fprintln(writer, a...) }



Measured memory_bytes: 6924
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A.sort()
A = np.array(A)
B = list(map(int, input().split()))
B.sort()
B = np.array(B)
C = list(map(int, input().split()))
C.sort()
C = np.array(C)

cnt_A = np.searchsorted(A,B,side='left')
cnt_C = np.searchsorted(C,B,side='right')

ans = (cnt_A * (N-cnt_C)).sum()

print(ans)

Measured memory_bytes: 33688
import numpy as np
N=int(input())
v=np.sort(list(map(int, input().split())))
v1=[]
v1.append(v[0]/2**(N-1)) 
for i in range(N-1):
    v1.append(v[i+1]/2**((N-1)-i))
print(sum(v1))

Measured memory_bytes: 12488
S = input()
N = len(S)

# create ptn
ptn = []
for bit in range(2**(N-1)):
    tmp = [False]*(N-1)
    for i in range(N-1):
        if ((bit>>i) & 1):
            tmp[i] = True
    ptn.append(tmp)

# calc sum
tot = []
for p in ptn:
    a = []
    for i, s in enumerate(S):
        if i==0:
            now = int(s)
            continue
        if p[i-1]==False:
            now *= 10
            now += int(s)
        else:
            a.append(now)
            now = int(s)
    a.append(now)
    tot.append(sum(a))
print(sum(tot))

Measured memory_bytes: 3064
#include<stdio.h>

int main(){

	int a,b;

		scanf("%d %d",&a,&b);

	if(a>b) printf("%d",2*a-1);
	if(a==b) printf("%d",a+b);
	if(a<b)	printf("%d",2*b-1);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N=150000;
const double inf=99999999;
double delta=3.14159265358979*(1.0/(double)N);
const double C = cos(delta) , S=sin(delta);

void delta_rotate(pair<double,double> &p){
    pair<double,double> tmp;
    tmp.first=p.first*C-p.second*S;
    tmp.second=p.first*S+p.second*C;
    p=tmp;
}

int main(void){
    int n,m,i;
    while(cin>>n>>m,n){
        vector<pair<double,double>> bl;
        vector<pair<double,double>> wh;
        double a,b;
        for(i=0;i<n;i++){
            cin>>a>>b;
            bl.emplace_back(a,b);
        }
        for(i=0;i<m;i++){
            cin>>a>>b;
            wh.emplace_back(a,b);
        }
        for(i=0;i<N+1;i++){
            double blmax=-99999999,whmax=-99999999,whmin=inf,blmin=inf;
            for(auto &p:bl){
                delta_rotate(p);
                blmax=max(blmax,p.first);
                blmin=min(blmin,p.first);
            }
            for(auto &p:wh){
                delta_rotate(p);
                whmin=min(whmin,p.first);
                whmax=max(whmax,p.first);
            }
            if(whmin-blmax>0.00000001 || blmin-whmax>0.00000001){
                cout<<"YES"<<endl;
                goto while_continue;
            }
        }
        cout<<"NO"<<endl;
        while_continue:;
    }
}



Measured memory_bytes: 3288
#include <iostream>

using namespace std;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    char pc = S[0];
    for(int i = 1; i < S.length(); i++) {
        if (pc != S[i]) {
            ans += 1;
            pc = S[i];
        }
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 512
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
typedef long long LL;
const int MAXN = 20;
const int MAXM = 60;
const int INF = 0x3f3f3f3f;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

struct Edge {
  int u, v, w;
  Edge() {}
  Edge(int _u,int _v, int _w) : u(_u), v(_v), w(_w) {}
}e[MAXM + 5];

int tot;
inline void add(int u, int v, int w) {
  e[++tot] = Edge(u, v, w);
}

int n, l;

void init() {
  //enableFileIO();
  l = read();
}

inline int lowbit(int x) {
  return x & (-x);
}

int main() {
  init();
  
  n = 20;
  for (int i = n - 1; i > 1; --i) {
    add(i, i + 1, 0);
    add(i, i + 1, 1 << (20 - i - 1));
  }
  while (l) {
    int p = log2(lowbit(l));
    if (p == 19) {
      add(1, 2, 0);
      add(1, 2, 1 << 18);
    } else {
      add(1, 20 - p, l ^ lowbit(l));
    }
    l ^= lowbit(l);
  }

  printf("%d %d\n", n, tot);
  for (int i = 1; i <= tot; ++i) {
    printf("%d %d %d\n", e[i].u, e[i].v, e[i].w);
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;
 
int main()
{
  ios::sync_with_stdio(false);
  int a,b,c; cin >> a >> b >> c;
  int d = a - b;
  int e = c - d;
  cout << max(0, e) << endl;
  return 0;
}


Measured memory_bytes: 256
//Colorful Subsequence

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;string s;cin>>n>>s;
    int ans=1;
    map<char,int>m{};
    rep(i,0,n)m[s[i]]++;
    irep(i,m){
        ans=ans*(1+i->second)%1000000007;
    }
    cout<<ans-1<<nnn;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  char x,y,al[]="abcdefghijklmnopqrstuvwxyz";
  cin >>x;
  
  for(int i=0;i<25;i++){
    if(x == al[i]) y = al[i+1];
  }
  
  cout << y << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

cnt = 0
ans = ''
for ch in S:
    if ch == '(':
        cnt = cnt + 1
    if ch == ')':
        cnt = cnt - 1
        
    if cnt == -1:
        cnt = 0
        ans = '(' + ans

    ans = ans + ch


while cnt:
    cnt = cnt - 1
    ans = ans + ')'

print (ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,a[100005],sum=0,sum1=0;
int b[100005];
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>a[i],sum+=a[i],a[i]*=2;
	for(int i=1;i<=n-1;i+=2)	sum1+=a[i];
	b[n]=sum-sum1;
	for(int j=n-1;j>=0;j--)	b[j]=a[j]-b[j+1];
	for(int i=1;i<=n;i++)	cout<<b[i]<<((i==n)?'\n':' ');
	return 0;
}

Measured memory_bytes: 2816
// AOJ ALDS1_15_B Fractional Knapsack Problem
// 2018.3.22 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

//// 高速数値入出力
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
// 非負整数の入力
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define EPS			1e-8
int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }

typedef struct { int v, w; double x; } T;
T t[100005]; int N, W;

int cmp(const void *a, const void *b) { return dcmp(((T *)b)->x - ((T *)a)->x); }

int main()
{
	int i, sum;
	double ans;

	N = in(), W = in();
	for (i = 0; i < N; i++) {
		t[i].v = in(), t[i].w = in();
		t[i].x = (double)t[i].v / t[i].w;
	}
	qsort(t, N, sizeof(T), cmp);

	ans = 0, sum = 0;
	for (i = 0; i < N; i++) {
		if (sum + t[i].w <= W) sum += t[i].w, ans += t[i].v;
		else {
			ans += (double)t[i].v * (W - sum) / t[i].w;
			break;
		}
	}
	printf("%.12lf\n", ans);
	return 0;
}



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

int main(){
  int a,b,c;
  cin>>a>>b;
  c=0;
  vector<int> d(a);
  for(int i=0;i<a;i++){
    cin>>d.at(i);
  }
sort(d.begin(),d.end());
  for(int i=0;i<a;i++){
    c+=d.at(i);
    if(b<c){
      cout<<i<<endl;
      break;
    }
    if(i==a-1){
      if(b==c)
      cout<<a<<endl;
      else
        cout<<i<<endl;
    }
  }
}
      

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };

//1-indexed S文字目からT文字目までが同じか
bool sm(int s, int t, string str) {
	if (!(1 <= s && s < t && t <= str.size()))return false;
	--s; --t;
	for (int i = s; i < t; ++i) if (str[i] != str[i + 1])return false;
	return true;
}

bool p(int x, string str) {
	if (x <= (str.size() + 1) / 2)return true;
	int i = x-(str.size() + 1) / 2;
	if (str.size() % 2 == 0) return sm(str.size() / 2 + 1 - i, str.size() / 2 + i, str);
	else return sm((str.size() + 1) / 2 - i, (str.size() + 1) / 2 + i, str);
}

int main() {
	string str;
	cin >> str;
	ll l = 1;
	ll r = str.size()+1;
	while (r - l > 1) {
		ll mid = l + (r - l) / 2;
		if (p(mid, str)) l = mid;
		else r = mid;
	}
	PRI(l);
	return 0;
}

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

#define ll long long
const ll mod = 1e9+7;
int tc;
ll sum, n;
ll dp[2005];

ll func(ll x)
{
    if(x<=2)
        return 0;
    if(x>=3 && x<=5)
        return 1;
    if(dp[x]!=-1)
        return dp[x];
    ll ss=0;
    for(ll i=3; i<=x; i++){
        ss = (ss%mod + func(x-i)%mod)%mod;
    }
    if(x>2)
        ++ss;
    return dp[x] = ss;

}

void solve(int kk)
{
   memset(dp, -1, sizeof dp);
   cin >> n;
   cout << func(n) << "\n";
}

int main(){
  #ifndef ONLINE_JUDGE
freopen("D:\\Codings\\CPP\\input.in", "r", stdin);
freopen("D:\\Codings\\CPP\\output.in", "w", stdout);
#endif
	ios::sync_with_stdio(0), cin.tie(0);
	int t=1;
    //cin >> t;
    while(++tc<=t)
        solve(tc);
}


Measured memory_bytes: 3692
package main

import (
	"fmt"
)

func main() {
	var n, y int
	fmt.Scan(&n, &y)

	for i := 0; i <= n; i++ {
		for j := 0; j <= n; j++ {
			if i + j > n {
				break;
			}
			k := n - (i + j)
			if 10000 * i + 5000 * j + 1000 * k == y {
				fmt.Println(i, j, k)
				return
			}
		}
	}

	fmt.Println(-1, -1, -1)
}


Measured memory_bytes: 512
from bisect import bisect_left,bisect

x,N,*p = map(int,open(0).read().split())
dif = 300
near = 300
all_ = set(range(0,102))

for i in p:
    d = abs(i - x)
    if dif > d:
        dif = d
        near = i
left = list(all_ - set(p))        

dif2 = 300
near = 300
for i in left:
    d = abs(x-i)
    if d < near:
        near = d
        dif2 = i
print(dif2)        
    

Measured memory_bytes: 62156