akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(void) {
    int H, W;
    cin >> H >> W;
    char s[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> s[i][j];
        }
    }

    bool success = true;
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (s[i][j] == '#') {
                bool can = false;
                for (int k = 0; k < 4; ++k) {
                    int ny = i + dy[k], nx = j + dx[k];
                    if (0 <= nx && nx < W && 0 <= ny && ny < H && s[ny][nx] == '#') {
                        can = true;
                    }
                }
                if (!can) {
                    success = false;
                }
            }
        }
    }

    if (success) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;

vector<ll> a(100005);

bool isOK(int index, int key){
  /*indexが条件を満たすかどうかを判定(今回はkeyよりおおきいか)*/
  if(a[index]<key) return true;
  else return false;
}

int binary_search(int key){
  int ng = a.size();
  int ok = -1;
  //okとngの初期値によって最大値だけでなく最小値も求められる.
  //ng=-1の時はkey以上の数値の最小値

  while(abs(ok - ng) > 1){
    int mid = (ok + ng) / 2;

    if(isOK(mid,key)) ok = mid;
    else ng = mid;
  }

  return ok;
}


int main(){
  ll i,j,k,n,m;
  cin >> n;
  a.resize(n);
  for(i=0;i<n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  vector<pair<ll,ll> > v(n);
  int vp=0;
  if(a.back()<0){
    v[vp++]=make_pair(a[n-1],a[0]);
    a[0]=a[n-1]-a[0];
    a.pop_back();
    sort(a.begin(),a.end());
  }
  //cout << (int)a.size() << endl;
  //cout << a[0] << a[1] << endl;
  int x = binary_search(0LL);
  if(x==-1)x=0;
  int t=x;
  ll now=a[x];
  bool f=0;
  ll as=a.size();
  for(i=x+1;i<as-1;i++){
    f=1;
    v[vp++]=make_pair(now,a[i]);
    now-=a[i];
  }
  v[vp++]=make_pair(a.back(),now);
  now = a.back()-now;
  for(i=0;i<x;i++){
    v[vp++]=make_pair(now,a[i]);
    now-=a[i];
  }
  cout << now << endl;
  for(i=0;i<vp;i++)cout << v[i].first << " " << v[i].second << endl;
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int k, x;
  cin >> k >> x;
  rep2(i, x-k+1, x+k){
    if(i != x-k+1) cout << " ";
    cout << i;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, M, L;
  cin >> N >> M >> L;

  vector<vector<int>> dist(N, vector<int>(N, INF));
  REP(i, N) dist[i][i] = 0;
  REP(i, M){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dist[a][b] = c;
    dist[b][a] = c;
  }

  REP(k, N) REP(i, N) REP(j, N){
    chmin(dist[i][j], dist[i][k]+dist[k][j]);
  }

  vector<vector<int>> vec(N, vector<int>(N, INF));
  REP(i, N) vec[i][i] = 0;

  REP(i, N) REP(j, N){
    if(dist[i][j] <= L) vec[i][j] = 1;
  }

  REP(k, N) REP(i, N) REP(j, N){
    chmin(vec[i][j], vec[i][k]+vec[k][j]);
  }

  int q;
  cin >> q;
  while(q--){
    int s, t;
    cin >> s >> t;
    s--; t--;
    if(vec[s][t] == INF) cout << -1 << endl;
    else cout << vec[s][t]-1 << endl;
  }


  return 0;
}

Measured memory_bytes: 1920
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define ll long long
using namespace std;
const int N=200005;
int n,m,col[N<<2],mx[N<<2];
vector<int>V[N];

inline void read(int &i){
	i=0;char c=getchar();bool j=0;
	for(;!isdigit(c);c=getchar())if(c=='-')j=1;
	for(;isdigit(c);c=getchar())i=(i<<1)+(i<<3)+c-'0';i=j?-i:i;
}

void build(int u,int l,int r){
	if(l==r){mx[u]=-(m-l+1);return;}
	int mid=(l+r)>>1;
	build(u<<1,l,mid);
	build(u<<1|1,mid+1,r);
	mx[u]=max(mx[u<<1],mx[u<<1|1]);
}

inline void color(int u,int v){mx[u]+=v,col[u]+=v;}
inline void push(int u){if(col[u])color(u<<1,col[u]),color(u<<1|1,col[u]),col[u]=0;}

void mdf(int u,int l,int r,int L,int R){
	if(L<=l&&r<=R){color(u,1);return;}
	int mid=(l+r)>>1;push(u);
	if(L<=mid)mdf(u<<1,l,mid,L,R);
	if(mid<R)mdf(u<<1|1,mid+1,r,L,R);
	mx[u]=max(mx[u<<1],mx[u<<1|1]);
}

int qmx(int u,int l,int r,int L,int R){
	if(L<=l&&r<=R)return mx[u];
	int mid=(l+r)>>1,as=-1e9;push(u);
	if(L<=mid)as=max(as,qmx(u<<1,l,mid,L,R));
	if(mid<R)as=max(as,qmx(u<<1|1,mid+1,r,L,R));
	return as;
}

int main(){
	read(n);read(m);
	for(int i=1,x,y;i<=n;++i)read(x),read(y),V[x].push_back(y);
	build(1,1,m+1);int ans=0;
	for(int i=0;i<=m;++i){
		for(int j=0;j<(int)V[i].size();++j){
			int x=V[i][j];
			mdf(1,1,m+1,1,x);
		}
		ans=max(qmx(1,1,m+1,1,m+1)-i,ans);
	}
	ans=max(ans,n-m);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14080
//*********************Cr!TikaL**********************//
//*****|||||******|||||*******||||||******|||||*****//

#include<iostream>
#include<algorithm>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define endl "\n"
#define si(x)    scanf("%d",&x)
#define sl(x)    scanf("%lld",&x)
#define ss(s)    scanf("%s",s)
#define pi(x)    printf("%d\n",x)
#define pl(x)    printf("%lld\n",x)
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

#define rep(qqq,ttt,www) for(int qqq = ttt; qqq < www; qqq++)
#define repe(qqq,ttt,www) for(int qqq = ttt; qqq <= www; qqq++)
#define rev(qqq,ttt,www) for(int qqq = www; qqq > 0; qqq--)
#define reve(qqq,ttt,www) for(int qqq = www; qqq >= 0; qqq--)

#define setp(x,y) cout << setprecision(x) << y << endl
#define deb(x) cout << #x << " --- " << x << endl
#define TT template<class T
#define Tt template<typename... T

Tt> void read(T&... a){((cin >> a), ... );}
Tt> void write(T&... a){((cout << a << " "), ... );cout << endl;}

ll getInt(char s){stringstream ss;ss << s;int p;ss >> p;return p;}
ll getInt(string s){stringstream ss;ss << s;int p;ss >> p;return p;}
string getStr(long long int a){stringstream ss;ss << a;string s;ss >> s;return s;}
TT> T inline min(T& a,T& b){if( a <= b)return a;else return b;}
TT> T inline max(T& a,T& b){if( a >= b)return a;else return b;}
TT> T inline min3(T& a,T& b,T& c){if (a <= b && a <= c)return a;else if (b <= a && b <= c)return b;else return c;}
TT> T inline max3(T& a,T& b,T& c){if (a >= b && a >= c)return a;else if (b >= a && b >= c)return b;else return c;}

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18;


int main()
{

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    ll sum = 0;
    for(ll i = 0; i < s.size(); i++)
    {
        sum += getInt(s[i]);
    }
    if(sum%9 == 0)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;

    return 0;

}


Measured memory_bytes: 3752
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input=Console.ReadLine().Split(' ');
        int score = int.Parse(input[0]);
        string contest;

        if (score < 1200)
            contest = "ABC";
        else
            contest = "ARC"; 

        Console.WriteLine(contest);

    }
}

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

int main()
{
  string s;
  cin>>s;
  ll flg=0,length=s.size();
  
  for(ll i=0;i<length;i++)
  {
      if(s[i]!=s[length-i-1])
        {
            flg=1;
            break;
        }
  }

if(!flg)
{
    
    for(ll i=0;i<(length-1)/2;i++)
    {
      if(s[i]!=s[((length-1)/2)-i-1])
        {
            flg=1;
            break;
        }
    }
    
   
} 
 
    if(!flg)
    {
     for(ll i=((length+3)/2)-1;i<length;i++)
     {
      if(s[i]!=s[length-i-1])
        {
            flg=1;
            break;
        }
    }
    }
    if(flg)
        cout<<"No\n";
    else
        cout<<"Yes\n";
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtCoder
{
    partial class Program
    {
        static void Main(string[] args)
        {
			//↓


            var n = int.Parse(Console.ReadLine());
            long total = 0;

            var dict = new Dictionary<string, int>();
            
            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                s = new String(s.OrderBy(c => c).ToArray());
                if (dict.ContainsKey(s))
                {
                    dict[s] += 1;
                }
                else
                {
                    dict[s] = 1;
                }
            }

            foreach (var kv in dict)
            {
                var c = kv.Value;

                long comb = (long)c * ((long)c - 1) / 2;
                total += comb;
            }
            Console.WriteLine(total);

			//↑
        }
	}
}

Measured memory_bytes: 31124
a, b, c, k = map(int, input().split())

ans = 0
if k < a:
  print(k)
  exit()
  
if k >= a:
  ans += a
  k -= (a+b)
  
if k <= 0:
  print(ans)
  exit()
  
if k >= c:
  ans -= c
  print(ans)
  exit()
  
else:
  ans -= k
  print(ans)
  exit()  

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

int cell[100][100];
int x = 0, y = 0, dir = 1;
int h, w;

void paint(int c, int num) {
    rep(i, num) {
        cell[x][y] = c;
        y += dir;
        if (y == w) {
            dir = -1;
            x++;
            y = w-1;
        } else if (y == -1) {
            dir = 1;
            x++;
            y = 0;
        }
    }
}

void show() {
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (j == 0) {
                cout << cell[i][j];
            } else {
                cout << " " << cell[i][j];
            }
        }
        cout << endl;
    }
}


void solve() {
    int n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    rep(i, n) {
        paint(i+1, a[i]);
    }

    show();
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextInt();
        long W = sc.nextInt();

        long ans = Math.min(H, W);
        if (H%3==0 || W%3==0) ans = 0;

        long w = W/2;
        long h = H*W/3/w;
        for (int i=(int)w-10;i<(int)w+10;i++) {
            for (int j=(int)h-10;j<(int)h+10;j++) {
                if (i<=0 || i>=W) continue;
                if (j<=0 || j>=H) continue;
                long[] area = new long[3];
                area[0] = (long)i*j;
                area[1] = (W-i)*j;
                area[2] = W*(H-j);
                Arrays.sort(area);
                ans = Math.min(ans, area[2]-area[0]);
            }
        }

        long y = H/2;
        long x = H*W/3/y;
        for (int i=(int)x-10;i<(int)x+10;i++) {
            for (int j=(int)y-10;j<(int)y+10;j++) {
                if (i<=0 || i>=W) continue;
                if (j<=0 || j>=H) continue;
                long[] area = new long[3];
                area[0] = i*j;
                area[1] = i*(H-j);
                area[2] = (W-i)*H;
                Arrays.sort(area);
                ans = Math.min(ans, area[2]-area[0]);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22228
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    System.out.println((A + B) >= C ? "Yes" : "No");
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define adarsh ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);



int main()
{
	adarsh;
	string s;
	int ans = 0, flag = 1;
	cin >> s;
	if (s[1] == 'S')
	{
		flag = 0;
	}
	for (int i = 0; i < s.size() ; i++)
	{
		if (s[i] == 'R')
		{
			ans++;
			if (!flag)
			{
				break;
			}
		}

	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std ;

int main(){
    int n;

    cin>>n;

    int a[n];
    a[0]=0;

    int counter[n+10]={};

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

Measured memory_bytes: 5156
X, N = map(int, input().split())
if N>0:
  P = list(map(int, input().split()))
else:
  P = []
i = 0
while True:
  if X-i not in P:
    print(X-i)
    break
  if X+i not in P:
    print(X+i)
    break
  i += 1

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;

ll next_comb(ll nCk,ll n,ll k,ll mod){
  return ((n-k)*nCk/(k+1))%mod;
}

ll kaizyo(ll n){
  if(n==1)return (ll)1;
  return n*kaizyo(n-1);
}

int main(){
  ll n,k;
  cin >> n >> k;
  n=n+1;
  vector<ll>r(n+1,0);
  rrep(i,1,n)r[i+1]=i+r[i];
  ll sum=0;
  for(int i=k;i<=n;i++){
    sum+=(r[n]-r[n-i]-r[i]+1);
    sum%=mod;
    //debug("sum",sum);
  }
  cout << sum << endl;
}






Measured memory_bytes: 4840
(let [n (read)]
  (->> (range 1 (+ 1(int (Math/sqrt n))))
       (filter #(= (mod n %) 0))
       (map #(max % (quot n %)))
       (map #(int (Math/log10 %)))
       (reduce min)
       (+ 1)
       println 
       ))


Measured memory_bytes: 70484
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data1 = new int[n];
			int [] data2 = new int[n];
			for(int i = 0; i < n; i++){
				data1[i] = sc.nextInt();
			}
			for(int i = 0; i < n; i++){
				data2[i] = sc.nextInt();
			}
			long cap = 0;
			for(int i = 0; i < n; i++){
				if(data1[i] < data2[i]){
					cap += (data2[i] - data1[i]) / 2;
				}
			}
			
			for(int i = 0; i < n; i++){
				if(data1[i] > data2[i]){
					cap -= (data1[i] - data2[i]);
				}
			}
			if(cap < 0){
				System.out.println("No");
			}
			else{
				System.out.println("Yes");
			}
			
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 42648
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	long long int N, size, cou;
	cou = 0;
	cin >> N;
	vint A(N);
	for (int i = 0; i < N; i++)cin >> A[i];



	for (int j = 0;; j++) {
		cou = 0;
		size = A.size();
		sort(A.begin(), A.end());
		for (int i = 1; i+cou < size; i++) {

			A[i] %= A[0];
			if (A[i] == 0) {
				A.erase(A.begin() + i);
				cou++;
i--;
			}
		}
		size = A.size();
		if (size == 1)break;
	}

	sort(A.begin(), A.end());
	cout << A[0] << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rint register int
#define rep(i, l, r) for (rint i = l; i <= r; i++)
#define per(i, l, r) for (rint i = l; i >= r; i--)
#define mset(s, _) memset(s, _, sizeof(s))
#define pb push_back
#define pii pair <int, int>
#define mp(a, b) make_pair(a, b)

inline int read() {
  int x = 0, neg = 1; char op = getchar();
  while (!isdigit(op)) { if (op == '-') neg = -1; op = getchar(); }
  while (isdigit(op)) { x = 10 * x + op - '0'; op = getchar(); }
  return neg * x;
}
inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

ll n,blue,red;

int main(){
    //freopen("in.txt","r",stdin);
    cin>>n>>blue>>red;
    cout << n/(blue+red)*blue+min(n%(blue+red),blue) << endl;
    return 0;

}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	string S;
	
	cin >> S;
	
	int ans = 10000;
	
	rep(i, S.length() - 2){
		int X = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0');
		ans = min(ans, abs(753 - X));
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		int[][] A = new int[N][N - 1];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N - 1; j++) {
				A[i][j] = sc.nextInt() - 1;
			}
		}

		sc.close();

		int ans = 0;

		Queue<Integer> que = new ArrayDeque<>();
		for (int i = 0; i < N; i++) {
			que.add(i);
		}

		int[] idx = new int[N];
		for (;;) {
			boolean b = false;
			boolean[] z = new boolean[N];

			Queue<Integer> newQue = new ArrayDeque<>();
			while (!que.isEmpty()) {
				int p = que.poll();

				if (idx[p] >= N - 1 || idx[A[p][idx[p]]] >= N - 1 || z[p] || z[A[p][idx[p]]]) {
					continue;
				}
				int aite = A[p][idx[p]];
				if (p == A[aite][idx[aite]]) {
					b = true;
					idx[p]++;
					idx[aite]++;
					z[p] = true;
					z[aite] = true;
					newQue.add(p);
					newQue.add(aite);

				}
			}
			que = newQue;
			if (b) {
				ans++;
			} else {
				break;
			}
		}

		for (int i = 0; i < N; i++) {
			if (idx[i] < N - 1) {
				ans = -1;
			}
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> d(n);
	rep(i,n) cin >> d.at(i);
	sort(d.begin(), d.end());
	int half = n/2; half--;
	if(d.at(half) == d.at(half + 1)) cout << 0 << endl;
	else{
		cout << d.at(half + 1) - d.at(half) << endl;
	}
} 

Measured memory_bytes: 640
#include<stdio.h>

int candy(int n){
    int i;
    int tmp;

    for(i = 1; i <= n; i++){
        tmp += i;
    }

    return tmp;
}

int main(void){
    int N;

    scanf("%d", &N);

    printf("%d\n", candy(N));

    return 0;
}

Measured memory_bytes: 128
let rec print_rectangle h w =
  match h with
  |0 -> ()
  |_ -> let rec print_sharp w =
          match w with
          |0 -> print_string "\n"
          |_ -> print_string "#";
                print_sharp (w-1)
        in
        print_sharp w;
        print_rectangle (h-1) w
;;

let () =
  let rec loop () =
    Scanf.sscanf (read_line()) "%d %d" (fun h w -> if h != 0 || w != 0 then
                                                     begin
                                                       print_rectangle h w ;
                                                       print_string "\n";
                                                       loop ()
                                                     end
      )
    in
    loop ()
;;


Measured memory_bytes: 2232
#include<stdio.h>
#include<math.h>
#define N 10000

int isPrime(int);

int main(){
  int i, n, a, count=0;

  scanf ("%d", &n);
  for (i = 0; i < n; i++) {
    scanf ("%d", &a);
    if(isPrime(a) == 0) count++;
  }

  printf("%d\n", count);

  return 0;
}

int isPrime(int a){
  int i=3;

  if(a == 2)return 0;
  if(a < 2 || a%2 == 0)return 1;
  while(i <= sqrt(a)){
    if(a%i == 0)return 1;
    i = i+2;
  }

  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
#include <complex>
#include <cassert>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define deb(a) cerr<< #a << "= " << (a)<<"\n";

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long double ld;
typedef complex<double> base;
typedef vector<int> vi;
typedef pair<int,int> pii;

template<class T> ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream; }
ll fpow(ll x, ll p, ll m){ll r=1; for (;p;p>>=1){ if (p&1) r=r*x%m; x=x*x%m; } return r;}
int gcd(int a, int b){ if (!b) return a; return gcd(b,a%b);}
ll gcd(ll a, ll b){ if (!b) return a; return gcd(b,a%b);}

ll N,a[100010],b[100010],c[100010],t[100010];

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

    int i;
    for (i=1; i<=N; i++)
        cin >> a[i];
    for (i=1; i<=N; i++)
        cin >> b[i];
    for (i=1; i<=N; i++)
        cin >> c[i];

    sort(a+1,a+N+1);
    sort(b+1,b+N+1);
    sort(c+1,c+N+1);

    int l=0;
    for (i=1; i<=N; i++){
        while (l<N && a[l+1]<b[i])
            l++;

        t[i]=l;
    }

    ll sz=0,res=0;
    l=0;
    for (i=1; i<=N; i++){
        while (l<N && b[l+1]<c[i]){
            l++;
            sz+=t[l];
        }

        res+=sz;
    }

    cout << res << "\n";
	return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == 5 && b == 5 & c == 7){
		cout << "YES" << endl;
	}
	else if(a == 5 && b == 7 & c == 5){
		cout << "YES" << endl;
	}
	else if(a == 7 && b == 5 & c == 5){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}

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

typedef long long ll;
ll arr[2000005] ;
ll MOD = 1e9 + 7;

int big_mod(ll base, ll power, ll mod)
{
  if(power == 0)  return 1;
  else if(power % 2 == 1) {
    ll p1 = base % mod;
    ll p2 = (big_mod(base, power-1, mod) ) % mod;
    return (p1 * p2) % mod;
  }
  else if(power % 2 == 0) {
    ll p1 = (big_mod(base, power/2, mod) ) % mod;
    return (p1 * p1) % mod;
  }
}

struct Point{
  ll L;
  ll R;
  ll hit;
};

//This is a custom Compare function for Priority Queue. Return statements are reversed.
struct customComp_priorityQueue {
  bool operator()(Point const& x, Point const& y) {
    if(x.L != y.L)  return (x.L > y.L);
    else  return  (x.R < y.R);
  }
};

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

  if((b*2) >= a)  cout<<0<<endl;
  else  cout<<(a - (b * 2))<<endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $H);
$hp = $H;
$num = 1;
$ans = 0;
while($hp > 1) {
    $ans += $num;
    $num *= 2;
    $hp = intdiv($hp, 2);
}
$ans += $num;
printf('%d', $ans);


Measured memory_bytes: 4604
N,Q=map(int,input().split())
s=input()
A=[0]
for i in range(N-1):
  if s[i]+s[i+1]=="AC":
    A.append(A[i]+1)
  else:
    A.append(A[i])
for i in range(Q):
  l,r=map(int,input().split())
  print(A[r-1]-A[l-1])


Measured memory_bytes: 6100
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	ll b = 0;
	ll ans = 0;
	map<ll,ll> ma;
	ma[0]++;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		b += a;
		ans += ma[b];
		ma[b]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12800
#include<iostream>
using namespace std;
#define ll long long

ll A,B;

ll f(ll N){
  if(N&1){
    if(((N+1)/2)&1) return 1;
    else return 0;
  }else{
    if((N/2)&1) return N^1;
    else return N;
  }
}

int main(){
  cin>>A>>B;
  if(A==0) cout<<f(B)<<endl;
  else cout<<(ll)(f(B)^f(A-1))<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;





int gcd(int a, int b)
{

	if (a%b == 0) {
		return b;
	}

	return gcd(b, a%b);
}
		
		

int main()
{

	int a,b,k;

	cin >> a;
	cin >> b;
	cin >> k;


	
	int s = gcd(a, b);
	int c = 0;


	while (k) {
		if (a % s == 0 && b % s == 0) {
			k--;
		}
		s--;
	}


	cout << s+1 << std::endl;
			   
	
}




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

int main() {
  int a;

  // 変数aで入力を受け取る
  cin >> a;

  if (a == 0) {
    cout << 0 << endl;
  }
  else {
    if (a % 3 == 1) {
      cout << 1 << endl;
    }
    else if (a % 3 == 2) {
      cout << 2 << endl;
    }
    else {
      cout << 3 << endl;
    }
  }
}


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

int main()
{
	const int num=3010;
	int dp[num][num]={};//i文字共通の最後要素がjに存在
	int mdp[num];
	string s,l;
	cin>>s>>l;
	if(s.length()>=l.length())
		swap(s,l);
	int sln=s.length();
	int lln=l.length();
	dp[0][0]=-1;
	int dpm=0;
	int va=0;
	for(int i=0;i<sln;i++)//s[i]のとき
	{
		if(i>0)
			for(int j=0;j<=dpm;j++)
		{
			dp[i][j]=mdp[j];
		}
		va=0;
		for(int j=0;j<=dpm&&va==0;j++)//dp[j]のとき
		{
			dp[i][dpm+1]=99999;
			for(int k=dp[i-1>=0?i-1:0][j]+1;k<lln;k++)//l上をs[i]探索
			{
				dp[i][0]=-1;
				if(s[i]==l[k])
					{
						if(j==dpm)
							{
								dpm++;
								va++;
						}
						dp[i][j+1]=min(k,dp[i][j+1]);
						break;
				}
			}
		}
		for(int j=0;j<=dpm;j++)
		{
			mdp[j]=dp[i][j];
		}
	}
	string ans="";
	int i=sln;
	int temp=-1;
	for(int j=dpm+1;i>=0&&j>1;)
	{
		while(true){
			i--;
			if(temp==dp[i][j])
			{
				continue;
			}
			j--;
			ans=l[dp[i][j]]+ans;
			temp=dp[i][j];
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35712
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		String s = sn.next();
		long total = 0;
		System.out.println(sum(total,s));
	}
	
	public static long sum(long total,String s){
		long tmp = 0;
		int n = s.length();
		for(int i = 0; i < n ;++i){
			if(i == 0) tmp = total + Long.parseLong(s);
			else{
				tmp += sum(total + Long.parseLong(s.substring(0,i)),s.substring(i,n));
			}
		}
		return tmp;
	}
}


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

using namespace std;

int main() {

    long long H, W;
    cin >> H >> W;

    long long ans = 0;

    if(H == 1 || W == 1) {
        ans = 1;
    } else {
        ans = (H * W + 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
bool check(ll mid,vi A){
  for(int i=0;i<A.size();i++){
    mid=mid-mid%A[i];
  }
  return (mid==2)?true:false;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vi A(n);
  for(int i=0;i<n;i++)cin>>A[i];
  reverse(ALL(A));
  ll ma=3,mi=2;
  for(int i=1;i<n;i++){
    mi=A[i]*(1+mi/A[i]-(mi%A[i]==0));
    ma=A[i]-1+mi;
  }
  bool flag=true;
  reverse(ALL(A));
  ll num=mi;
  for(int i=0;i<n;i++){
    num=num-num%A[i];
  }
  if(num!=2)flag=false;
  if(flag){
    ll left=ma,right=llINF;
    while(right-left>1){
      ll mid=(right+left)/2;
      if(check(mid,A))
	left=mid;
      else
	right=mid;
    }
    cout<<mi<<" "<<left<<endl;
  }else
    cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i++) a[i] = sc.nextInt();

        int button = 0;
        int count = 1;
        while(a[button] != 2){
            button = a[button] - 1;
            count++;
            if(count > N) break;
        }
        System.out.println( count < N ? count : -1);
    }
}
 

Measured memory_bytes: 50784
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;



class mint {
public:
  static int MOD;
  int x;
  mint() : x(0) {}
  mint(int x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a) {
    if ((x += a.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) {
    mint b{a};
    return *this *= b.power(MOD - 2);
  }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(int N) {
    if (N == 0) {
      return 1;
    }
    else if (N % 2 == 1) {
      return *this * power(N - 1);
    }
    else {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
int mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }


mint d[55][55][55 * 55];


signed main()
{
#ifndef ONLINE_JUDGE
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	signed n, K;
	scanf("%d%d", &n, &K);
	d[0][0][0] = 1;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j <= i; ++j) {
			for(int k = 0; k <= K; ++k) {
				d[i + 1][j + 1][k + 2 * (j + 1)] += d[i][j][k];
				d[i + 1][j][k + 2 * j] += d[i][j][k] * (2 * j + 1);
				if(j) d[i + 1][j - 1][k + 2 * (j - 1)] += d[i][j][k] * j * j;
			}
		}
	}

	cout << d[n][0][K] << endl;

    
	return 0;
}

Measured memory_bytes: 71680
#include<stdio.h>
int main(void){
	int N,l[1000],r[1000],i,s=0;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d %d",&l[i],&r[i]);
		s+=r[i]-l[i]+1;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	string S;
	int b,a0=0,a1=0,i;
	cin >> S;
	for(i=0;i<S.length();i++){
		if(S[i]=='0'){
			a0++;
		}
		else
			a1++;
		
	}
	if(a0>a1){
		cout << a1*2 << endl;
	}
	else
		cout << a0*2 << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
#define MAX 20000

bool isP[MAX];
int sumP[MAX];
void make_table(){
  for(int i=0;i<MAX;i++)isP[i]=true;
  isP[0]=isP[1]=false;
  for(int i=2;i*i<=MAX;i++){
    if(isP[i]==false)continue;
    for(int j=i*i;j<MAX;j+=i)isP[j]=false;
  }
  sumP[0]=0;
  for(int i=1;i<MAX;i++)sumP[i]=isP[i]+sumP[i-1];
}
int main(){
  make_table();
  int n,cnt;
  while(cin>>n){
    cnt=0;
    for(int i=1;i<=n;i++){
      cnt+=isP[i]&&isP[n-i+1];
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM =  1000000007;
int main()
{
    // 整数の入力
    ll N;
    bool creatable = true;
    vector<ll> H;
    cin >> N;
    for (int i = 0;i< N;i++){
        ll h;
        cin >> h;
        H.push_back(h);
    }

    H[0]--;
    for (int i = 1;i < N;i++){
        if (H[i-1] < H[i]){
            H[i]--;
        }

        if (H[i] < H[i-1]){
            creatable = false;
            break;
        }
    }
    if (creatable){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1400
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

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

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 4123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
vector < int > g[N];
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int tot[N][4];
int cnt[N][N][4];


int main () {
	SpeedForce;
	string s;
	cin >> n >> s;
	//n = sz(s);
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'R') a[i] = 0;
		else if (s[i] == 'G') a[i] = 1;
		else a[i] = 2;
	}

	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) if (a[i] != a[j]) {
			cnt[j][j-i][a[i]|a[j]]++;
			tot[j][a[i]|a[j]]++;
		}
	}
	ll ans = 0;
	for (int j = 1; j < n; ++j) {
		for (int k = j + 1; k < n; ++k) if (a[j] != a[k]) {
			int msk = 3;
			msk ^= a[k];
			ans += tot[j][msk] - cnt[j][k-j][msk];
		}
	}
	cout << ans << '\n';


	return Accepted;
}

// B...a

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

int main(){

  long long n;
  cin >>n;
  
  string s;
  cin >>s;
  
  int c=n;
  
  for(int i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1)){
    c--;}
  }
  
  
cout<<c<<endl;
  return(0);
  
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9+7;
const long double PI=acos(-1);



void solve(int T){
    int n,a,b;
    cin>>n>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%n==0){
            cout<<"OK\n";
            return;
        }
    }
    cout<<"NG\n";
}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


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

using namespace std;

const int N = 1e6 + 7;
int n;
long double k;
long double a[N];

int main()
{

        ios_base::sync_with_stdio(0);
        cin.tie(0);
        //freopen("in.in", "r", stdin);
        cin >> n >> k;
        for (int i = 0; i < n; i++)
        {
                cin >> a[i];
        }

        long double l = 0.1, r = 1e9;
        long double ans = 0;
        for (int i = 0; i < 500; i++)
        {
                long double mid = (l + r) / 2;
                long double req = 0;
                for (int i = 0; i < n; i++)
                {
                        if (a[i] <= mid)
                                continue;
                        long double x = a[i] / mid;
                        if (x == trunc(x))
                        {
                                req--;
                        }
                        req += floor(x);
                }

                if (req <= k)
                {
                        ans = mid;
                        r = mid;
                }
                else
                        l = mid;
        }
        cout << fixed << setprecision(0) << ceil(ans);
        return 0;
}


Measured memory_bytes: 6864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main() {
  string s;
  cin >> s;
  vector<int> cnt(2);
  rep(i, s.size()) cnt[s[i] - '0']++;
  cout << 2 * min(cnt[0], cnt[1]) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;
const int maximum = 2e5+1;

void solve() {
  int n;
  long long sum = 0;
  int a[maximum] = {};
  long long ans = 0;

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

  for(int i = n-1; i >= 0; i--) {
    sum -= a[i];
    ans += ((sum % mod) * a[i]) % mod;
    ans %= mod;
  }

  cout << ans << endl;
}

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

Measured memory_bytes: 4440
N = int(input())
monsters = list(map(int, input().split()))
legends  = list(map(int, input().split()))
counts = 0
for i in range(N):
  if monsters[i] >= legends[i]:
    counts += legends[i]
  else:
    if monsters[i + 1] + monsters[i] >= legends[i]:
      monsters[i + 1] = monsters[i + 1] - (legends[i] - monsters[i])
      counts += legends[i]
    else:
      counts += monsters[i + 1] + monsters[i]
      monsters[i + 1] = 0  
print(counts)

Measured memory_bytes: 18476
import sys
import math
input = sys.stdin.readline
a, b, x = map(int, input().split())
if x <= a ** 2 * b / 2:
  y = x / (a * b / 2)
  res = math.degrees(math.atan(y / b))
  print(90.0 - res)
else:
  y = 2 * b - 2 * x / (a ** 2)
  res = math.degrees(math.atan(y / a))
  print(res)

Measured memory_bytes: 38384
#include <stdio.h>

int main(void) {
	int i,x,y,s;
	
	for(i=0;;i++){
	scanf("%d %d",&x,&y);
	if(x==0 && y==0)break;
	if(x>y){
		s=x;
		x=y;
		y=s;
	}
	printf("%d %d\n",x,y);
	}
	return 0;
}



Measured memory_bytes: 2044
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>

#define rep(i,n)for(ll i=0;i<(n);i++)
using namespace std;
using ll =long long;
//const int mod = 1000000007;
//class mint {
//	long long x;
//public:
//	mint(long long x = 0) : x((x% mod + mod) % mod) {}
//	mint operator-() const {
//		return mint(-x);
//	}
//	mint& operator+=(const mint & a) {
//		if ((x += a.x) >= mod) x -= mod;
//		return *this;
//	}
//	mint & operator-=(const mint & a) {
//		if ((x += mod - a.x) >= mod) x -= mod;
//		return *this;
//	}
//	mint & operator*=(const  mint & a) {
//		(x *= a.x) %= mod;
//		return *this;
//	}
//	mint operator+(const mint & a) const {
//		mint res(*this);
//		return res += a;
//	}
//	mint operator-(const mint & a) const {
//		mint res(*this);
//		return res -= a;
//	}
//	mint operator*(const mint & a) const {
//		mint res(*this);
//		return res *= a;
//	}
//	mint pow(ll t) const {
//		if (!t) return 1;
//		mint a = pow(t >> 1);
//		a *= a;
//		if (t & 1) a *= *this;
//		return a;
//	}
//	// for prime mod
//	mint inv() const {
//		return pow(mod - 2);
//	}
//	mint& operator/=(const mint & a) {
//		return (*this) *= a.inv();
//	}
//	mint operator/(const mint & a) const {
//		mint res(*this);
//		return res /= a;
//	}
//
//	friend ostream& operator<<(ostream & os, const mint & m) {
//		os << m.x;
//		return os;
//	}
//};

int main() {
	double N,K;
	cin >> N >> K;
	double num[25];
	rep(i, 25) {
		num[i] = pow(2, i);
	}
	
		map<double, ll>tmp;
		for (double j = 1; j <= N; j++) {
		rep(i, 25) {
			if (K<=j*num[i]) {
				tmp[i]++;
				break;

			}
		}

		}
		double ans=0;
		for (auto i : tmp) {

			ans += i.second *(1/N)*(double)pow(0.5, i.first);

	}
		cout << fixed << setprecision(10) << ans;
}


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

using namespace std;

int main(){
  int i, n, x, sum, _sum;
  vector<int> data;

  while(cin >> n){
    for(i=0; i<n; ++i){
      cin >> x;
      data.push_back(x);
    }

    sort(data.begin(), data.end());

    for(i=0, sum=0, _sum=0; i<data.size(); ++i){
      _sum += data[i];
      sum += _sum;
    }

    cout << sum << endl;
    data.clear();
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

template <typename T>
std::vector<T> dijkstra(std::vector<std::vector<std::pair<int,T> > > & G, int s) {
	const T INF = std::numeric_limits<T>::max();
	int n = G.size();
	using n_node = std::pair<T,int>;
	std::vector<T> dist(n,INF);
	std::priority_queue<n_node,std::vector<n_node>,std::greater<n_node> > next;
	next.emplace(0,s);
	while(!next.empty()) {
		n_node t = next.top(); next.pop();
		int i = t.second; T cost = t.first;
		if(dist[i]!=INF) continue;
		dist[i] = cost;
		for(auto e:G[i]) {
			next.emplace(cost+e.second,e.first);
		}
	}
	return dist;
}


signed main() {
	int n,m,s;
	std::cin >> n >> m >> s;
	int X=50*n+1;
	auto enc = [&] (int i, int j) -> int {
		return i + j*n;
	};
	std::vector<std::vector<std::pair<int,int> > > g(n*X);
	rep(i,m) {
		int u,v,a,b;
		std::cin >> u >> v >> a >> b;
		u--;v--;
		for(int j=a;j<X;j++) {
			g[enc(u,j)].emplace_back(enc(v,j-a),b);
			g[enc(v,j)].emplace_back(enc(u,j-a),b);
		}
	}
	rep(i,n) {
		int c,d;
		std::cin >> c >> d;
		for(int j=0;j<X-1;j++) {
			g[enc(i,j)].emplace_back(enc(i,std::min(X-1,j+c)),d);
		}
	}
	auto dist = dijkstra<int>(g,enc(0,std::min(X-1,s)));
	for(int i=1;i<n;i++) {
		int min=INF;
		rep(j,X) {
			min=std::min(min,dist[enc(i,j)]);
		}
		print(min);
	}
	return 0;
}


Measured memory_bytes: 26060
#参考
#https://atcoder.jp/contests/abc148/submissions/9105497

import sys

n = int( input() )

if n % 2: #入力が偶数の場合、末尾にゼロは付かない
    print(0)
    sys.exit()

ans = 0
i = 0

while (10 * 5**i) <= n:
    ans += n // (10 * 5**i)
    i += 1

print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

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

int main() {
  string S;
  string ans="No";
  cin>>S;
  if(S[2]==S[3]&&S[4]==S[5])ans="Yes";
  cout<<ans;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a+b)%24 << "\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999

int main(){
    int n,m;
    while(cin>>n){
        if(n==0)break;
        cin>>m;
        string s;
        cin>>s;

        char bef='O';
        string b="";
        int ans=0;

        rep(i,s.size()){
            if(s[i]=='I'){
                if(bef=='O'){
                    b+=s[i];
                    bef='I';
                }
                else{
                    bef='I';
                    if(((int)b.size()-1)/2>=n){
                        ans+=((int)b.size()-1)/2-n+1;
                    }

                    b="I";
                }
            }
            else if(s[i]=='O'){
                if(bef=='I'){
                    bef='O';
                    b+=s[i];
                }else{
                    bef='O';
                    if(((int)b.size()-1)/2>=n){
                        ans+=((int)b.size()-1)/2-n+1;
                    }
                    b="";
                }
            }
//            cout<<i<<" "<<b<<endl;
        }
        
        if(((int)b.size()-1)/2>=n){
            ans+=((int)b.size()-1)/2-n+1;
        }

        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2120