akhauriyash/Code-Regression huggingface dataset:
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0, K =0;
    cin >> N >> K;

    vll A(N);
    REP(i,N) cin >> A[i];


    //本文
    set<ll> cnt;
    REP(i,N){
      cnt.insert(A[i]);
    }

    ll ans = cnt.size()-K;

    //出力
    if(ans<0){
    cout << 0  << endl;
    }
    else{
    vll cnt2(N+1);
    REP(i,N){
      cnt2[A[i]]++;
    }

    sort(ALL(cnt2),greater<>());

ll cnt3=0;
    REP(i,K){
      cnt3+=cnt2[i];
    }

  cout << N-cnt3 << endl;
    }

    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  set<string> set;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    set.insert(s);
  }
  cout << set.size() << endl;
}

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

int f(int n){
    int x;
    if (n % 2 == 0) x = n / 2;
    else x = n * 3 + 1;
    return x;
}

int main(){
    int s;
    cin >> s;
    vector<int> a;
    REP(i, 1000000){
        bool fin = false;
        if (i == 0){
            a.push_back(s);
        }else {
            a.push_back(f(a[i - 1]));
        }
        REP(j, i - 1){
            if (a[j] == a[i]) {
                cout << i + 1 << "\n";
                fin = true;
                break;
            }
        }
        if(fin) break;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string S; cin >> S;

  int result;
  for (int i=S.length()-1; i>=0; i--) {
    if (i%2==1) continue;
    bool flg = true;
    rep(j, i/2) if (S[j]!=S[j+i/2]) flg = false;
    if (flg) { result = i; break; }
  }
  cout << result << endl;
  return 0;
}

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

int main(void)
{
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    for (int i = 0; i < N; i++)
    {
        cin >> T[i];
    }

    int busCnt = 0;
    int passnger = 0;
    sort(T.begin(), T.end(), less<int>());
    
    int tbegin = T[0];
    int tend = T[0] + K;
    passnger++;
    busCnt++;

    for(int i = 1; i < N; i++){
        if(T[i] <= tend && passnger < C) {
            passnger++;
        }

        if(T[i] > tend || passnger >= C){
            busCnt++;
            passnger = 0;
            tend = T[i] + K;
        }
    }

    cout << busCnt << endl;
    
    return 0;
}


Measured memory_bytes: 3728
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int r,g,b;
  int a;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int X;
    cin >> X;
    if(X>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
n = int( raw_input( ) )
nums = [ int( val ) for val in raw_input( ).split( " " ) ]
print( " ".join( map( str, nums ) ) )

for i in range( 1, len( nums ) ):
	key = nums[i]
	j = i - 1
	while 0 <= j and key < nums[j]:
		nums[ j+1 ] = nums[j]
		j -= 1
	nums[ j+1 ] = key
	print( " ".join( map( str, nums ) ) )

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int const nmax = 100;
string v[1 + nmax];

int main()
{
    int n, l;
    cin >> n >> l;
    for(int i = 1;i <= n;i++){
      cin >> v[i];
    }
    sort(v + 1, v + n + 1);
    for(int i = 1;i <= n;i++){
      cout << v[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = int(s.size());
  bool flag = true;
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[n-1-i]) flag = false;
  }

  string tmp2 = s.substr(0, (n-1)/2);
  int n2 = int(tmp2.size());
  for(int i = 0; i < n2/2; i++){
    if(s[i] != s[n2-1-i]) flag = false;
  }
  string tmp3 = s.substr((n+2)/2);
  n = int(tmp2.size());
  for(int i = 0; i < n/2; i++){
    if(s[i] != s[n-1-i]) flag = false;
  }

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <set>

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);

  std::set<std::string> U;
  for (size_t i = 0; i < n; ++i) {
    char buf[16];
    scanf("%s", buf);
    U.insert(buf);
  }

  size_t m;
  scanf("%zu", &m);
  bool opens = false;
  for (size_t i = 0; i < m; ++i) {
    char buf[16];
    scanf("%s", buf);
    if (U.count(buf)) {
      printf("%s by %s\n", (opens? "Closed": "Opened"), buf);
      opens = !opens;
    } else {
      printf("Unknown %s\n", buf);
    }
  }
  return 1;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;  // 番兵の次の要素から辿る
  while ( cur != nil && cur->key != key)
    cur = cur->next;
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if ( t == nil ) return;  // t が番兵の場合は処理しない
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  // 検索したノードを削除
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  // 番兵の直後に要素を追加
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key);  // より高速な入力関数を使用
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L') deleteLast();
      } else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}


Measured memory_bytes: 33924
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <memory>        // unique_ptr, shared_ptr, weak_ptr

using namespace std;

int main() {
    int x, y;
    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x > y) swap(x, y);
        cout << x << " " << y << endl;
    }
    return 0;		 
}


Measured memory_bytes: 3000
#include <utility>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <numeric>
#include <limits>
#include <queue>
#include <cstdint>


#define ll long long int
#define rep(i,rept) for (ll i = 0; i < rept; i++)
#define Yes(b) std::cout<< (b ? "Yes" : "No")<<std::endl
#define YES(b) std::cout<< (b ? "YES" : "NO")<<std::endl
#define fr first
#define se second
#define lolo 92233720368547757
#define susu 1000000007

using namespace std;
int main() {
	int n, m, x, y;
	vector<pair<int, int>> v;
	cin >> n >> m;
	rep(i, m) {
		cin >> x >> y;
		v.push_back(make_pair(y, x));
	}
	x = 0;
	y = 0;
	sort(v.begin(), v.end());
	rep(i, m) {
		if (v[i].se <= x) {
			continue;
		}
		x = v[i].fr - 1;
		y++;
	}
	cout << y;
	return 0;
}

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

vector<int> ans;

void factorize(long long n) 
{ 
	int count = 0; 

	
	while (!(n % 2)) { 
		n >>= 1;  
		count++; 
	} 

	
	if (count) 
		ans.push_back(count);//cout << 2 << " " << count << endl; 

	
	for (long long i = 3; i <= sqrt(n); i += 2) { 
		count = 0; 
		while (n % i == 0) { 
			count++; 
			n = n / i; 
		} 
		if (count) 
			ans.push_back(count);//cout << i << " " << count << endl; 
	} 

	 
	if (n > 2)
             ans.push_back(1);
		//cout << n << " " << 1 << endl; 
} 


int main()
{

  //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);

   //pr();
   //facto(mod);
  int t;
  //cin>>t;
  t=1;
  int id=1;

  

  while(t--)
{
   
      vector<int> arr;
        arr.push_back(0);
        arr.push_back(1);
        //arr[1]=1;

        for(int i=2;i<51;i++)
          arr.push_back(arr[i-1]+i);

         //for(int i=0;i<51;i++)
          //cout<<arr[i]<<" ";


     long long n;
      cin>>n;

     factorize(n);

    int sum=0;

    for(int i=0;i<ans.size();i++)
    {
        int x= lower_bound(arr.begin(),arr.end(),ans[i])-arr.begin();

         if(arr[x]>ans[i])
           x--;
        
          sum+=x;
    }

    cout<<sum;



       
}
     


return 0;
}







Measured memory_bytes: 3728
while(True):
    a,b=map(int,input().split())
    if(a==0 and b==0):
        break
    else:
        for i in range(a):
            for j in range(b):
                if((i+j) % 2 == 0):
                    print("#",end="")
                else:
                    print(".",end="")
            print()
        print()


Measured memory_bytes: 7000
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;
typedef long long ll;

ll lcm(ll a, ll b)
{
    ll x = a * b;
    if (a < b)
    {
        ll tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return x / b;
}

int main()
{
    ll l, M, x, ans;
    int N;
    cin >> N >> M;
    vector<ll> a(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> x;
        a[i] = x / 2;
    }

    l = a[0];
    bool flag = false;
    for (int i = 1; i < N; ++i)
    {
        l = lcm(l, a[i]);
        if ((l / a[i]) % 2 == 0)
        {
            flag = true;
            break;
        }
    }

    if (flag)
    {
        ans = 0;
    }
    else
    {
        x = M / l;
        ans = (x + 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: a,b,c,k

    read*, a,b,c
    read*, k

    do while(b <= a)
        b=b*2
        k=k-1
    end do

    do while(c <= b)
        c=c*2
        k=k-1
    end do

    if (k < 0) then
        print'(a)', "No"
    else
        print'(a)', "Yes"
    end if
end program main

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


int simulate (const string &s, const vector<pair<char, char>> &td, int pos) {
    for (auto c : td) {
        if (s[pos] != c.fi) continue;
        if (c.se == 'L') --pos;
        else ++pos;
        if (pos < 0) return -1;
        if (pos >= (int)s.size()) return 1;
    }
    return 0;
}

int solve(int N, const string &s, const vector<pair<char, char>> &td) {
    int low = -1, high = N;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (simulate(s, td, mid) == -1) low = mid;
        else high = mid;
    }
    int left_fall = high;
    low = -1, high = N;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (simulate(s, td, mid) == 1) high = mid;
        else low = mid;
    }
    int right_fall = N - 1 - low;
    return N - (left_fall + right_fall);
}

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

    int N, Q;
    string s;
    cin >> N >> Q >> s;
    vector<pair<char, char>> td(Q);
    rep(i, Q) {
        cin >> td[i].fi >> td[i].se;
    }
    cout << solve(N, s, td) << endl;
    return 0;
}

Measured memory_bytes: 976
#include<stdio.h>
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0},x,y;
char a[12][13];
void func(int y,int x){
	int i,xx,yy;
	a[y][x]='0';
	for(i=0;i<4;i++){
		xx=x+dx[i]; yy=y+dy[i];
		if(x>=0&&y>=0&&x<12&&y<12&&a[yy][xx]=='1') func(yy,xx);
	}
}
int main(void){
	int i,j,cnt;
	while(scanf("%s",&a[0])!=EOF)	{
		for(i=1;i<12;i++) scanf("%s",a[i]);
		cnt=0;
		for(i=0;i<12;i++){
			for(j=0;j<12;j++){
				if(a[i][j]=='1'){
					cnt++;
					func(i,j);
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 2696
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cstdio>
#include <cstring>
#include <climits>
#include <sstream>
#include <cmath>
#include <complex>
using namespace std;

typedef complex<double> point;
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define DEB 0
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); itr++)

point s[100],e[100];
point v[100];

double cross(point a, point b){
  return (a.real()*b.imag() - a.imag()*b.real());
}
int is_intersected_ls(point a1, point a2, point b1, point b2){
  return ( (cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1))<EPS &&
           (cross(b2-b1,a1-b1) * cross(b2-b1,a2-b1))<EPS );
}
point intersection_ls(point a1, point a2, point b1, point b2){
  point b = b2 - b1;
  double d1 = abs(cross(b, a1-b1));
  double d2 = abs(cross(b, a2-b1));
  double t = d1 / (d1 + d2);
  return a1 + (a2-a1) * t;
}

int main(){
  int n;
  while(scanf("%d",&n),n){
    rep(i,n){
      int a1,a2,b1,b2;
      scanf("%d%d%d%d",&a1,&a2,&b1,&b2);
      //cin >> s[i].real() >> s[i].imag() >> e[i].real() >> e[i].imag();
      s[i].real() = a1; s[i].imag() = a2;
      e[i].real() = b1; e[i].imag() = b2;
    }
    int ans = 1;
    rep(i,n){
      int cnt = 0;
      int sz = 0;
      rep(j,i){
        if( is_intersected_ls(s[i],e[i], s[j],e[j]) ){
          point kouten = intersection_ls(s[i],e[i],s[j],e[j]);
          if( abs(kouten.real()) > 100.0 - EPS ) continue;
          if( abs(kouten.imag()) > 100.0 - EPS ) continue;
#if DEB          
          cout << kouten << endl;
#endif          
          int k;
          for(k=0; k<sz; k++){
#if DEB
            cout << kouten << " : " << v[k] << " , " << EQV(kouten,v[k]) << endl;
#endif
            if( EQV(kouten, v[k]) ) break;
          }
          if( k==sz ){
            cnt++;
            v[sz++] = kouten;
          }
        }
      }
#if DEB
      printf("cnt:%d\n",cnt);
#endif
      ans += cnt+1;
    }
    printf("%d\n",ans);
  }
  return 0;
}

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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;





void one_case() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ( a + b == c + d) {
        cout << "Balanced\n";
        return;
    }
    if (a + b > c + d) {
        cout << "Left\n";
    } else {
        cout << "Right\n";
    }


}


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


    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int main() {
  int A, B;
  cin >> A >> B;
  int C, D;
  cin >> C >> D;

  cout << max(0, min(B, D) - max(A, C)) << endl;
}

Measured memory_bytes: 256
//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return 0;}
template<class T> constexpr inline T end(const T& x) {return max(T(0), x);}

#define SZ(x) int((x).size())
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define CHECK(a,b) static_assert(std::is_same<decltype(a), decltype(b)>::value, "REP diff types");

#define REPPP(i,s,c,t) for(i; ((s) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REPP2(i,n) REPPP(auto i=begin(n),i==begin(n),i!=end(n),++i)
#define REPP3(i,m,n) CHECK(m,n) REPPP(auto i=(m),i==(m),i<(n),++i)
#define REPP4(i,m,n,s) CHECK(m,n) REPPP(auto i=(m),i==(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s))
#define REPP(...) GET_MACRO(__VA_ARGS__, REPP4, REPP3, REPP2)(__VA_ARGS__)

#define REP2(i,n) for(auto i=begin(n);i!=end(n);++i)
#define REP3(i,m,n) CHECK(m,n) for(auto i=(m);i<(n);++i)
#define REP4(i,m,n,s) CHECK(m,n) for(auto i=(m);((s)>0 and i<(n)) or ((s)<0 and i>(n));i+=(s))
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)

template<class T> void _read(T &x) {cin >> x;}
void _read(size_t &x) {scanf("%zu", &x);}
void _read(int &x) {scanf("%d", &x);}
void _read(LL &x) {scanf("%lld", &x);}
void _read(ULL &x) {scanf("%llu", &x);}
void _read(double &x) {scanf("%lf", &x);}
void _read(char &x) {scanf(" %c", &x);}
void _read(char *x) {scanf("%s", x);}
void read() {}
template<class T, class... U>
void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> void _print(const T &x) {cout << x;}
void _print(const size_t &x) {printf("%zu", x);}
void _print(const int &x) {printf("%d", x);}
void _print(const LL &x) {printf("%lld", x);}
void _print(const ULL &x) {printf("%llu", x);}
void _print(const double &x) {printf("%.16lf", x);}
void _print(const char &x) {putchar(x);}
void _print(const char *x) {printf("%s", x);}
void _print(const string &x) {printf("%s", x.c_str());}
template<class T> void _print(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _print(*i++)) {
        if (i != x.cbegin()) putchar(' ');
    }
}
void print() {putchar('\n');}
template<class T, class... U> void print(const T& head, const U&... tail) {
    _print(head);
    if(sizeof...(tail)) putchar(' ');
    print(tail...);
}

//}}}
const int MOD = 1000000007;

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

#define MAX_N 200005

LL d[MAX_N], c[MAX_N];

int main()
{
    int M;
    read(M);
    REP(i, M) {
        read(d[i], c[i]);
    }

    LL ans = 0, r = 0;
    REP(i, M) {
        LL tmp = d[i] * c[i] + r;
        r = tmp % 9;
        ans += c[i];
        ans += tmp / 9;
    }
    if(r == 0) {
        ans -= 1;
    }
    print(ans - 1);
    return 0;
}


Measured memory_bytes: 3328
ma = lambda : map(int,input().split())
import sys
sys.setrecursionlimit(10**6)
class unionfind():
    def __init__(self,n):
        self.par = list(range(n))
        self.size = [1]*n
        self.rank = [0]*n

    def root(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self,x,y):
        return self.root(x) == self.root(y)

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x!=y:
            if self.rank[x] < self.rank[y]:
                 x,y = y,x
            if self.rank[x] < self.rank[y]:
                self.rank[x]+=1
            self.par[y] = x
            self.size[x] +=self.size[y]
    def get_size(self,x):
        x = self.root(x)
        return self.size[x]

n,m = ma()
ans = [0]*m
ab = []
for i in range(m):
    a,b = ma()
    ab.append((a-1,b-1))

uf = unionfind(n)
ans[m-1] = n*(n-1)//2
for i in range(m-1,0,-1):
    a,b = ab[i]
    if uf.same(a,b):
        ans[i-1] = ans[i]
    else:
        ans[i-1] = ans[i] - uf.get_size(a)*uf.get_size(b)
        uf.unite(a,b)
for a in ans:print(a)


Measured memory_bytes: 37416
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 998244353
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/

signed main()/*Check flow ---question galat mat padhna yr*/
{
    fast;
    ll n,k;
    cin>>n>>k;
    map<ll,ll>mp;
    For(i,k)
    {
        ll d;
        cin>>d;
        For(i,d)
        {
            ll x;
            cin>>x;
            mp[x]++;
        }
    }
    ll cnt=0;
    for(auto x:mp)
    {
        if(x.se)cnt++;
    }
    cout<<n-cnt<<endl;
}   

Measured memory_bytes: 3664
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		Uf uf=new Uf(s[0]);
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<s[1];i++) {
			var e=sc.Ia;
			if(e[0]==0){uf.Union(e[1],e[2]);}
			else{sb.Append((uf.Same(e[1],e[2])?1:0)+"\n");}
		}
		Console.Write(sb);
	}
}
public class Uf{
	private int[] arr,hi;
	public int all;
	public Uf(int n){
		arr=new int[n];
		hi=new int[n];
		all=n;
		for(int i=0;i<n;i++){arr[i]=-1;}
	}
	public void Union(int a,int b){
		a=Root(a);
		b=Root(b);
		if(a!=b){
			if(hi[a]<hi[b]){(a,b)=(b,a);}
			arr[a]+=arr[b];
			hi[a]=Max(hi[a],hi[b]+1);
			arr[b]=a;
			all--;
		}
	}
	public bool Same(int a,int b){return Root(a)==Root(b);}
	public int Size(int a){return -arr[Root(a)];}
	public int Root(int a){return arr[a]<0?a:arr[a]=Root(arr[a]);}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 47688
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node
{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *u, int k)
{
  while (u != NIL && k != u->key)
  {
    if (k < u->key)
      u = u->left;
    else
      u = u->right;
  }
  return u;
}

void insert(int k)
{
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL)
  {
    y = x;
    if (z->key < x->key)
    {
      x = x->left;
    }
    else
    {
      x = x->right;
    }
  }

  z->parent = y;
  if (y == NIL)
  {
    root = z;
  }
  else
  {
    if (z->key < y->key)
    {
      y->left = z;
    }
    else
    {
      y->right = z;
    }
  }
}

void inorder(Node *u)
{
  if (u == NIL)
    return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node *u)
{
  if (u == NIL)
    return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  int n, i, x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++)
  {
    cin >> com;
    if (com[0] == 'f')
    {
      scanf("%d", &x);
      Node *t = find(root, x);
      if (t != NIL)
        printf("yes\n");
      else
        printf("no\n");
    }
    else if (com == "insert")
    {
      scanf("%d", &x);
      insert(x);
    }
    else if (com == "print")
    {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}


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

int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if (b + c + d + e == a + b + c + d + e){
    cout << 1;
  }
  else if(a + c + d + e == a + b + c + d + e){
    cout << 2;
  }
  else if(a + b + d + e == a + b + c + d + e){
    cout << 3;
  }
  else if(a + b + c + e == a + b + c + d + e){
    cout << 4;
  }
  else{
    cout << 5;
  }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    string s;
    cin >> s;
    ll n = len(s);
    vector<vector<ll>> dp(n + 1, vector<ll>(2, 0));
    dp[0][0] = 1;
    rep(i, n) {
        if (s[i] == '1') {
            dp[i + 1][0] = (dp[i][0] * 2) % mod;
            dp[i + 1][1] = (dp[i][0] + dp[i][1] * 3) % mod;
        }
        else {
            dp[i + 1][0] = dp[i][0];
            dp[i + 1][1] = (dp[i][1] * 3) % mod;
        }
    }
    cout << ((dp[n][0] + dp[n][1]) % mod) << endl;
    return 0;
}


Measured memory_bytes: 5840
#include <bits/stdc++.h>
typedef long long ll;

int gcd(int a, int b){ return b == 0 ? a : gcd(b, a % b);};
ll lcm(ll a, ll b){ return a * (b / gcd(a, b)); }
using namespace std;


int main(){

    string s = "";
    cin >> s;
    if(s.size() == 2){
        cout << s << "\n";
    }else{
        reverse(s.begin(), s.end());
        cout << s << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int num[1000] = {};
    int a, b, c;

    cin >> a >> b >> c;
    num[a+100]++; num[b+100]++; num[c+100]++;

    for (int i = 0; i <= 200; i++) {
        if (num[i] == 1) {
            cout << i-100 << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<long long>A(N);
  vector<long long>B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    B.at(A.at(i)-1)=B.at(A.at(i)-1)+1;
  }
  long long sum=0;
  for(int i=0;i<N;i++){
    sum=sum+(B.at(i)*(B.at(i)-1))/2;
  }
  for(int i=0;i<N;i++){
    cout<<sum-(B.at(A.at(i)-1)-1)<<endl;
  }
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m;
    cin >> n >> m;
    if (n < m)
        swap(n,m);
    if (m == 1)
        cout << (n == 1 ? 1 : n - 2) << endl;
    else
        cout << (n - 2) * (m - 2) << endl;
}


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

int top;
int S[1000];

void push(int);
int pop(void);

int main(){
  char inp[1000];
  int  top = 0;
  int f,s;

  while(scanf("%s", inp) != EOF){
    if(inp[0] == '\n') break;
    if(inp[0] == '+'){
      f = pop();
      s = pop();
      push(f + s);
    }
    else if(inp[0] == '-'){
      s = pop();
      f = pop();
      push(f - s);
    }
    else if(inp[0] == '*'){
      f = pop();
      s = pop();
      push(f * s);
    }
    else {
      push(atoi(inp));
    }
  }

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

  return 0;
}

void push(int x){
  S[top] = x;
  top++;
}

int pop(){
  top--;
  return S[top];
}



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


using namespace std;
using ll = long long;
ll N;

int F(ll a,ll b){
  ll n = max(a,b);
  int count = 0;
    while(n > 0){
    n /= 10;
    count ++;
    }
  return count;
  }

int main(){
  ll ans = LLONG_MAX;
  cin >> N;
  for(ll i = 1LL; i <= sqrt(N); i++){
    ll tmp;
    if(N % i == 0){
      tmp = F(N/i,i); 
    }
  ans = min(ans,tmp);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    int n, k;
    std::string s;
    std::cin >> n >> k >> s;
    s[k - 1] -= 'A' - 'a';
    out(s);
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


Measured memory_bytes: 256
let m, d = Scanf.scanf " %d %d" @@ fun a b -> a, b
let f m d = d mod 10 >= 2 && d / 10 >= 2 && d / 10 * (d mod 10) = m
let ans = ref 0
let _ = for i = 2 to m do for j = 2 to d do if f i j then incr ans done done; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;




int main(void) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    ll p=b-d, q=c-a;
    pt(c+p << " " << d+q << " " << a+p << " " << b+q);
    
    
    
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <deque>
using namespace std;

struct S {
	int now, t, rem;
};
bool comp(const S& s1, const S& s2) {
	return s1.t < s2.t;
}

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

	int n;
	while(cin >> n, n) {
		deque<S> lane[2];
		for(int i = 0; i < n; i++) {
			int t, c;
			cin >> t >> c;
			S s = { 0, t, c };
			lane[0].push_back(s);
		}
		sort(lane[0].begin(), lane[0].end(), comp);

		int ans = 0;
		while(lane[0].size() + lane[1].size()) {
			int idx = 0;
			if(lane[0].size() == 0 || lane[1].size() && lane[0][0].t - lane[0][0].now > lane[1][0].t - lane[1][0].now)
				idx = 1;

			int time = lane[idx][0].t - lane[idx][0].now;
			deque<S> temp;
			while(lane[idx].size() && lane[idx][0].t - lane[idx][0].now <= time) {
				S s = lane[idx][0];
				lane[idx].pop_front();

				s.now = 0;
				if(idx == 1) {
					s.rem--;
				}
				if(s.rem) {
					temp.push_back(s);
				}
			}

			sort(temp.begin(), temp.end(), comp);
			for(int i = 0; i < 2; i++) {
				for(S& s : lane[i]) {
					s.now += time;
				}
			}

			for(S s : temp) {
				lane[1 - idx].push_back(s);
			}
			ans += time;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3020
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s.size()%2==1){
		cout<<"No";
		return 0;
	}
	for(int i=0;i<s.size();i+=2)
		if(s[i]!='h'||s[i+1]!='i'){
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 384
import copy
from collections import deque
import bisect

N=int(input())
A=deque(map(int, input().split()))

i = 1
sum = 0
end = False
while True:
    while A[0] != i:
        A.popleft()
        sum += 1
        if len(A) == 0:
            end = True
            break

    if end == True:
        if i == 1:
            sum = -1
        break

    A.popleft()
    i += 1
    if len(A) == 0:
        break

print(sum)

Measured memory_bytes: 78064
import numpy as np


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    sum_A = np.sum(A)
    sum_B = np.sum(B)
    diff_AB = A - B

    if sum_A > sum_B:
        ans = 'No'
    else:
        cnt_1 = 0
        cnt_2 = 0
        for d in diff_AB:
            if d > 0:
                cnt_1 += d
            else:
                cnt_2 += (-d + 1) // 2

        if max(cnt_1, cnt_2) <= sum_B - sum_A:
            ans = 'Yes'
        else:
            ans = 'No'

    print(ans)


main()


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

using namespace std;

int main() {
    string s;
    cin >> s;
    if(s == "SUN") puts("7");
    else if(s == "MON") puts("6");
    else if(s == "TUE") puts("5");
    else if(s == "WED") puts("4");
    else if(s == "THU") puts("3");
    else if(s == "FRI") puts("2");
    else if(s == "SAT") puts("1");

}

Measured memory_bytes: 256
s=input()
N=len(s)
res = (-1, -1)
# 2文字
for i in range(N-1):
    tgt = s[i:i+2]
    if tgt[0]==tgt[1]:
        res = (i+1,i+2)

# 3文字
for i in range(N-2):
    tgt = s[i:i+3]
    if tgt[0]==tgt[2]:
        res = (i+1,i+3)
print(*res)

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

int main() {
  int n,k,ans=1000000001;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin >> h[i];
  sort(h.begin(),h.end());
  for(int i=0;i<n+1-k;i++) {
    ans=min(h.at(i+k-1)-h.at(i),ans);
  };
  cout << ans << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s == "abc")cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int d,g;
    std::cin >> d>>g;
    std::vector<int> p(d),c(d);
    rep(i,d)std::cin >> p[i]>>c[i];
    int ans=INF;
    brep(d){
        int dum=0,gdum=0;
        std::vector<bool> h(d,0);
        rep(i,d)if(bit&(1<<i))h[i]=1;
        rep(i,d){
            if(h[i]){
                gdum+=c[i];
                gdum+=p[i]*100*(i+1);
                dum+=p[i];
            }
        }
//        std::cout << gdum << std::endl;
        irep(i,d){
            if(gdum>=g)break;
            if(!h[i])rep(j,p[i]){
                if(gdum>=g)break;
                dum++;
                gdum+=100*(i+1);
            }
        }
        if(gdum>=g)ans=min(ans,dum);
    }
    std::cout << ans << std::endl;
}

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

constexpr int inf = 1e9;

bool dfs(vector<vector<int>> const& g, vector<int>& col, int v, int& sz1, int& sz2, int c) {
    if(col[v] != -1 && c != col[v]) return false;
    if(col[v] != -1) return true;
    col[v] = c;
    sz1 += c; sz2 += !c;
    bool res = true;
    for(int i = 0; i < (int)g.size(); ++i) {
        if(g[v][i] == 0 || i == v) continue;
        res &= dfs(g, col, i, sz1, sz2, !c);
    }
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n, vector<int>(n, 1));
    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        g[a - 1][b - 1] = g[b - 1][a - 1] = 0;
    }

    vector<int> sz1, sz2, col(n, -1);
    for(int i = 0; i < n; ++i) {
        if(col[i] != -1) continue;
        int s1 = 0, s2 = 0;
        if(!dfs(g, col, i, s1, s2, 0)) {
            cout << -1 << endl;
            return 0;
        }
        sz1.push_back(s1), sz2.push_back(s2);
    }
    vector<int> dp(n + 1, -inf);
    dp[0] = 0;
    const int sz = sz1.size();
    int sum = 0;
    for(int i = 0; i < sz; ++i) {
        vector<int> nxt(n + 1, -inf);
        for(int j = 0; j <= n; ++j) {
            if(dp[j] == -inf) continue;
            int k = sum - j;
            nxt[j + sz1[i]] = max(nxt[j + sz1[i]], dp[j] + sz1[i] * k + sz2[i] * j + sz1[i] * sz2[i]);
            nxt[j + sz2[i]] = max(nxt[j + sz2[i]], dp[j] + sz2[i] * k + sz1[i] * j + sz1[i] * sz2[i]);
        }
        sum += sz1[i] + sz2[i];
        dp = move(nxt);
    }

    int ans = 0;
    for(int i = 0; i <= n; ++i) {
        ans = max(ans, dp[i]);
    }
    ans -= n * (n - 1) / 2 - m;
    ans = m - ans;

    cout << ans << endl;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long

int N, M, ans, time_sum;
double q;

void solve(){
    time_sum = 1900 * M + 100 * (N - M);

    q = pow(0.5, M);

    ans = (int)(time_sum / q);

    cout << ans << endl;
}

int main(){
    cin >> N >> M;

    solve();
}


Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
#include<map>
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll kai[3000],inv[3000];
int n,k;
ll mod_pow( ll x,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1){
            res=res*x%mod;
        }
        x=x*x%mod;
        n/=2;
    }
    return res;
}
void init(){
    kai[0]=1LL;
    for(ll i=1LL;i<=2500;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=MOD;
    }
    inv[2500]=mod_pow(kai[2500],MOD-2LL,MOD);
    for(ll i=2499;i>=0;i--){
        inv[i]=inv[i+1]*(i+1);
        inv[i]%=MOD;
    }
}
int main(){
    ll ans;
    scanf("%d %d",&n,&k);
    init();
    for(ll i=1;i<=k;i++){
        ans=1LL;
        ans*=kai[k-1];
        ans%=MOD;
        ans*=inv[i-1];
        ans%=MOD;
        ans*=inv[k-i];
        ans%=MOD;
        ans*=kai[n-k+1];
        ans%=MOD;
        ans*=inv[i];
        ans%=MOD;
        if(n-k+1-i>=0){
            ans*=inv[n-k+1-i];
            ans%=MOD;
            printf("%lld\n",ans);
        }
        else{
            printf("0\n");
        }
    }
}

Measured memory_bytes: 256
/*************************************************************************
  >         File: C.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sun 23 Oct 2016 10:16:05 PM CST
*************************************************************************/
#include <bits/stdc++.h>

const int N = 1e5 + 5;
int A[N], B[N], C[N], D[N];

int main() {
  std::ios::sync_with_stdio(0);
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) std::cin >> A[i];
  for (int i = 0; i < n; ++i) std::cin >> B[i];
  for (int i = 0; i < n; ++i) {
    if (i == 0) C[i] = A[i];
    else if (A[i] != A[i - 1]) C[i] = A[i];
  }
  for (int i = n - 1; i >= 0; --i) {
    if (i == n - 1) D[i] = B[i];
    else if (B[i] != B[i + 1]) D[i] = B[i];
  }
  int ans = 1;
  const int MO = 1e9 + 7;
  for (int i = 0; i < n; ++i) {
    if (C[i] && C[i] > B[i]) ans = 0;
    if (D[i] && D[i] > A[i]) ans = 0;
    else if (!C[i] && !D[i]) ans = 1LL * ans * std::min(A[i], B[i]) % MO;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1536