akhauriyash/Code-Regression huggingface dataset:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

a = []

for i in range(n):
    a.append(input())
a.sort()

aa = s(a)

aa.sort(key = lambda x:x[1],reverse = True)

for i in range(len(aa)):
    if i == 0:
        co = aa[i][1]
        print(aa[i][0],end = "")
    else:
        if aa[i][1] == co:
            print(aa[i][0],end = "")
        else:
            break







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

int A[100005], N;
const int bsr = 1e18;

int mul(int A, int B) {
  if(log10(A) + log10(B) > 18) {
    cout << "-1\n";
    cin >> N;
    exit(0);
  }else if(A > bsr || B > bsr || (long double) A * B > bsr) {
    cout << "-1\n";
    cin >> N;
    exit(0);
  }
  return A * B;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  int sum = 1;
  for(int i = 1; i <= N; i++) {
    cin >> A[i];
    if(A[i] == 0) {
      cout << "0\n";
      exit(0);
    }
  }
  for(int i = 1; i <= N; i++) {
    sum = mul(sum, A[i]);
  }
  cout << sum << "\n";
  cin >> N;
}

Measured memory_bytes: 4736
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (998244353)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int ll

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int mini[12345],powi[12345];

main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int i,j;
    if(a==c){
    	int ans=1;
    	f(i,b,d){
    		ans*=a;
    		ans%=mod;
    	}
    	cout<<ans<<endl;
    	return 0;
    }
    else if(b==d){
    	int ans=1;
    	f(i,a,c){
    		ans*=b;
    		ans%=mod;
    	}
    	cout<<ans<<endl;
    	return 0;
    }
    mini[a]=a;
    mini[a+1]=b;
    //cout<<mini[a]<<" "<<mini[a+1]<<endl;
    powi[0]=1;
    f(i,1,12345){
    	powi[i]=powi[i-1]*d;
    	powi[i]%=mod;
    }
    f(i,a+2,c+1){
    	mini[i]=mini[i-1]*b;
    	mini[i]%=mod;
    }
    int val;
    f(i,b+2,d+1){
    	int sofar=mini[a]*(i-1);
    	sofar%=mod;
    	mini[a]*=a;
    	mini[a]%=mod;
    	f(j,a+1,c+1){
    		val=j*mini[j]+sofar;
    		val%=mod;
    		sofar+=mini[j];
    		sofar*=i-1;
    		sofar%=mod;
    		mini[j]=val;
    	}
    }
    int ans=0;
    f(i,a,c+1){
    	ans+=mini[i]*powi[c-i];
    	ans%=mod;
    }	
    cout<<ans<<endl;
    return 0;   
}


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

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

    int a = -1,z = 0;

    for(int i = 0;i < s.size();i++){
        if(s.at(i) == 'A' && a == -1){
            a = i;
        }

        if(s.at(i) == 'Z' && z <= i){
            z = i;
        }
    }

    cout << z - a + 1 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,d,c=0;
  double dist;
  vector<vector<int>> v;
  cin>>n>>d;
  v.resize(n);
  for(auto& x:v){
    x.resize(d);
    for(auto& y:x){
      cin>>y;
    }
  }
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      dist=0;
      for(int k=0;k<d;k++){
        dist+=pow((v[i][k]-v[j][k]),2);
      }
      dist=sqrt(dist);
      if(dist==floor(dist)){
        c++;
      }
    }
  }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
//ITP1_8_B
#include<iostream>
#include<cstdio>
using namespace std;

int main(){
	int sum,i;
	char c;
	
	for(sum=0;;sum=0){
		for(i=0;;i++){
			c=getchar();
			if(c=='\n'){
				cout<<sum<<endl;
				break;
				}
			else if(c=='0'&&i==0)
				return 0;
			sum+=c-'0';
		}
	}
	return 0;
}

Measured memory_bytes: 1124
import itertools as it

n, x = map(int, input().split())

while True:
    if n == 0 and x == 0:
        break

    res = 0
    li = range(1, n + 1, 1)
    for c in it.combinations(li, 3):
        res += 1 if sum(c) == x else 0
    print(res)

    n, x = map(int, input().split())



Measured memory_bytes: 5628
s = raw_input()
K = input()

def dista(c):
    if(c=='a'):return 0
    return ord('z')-ord(c)+1

s = [c for c in s]

for i in range(len(s)):
    if(dista(s[i])<=K):
        K -= dista(s[i])
        s[i] = 'a'
    

if(K>0):
    last = s[-1]
    p = ord(last)-ord('a')
    p = (p+K)%26
    last = chr(p+ord('a'))
    s[-1] = last
    
print ''.join(s)

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int s[1001][1001][1001];

int main() {
  int n, ans = 0;
  cin >> n;
  rep(i, 0, n) {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if(s[a[0]][a[1]][a[2]]) ans++;
    else s[a[0]][a[1]][a[2]] = 1;
  }

  cout << ans << endl;
}

Measured memory_bytes: 7004
n, m, t = map(int, input().split())
B = [0]*t
*A, = map(int, input().split())
for a in A:
    B[a-m] += 1
    if a+m < t:
        B[a+m] -= 1
cnt = ans = 0
for b in B:
    cnt += b
    if cnt == 0:
        ans += 1
print(ans)

Measured memory_bytes: 7680
<?php
$n = intval(fgets(STDIN));
$str = trim(fgets(STDIN));
$Q = intval(fgets(STDIN));

function op($a, $b){return $a | $b;}

for($i = 0; $i < $n; $i++){
  $array[] = 1<<(ord($str[$i])-97);
}
$seg = new SegTree($array);

while($Q--){
  list($q, $a, $b) = explode(" ", trim(fgets(STDIN)));
  if($q == "1"){
    $seg->set($a-1, 1<<(ord($b)-97));
  }else{
    $ret[] = popcount($seg->get($a-1, $b));
  }
}
echo implode("\n", $ret);

class SegTree{
  public $tree;
  public $bits;
  function __construct($n){
    if(is_array($n)){
      $array = $n;
      $n = count($array);
      $this->bits = max(1, ceil(log($n)/log(2)));
      for($i = $n, $I = 2**$this->bits; $i < $I; ++$i){
        $array[] = 0;
      }
      $this->tree[0] = $array;
      $this->rollupAll();
    }else{
      $this->bits = max(1, ceil(log($n)/log(2)));
      for($i = 0; $i < $this->bits; ++$i){
        $this->tree[$i] = array_fill(0, 2**($this->bits-$i), 0);
      }
    }
  }
  function rollupAll(){
    for($i = 1; $i < $this->bits; ++$i){
      $treei = &$this->tree[$i];
      $treeim = $this->tree[$i-1];
      for($j = 0, $J = 2**($this->bits - $i + 1); $j < $J; $j+=2){
        $treei[] = op($treeim[$j], $treeim[$j+1]);
      }
    }
  }
  function set($i, $amount){
    $this->tree[0][$i] = $amount;
    for($j = 1, $J = $this->bits; $j < $J; ++$j){
      $this->tree[$j][$i>>$j] = op($this->tree[$j-1][$i>>$j<<1], $this->tree[$j-1][($i>>$j<<1) + 1]);
    }
  }
  function get($f, $t){
    $sum = 0;
    $tree = $this->tree;
    $bits = $this->bits;
    $i = 0;
    while($f!=$t){
      $treei = $tree[$i];
      if(($f >> $i) & 1 == 1){
        $sum = op($sum, $treei[$f>>$i]);
        $f+=1<<$i;
      }
      if(($t >> $i) & 1 == 1){
        $sum = op($sum, $treei[($t>>$i)-1]);
        $t-=1<<$i;
      }
      ++$i;
    }
    return $sum;
  }
}

//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 55912
#include<stdio.h>

int main(){
	int N, M, i;
	if(scanf("%d%d", &N, &M));
	for(i=N; i<=M/10000; i++){
		if(M%i==0){
			printf("%d\n", M/i);
			return 0;
		}
	}
	for(i=10000;; i--){
		if(M%i==0 && M/i>=N){
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 128
main = readLn >>= putStrLn.answer

alphabet = ['a'..'z']

answer = map ((!!) alphabet) . reverse . decTo26

decTo26 v
    | v <= 26 = [mod (v-1) 26]
    | otherwise = mod (a-1) 26 : decTo26 b where 
        a = mod v 26
        b = if a == 0 then (div (v-a) 26)-1 else div (v-a) 26

Measured memory_bytes: 3916
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 234567;
int h[MAXN], v[MAXN];
LL dp[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++)
        scanf("%d", &h[i]);
    for (int i = 1; i <= N; i++)
        scanf("%d", &v[i]);
    set<int> st;
    st.insert(0);
    for (int i = 1; i <= N; i++) {
        auto cur = *prev(st.upper_bound(h[i]));
        LL val = dp[cur] + v[i];
        for (auto j = st.upper_bound(h[i]); j != st.end();) {
            int tmp = *j;
            if (tmp > h[i] && dp[tmp] <= val) j = st.erase(j);
            else break;
        }
        dp[h[i]] = val;
        //printf("i = %d cur = %d val = %lld\n", i, cur, val);
        st.insert(h[i]);
    }
    LL ans = 0;
    for (int i = 1; i <= N; i++) ans = max(ans, dp[i]);
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
  ll k, s;
  cin >> k >> s;
  
  ll ans = 0;
  
  for ( ll i = 0; i <= k; i++ ){
    if ( s - i > 2 * k || s - i < 0 ) continue;
    ans += (s - i > k) ? 2 * k - (s - i) + 1 : s - i + 1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]

def stri(n):
    a = 1
    for i in range(n):
        a *= i+1
    return a

def cou(lis):
    tlis = sorted(lis)
    r = 0
    for n in lis:
        r += stri(len(tlis)-1)*(tlis.index(n)-1)
        tlis.remove(n)
    return r



print(abs(cou(P)-cou(Q)))

Measured memory_bytes: 3064
n = int(input())

rdict = {}
slist = []
for i in range(1, n+1):
    s = str(i)
    key = (s[0], s[-1:])
    if key in rdict:
        rdict[key] += 1
    else:
        rdict[key] = 1
ans = 0
for i in range(1, n+1):
    s = str(i)
    key = (s[-1:], s[0])
    if key in rdict:
        ans += rdict[key]
#print(slist)
print(ans)


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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, a[max_n];
pair<int, int> cnt[2][max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        ++cnt[i % 2][a[i]].first;
    }
    for (int i = 0; i < max_n; ++i) {
        cnt[0][i].second = i;
        cnt[1][i].second = i;
    }
    sort(cnt[0], cnt[0] + max_n);
    sort(cnt[1], cnt[1] + max_n);
    reverse(cnt[0], cnt[0] + max_n);
    reverse(cnt[1], cnt[1] + max_n);
    int ans = n;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (cnt[0][i].second != cnt[1][j].second) {
                //cout << i << " " << j << " " << cnt[0][i].first << " " << cnt[1][j].first << endl;
                ans = min(ans, n - cnt[0][i].first - cnt[1][j].first);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2176
A,B,K = map(int,input().split())

count = 0
import math
R = []
for i in range(1,int(math.sqrt(A))+1+1):
    if A%i == 0:
        R.append(i)
        if not i == A//i:
            R.append(A//i)
R.sort(reverse=True)
for r in R:
    if B%r==0:
        count+=1
        if count == K:
            print(r)





Measured memory_bytes: 9036
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#define LL int
using namespace std;

int n, m;
vector<int> a[1000];
int vis[1000];
int tmp[1000];
int p[1000];
int ans = 0;

void DFS(int x) {
	int i, j;
    if(x == n+1) {
        memset(tmp, 0, sizeof(tmp));
        for(i = 1;i <= n;i ++) {
            if(!vis[i]) continue;
            for(j = 0;j < a[i].size();j ++) {
                int b = a[i][j];
                tmp[b] ++;
            }
        }
        for(i = 1;i <= m;i ++) if(tmp[i] %2 != p[i]) return ;
        ans ++;
        return ;
    }
    DFS(x+1);
    vis[x] = true;
    DFS(x+1);
    vis[x] = false;
}

int main() {
    scanf("%d%d", &n, &m);
	int i, j;
    for(i = 1;i <= m;i ++) {
        int k;
        scanf("%d", &k);
        for(j = 0;j < k;j ++) {
            int t;
            scanf("%d", &t);
            a[t].push_back(i);
        }
    }
    for(i = 1;i <= m;i ++) scanf("%d", p + i);
    DFS(1);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int ans = 0;
  rep(i, n - 1) if (s[i] == s[i + 1]) ans++;
  int cnt = n - 1 - ans; // rep(i, n - 1) if (s[i] != s[i + 1]) cnt++;
  cerr << ans << " " << cnt << endl;
  if (2 * k <= cnt) ans += 2 * k;
  else ans += cnt;
  cout << ans << endl;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int n; cin >> n;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    vector<int>s = a;
    sort(s.rbegin(),s.rend());
    rep(i,n){
        int ans = s[0];
        if(s[0] == a[i])ans = s[1];
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
bool cmp(pair<long long ,int>p1,pair<long long ,int>p2)
{
    if(p1.first==p2.first)
    {
        return p1.second<p2.second;
    }
    return p1.first>p2.first;
}
int main()
{
    long long n,h;
    cin>>n>>h;
    vector<pair<long long ,int> >v;
    for(int i=0; i<n; i++)
    {
        long long x,y;
        cin>>x>>y;
        v.push_back({x,1});
        v.push_back({y,2});
    }
    sort(v.begin(),v.end(),cmp);
    long long c=0;
    long long sum=0;
    for(int i=0; i<v.size(); i++)
    {
        if(sum>=h)break;
        int type=v[i].second;
        long long val=v[i].first;
        if(type==1)
        {
           long long left=h-sum;
           c+=left/val;
           if(left%val)c++;
           sum=sum+val*c;
        }
        else
        {
            sum+=val;
            c++;
        }
    }
    cout<<c<<endl;

}



Measured memory_bytes: 6128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    string s,t;
    cin >> s;
    cin >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    cout << ((s<t) ? "Yes" : "No") << endl;;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  private static final long mod = 1000_000_000 + 7;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    // #use-or-not - #empty - #a - #b
    // 2^n -1 - #a - #b
    long ans = pow(2, n);
    ans--;
    ans -= select(n, a);
    if (ans < 0) {
      ans += mod;
    }
    ans -= select(n, b);
    if (ans < 0) {
      ans += mod;
    }
    System.out.println(ans % mod);
  }
  // C(n,k)
  private static long select(int n, int k) {
    long nume = 1;
    for (int i = n; i >= n - k + 1; i--) {
      nume *= i;
      nume %= mod;
    }
    long factK = 1;
    for (int i = 1; i <= k; i++) {
      factK *= i;
      factK %= mod;
    }
    // fermat small theorem.
    return (nume* pow(factK, mod - 2)) % mod;
  }

  private static long pow(long base, long b) {
    long ans = 1;
    do {
      if (b % 2 == 1) {
        ans *= base;
        ans %= mod;
        b--;
        if (b == 0) break;
      }
      b /= 2;
      base *= base;
      base %= mod;
    } while (b > 0);
    return ans;
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll,ll>
#define psi pair<string,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define r0 return 0

/* typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
*/
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

using namespace std;
int digitCount(long long n) 
{ 
    return floor(log10(n) + 1); 
} 

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

    ll count=0,cnt=0,t=0;
    count=(ll)digitCount(n);
    // cout<<count<<endl;
    for(int i=1;i<=count-1;i++){
        t=(ll)9*pow(10,i-1);
        // cout<<t<<endl;
        if((digitCount(t))%2!=0) {
            cnt+=t;
            // cout<<cnt<<endl;
        }
    }
    t=n;
    if(digitCount(n)%2!=0) cnt+=n-pow(10,count-1)+1;
    cout<<cnt;
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = ReadIntArray();
            int[] difX = new int[] { 0, 1, 1, 1, 0, -1, -1, -1 };
            int[] difY = new int[] { -1, -1, 0, 1, 1, 1, 0, -1 };
            List<char[]> graph = new List<char[]>();
            for (int i = 0; i < HW[0]; i++)
            {
                graph.Add(Read().ToCharArray());
            }

            for (int height = 0; height < HW[0]; height++)
            {
                for (int width = 0; width < HW[1]; width++)
                {

                    if (graph[height][width] == '.')
                    {
                        int countBom = 0;
                        for (int i = 0; i < difX.Length; i++)
                        {
                            if (width + difX[i] < 0 ||
                                width + difX[i] >= HW[1] ||
                                height + difY[i] < 0 ||
                                height + difY[i] >= HW[0])
                            {
                                continue;
                            }

                            if (graph[height + difY[i]][width + difX[i]] == '#')
                            {
                                countBom++;
                            }
                        }

                        graph[height][width] = countBom.ToString().ToCharArray()[0];
                    }
                }
            }

            foreach (var row in graph)
            {
                Console.WriteLine(new string(row));
            }
        }
        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 14036
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld k, x;
	cin >> k;
	cin >> x;
	lld beg = x - (k-1);
	lld end = x + (k-1);
	for(lld i = beg; i <= end; i++){
		cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	int d[101], e[101];
	for(int i=0; i<n; i++) cin>>d[i]>>e[i];
	for(int i=0; i<n-2; i++){
		bool ok=1;
		for(int j=0; j<3; j++){
			if(d[i+j]!=e[i+j]) ok=0;
		}
		if(ok){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;i++)
#define print(var) cout<<var<<endl;
#define DEBUG(var) cerr<<var<<endl

const int inf = 1000000000;//10^9



int main(){
long long N,A,B;
cin >> N>>A>>B;
long long set,rest;
if(A==0&&B==0){
  print("0");
  return 0;
}
set=N/(A+B);
rest=N%(A+B);
long long ans;
ans=set*A+min(A,rest);

print(ans);
return 0;
}


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

using I = long long;

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

  vector<I> L(N+1), R(N+1);
  for(auto i=0; i<N; ++i) cin >> L[i] >> R[i];
  L[N] = R[N] = 0;
  sort(begin(L), end(L), greater<I>());
  sort(begin(R), end(R));

  I ans = 0;
  I l = 0, r = 0;
  for(auto i=0; i<N; ++i) {
    l += L[i];
    r += R[i];
    ans = max(ans, 2 * (l - r));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1920
import itertools

n,m=map(int,input().split())
ans=0

graph=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

for lst in itertools.permutations([j for j in range(1,n)],n-1):
  now=0
  flag=True
  for i in range(n-1):
      if lst[i] not in graph[now]:
          flag=False
          break
      
      else:
          now=lst[i]

  if flag:
          ans+=1


print(ans)  

Measured memory_bytes: 68892
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

char am[30][11];
int n,m,g,c;

int hantei(int b) {
 int i,f;
 for (i=0;i<c;i++) {
	 if (b>0) if (am[i][b-1]=='1')  { b--; continue;} 
	 if (b<n-1) if (am[i][b]=='1') b++;
 }
 f=(b==g) ? 1 : 0;
 return f;
}

int main() {
 int i,j,f;
 while(cin >> n) {
	 if (n==0) break;
	 cin >> m >> g >> c;
	 getchar();
	 m--; g--;
	 for (i=0;i<c;i++) gets(am[i]);
	 if (hantei(m)==1) { cout << 0 << endl; continue; }
	 for (i=0;i<c;i++) for (j=0;j<n-1;j++) {
		 f=0;
		 if (am[i][j]=='0') {
			 if (j>0) if (am[i][j-1]=='1') f=1;
			 if (j<n-2) if (am[i][j+1]=='1') f=1;
		     if (f==0) {
			 am[i][j]='1'; 
			 if (hantei(m)==1) { cout << i+1 << ' ' << j+1 << endl; i=j=100; }
             am[i][j]='0';
			 }
		 }
	 }
     if (i<100) cout << 1 << endl;
 }
 return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> B(n-1);
  for ( int i = 0; i < n-1; i++){
    cin >> B[i];
  }
  
  int sum = 0;
  
  vector<int> A(n);
  A[0] = B[0];
  sum += A[0];
  
  for ( int i = 1; i < n-1; i++){
    A[i] = min(B[i],B[i-1]);
    sum += A[i];
  }
  
  A[n-1] = B[n-2];
  
  sum += A[n-1];
  
  cout << sum << endl;  
  
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<stack>
#include<vector>
using namespace std;
int main(){
	//freopen("ALDS1_3_D.txt","r",stdin);
	stack<int>S1;
	stack<pair<int,int> >S2;
	char ch;
	int sum=0;
	for(int i=0;cin>>ch;i++){
		if(ch=='\\')S1.push(i);
		else if(ch=='/'&&S1.size()){
			int j=S1.top();
			S1.pop();
			int a=i-j;
			sum+=a;
			while(S2.size()&&S2.top().first>j){
				a+=S2.top().second;
				S2.pop();
			}
			S2.push(make_pair(j,a));
		}
	}
	vector<int>ans;
	while(S2.size()){
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(),ans.end());
	int size=ans.size();
	printf("%i\n%i",sum,size);
	for(int i=0;i<size;i++)printf(" %i",ans[i]);
	putchar('\n');
}


Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
typedef struct line
{
	int lp,rp,value;
	bool operator < (const struct line & n)const
	{
		return rp<n.rp;
	}
}LINE,*PLINE;
LINE arr[200000];
long long linetree[1<<19],lazy[1<<19];
long long query(int index,int lb,int rb,int lq,int rq)
{
	if(lb==lq&&rb==rq)
		return linetree[index];
	long long mid=(lb+rb)>>1;
	if(lazy[index]!=0)
	{
		linetree[index<<1]+=lazy[index];
		linetree[index<<1|1]+=lazy[index];
		lazy[index<<1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	if(rq<=mid)
	{	
		return query(index<<1,lb,mid,lq,rq);
	}
	else if(lq>mid)
	{
		return query(index<<1|1,mid+1,rb,lq,rq);	
	}
	else
	{
		return max(query(index<<1,lb,mid,lq,mid),query(index<<1|1,mid+1,rb,mid+1,rq));
	}
}
void update(int index,int lb, int rb,int lq,int rq,long long value)
{
	if(lb==lq&&rb==rq)
	{
		linetree[index]+=value;
		lazy[index]+=value;
		return;
	}
	long long mid=(lb+rb)>>1;
	if(lazy[index]!=0)
	{
		linetree[index<<1]+=lazy[index];
		linetree[index<<1|1]+=lazy[index];
		lazy[index<<1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	if(rq<=mid)
	{	
		update(index<<1,lb,mid,lq,rq,value);
	}
	else if(lq>mid)
	{
		update(index<<1|1,mid+1,rb,lq,rq,value);	
	}
	else
	{
		update(index<<1,lb,mid,lq,mid,value);
		update(index<<1|1,mid+1,rb,mid+1,rq,value);
	}
	linetree[index]=max(linetree[index<<1],linetree[index<<1|1]);
}
int main()
{
	int i,j,k,cnt=0;
	int n,m;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %d %d",&arr[i].lp,&arr[i].rp,&arr[i].value);
	}
	sort(arr,arr+m);
	for(i=1;i<=n;i++)
	{
		update(1,0,n,i,i,query(1,0,n,0,i-1));
		while(arr[cnt].rp==i)
		{
			update(1,0,n,arr[cnt].lp,arr[cnt].rp,arr[cnt].value);
			cnt++;
		}
	}
	printf("%lld",linetree[1]);
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200100;
int to[maxn][26], lnk[maxn], len[maxn], last, sz;
void init(){
	memset(to, -1, sizeof(to));
	lnk[0] = -1;
	last = 0;
	sz = 1;
}
void extend(int c){
	int cur = sz++;
	len[cur] = len[last] + 1;
	int p = last;
	while(p != -1 && to[p][c] == -1){
		to[p][c] = cur;
		p = lnk[p];
	}
	if(p == -1)
		lnk[cur] = 0;
	else {
		int q = to[p][c];
		if(len[p] + 1 == len[q])
			lnk[cur] = q;
		else {
			int nq = sz++;
			memcpy(to[nq], to[q], sizeof(to[nq]));
			lnk[nq] = lnk[q];
			len[nq] = len[p] + 1;
			lnk[q] = nq;
			lnk[cur] = nq;
			while(p != -1 && to[p][c] == q){
				to[p][c] = nq;
				p = lnk[p];
			}
		}
	}
	last = cur;
}
int main(){
	string s; cin >> s;
	int siz = s.size();
	init();
	for(int i = 0; i < siz; i++) extend(s[i] - 'a');
	vector<int> cnt(siz + 10, 0);
	for(int i = 1; i < sz; i++){
		cnt[len[lnk[i]]+1]++;
		cnt[len[i]+1]--;
	}
	int ans = 0;
	for(int i = 1; i <= siz; i++){
		cnt[i] += cnt[i - 1];
		ans = max(ans, cnt[i]);
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  int n; cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n){
    while(a[i]%2==0){
      ans++;
      a[i]/=2;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
l = gets.split
ln = {:mx => 0, :wd => ""}
lm = {:mx => 0, :wd => ""}
l.each{|w|
  if lm[:mx] < l.count(w)
    lm[:mx] = l.count(w)
    lm[:wd] = w
  end
  if ln[:mx] < w.length
    ln[:mx] = w.length
    ln[:wd] = w
  end
}
puts "#{lm[:wd]} #{ln[:wd]}"

Measured memory_bytes: 8576
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb emplace_back
#define pi pair<int,int>
using namespace std;
const int maxn = 3e3 + 4;

int n;
ld p[maxn];
ld dp[maxn][maxn];

int main(){
	cin>>n;
	for (int i = 1; i <= n; ++i){
		cin>>p[i];
	}
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i){
		dp[i][0] = dp[i-1][0] * (1.0-p[i]);
		for (int j = 1; j <= i; ++j){
			dp[i][j] = (1.0 * dp[i-1][j-1] * p[i]) + (1.0 * dp[i-1][j] * (1.0-p[i])); 
		}
	}
	ld ans = 0;
	int bhalf = (n+1)/2;
	for (int i = bhalf; i <= n; ++i){
		ans += dp[n][i];
	}
	cout<<fixed<<setprecision(9);
	cout<<ans<<'\n';
}

Measured memory_bytes: 139264
import scala.io.StdIn.readLine
import scala.math.pow

object Main extends App {
  val Array(d, n) = readLine().split(' ').map(_.toInt)
  require(Seq(0, 1, 2).contains(d))
  val realN = if (n == 100) 101 else n
  println(realN * pow(100, d).toInt)
}

Measured memory_bytes: 54732
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

use std::collections::HashSet;

fn main() {
    let N = get!(usize);
    let W = get!(String; N);

    let ans = if
            W.iter()
                .collect::<HashSet<&String>>()
                .len() == N &&
            W[1..].iter()
                .zip(W.iter())
                .all(|(s, t)|
                    s.chars()
                        .collect::<Vec<_>>()[0] ==
                    t.chars()
                        .collect::<Vec<_>>()[t.len() - 1]
                )
            {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 1;
  for(int i = 0; i < S.length() - 1; i++){
  	if(S.at(i) != S.at(i+1)){
    	count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 512
def f(s):
    m, f, r = list(map(int, s.split()))
    if m == -1 or f == -1:
        return "F"

    t = m + f
    if 80 <= t:
        return "A"
    elif 65 <= t:
        return "B"
    elif 50 <= t:
        return "C"
    elif 30 <= t:
        return "C" if 50 <= r else "D"
    else:
        return "F"

while True:
    s = input()
    if s == "-1 -1 -1":
        break
    print(f(s))

Measured memory_bytes: 7776
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
size = 2*10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, size + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

H, W, A, B = map(int,input().split())

ans = 0

for i in range(W-B):
    ans += cmb(H-A-1+(B+i), B+i, mod) * cmb(A-1+W-B-1-i, A-1, mod)
    ans %= mod

print(ans)

Measured memory_bytes: 27092
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI1(x) scanf("%d",&x);
#define inI2(x,y) scanf("%d %d",&x,&y);
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z);
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
int n,x,k;
map<int,int>mm;
int main()
{
    inI1(n);
    for(int i=1;i<=n;i++)
    {
        inI1(x);
        if(mm[x]==0)
        {
            mm[x]++;
            k++;
        }
        else
        {
            mm[x]--;
            k--;
        }
    }
    printf("%d",k);
}


Measured memory_bytes: 4864
#include <stdio.h>
#include <limits.h>

int p[100],m[100][100],n;

void MatrixChainOrder(){
  int i,j,l,k,q;
  for(i = 1; i < n+1; i++){
    m[i][i] = 0;
  }
  for(l = 2; l < n+1; l++){
    for(i = 1; i < n-l+2; i++){
      j = i + l - 1;
      m[i][j] = INT_MAX;
      for(k = i; k < j; k++){
        q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
        m[i][j] = min(m[i][j],q);
      }
    }
  } 
  printf("%d\n",m[1][n]); 
}
int min(int a, int b){
  if(a <= b) return a;
  else return b;
}
int main(){
  int i,r,c;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d %d",&r,&c);
    p[i] = r;
    p[i+1] = c;
  }
  MatrixChainOrder();
  return 0;
}

Measured memory_bytes: 636
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N, count = 1;
	static long long T[100000], A[100000], MAX[100000], MIN[100000];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		MAX[i] = T[i];
		if (i == 0) MIN[0] = T[i];
		else if (T[i] != T[i - 1]) MIN[i] = T[i];
		else MIN[i] = 1;
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		MAX[i] = min(MAX[i], A[i]);
	}
	for (int i = 0; i < N - 1; i++) {
		if (A[i] != A[i + 1]) MIN[i] = max(MIN[i], A[i]);
	}
	MIN[N - 1] = max(MIN[N -1], A[N - 1]);
	for (int i = 0; i < N; i++) {
		if (MIN[i] > MAX[i]) {
			count = 0;
			break;
		}
		else count *= MAX[i] - MIN[i] + 1;
		count = count % 1000000007;
	}
	cout << count;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    long long area = 1ll * w * h;
    cout << area / 2;
    if (area % 2 == 1) {
        cout << ".5";
    }
    cout << " ";

    cout << (x * 2 == w && y * 2 == h ? 1 : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

(shop_count, require) = [int(i) for i in input().rstrip().split(" ")]
shop_list = sorted([[int(i) for i in input().rstrip().split(" ")] for j in range(shop_count)])

ans = 0
count = 0
for i in shop_list:
    if count + i[1] >= require:
        ans += i[0] * (require - count)
        break
    else:
        ans += i[0] * i[1]
        count += i[1]

print(ans)


Measured memory_bytes: 22380
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

ll int mod_inverse(int a,int M){
	int x=M-2;
	ll int temp=a;
	ll int ret=1;
	//a^(MOD-1)==1(mod MOD)を利用
	//a^-1==a^(MOD-2) (mod MOD)を繰り返し二乗法で求める

	while(x!=0){
		if(x%2==1){
			ret=(ret*temp)%M;
		}
		temp=(temp*temp)%M;
		x=x/2;
	}
	return ret;
}

int main(void)
{
	//変数の宣言
	int n,a,b,c;
	static ll conbi[100010]; 
	static ll ruijouA[100010];
	static ll ruijouB[100010];
	ll modAB;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	ll int temp=0;
	ll int temp1=0;
	ll int temp2=0;
	int temp3=0;
	int max=0;
	int min=INFINT;
	int len=0;
	ll int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	char stemp[11];
	ll antisum;

	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);

//	scanf("%s",&s);
//	scanf_s("%s",&s,5);


/*	for(i=0;i<n;i++){
//		scanf("%d",&s[i]);
		scanf_s("%d",&s[i]);
	}*/


/*	for(i=0;i<m;i++){
//		scanf("%d",&p[i]);
		scanf_s("%d",&p[i]);
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	//	printf("計算部分終了\n");

	//出力
	printf("%d",(n-2)*180);

//	printf("\n mod_inverse(93/16)=%lld",5*mod_inverse(8,MOD)%MOD);
	//	printf("結果の出力終了\n");

	return 0;
}



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

int main() {
  int a, b, c; cin >> a >> b >> c;
  string result;
  if (b-a==c-b) result = "YES";
  else result = "NO";
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int h,w,i,ii;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0)break;
		for(i=0;i<h;i++){
			for(ii=0;ii<w;ii++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    int a, b, c = 1;
    cin >> a >> b;
    while (c < b && a) c *= 2, a--;
    while (a > 0) c += b, a--;
    cout << c;
}


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

int main(){
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1;i<=n-1;++i){
        if((n-i)<i*(i+1))break;
        if((n-i)%i==0)ans+=(n-i)/i;
    }
    cout << ans << endl;
}

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

using namespace std;

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

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        int k = fs.nextInt();
        ArrayList<Integer> ans = new ArrayList<>();
        for (int TT = 0; TT < k; TT++) {
            int d = fs.nextInt();
            int[] ar = fs.readArray(d);
            boolean t = false;
            for (int i = 0; i < d; i++) {
                t = false;
                for (int q = 0; q < ans.size(); q++) {
                    if (ar[i] == ans.get(q)) {
                        t = true;
                        break;
                    }
                }
                if (t == false) {
                    ans.add(ar[i]);
                }

            }
        }
        System.out.println(n-ans.size());
    }


    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] readArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }

}


Measured memory_bytes: 36576
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[10000],ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) for(int j=i;j<=n;j++) 
	ans=max(ans,abs(a[i]-a[j]));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    S=list(input())
    N=len(S)
    dp=[[0]*13 for _ in range(10**5*2)]
    dp[0][0]=1
    for i,s in enumerate(S):
        if s=='?':
            for k in range(10):
                for j in range(13):
                    dp[i+1][(j*10+k)%13]+=dp[i][j]
                    dp[i+1][(j*10+k)%13]%=MOD
        else:
            for j in range(13):
                dp[i+1][(j*10+int(s))%13]+=dp[i][j]
                dp[i+1][(j*10+int(s))%13]%=MOD
    print(dp[N][5])

if __name__ == '__main__':
    main()


Measured memory_bytes: 84216