akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
using namespace std;

int main(){
  int q; cin>>q;
  set<int>s;
  while(q--){
    int x,y;
    cin>>x>>y;
    if(x==1)cout<<s.count(y)<<endl;
    else if(x==0){
      s.insert(y);
      cout<<s.size()<<endl;
    }
    else if(x==2)s.erase(y);
    else{
      int l=y,r;
      cin>>r;
      set<int>::iterator end,it;
      it=s.lower_bound(l);
      end=s.upper_bound(r);
      for(;it!=end;it++){
        cout<<(*it)<<endl;
      }
    }
  }
}


Measured memory_bytes: 12352
s = input()
p = input()

s_charlist = list(s)
s_length = len(s)
p_length = len(p)
p_head = p[0]

msg = 'No'
for i in range(s_length):
    if p_head == s[i]:
        ans = ''
        if s_length - i < p_length:
            ans = ''.join(s_charlist[i:]) + ''.join(s_charlist[:p_length - (s_length - i) ])
        else:
            ans = ''.join(s_charlist[i:i + p_length])
        if ans == p:
            msg = 'Yes'
            break

print(msg)


Measured memory_bytes: 5564
import bisect
import sys
input = sys.stdin.readline
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
A = A[::-1]
INF = int(1e+9 + 10)
lis = [INF]* (N+1)
lis[0] = -1
for n in range(N):
    i = bisect.bisect(lis, A[n])    
    lis[i] = A[n]
print (bisect.bisect_left(lis, INF) - 1)

Measured memory_bytes: 7836
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int n1, n2;
string t1[12], t2[12];
vector<int> R, C, S;

bool passed(int r, int c, int s){
  int rcnt = 0;
  int ccnt = 0;
  int scnt = 0;

  for(int i = 0; i < n1; i++){
    int ind = 0;
    for(int j = 0; t1[i][j] == '.'; j++) ind++;

    if(r * rcnt + c * ccnt + s * scnt != ind){
      return false;
    }

    for(int j = 0; j < t1[i].size(); j++){
      switch(t1[i][j]){
      case '(': rcnt++; break;
      case '{': ccnt++; break;
      case '[': scnt++; break;
      case ')': rcnt--; break;
      case '}': ccnt--; break;
      case ']': scnt--; break;
      }
    }
  }

  return true;
}

void solve(){
  R.clear();
  C.clear();
  S.clear();

  for(int r = 1; r <= 20; r++){
    for(int c = 1; c <= 20; c++){
      for(int s = 1; s <= 20; s++){
        if(passed(r, c, s)){
          R.push_back(r);
          C.push_back(c);
          S.push_back(s);
        }
      }
    }
  }

  int rcnt = 0;
  int ccnt = 0;
  int scnt = 0;

  for(int i = 0; i < n2; i++){
    int ind = -1;

    for(int j = 0; j < R.size(); j++){
      int tind = R[j] * rcnt + C[j] * ccnt + S[j] * scnt;
      if(ind == -1){
        ind = tind;
      }
      else if(ind != tind){
        ind = -1;
        break;
      }
    }

    if(i == 0){
      cout << 0;
    }
    else{
      cout << " " << ind;
    }

    for(int j = 0; j < t2[i].size(); j++){
      switch(t2[i][j]){
      case '(': rcnt++; break;
      case '{': ccnt++; break;
      case '[': scnt++; break;
      case ')': rcnt--; break;
      case '}': ccnt--; break;
      case ']': scnt--; break;
      }
    }
  }
  cout << endl;
}

int main(){
  while(cin >> n1 >> n2, n1){
    for(int i = 0; i < n1; i++){
      cin >> t1[i];
    }
    for(int i = 0; i < n2; i++){
      cin >> t2[i];
    }
    solve();
  }
}

Measured memory_bytes: 1360
# -*- coding: utf-8 -*-

import os
import sys

def main():
    n = int(input())
    c = [
        "C",
        "D",
        "E",
        "F",
        "G",
        "H",
        "I",
        "J",
        "K",
        "L",
    ]
    print("AB" + c[n // 1000])

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int M=10000;
		for(;;)
		{
			int n=in.nextInt(),m=in.nextInt();
			if((n|m)==0)
				return;
			int cost[][]=new int[n][n];
			int mincost[]=new int[n];//頂点iへの辺の最小コスト
			boolean use[]=new boolean[n];//頂点iが部分全域木に含まれているか
			int total=0;//answer
			for(int i=0;i<n;i++)
				Arrays.fill(cost[i], M);
			Arrays.fill(mincost, M);
			Arrays.fill(use, false);
			for(int i=0;i<n;i++)
				cost[i][i]=0;
			for(int i=0;i<m;i++)
			{
				int s=in.nextInt();
				int t=in.nextInt();
				int c=in.nextInt();
				cost[s][t]=c;
				cost[t][s]=c;
			}
			mincost[0]=0;
			for(;;)
			{
				int v=-1;//追加する頂点				
				for(int j=0;j<n;j++)//追加する頂点を探す
					if(!use[j]&&(v==-1||mincost[v]>mincost[j]))
						v=j;
				if(v==-1) //全ての頂点を選んだ
					break;
				total+=mincost[v];
				use[v]=true;

				for(int j=0;j<n;j++)//追加した頂点と繋がっている辺を調べ最小コストを更新
				{
					if(!use[j]&&mincost[j]>cost[v][j])
						mincost[j]=cost[v][j];
				}
			}
			System.out.println(total);
		}
	}
}

Measured memory_bytes: 12000
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 14:58:56 2019

@author: Yamazaki Kenichi
"""

N, M, X, Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

x.sort()
y.sort()

if x[-1] >= y[0] or x[-1] >= Y or y[0] <= X:
    print('War')
else:
    print('No War')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
// #define INT_MAX 1000000000 this is wrong as INT_MAX is already included in header<climits> and  2147483647  
// #define INT_MIN -1000000000
#define INF 1000000000
#define LL_MAX 1000000000000000000
#define LL_MIN -1000000000000000000
#define mod1 1000000007
#define ll long long 
#define ld long double
#define vi vector <int>
#define vvi vector <vector<int>>
#define vll vector<long long>
#define vvl vector <vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pair<int,int>>
#define pld pair<ld,ld>
#define vpll vector<pair<ll,ll>>
#define vpld vector<pair<ld,ld>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; } 
constexpr int pct(int x) { return __builtin_popcount(x); } 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))

template<class T>
T binpow(T a, T b, T m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main(){
	int n;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++)cin>>a[i];
    b[n-1]=0;
    for(int i=n-2;i>=0;i--)b[i]=b[i+1]+a[i+1], b[i] = b[i]%mod1;
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=(a[i]*b[i])%mod1;
        sum%=mod1;
    }
    cout<<sum<<endl;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/

Measured memory_bytes: 6736
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = IntArray(n, { readLine()!!.toInt() - 1 })  // 0 オリジン

    var result = 0
    var here = 0            // 0 オリジン
    val destination = 1     // 0 オリジン
    //val visited: MutableList<Int> = mutableListOf()
    val visited = -1

    while (here != destination) {
        val next = a[here]
        if (next == visited) {    // 無限ループが発生するので到達不能
            result = -1
            break
        }
        //visited.add(next)
        a[here] = visited       // 訪問済みをマーク
        here = next
        result++
    }

    println(result)
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}
struct UnionFind {
  vector<int> par;  // 親ノード
  vector<int> rank; // ランク
  vector<int> ren;
  UnionFind(int n = 1) { init(n); }

  void init(int n = 1) {
    par.resize(n);
    rank.resize(n);
    ren.resize(n);
    for(int i = 0; i < n; ++i) {
      par[i] = i, rank[i] = 0, ren[i] = 1;
    }
  }

  int root(int x) {
    if(par[x] == x) {
      return x;
    } else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  bool merge(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y)
      return false;
    if(rank[x] < rank[y])
      swap(x, y);
    if(rank[x] == rank[y])
      ++rank[x];
    par[y] = x;
    ren[x] += ren[y];
    return true;
  }

  int getSize(int x) {
    int rootX = root(x);
    return ren[rootX];
  }
};

/*ex
UnionFind uf(N);
    double hosyu = 0;
    for (auto e : edges) {
        int u = e.second.first, v = e.second.second;
        if (uf.issame(u, v)) continue;
        hosyu += e.first;
        uf.merge(u, v);
    }
    cout << fixed << setprecision(10) << all - hosyu << endl;
*/

/*ex
UnionFind uf(N);
    double hosyu = 0;
    for (auto e : edges) {
        int u = e.second.first, v = e.second.second;
        if (uf.issame(u, v)) continue;
        hosyu += e.first;
        uf.merge(u, v);
    }
    cout << fixed << setprecision(10) << all - hosyu << endl;
*/

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  VI a(m), b(m), c(k), d(k);
  VI f(n, 0);
  VVI bl(n);
  UnionFind uf(n);
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    f[a[i]]++;
    f[b[i]]++;
    uf.merge(a[i], b[i]);
  }

  rep(i, k) {
    cin >> c[i] >> d[i];
    c[i]--, d[i]--;
    bl[c[i]].push_back(d[i]);
    bl[d[i]].push_back(c[i]);
  }

  rep(i, n) {
    ll res = uf.getSize(i) - 1 - f[i];
    for(int x : bl[i]) {
      if(uf.issame(x, i))
        res--;
    }
    cout << res << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 9088
require 'prime'
a,b = gets.split.map(&:to_i)
i = 1
mx = ([a,b].max)**0.5
diva = []
divb = []
while i <= mx
  if a % i == 0
    diva << i
    diva << a/i
  end
  if b % i == 0
    divb << i
    divb << b/i
  end
  i += 1
end
div = (diva & divb).uniq
ans = 0
div.each do |v|
  ans += 1 if v.prime?
end
p ans+1


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
  
}

Measured memory_bytes: 256
import java.util.*;

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

Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
Set<Integer> hs = new HashSet<>();
hs.add(a);
hs.add(b);
hs.add(c);
System.out.println(hs.size());

}
}



Measured memory_bytes: 21844
#include <iostream>
#include <vector>

using namespace std;

vector<string> v;
int w, h;

int dfs(int i, int j) {
	int cnt = 0;
	if (i < 0 || j < 0 || i >= h || j >= w) return 0;
	if (v[i][j] == '#') return 0;
	v[i][j] = '#';
	cnt++;
	cnt += dfs(i, j - 1) + dfs(i, j + 1) + dfs(i - 1, j) + dfs(i + 1, j);
	return cnt;
}

int main()
{
	int di, dj;

	while (cin >> w >> h, w) {
		v = vector<string>(h);
		for (int i = 0; i < h; i++) {
			cin >> v[i];
			for (int j = 0; j < w; j++) {	
				if (v[i][j] == '@') {
					di = i;
					dj = j;
				} 
			}
		}
		cout << dfs(di, dj) << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<complex>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<cstring>
using namespace std;
 
#define REP(i,x,n) for(int i = x ; i < (int)(n) ; i++)
#define rep(i,n) REP(i, 0, n)
 
struct Dice{
  //top, front, right, left, back, bottom
  string side[6];
  Dice(){}
  Dice(string s[]){
    rep(i,6) side[i] = s[i];
  }
    
  void rotate(int op){
    string tmp = "";
    //右に倒す
    if(op==0){
      tmp = side[0];
      side[0] = side[3];
      side[3] = side[5];
      side[5] = side[2];
      side[2] = tmp;
    }
  
    //前に倒す
    if(op==1){
      tmp = side[0];
      side[0] = side[4];
      side[4] = side[5];
      side[5] = side[1];
      side[1] = tmp;
    }
        
    //左に倒す
    if(op==2){
      tmp = side[0];
      side[0] = side[2];
      side[2] = side[5];
      side[5] = side[3];
      side[3] = tmp;
    }
        
    //後ろに倒す
    if(op==3){
      tmp = side[0];
      side[0] = side[1];
      side[1] = side[5];
      side[5] = side[4];
      side[4] = tmp;
    }
  
    //topとbottomを軸に右回転
    if(op==4){
      tmp = side[1];
      side[1] = side[2];
      side[2] = side[4];
      side[4] = side[3];
      side[3] = tmp;
    }
        
    //topとbottomを軸に左回転
    if(op==5){
      tmp = side[1];
      side[1] = side[3];
      side[3] = side[4];
      side[4] = side[2];
      side[2] = tmp;
    }
  }
};
 
int n;
int ans;
Dice dice[4];
 
void solve(){
  int res = 0;
   
  rep(j,6){
    if(ans <= res) break;
    vector<string> s;
    rep(i,n) s.push_back(dice[i].side[j]);
    sort(s.begin(), s.end());
    if(n==2){
      if(s[0] != s[1]) res++;
    }
    if(n==3){
      if(s[0] != s[1] && s[1] != s[2]) res+=2;
      else if(s[0] != s[1] || s[1] != s[2]) res++;
    }
    if(n==4){
      if(s[0] != s[1] && s[1] != s[2] && s[2] != s[3]) res+=3;
      else if(s[0] == s[1] && s[1] != s[2] && s[2] != s[3]) res+=2;
      else if(s[0] != s[1] && s[1] == s[2] && s[2] != s[3]) res+=2;
      else if(s[0] != s[1] && s[1] != s[2] && s[2] == s[3]) res+=2;
      else if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) res+=2;
      else if(s[0] == s[1] && s[1] == s[2] && s[2] != s[3]) res+=1;
      else if(s[0] != s[1] && s[1] == s[2] && s[2] == s[3]) res+=1;
    }
  }
 
  ans = min(ans, res);
}
 
void dfs(int idx){
  if(idx==n) solve();
  else{
    rep(i,24){
      if(i==4) dice[idx].rotate(1);
      if(i==8) dice[idx].rotate(1);
      if(i==12)dice[idx].rotate(1);
      if(i==16){
        dice[idx].rotate(1);
        dice[idx].rotate(0);
      }
      if(i==20){
        dice[idx].rotate(2);
        dice[idx].rotate(2);
      }
       
      dice[idx].rotate(4);
      dfs(idx + 1);
    }
  }
}
 
int main(){
  while(cin >> n && n){
    rep(i,n){
      rep(j,6){
        cin >> dice[i].side[j];
      }
    }
    ans = 6 * n;
    if(n > 1) dfs(1);
    else ans = 0;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
#include <string.h>

int main(void) {
  char s[110], ans = 0, i;
  scanf("%s", s);
  if(s[0] == 'A') ans = 1;
  for(i = 1; i < strlen(s); ++i) {
    if(s[i] <= s[i - 1]) ++ans;
  }
  printf("%d\n",ans);
  return 0;
} 


Measured memory_bytes: 2728
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    double pi = 3.14159265358979323846;
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    
    double h_seta = 2 * pi * (h+m/60) / 12;
    double m_seta = 2* pi * m / 60;
    double ans;
    double kaku = h_seta-m_seta;


    double temp = a*a+b*b - 2*a*b*cos(kaku);
    ans = sqrt(temp);
    print(ans);
    return 0;
}


Measured memory_bytes: 4260
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair< pair<ll,ll>,int > p;
typedef pair<ll,ll> P;



int par[110000]; //親
int ran[110000]; //木の深さ

// n要素を初期化
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    ran[i]=0;
  }
}

//木の根を求める
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

//xとyの属する集合を併合
void unite(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y) return;

  if(ran[x]<ran[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(ran[x]==ran[y]) ran[x]++;
  }
}

//xとyが同じ集合に属するか否か
bool same(int x,int y){
  return find(x)==find(y);
}

struct edge{
  int u,v,cost;
};

bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}

edge es[1100000];
int V,E,mycount=0; //頂点数と辺数
int N;


ll kruskal(){
  sort(es,es+E,comp);
  int res=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unite(e.u,e.v);
      res+=e.cost;
    }
  }
  return res;
}

void koutiku(p z[]){
    for(int i=0;i<N-1;i++){
        es[mycount].u=z[i].second;
        es[mycount].v=z[i+1].second;
        es[mycount].cost=z[i+1].first.first-z[i].first.first;
        mycount++;
    }
}

int main(){
    cin>>N;
    init(N);
    p z1[110000],z2[110000];
    for(int i=0;i<N;i++){
        cin>>z1[i].first.first>>z1[i].first.second;
        z1[i].second=i;
        z2[i].first.first=z1[i].first.second;
        z2[i].first.second=z1[i].first.first;
        z2[i].second=i;
    }
    sort(z1,z1+N);
    sort(z2,z2+N);
    koutiku(z1); koutiku(z2);
    E=mycount;
    cout<<kruskal()<<endl;;
}


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

int main(void) {
	int N;
	double D2, x, y;
	int i;
	int result;
	char buf[256], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	ch = strtok(NULL, " ");
	D2 = atof(ch);
	D2 = D2 * D2;

	result = 0;

	for(i = 0; i < N; i += 1) {
		fgets(buf, sizeof(buf), stdin);
		ch = strtok(buf, " ");
		x = atof(ch);
		ch = strtok(NULL, " ");
		y = atof(ch);
		if(x * x + y * y <= D2) {
			result += 1;
		}
	}

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


Measured memory_bytes: 2156
#include <stdio.h>

int dp[50];

int fib(int n){
	if(n==0||n==1){
		return dp[n]=1;
	}
	
	if(dp[n]!=-1) return dp[n];
	
	return dp[n] = fib(n-1)+fib(n-2);
} 

int main(){
		int n,i;
	for(i=0;i<50;i++) dp[i] = -1; 

	scanf("%d",&n);
	printf("%d\n",fib(n));
	return 0;
}

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

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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define forn(i,n) for(int i=0; i<(int)n; i++)
ll power(ll x,ll n);
bool isprime(ll n);


void test_case()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    int t=60*h+m;
    long double thetaM=M_PI*t/30 , thetaH=M_PI*t/360;

    cout<<fixed<<setprecision(9)<<sqrt((a*cos(thetaH)-b*cos(thetaM))*(a*cos(thetaH)-b*cos(thetaM)) + (a*sin(thetaH)-b*sin(thetaM))*(a*sin(thetaH)-b*sin(thetaM)));

}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}
ll power(ll x,ll n)
{
    ll ans=1;
    while(n>0) {
        if(n&1)
            ans*=x;
        n>>=1;
        x*=x;
    }
    return ans;
}

bool isprime(ll n)
{
    if(n==2 || n==3)
        return true;
    if(n<=1 || n%2==0 || (n%6!=1 && n%6!=5))
        return false;
    for(ll i=3;i*i<=n;i+=2) {
        if(n%i==0)
            return false;
    }
    return true;
}


Measured memory_bytes: 4132
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void A_Duplex_Printing(void) {

	int N;
	cin >> N;
	cout << int((N + 1) / 2);
	return;
}

void B_Bingo(void) {

	struct Num {
		int a;
		bool state = false;
	};

	struct Num num[3][3];
	
	for (int loop1 = 0; loop1 < 3; loop1++) {
		for (int loop2 = 0; loop2 < 3; loop2++) {
			cin >> num[loop1][loop2].a;
		}
	}

	int N;
	cin >> N;

	int b;
	for (int loop = 0; loop < N; loop++) {
		cin >> b;
		for (int loop1 = 0; loop1 < 3; loop1++) {
			for (int loop2 = 0; loop2 < 3; loop2++) {
				if (num[loop1][loop2].a == b) {
					num[loop1][loop2].state = true;
					goto label1;
				}
			}
		}
	label1:
		continue;
	}

	for (int loop = 0; loop < 3; loop++) {
		if (num[loop][0].state && num[loop][1].state && num[loop][2].state
			|| num[0][loop].state&& num[1][loop].state&& num[2][loop].state) {
			cout << "Yes" << flush;
			return;
		}
	}
	if (num[0][0].state && num[1][1].state && num[2][2].state
		|| num[0][2].state&& num[1][1].state&& num[2][0].state) {
		cout << "Yes" << flush;
		return;
	}

	cout << "No" << flush;
	return;
}

int main(void) {

	//A_Duplex_Printing();
	B_Bingo();
	return 0;
}


Measured memory_bytes: 256
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    w, a, b = map(int, input().strip().split())
    print(max(a, b) - (min(a, b)+w) if max(a, b) - (min(a, b)+w) >= 0 else 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 60396
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n;
bool flag;
string a,b;
int main()
{
    cin>>n>>a>>b;
    rep(i,0,a.size()-1)cout<<a[i]<<b[i];
    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Map<Integer, Integer> map = new HashMap<>();

		for (int i = 0; i < n; i++) {
			int key = scanner.nextInt();
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}

		long ans = 0;
		for (int key : map.keySet()) {
			int value = map.get(key);
			if (key == value) {
				continue;
			} else if (key > value) {
				ans += value;
			} else {
				ans += value - key;
			}
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 61088
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P_X = []

for i in range(M):
    P_X.append(list(map(int, input().split())))

for i in range(M):
    T_copy = T.copy()
    T_copy[P_X[i][0]-1] = P_X[i][1]
    print(sum(T_copy))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include "atcoder/all"
using namespace std;

int main(){
    int n, q;
    cin >> n >> q;
    atcoder::fenwick_tree<uint64_t> ft{n};
    for(int i=0;i<n;++i){
        uint64_t a;
        cin >> a;
        ft.add(i, a);
    }
    for(int i=0;i<q;++i){
        int t;
        uint64_t a, b;
        cin >> t >> a >> b;
        if(t == 0) ft.add(a, b);
        else cout << ft.sum(a, b) << "\n";
    }

    return 0;
}

Measured memory_bytes: 8228
#include<bits/stdc++.h>
#define MAX 5002
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);
	
	ll n;string s;cin>>s;
	n = s.size();

	if(s[n-1]=='1'){
		cout<<-1<<endl;
		return 0;
	}
	For(i,0,n-1){
		if(s[i]!=s[(n-1)-i-1]){
			cout<<-1<<endl;
			return 0;
		}
	}
	if(s[0]!='1'){
		cout<<-1<<endl;
		return 0;
	}

	vector<ll> v;
	For(i,0,n){
		if(s[i]=='1'){
			v.pb(i+1);
			s[(n-1)-i-1]='0';
		}
	}
	ll prev = n;
	while(v.size()>0){
		For(i,v[v.size()-1]+1,prev){
			cout<<prev<<" "<<i<<endl;
		}
		cout<<prev<<" "<<v[v.size()-1]<<endl;
		prev = v[v.size()-1];
		v.pop_back();
	}



}

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

int main() {
    int n; cin >> n;
    vector<int> v(n, 0);
    vector<int> pos(n + 1, 0);

    for(int i = 0; i < n; ++i) {
        cin >> v[i];
        pos[v[i]] = i;
    }
    
    set<int> S;
    S.insert(-1);
    S.insert(n);
    
    int64_t ans = 0;

    for(int i = 1; i <= n; ++i) {
        auto it = S.lower_bound(pos[i]);
        int right = (*it);
        it--;
        int left = (*it);
        ans += 1LL * i * (pos[i] - left) * (right - pos[i]);
        S.insert(pos[i]);
    }

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

Measured memory_bytes: 11136
ai,ao,at,aj,al,As,az = map(int,input().split())

ans = (ai//2)*4 + ao*2 + (aj//2)*4 + (al//2)*4
if(ai>0)&(aj>0)&(al>0):
    ai -= 1
    aj -= 1
    al -= 1
    tmp = 6 + (ai//2)*4 + ao*2 + (aj//2)*4 + (al//2)*4
    ans = max(ans,tmp)
print(ans//2)

Measured memory_bytes: 61964
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] += 0x20;
    cout << s << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    int h=0,w=0,c=1,d=0,n,m,k,ans=0,y;
    string s,s2;
    cin >> n;

    rep(i,n){
        rep(j,n){
            if(n==(4*i)+(7*j)){
                cout << "Yes" <<endl;
                return 0;
            }
        }
    }
    cout << "No" <<endl;
    return 0;
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    ll ans = 180 * (N-2);
    p(ans);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n;
    int ans=INF;

    cin>>n;
    rep(i,0,n+1){
        int x=i,y=n-i;
        int anss=0;
        while(x>0){
            anss+=x%6;
            x/=6;
        }
        while(y>0){
            anss+=y%9;
            y/=9;
        }
        ans=min(anss,ans);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

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

	vi cnt(100010,0);
	for(int i = 0; i < m; i++){
		int l,r;
		cin >> l >> r;
		cnt[l]++;
		cnt[r+1]--;
	}
	for(int i = 2; i <= n; i++) cnt[i] += cnt[i-1];

	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(cnt[i] == m) ans++;
	} 

	cout << ans << endl;

	return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

bool check(int m);

int N, K;
vector<int> v;

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

    cin >> N >> K;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        v.pb(a);
    }

    int l = 0, r = 1e9;
    while(r - l > 1) {
        int m = (r + l) / 2;
        if(check(m)) r = m;
        else l = m;
    }
    cout << r << endl;

    return 0;
}

bool check(int m) {
    LL c = 0;
    for(int i = 0; i < N; ++i) {
        c += (v[i] - 1) / m;
    }

    return c <= K;
}



Measured memory_bytes: 4256
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <iostream>

#pragma warning(disable:4996)

using namespace std;



int main()
{
	int a, b, c;
	while (~scanf("%d%d%d", &a, &b, &c))
	{
		bool res = false;
		for (int i = 0; i < b; ++i)
		{
			if ((a*i) % b == c)
			{
				res = true;
				break;
			}
		}
		printf("%s\n", res ? "YES" : "NO");
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output14.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long n, m, k, x, ans = 0;
	cin >> n >> m >> k;

	vector<long long> a(n + 1, 0), b(m + 1, 0);

	for (long long i = 1; i <= n; i++) {
		cin >> x;
		a[i] = a[i - 1] + x;
	}

	for (long long i = 1; i <= m; i++) {
		cin >> x;
		b[i] = b[i - 1] + x;
	}

	long long j = m;
	for (long long i = 0; i <= n; i++) {
		if (a[i] > k) break;

		while (b[j] > k - a[i]) j--;

		ans = max(ans, i + j);
		///cout << ans << "\n";
	}

	cout << ans << endl;
}

Measured memory_bytes: 6328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    vector<int>b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    if (n % 2 == 0){
        for (int i = n-1; i >= 0; i-=2) {
            cout << a.at(i) << ' ';
        }
        for (int i = 0; i < n; i+=2) {
            cout << a.at(i);
            if (i == n-2){
                cout << endl;
            }
            else {
                cout << ' ';
            }
        }
    }
    else {
        for (int i = n-1; i >= 0; i-=2) {
            cout << a.at(i) << ' ';
        }
        for (int i = 1; i < n; i+=2) {
            cout << a.at(i);
            if (i == n-1){
                cout << endl;
            }
            else {
                cout << ' ';
            }
        }
    }
}


Measured memory_bytes: 4840
#!/usr/bin/env python
# coding: utf-8

# In[1]:


C=[list(map(int,input().split())) for l in range(3)]
a=0
b=0
c=0
if C[0][0]-C[0][1]==C[1][0]-C[1][1] and C[1][0]-C[1][1]==C[2][0]-C[2][1]:
    a=1
if C[0][1]-C[0][2]==C[1][1]-C[1][2] and C[1][1]-C[1][2]==C[2][1]-C[2][2]:
    b=1
if C[0][2]-C[0][0]==C[1][2]-C[1][0] and C[1][2]-C[1][0]==C[2][2]-C[2][0]:
    c=1
if a==1 and b==1 and c==1:
    print('Yes')
else:
    print('No')


# In[ ]:






Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		arr[i] = tmp
	}
	sort.Sort(sort.IntSlice(arr))
	mn := math.MaxInt32
	for i := 0; i < n - k + 1; i++ {
		tmp := arr[i + k - 1] - arr[i]
		if tmp < mn {
			mn = tmp
		}
	}
	fmt.Println(mn)
}

Measured memory_bytes: 5504
#include <iostream>

using namespace std;

int main() {
    const int CAKE = 4;
    const int DONUTS = 7;

    int N;
    cin >> N;

    for (int c = 0; c * CAKE <= N; ++c) {
        for (int d = 0; c * CAKE + d * DONUTS <= N; ++d) {
            if (c * CAKE + d * DONUTS == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final int q = scanner.nextInt();

        final int[] members = new int[n];

        for (int i = 0; i < q; i++) {
            members[scanner.nextInt()-1]++;
        }

        for (final int member : members) {
            if(member > q-k){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 59116
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int cnt = 0;
            while (true)
            {
                if (H.Max() == 0) break;
                //前の数が0だとtrue
                bool flag = true;
                for(int i = 0; i < n; i++)
                {
                    if (H[i] == 0) flag = true;
                    if (H[i] > 0)
                    {
                        if (flag) cnt++;
                        H[i]--;
                        flag = false;
                    }
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();

    int64_t ans = 0;
    for(int i=1; i<=n; i++){
        for(int j=0; j<=n-i; j++){
            if(j == 0  &&  i == n){
                ans += stoll(s.substr(j, i));  //1回
                //cout << ans << endl;
            }else if(j == 0  ||  i == n-j){
                for(int k=0; k<(int)pow(2, n-i-1); k++) ans += stoll(s.substr(j, i));
                //cout << ans << endl;
            }else{
                for(int k=0; k<(int)pow(2, n-i-2); k++) ans += stoll(s.substr(j, i));
                //cout << ans << endl;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

/* UnionFind：素集合系管理の構造体(union by size)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
    treeSize(x): x を含む集合の要素数。
*/
struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind uf(N);              // Union-Find Tree で考える
    vector<int> edges_num(N, 0);  // 自身から出る辺の数
    vector<int> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A.at(i) >> B.at(i);
        A[i]--, B[i]--;
        edges_num[A[i]]++;
        edges_num[B[i]]++;
        uf.unite(A[i], B[i]);
    }
    vector<int> C(K), D(K);
    for (int i = 0; i < K; i++) {
        cin >> C.at(i) >> D.at(i);
        C[i]--, D[i]--;
    }

    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        ans[i] = uf.treeSize(i) - 1 - edges_num[i];
    }
    for (int i = 0; i < K; i++) {  // 同じ連結成分にあるブロック関係を引く
        if (uf.isSame(C[i], D[i])) {
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i];
        if (i != (int)ans.size() - 1) cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3968
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <queue>
using namespace std;
int main(void){
	int n,i,h=1;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++) cin>>a[i];
	for(i=1;i<=n;i++){
		h=a[h-1];
		if(h==2){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,M;
vector<ll> D,T;


int main(){
    cin >> N;
    D.resize(N);
    rep(i,N){
        cin >> D[i];
    }
    cin >> M;
    T.resize(M);
    rep(i,M){
        cin >> T[i];
    }

    if(M>N){
        cout << "NO" << endl;
        return 0;
    }else{
        map<ll,ll> mp;
        rep(i,N) mp[D[i]]++;
        rep(i,M){
            if(mp[T[i]] > 0){
                mp[T[i]]--;
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }
        cout << "YES" << endl;
    }
}


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

const int INF = 1e9;

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

  map<int, long long> a;
  for (int m=2; m<=n; m++) {
    int l = m;
    for (int i=2; i<=m; i++) {
      int cnt = 0;
      while (l % i == 0) {
        ++cnt;
        l = l / i;
      }
      a[i] += cnt;
    }
  }

  long long ans = 1;
  for (auto ai: a) {
    ans = ans * (ai.second + 1);
    ans = ans % (long long)(1e9 + 7);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
// ABC090B - Palindromic Number

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

bool isPalindromic(int n) {
	int original = n;
	int rev = 0;

	while (n > 0) {
		rev *= 10;
		rev += n % 10;
		n /= 10;
	}

	return original == rev;
}

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

	int ans = 0;
	for (int i = A; i <= B; i++) {
		if(isPalindromic(i)) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y;
	cin>>x>>y;
	for(int i=0;i<101;i++){
		for(int j=0;j<101;j++){
			if(i*2+j*4==y && i+j==x){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define lson now<<1
#define rson now<<1|1
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int mod=1e9+7;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=2e5+10;
const ll inf=0x3f3f3f3f;
double a[maxn],sum[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        a[i]=(1+a[i])/2;
        sum[i]=sum[i-1]+a[i];
    }
    double ans=0;
    for(int i=k;i<=n;i++)ans=max(ans,sum[i]-sum[i-k]);
    printf("%.10f",ans);
}



Measured memory_bytes: 3456
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	fmt.Print(getUnhiddenLength(a, b))
}

func getUnhiddenLength(a, b int) int {
	unhiddenLength := a - b*2
	if unhiddenLength <= 0 {
		return 0
	}
	return unhiddenLength
}


Measured memory_bytes: 512
import sys
# import numpy as np

def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

N, W = IL()
v_list = [0] * N
w_list = [0] * N

for i in range(N):
	w_list[i], v_list[i] = IL()

v_max = 100100
dp = [[sys.maxsize] * (v_max+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
	for j in range(v_max+1):
		if j >= v_list[i]:
			dp[i+1][j] = min(dp[i][j-v_list[i]] + w_list[i], dp[i][j])
		else:
			dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = 0
for j in range(v_max+1):
	if dp[N][j] <= W:
		ans = j

print(ans)

Measured memory_bytes: 119644