akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int s=sc.nextInt();
		int g=sc.nextInt();
		int cosu=0;

		for(int i=s; i<=g; i++) {
			int a=i/10000;
			int b=(i%10000)/1000;
			int c=(i%1000)/100;
			int d=(i%100)/10;
			int e=i%10;

			if(a==e && b==d) {
				cosu++;
			}
		}
		System.out.println(cosu);
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end() 
typedef long long ll;
using namespace std;

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

    if(n%10 == 3) {
        ans = "bon";
    } else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) {
        ans = "pon";
    } else {
        ans = "hon";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
tokuhyo = []

N, M = map(int,input().split())
tokuhyo = list(map(int, input().split()))

yuukou = sum(tokuhyo) / (M * 4)

ok = 0

for i in range(N):
    if tokuhyo[i] >= yuukou:
        ok += 1

if ok >= M:
    print('Yes')
else:
    print('No')

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

void solve(){
	ll n,sum=0;
	cin >> n;
	for(ll i=1; i<=n; ++i){
		if(i%3 != 0 && i%5 != 0){
			sum += i;
		}
	}
	cout << sum << "\n"; 
}

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


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    while ( a.size()>1 ) {
        sort(a.begin(), a.end());
        vector<int> b;
        b.push_back(a[0]);
        for (int i=1; i<a.size(); i++) {
            int x=a[i]%a[0];
            if ( x ) b.push_back(x);
        }
        swap(b,a);
    }
    if ( a.size() ) cout << a.back() << '\n';
    else cout << 0 << '\n';
    return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#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 FORR(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 llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

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




//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x / tmp) * y;
}


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


int main() {

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

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

	if (a[n / 2] == a[n / 2 - 1]) {

		cout << "0" << endl;

	}
	else
	{
		cout << a[n / 2] - a[n / 2 - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


long long n, m;

long long cdif(long long a, long long b) {
  if (a % 2 == 0 || b % 2 == 0) return 0;
  else return min(a, b);
}
long long tmp[3];

int main() {
  while (cin >> n >> m) {
	long long res = n*m;
	for (long long i = 1; i < m; ++i) {
	  tmp[0] = n * i;
	  long long rem = m - i;
	  long long dif = cdif(n, rem);
	  tmp[1] = (n * rem + dif)/2;
	  tmp[2] = (n * rem - dif)/2;
	  sort(tmp, tmp+3);
	  chmin(res, tmp[2] - tmp[0]);
	}
	swap(n, m);
	for (long long i = 1; i < m; ++i) {
	  tmp[0] = n * i;
	  long long rem = m - i;
	  long long dif = cdif(n, rem);
	  tmp[1] = (n * rem + dif)/2;
	  tmp[2] = (n * rem - dif)/2;
	  sort(tmp, tmp+3);
	  chmin(res, tmp[2] - tmp[0]);
	}
	cout << res << endl;
  }
}









Measured memory_bytes: 256
#include <stdio.h>
#define N 8
int A[N][N]={-1};
int row[N]={-1}; //yoko
int col[N]={-1}; //tate
int dpos[15]={-1};//hidarinaname
int dneg[15]={-1}; //miginaname
void putQueen(int i);
void printBoard();     
int main(){
  int i,j,k,l;
  scanf("%d",&k);
  for(l=0;l<k;l++){
    scanf("%d%d",&i,&j);
    A[i][j]=1;
  }
   putQueen(0);
  return 0;
}

void putQueen(int i){
  int j;
  //printf(" %d",i);
  if (i == N){
    printBoard();
    return;
  }
  for (j=0;j<N;j++){
    if (col[j] ==1 ||dpos[i+j] == 1 || dneg[i-j+N-1] == 1) continue;
    // put a queen at (i, j)
      row[i] = j;
      col[j] = dpos[i+j] = dneg[i-j+N-1] = 1;
      // try the next row
      putQueen(i+1);
       row[i]=col[j] = dpos[i+j] = dneg[i-j+N-1] = -1;
  }
}
void printBoard(){
  int i,j;
  for(i = 0;i<N;i++) {
    for(j = 0;j<N;j++) {
      if(A[i][j]==1) {
        if(row[i] != j) return;
      }
    }
  }
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, M;
  cin >> N >> M;
  map<ll, ll> m;
  rep(i, N) {
    ll k;
    cin >> k;
    rep(j, k) {
      ll a;
      cin >> a;
      m[a]++;
    }
  }

  ll ans = 0;
  for (auto mm : m) {
    if (mm.second == N) {
      ans++;
    }
  }
  COUT(ans);
  return 0;
}

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

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

typedef long long ll;
typedef unsigned long long ull;
const ull c = 1145148931919LL;

ull ro[1000100];
ull tei[1000100];
int nn;
bool check(int a, int b, int c, int d) {
	if(a < 0 || c < 0) return false;
	if(nn <= b || nn <= d) return false;
	ull aa = ro[b];
	ull bb = ro[d];
	if(a) aa += -ro[a - 1] * tei[b - a+1];
	if(c) bb += -ro[c - 1] * tei[d - c+1];
	return aa == bb;
}

int calc1(string &a, int l, int r) {
	int ll = 0;
	int rr = INT_MAX / 10;
	while(rr - ll > 1) {
		int mid = (ll + rr) / 2;
		if(check(l, l + mid - 1, r, r + mid - 1)) {
			ll = mid;
		}
		else {
			rr = mid;
		}
	}
	return ll;
}

int calc2(string &a, int l, int r) {
	int ll = 0;
	int rr = INT_MAX / 10;
	while(rr - ll > 1) {
		int mid = (ll + rr) / 2;
		if(check(l - mid + 1, l, r - mid + 1, r)) {
			ll = mid;
		}
		else {
			rr = mid;
		}
	}
	return ll;
}

int main() {
	string s, t;
	cin >> s >> t;
	string a = s + t;
	nn = a.size();
	int n = s.size();
	int m = t.size();
	int ans = 0;
	rep(i, n + m) {
		if(i) (ro[i] += ro[i - 1]);
		(ro[i] *= c);
		(ro[i] += a[i] - 'a' + 1);
	}
	tei[0] = 1;
	rep(i, n + m) {
		if(i) tei[i] = tei[i - 1] * c;
	}
	rep(i, n) {
		if(i + m - 1 >= n) break;
		int l = calc1(a,i,n);
		int r = calc2(a,i+m-1,n+m-1);
		if(l+r+1==m) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10936
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,sum;
  cin>>a>>b>>c;
  sum=a+b+c;
  
  if(sum>=22)
    cout<<"bust"<<"\n";
  else
    cout<<"win"<<"\n";
  return 0;
}

Measured memory_bytes: 256
class BIT():
    def __init__(self,size):
        self.size=size
        self.node=[0]*(size+1)

    def sum(self,idx):
        ret=0
        while idx>0:
            ret+=self.node[idx]
            idx-=idx&(-idx)
        return ret

    def add(self,idx,x):
        while idx<=self.size:
            self.node[idx]+=x
            idx+=idx&(-idx)

n,k=map(int,raw_input().split())
a=[int(raw_input()) for _ in xrange(n)]
diff=[]
for i in xrange(n):
    diff.append(a[i]-k)
for i in xrange(n-1):
    diff[i+1]+=diff[i]
bit=BIT(n)
s=set([])
for i in xrange(n):
    bit.add(i+1,1)
    s.add(diff[i])
li=list(s)
li.sort()
d={}
for i in xrange(len(li)):
    d[li[i]]=i
pos=[[] for _ in xrange(len(li))]
for i in xrange(n):
    idx=d[diff[i]]
    pos[idx].append(i+1)
ans=0
for i in xrange(len(li)):
    for j in pos[i]:
        ans+=bit.sum(n)-bit.sum(j)
        if diff[j-1]>=0:
            ans+=1
        bit.add(j,-1)
print ans


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

typedef long long ll;
const ll InF = 1e15;

int main() {
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    long double ans = (long double) w * h / 2;
    int ways;
    if (w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2) ways = 1;
    else ways = 0;
    cout<<ans<<" "<<ways<<endl;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  int x = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (x ^ a[i]) << ' ';
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 3952
x,y = map(int, input().split())

al = [1,3,5,7,8,10,12]
bl = [4,6,9,11]
cl = [2]

if x in al:
    if y in al:
        print("Yes")
    else:
        print("No")
        
elif x in bl:
    if y in bl:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int L[]=new int[M];
		int R[]=new int[M];
		int maxl,minr;
		int result;
		for(int i=0;i<M;i++) {
			L[i]=sc.nextInt();
			R[i]=sc.nextInt();
		}
		maxl=L[0];
		minr=R[0];
		for(int j=0;j<M;j++) {
			if(maxl<L[j]) {
				maxl=L[j];
			}
			if(minr>R[j]) {
				minr=R[j];
			}
		}
		result=minr-maxl+1;
		if(result<0) {
			result=0;
		}
		if(result>N) {
			result=N;
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 76760
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;

void main(){
	auto Q=readln.split.to!(int[]),A=Q[0],B=Q[1],C=Q[2];
	if(C>=A&&C<=B)writeln("Yes");
	else writeln("No");
}

Measured memory_bytes: 256
x=range(int(input()))
P=[]
Q=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:Q+=[P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]]
print(sum(Q)*0.5)

Measured memory_bytes: 7728
#include <bits/stdc++.h>
using namespace std;
using lint = long;
using ll = long long;
#define rep(i,n) for(lint (i) = 0;(i) < (lint)(n);(i)++)
#define repInRange(i,start,end) for(lint (i) = (start);(i) < (end);++(i))
using lpair = pair<lint,lint>;
using vl = vector<lint>;
using vll = vector<long long>;
using Llist = list<lint>;
using vs = vector<string>;
#define all(v) (v).begin(),(v).end()
#define out1(x) cout << (x) << '\n';

ll pow(ll k,ll l) {
	ll ret = 1;
	rep(i,l) {
		ret *= k;
	}
	return ret;
}

template <typename T>
T sum(vector<T> vec) {
	ll ret = 0;
	rep(i,vec.size()) {
		ret += vec.at(i);
	}
	return ret;
}

void Main() {
	lint m,n;
	cin >> m >> n;
	out1((n*(n-1))/2+(m*(m-1))/2);
}

signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>

int main() {
ll n,x,sum=0; cin>>n>>x;
vl a(n);
    rep(i,n)cin>>a[i];
    rep(i,n-1){
        if(a[i]+a[i+1]>x){
            sum+=a[i]+a[i+1]-x;
            a[i+1]-=min(a[i+1],a[i]+a[i+1]-x);
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
AB = [[int(i) for i in input().split()] for j in range(3)]

List = [0 for i in range(4)]
for i in range(len(AB)):
    for j in range(2):
        List[AB[i][j]-1] += 1
one = 0
two = 0
for i in List:
    if i == 1:
        one += 1
    if i == 2:
        two += 1
ans = "NO"
if one == 2 and two == 2:
    ans = "YES"

print(ans)


Measured memory_bytes: 3064
def main():
    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))
    inf = float('inf')
    dp = [inf] * n
    dp[0] = 0
    #dp = [0] * n

    for i1, each_h in enumerate(h):
        if i1 == 0:
            continue
        start = max(0, i1 - k)
        dp[i1] = min([abs(each_h - each_h2) + each_dp for each_h2, each_dp in zip(h[start:i1], dp[start:i1])])

    print(dp[n - 1])

if __name__ == '__main__':
    main()

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

int p;
vector<string> s;

int dfs(int d) {
  if (s[p][d] == '+') {
    int res = 0;
    p++;
    while (p < s.size() && s[p].size() - 1 > d) res += dfs(d + 1);
    return res;
  } else if (s[p][d] == '*') {
    int res = 1;
    p++;
    while (p < s.size() && s[p].size() - 1 > d) res *= dfs(d + 1);
    return res;
  } else {
    int res = s[p][d] - '0';
    p++;
    return res;
  }
}

int main() {
  int n;
  while (cin >> n, n) {
    s = vector<string>(n);
    REP(i, n) cin >> s[i];
    p = 0;
    cout << dfs(0) << endl;;
  }
}



Measured memory_bytes: 3044
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 998244353;
void Debug(auto a);
double PI = 3.14159265358979;
void input(vector<auto>& a,int n);
int n;

// 平方数かどうかの判定
bool is_squere(long long N) {
    long long r = (long long)floor(sqrt((long double)N));  // 切り捨てした平方根
    return (r * r) == N;
}

signed main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int d;
    cin >> n >> d;
    twovec(a,n,d);
    REP(i,n){
        input(a[i],d);
    }
    int ans = 0;
    REP(i,n){
        FOR(j,i+1,n){
            int cnt = 0;
            REP(k,d){
                cnt += (a[i][k]-a[j][k])* (a[i][k]-a[j][k]);
            }
            if(is_squere(cnt)){
                ans++;
            }
        }
    }
    print(ans);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,count,p = 0;
  string S;
  vector<int> group(0);
  string check = "10";
  cin >> N >> K >> S;
  int i = 0;
  while (p < S.size()) {
    count = 0;
    while (p < S.size() && S.at(p) == check.at(i%2)) {
      p++;
      count ++;
    }
    group.push_back(count);
    i++;
  }
  if (i % 2 == 0) {
    group.push_back(0);
  }
  
  int sum = 0, mymax = 0;
  if (2*K+1 >= group.size()) {
    for (int &x: group){
      sum += x;
    }
    cout << sum << endl;
    return 0;
  }
  for (int j = 1; j+2*K <= group.size(); j += 2) {
    sum = 0;
    for (int k = 0; k < 2*K+1; k++) {
      sum += group.at(j+k-1);
    }
    if (sum > mymax) {
      mymax = sum;
    }
  }
  cout << mymax << endl;
  return 0;
}

Measured memory_bytes: 1020
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution <int> range(1, 3);
typedef pair <int, int> pii;

const int N = 1000007;
int n, a[N], b[N], cnt[4];

int f(int x) {
    int tmp = 2, res = 0;
    while (x >= tmp) {
        res += x / tmp;
        tmp *= 2;
    }
    return res;
}

int c(int x, int y) {
    if (y > x) {
        return 0;
    }
    if (f(x) > f(y) + f(x - y)) {
        return 0;
    }
    return 1;
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
    #endif

    int tc;
//    cin >> tc;
    tc = 1;
    while (tc--) {
        cin >> n;
        char ch;
        for (int i = 1; i <= n; i++) {
            cin >> ch;
            a[i] = (ch - '0');
        }
        bool flag = false;
        for (int i = 1; i <= n - 1; i++) {
            for (int j = 1; j <= n - i; j++) {
                b[j] = abs(a[j] - a[j + 1]);
            }
            cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
            for (int j = 1; j <= n - i; j++) {
                a[j] = b[j];
                cnt[a[j]]++;
            }
            a[n - i + 1] = 0;
            int col = 0;
            for (int j = 0; j <= 3; j++) {
                if (cnt[j]) {
                    col++;
                }
            }
            if (col < 3 && cnt[0]) {
                int two = 0;
                if (cnt[2]) {
                    two = 1;
                    for (int j = 1; j <= n - i; j++) {
                        if (a[j] == 2) {
                            a[j] = 1;
                        }
                    }
                }
                int ans = 0;
                for (int j = 1; j <= n - i; j++) {
                    ans ^= (a[j] & c(n - i - 1, j - 1));
                }
                if (ans == 0) {
                    cout << "0\n";
                }   else {
                    cout << (1 + two) << '\n';
                }
                flag = true;
                break;
            }
        }
        if (!flag) {
            cout << a[1] << '\n';
        }
        cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = b[i] = 0;
        }
    }
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
int main()	{
    int h,n,i;
    string str;
    cin>>h>>n;
    rep(i,n){
        int a;
        cin>>a;
        h-=a;
    }
    if(h>0){str="No";}
    else {str="Yes";}
cout<<str<<endl;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll> a(n),b(n),c(m),d(m);
  for(i=0;i<n;i++)cin>>a[i]>>b[i];
  for(i=0;i<m;i++)cin>>c[i]>>d[i];

  for(i=0;i<n;i++){
    buf=INF;
    for(j=0;j<m;j++){
      if(buf>abs(a[i]-c[j])+abs(b[i]-d[j])){
        buf=abs(a[i]-c[j])+abs(b[i]-d[j]);
        res=j+1;
      }
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>

using namespace std;

int main(void) {
    string s; cin >> s; // 入力
    bool flag = true; // 「踏みやすい」かどうか判定するフラグ,

    // 文字列sの要素数だけループ回す(10文字だと10回回る)
    // 踏みにくいステップ(文字列)を受け取った場合、即座にフラグがfalseになる
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) { // 偶数ステップ(i=0,2,4,6...)
            if (s[i] == 'L') {
                flag = false; // 踏みにくい！
                break;
            }
        }
        else { // 奇数ステップ(i=1,3,5,7...)
            if (s[i] == 'R') {
                flag = false; // 踏みにくい！
                break;
            }
        }
    }

    // 踏みやすい(flag == true)なら"Yes"、そうでなければ"No"
    cout << (flag ? "Yes" : "No") << endl;
    //return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 2005
const int mod = 1000000007;
int n,a[maxn];
ll k,ans;
int main(){
  n = getint(), k = getint();
  for(int i = 1;i <= n;i++) a[i] = getint();
  for(int i = 1;i <= n;i++){
    ll cnt = 0;
    for(int j = i - 1;j >= 1;j--) cnt += (a[j] < a[i]);
    (ans += cnt * (k * (k - 1) / 2 % mod)) %= mod;
    cnt = 0;
    for(int j = i + 1;j <= n;j++) cnt += (a[j] < a[i]);
    (ans += cnt * (k * (k + 1) / 2 % mod)) %= mod;
  }
  putll(ans,'\n');
  bufo.flush();
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int vis[100010], flag;
int n, m, a, b;
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++){
		scanf("%d%d", &a, &b);
		vis[a]++, vis[b]++;
	}
	for(int i = 1; i <= n; i++){
		if(vis[i] & 1)flag = 1;
	}
	if(flag)printf("NO\n");
	else printf("YES\n");
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (4e18) + 9;
const int MOD = (1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { r, d, l, u };
int dx[] = { 0, 1, 0,-1 };
int dy[] = { 1, 0,-1, 0 };

//enum diR { d, r, u, l , dr, ur, dl, ul };
int dX[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dY[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou"; //and sometimes "aeiouy"

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D matrix to 1D array. (Zero-indexed)
int ord(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D matrix . (One-indexed)
ii rord(int n, int nCol) {
	int r = n%nCol, c = n / nCol;
	if (n%nCol == 0) c--, r = nCol;
	return ii(r, c);
}

ll poww(ll num, ll p, ll md = MOD) {
	num %= md;
	ll ret = 1;
	while (p > 0) {
		if (p & 1) ret = (ret * num) % md;
		num = (num * num) % md;
		p >>= 1;
	}
	return ret;
}

ll nCr(ll n, ll r) {
	if (n < r)
		return 0;
	if (r == 0)
		return 1;
	return n * nCr(n - 1, r - 1) / r;
}

const int N = 1e5 + 10;
ll dp[110][N], v[110];
int n, W, w[110];
ll solve(int idx, int we) {
	if (we < 0) return -oo;
	if (idx >= n) return 0;
	ll& ret = dp[idx][we];
	if (~ret) return ret;
	return ret = max(solve(idx+1, we), v[idx] + solve(idx+1, we - w[idx]));
}


int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> W;
	lop(i, n) cin >> w[i] >> v[i];
	mem(dp, -1);
	cout << solve(0,W) << endl;



	return 0;
}


Measured memory_bytes: 86272
n,m = map(int,input().split())
base_1 = []
key = {}
ans_str = []
ans_n = []

for i in range(m):
  p,y = map(int,input().split())
  base_1.append([p,y,i])
  
base_1.sort(key = lambda x:x[1])

for i in range(m):
  p_str = str(base_1[i][0])
  len_p = len(list(p_str))
  temp = "p"+p_str
  
  if temp not in key:
    key[temp] = 1
    count = str(1)
  else :
    a = key[temp]
    key[temp] = a + 1
    count = str(key[temp])
    
  len_count = len(list(count))
  
  for j in range(6-len_p):
    p_str = "0" + p_str
    
  for j in range(6-len_count):
    count = "0" + count
    
  base_1[i].append(p_str + count)
    
base_1.sort(key = lambda x:x[2])

for i in range(m):
  print(base_1[i][3])

Measured memory_bytes: 47152
package main

import (
	"fmt"
)

func main() {
	var h, w int
	for {
		fmt.Scan(&h, &w)
		if h == w && h == 0 {
			break
		}
		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				if 0 < i && i < h-1 && 0 < j && j < w-1 {
					fmt.Printf(".")
				} else {
					fmt.Printf("#")
				}
			}
			fmt.Printf("\n")
		}
		fmt.Printf("\n")
	}
}



Measured memory_bytes: 1096
#include <iostream>

int solve(int n, int r) {
  if (n >= 10) return r;
  return r + 1000 - 100 * n;
}

int main() {
  int n, r;
  std::cin >> n >> r;
  std::cout << solve(n, r) << std::endl;
  return 0;
}


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

using namespace std;
int main()
{
    string words;
    int n,i;

    getline(cin,words);

    n=words.size();


    for(i=0;i<n;i++)
    {
        if(words[i]>='a'&&words[i]<='z')
            words[i]+='A'-'a';

        else if(words[i]>='A'&&words[i]<='Z')
            words[i]+='a'-'A';

    }


cout<<words<<endl;

}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, M; cin >> N >> M;
    cout << (N * (N - 1)) / 2 + (M * (M - 1)) / 2 << endl;

    return 0;
}

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

int main() {
	int a, b, c;

	std::cin >> a >> b >> c;

	if ((a <= c && c <= b) || (a >= c && c >= b)) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    a--;b--;c--;d--;
    cin>>s;
    bool flag=true;

    if((b-a)*(d-c)>0){
        for(int i=min(a,b);i < max(c,d);i++)
        {
            if(s.at(i)=='#' && s.at(i+1)=='#'){
                flag=false;
            }
        }
    }else if((b-a)*(d-c)==0){
        cout << "No" << endl;
        return 0;
    }else{
        flag=false;
        for(int i=max(a,b)-1;i <min(c,d);i++)
        {
            if(i+2<n &&s.at(i)=='.'&&s.at(i+1)=='.' && s.at(i+2)=='.'){
                flag=true;
            }
        }
    }

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


Measured memory_bytes: 640
/* 
Rohit645
Rohit Kumar 
*/

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end() 
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
	fastIo();
	ll n; cin >> n;
	ll arr[n];
	for (ll i = 0; i < n; i++) cin >> arr[i];
	ll mn = arr[0];
	for (ll i = 0; i < n-1; i++) {
		if (arr[i] >= arr[i+1]) {
			mn = max(mn, arr[i]-1);
			trace(mn);
			if (arr[i] > mn)
				arr[i]--;
		}
	}
	for (ll i = 0; i < n-1; i++) {
		if (arr[i] > arr[i+1]) {
			cout << "No\n";
			return 0;
		}
	}
	cout <<"Yes\n";
	return 0;
}

Measured memory_bytes: 1152
sx, sy, tx, ty = gets.split.map(&:to_i)

w = tx - sx
h = ty - sy

path = ""

path += "U" * h + "R" * w
path += "D" * h + "L" * w
path += "L"
path += "U" * (h+1) + "R" * (w+1)
path += "D"
path += "R"
path += "D" * (h+1) + "L" * (w+1)
path += "U"
puts path


Measured memory_bytes: 1916
//#pragma GCC optimize(2)


#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#include<ext/rope>*/
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//void err(istream_iterator<string> it){cerr<<endl;}
//template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args){cerr << *it << " = " << a << " , ";err(++it, args...);}
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mem(a,b) memset((a),b,sizeof((a)))
#define fpre(x) cout<<fixed<<setprecision(x)
#define clr(v) (v).clear()
#define pii pair<int,int>
#define pdd pair<double,double>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp make_pair
#define eb emplace_back
#define pb emplace_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define uint unsigned int
#define ushort unsigned short
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lowbit(i) (i&(-i))
#define lson rt<<1
#define rson lson|1
#define fi first
#define se second
const double eps=1e-7;
const double pi=acos(-1);
inline int dcmp(double x)
{
    if(x<-eps)
        return -1;
    if(x>eps)
        return 1;
    return 0;
}
//-----------------------------------------------head

const ll mod=1e9+7;
const int maxn=405;
ll p[maxn][maxn];
ll dp[maxn][maxn];
ll a[maxn],b[maxn];
void init()
{
    for(int i=1;i<maxn;++i)
    {
        p[i][0]=1;
        for(int j=1;j<maxn;++j)
            p[i][j]=p[i][j-1]*i%mod;
    }
    for(int i=1;i<maxn;++i)
        for(int j=0;j<maxn;++j)
           (p[i][j]+=p[i-1][j])%=mod;
}
int main()
{
    init();
    int n,c;
    while(~scanf("%d%d",&n,&c))
    {
        mem(dp,0);
        for(int i=1;i<=n;++i)
            scanf("%d",a+i);
        for(int i=1;i<=n;++i)
            scanf("%d",b+i);
        dp[0][0]=1;
        for(int i=1;i<=n;++i)
            for(int j=0;j<=c;++j)
                for(int k=0;k<=j;++k)
                    (dp[i][j]+=dp[i-1][j-k]*(p[b[i]][k]-p[a[i]-1][k]+mod)%mod)%=mod;
        printf("%lld\n",dp[n][c]);

    }
}

/*
























*/









Measured memory_bytes: 2816
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

int main() {
  int h, w;
  cin >> h >> w;
  vv<string> s(h, vector<string>(w));
  int c, r;
  rep (i, h) {
    rep (j, w) {
      cin >> s[i][j];
      if (s[i][j] == "snuke") {
        c = j;
        r = i + 1;;
      }
    }
  }
  char cc = 'A' + c;
  printf("%c%d\n", cc, r);
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define is(s) freopen((const char*)(s),"r",stdin)
#define os(s) freopen((const char*)(s),"w",stdout)
#define elif else if
#define pb push_back

using namespace std;
int h,a,ans;
int main()
{
	//is("");os("");
	//ios_base::sync_with_stdio(false);cin.tie(0);
	cin>>h>>a;
	ans=h/a;
	if(h%a==0)
	cout<<ans;
	else cout<<ans+1;
	return 0;}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc144/tasks/abc144_d

#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const double PI = atan2(0.0, -1.0);

double a, b, x;

void solve() {
  double ans;
  double c = (2 * x) / (a * b);
  if (c <= a) {
    ans = atan2(b, c);
  } else {
    double e = (2 * x) / (a * a);
    // if (b >= a) {
    //   ans = atan2(a, e - b);
    // } else {
      ans = atan2(2 * b - e, a);
    // }
  }
  ans = ans * 180 / PI;
  printf("%.10lf\n", ans);
}

void input() {
  scanf("%lf%lf%lf", &a, &b, &x);
}

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


Measured memory_bytes: 256
n = int(input())
li = []
while True:
    try:
        li.append(list(map(int,input().split())))
    except:
        break

f_inf = float('inf')
dpa=[li[0][0]]+[0]*(n-1)
dpb=[li[0][1]]+[0]*(n-1)
dpc=[li[0][2]]+[0]*(n-1)

for i in range(1,n):
    dpa[i]=max(dpb[i-1],dpc[i-1])+li[i][0]
    dpb[i]=max(dpa[i-1],dpc[i-1])+li[i][1]
    dpc[i]=max(dpa[i-1],dpb[i-1])+li[i][2]

print(max(dpa[n-1],dpb[n-1],dpc[n-1]))


Measured memory_bytes: 66136
#include<iostream>
#include<cstring>
#include<algorithm>


using namespace std;

const long long inf= 1e10+ 123;
const int mx=1e5+123;
int dp[mx], h[mx], n, k;

int solve( int i)
{
    if(i==n)
        return 0;

    if(dp[i]!= -1)
        return dp[i];


    int ret= inf;

    for(int j=1; j<=k; j++)
    {
        if(i+j<=n)
            ret= min(ret, (abs(h[i]- h[i+j])+ solve(i+j)));
    }


    return dp[i]= ret;
}

int main()
{
    memset(dp, -1, sizeof(dp));

    cin>> n >> k;
    for(int i=1; i<=n; i++)
        cin>> h[i];

    cout<< solve(1)<< endl;

    return 0;
}



Measured memory_bytes: 12168
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
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;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
long long a,b,c;
cin>>a>>b>>c;
    if(c-a-b<0){
        cout<<"No"<<endl;
    }else{
if(4*a*b<(c-a-b)*(c-a-b)){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}
}










Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
#define rep(i,n) for(ll i=0; i<(n); i++)
template<class T> inline void chmax(T &a, T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a, T b){if(a>b)a=b;}
const ll inf=1LL<<60;
int main(){
    ll i,j=1,N,x;
    string s;
    cin>>s;
    N=s.size();
    vl ans(N+1,0),lin(N+1,0),v;
    stack<ll> st,er;
    rep(i,N){
        if(s[i]=='('){
            v.push_back(0);
            st.push(j);
            ans[j]=ans[j-1];
            lin[j]=0;
        }else if(s[i]==')'){
            v.push_back(1);
            x=-1;
            while(x<0&&!st.empty()){
                x=st.top();st.pop();
            }
            if(x<0&&st.empty()){
                cout<<(ans[j]=ans[j-1])<<endl;
                lin[j++]=0;
                er.push(-1);
                continue;
            }
            er.push(x);
            ans[j]=ans[j-1]+1;
            if(x>1&&v[x-2]==1){
                lin[j]=lin[x-1]+1;
            }else{
                lin[j]=1;
            }
            ans[j]+=lin[j]-1;
        }else{
            // cout << "dbg:" << v.back() << endl;
            if(v[j-2]){
                if(!er.empty()){st.push(er.top());er.pop();}
            }else{
                st.pop();
            }
            v.pop_back();
            ans[j]=ans[j-1]=lin[j]=lin[j-1]=0;
            j-=2;
        }
        cout<<ans[j]<<endl;
        j++;
    }
}


Measured memory_bytes: 9524
h,w,k=map(int,input().split())
s=[list(input())for i in range(h)]
a=[[0]*w for i in range(h+1)]
b=1
for i in range(h):
    if "#" in s[i]:
        for j in range(w):
            a[i+1][j]=str(b)
            if s[i][j]=="#" and "#" in s[i][j+1:]:
                b+=1
        b+=1
        if a[i][0]==0:
            f=i
            while a[f][0]==0:
                a[f]=a[f+1]
                f-=1
                if f<=0:
                    break
    else:
        a[i+1]=a[i]
for i in range(1,h+1):
    print(*a[i])

Measured memory_bytes: 10436
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>>N>>M;
}
//=============================
void func(){}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    int ans = 0;
    for( ; N<=M; N *= 2){
        ans++;
    }
    cout<<ans<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256