akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<char> Vc;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;
typedef vector<vector<char>> VVc;
typedef vector<vector<vector<ll>>> VVV;
typedef vector<vector<vector<vector<ll>>>> VVVV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define rEach(i, mp) for (auto i = mp.rbegin(); i != mp.rend(); ++i)
#ifdef LOCAL
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgset(st) cerr << #st << ":"<<endl; for (auto i = st.begin(); i != st.end(); ++i) { cerr << *i <<" ";}cerr<<endl;
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#else
#define dbg(...)
#define dbgmap(...)
#define dbgset(...)
#define dbgarr(...)
#define dbgdp(...)
#endif
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    Vec v(102);
    REP(i,a,b){
        v[i]++;
    }
    REP(i,c,d){
        v[i]++;
    }
    ll ans = 0;
    REP(i,0,102){
        if(v[i]==2){
            ans++;
        }
    }
    out(ans);
    return  0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
    solve();
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,ti,ai,k,l;
    cin>>n;
    
    i=1,j=1;
    while(n--)
    {
        cin>>ti>>ai;
  long long  x=(i-1)/ti+(long long)1,y=(j-1)/ai+(long long )1;
        k=max(x,y);
        i=ti*k,j=ai*k;
        
    }
    cout<<i+j;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define EPS 1e-10

int main(){
  int k;
  double r,l,po,e,t;
  cin>>k>>l>>r>>po>>e>>t;

  double ans = 0;
  using Map = map<pair<double,double>,double>;
  Map m;
  m[mp(l,r)] = 1;
  rep(i,k){
    Map nxt;
    for(auto p : m){
      double cl = p.fi.fi, cr = p.fi.se;
      if(t-e - EPS <= cl && cr <= t+e + EPS){
        ans += p.se;
        continue;
      }
      if(t+e < cl || cr < t-e) continue;
      double cm = (cl+cr)/2;
      if(t <= cm){
        if(1.0-po>EPS) nxt[mp(cl,cm)] += p.se * (1.0-po);
        if(po>EPS) nxt[mp(cm,cr)] += p.se * po;
      }
      else {
        if(po>EPS) nxt[mp(cl,cm)] += p.se * po;
        if(1.0-po>EPS) nxt[mp(cm,cr)] += p.se * (1.0-po);
      }
    }
    swap(nxt, m);
  }
  for(auto p : m){
    double mid = (p.fi.fi + p.fi.se) / 2.0;
    if(t-e - EPS <= mid && mid <= t+e + EPS){
      ans += p.se;
    }
  }

  printf("%.9f\n", ans);

  return 0;
}

Measured memory_bytes: 3264
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    td = [list(map(int, input().split())) for _ in range(n)]
    td.sort(reverse=True, key=lambda a: a[1])
    delicious = 0
    syurui = set()
    suteru = []
    for i in range(k):
        t, d = td[i]
        delicious += d
        if  t in syurui:
            suteru.append(d)
        else:
            syurui.add(t)
    heapify(suteru)
    neta = len(syurui)
    res = delicious + neta**2
    for i in range(k, n):
        t, d = td[i]
        if t in syurui:
            continue
        if len(suteru)==0:
            print(res)
            exit()
        syurui.add(t)
        delicious += d - heappop(suteru)
        neta += 1
        res = max(res, delicious+neta**2)
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 30460
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	vector<int> p(n);
	rep(i, n) cin >> p[i];

	set<int> st;
	st.insert(p[0]);
	int ans = 1;
	
	rep(i, n-1){
		auto itr = st.begin();
		if(*itr > p[i+1]) ans++;
		st.insert(p[i+1]);
	}

	cout << ans << endl;
}


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

int main(){
    int a;
    int b;
    int c;
    
    cin >> a >> b >> c;

    if(c <= a+b+1){
        cout << c+b << endl;
        
    }else if(c > a+b+1){
        cout << a+b+1+b << endl;
    }
}

Measured memory_bytes: 256
from collections import deque

s=deque(input())
q=int(input())
t=[list(map(str,input().split())) for i in range(q)]

def head(a):
    s.appendleft(a)
    
def end(a):
    s.append(a)

x=True
for i in range(q):
    if len(t[i])==1:
        x=not x
    else:
        if x==True:
            if t[i][1]=='1':
                head(t[i][2])
            else:
                end(t[i][2])
        else:
            if t[i][1]=='1':
                end(t[i][2])
            else:
                head(t[i][2])
if x==True:
    print(''.join(s))
else:
    s.reverse()
    print(''.join(s))

Measured memory_bytes: 44780
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define iterator IT
#define SIZ(V) V.size()
#define FS(a) fixed<<setprecision(a)
using namespace std;
namespace STARTER {
	int MAX(int a,int b) {
		return a>b?a:b;
	}
	int MIN(int a,int b) {
		return a<b?a:b;
	}
	int ABS(int a) {
		return a<0?-a:a;
	}
	int GCD(int a,int b) {
		return !b?a:GCD(b,a%b);
	}
	int LCM(int a,int b) {
		return a/GCD(a,b)*b;
	}
	int QSM(int a,int b,int p) {
		int ret=1;
		while (b) {
			if (b&1)
				ret=ret*a%p;
			a=a*a%p;
			b>>=1;
		}
		return ret;
	}
	int ROUND(double a) {
		return a+0.5;
	}
}
using STARTER::MAX;
using STARTER::MIN;
using STARTER::ABS;
using STARTER::GCD;
using STARTER::LCM;
using STARTER::QSM;
using STARTER::ROUND;
int main() {
	int n,r;
	cin>>n>>r;
	if (n>=10)
		cout<<r<<'\n';
	else
		cout<<r+100*(10-n)<<'\n';
	return 0;
}

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

int main(int argc, char *argv[]){
    int H,W;
    std::cin >> H >> W;
    std::string S[H];
    for(auto &s : S){
        std::cin >> s;
    }

    std::vector< std::pair<int,int> > extend(H*W,std::pair<int,int>(-1,-1));

    int i,j;
    std::vector<int> rowExtendCtr(H,0);
    std::vector<int> colExtendCtr(W,0);
    std::stack<std::pair<int,int> > rowStack[H];
    std::stack<std::pair<int,int> > colStack[W];
    for(i=0; i<H; ++i){
        std::string &s = S[i];
        for(j=0; j<W; ++j){
            if(s[j]=='.'){
                rowStack[i].push(std::pair<int,int>(i,j));
                colStack[j].push(std::pair<int,int>(i,j));
                ++(rowExtendCtr[i]);
                ++(colExtendCtr[j]);
            }
            if(s[j]=='#' || j==W-1){
                while(!rowStack[i].empty()){
                    auto &box = rowStack[i].top();
                    extend[W*box.first + box.second].first = rowExtendCtr[i];
                    rowStack[i].pop();
                }
                if(s[j]=='#'){
                    extend[W*i+j].first = 0;
                    rowExtendCtr[i] = 0;
                }
            }
            if(s[j]=='#' || i==H-1){
                while(!colStack[j].empty()){
                    auto &box = colStack[j].top();
                    extend[W*box.first+box.second].second = colExtendCtr[j];
                    colStack[j].pop();
                }
                if(s[j]=='#'){
                    extend[W*i+j].second = 0;
                    colExtendCtr[j] = 0;
                }
            }
        }
    }

    auto maxBox = *std::max_element(extend.begin(),extend.end(),[](const auto &a, const auto &b){
                                                                    return (a.first+a.second) < (b.first+b.second);
                                                                });
    std::cout << (maxBox.first + maxBox.second -1) << std::endl;
    return 0;
}


Measured memory_bytes: 73728
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
"""

# import {{{
from collections import ChainMap
from collections import Counter
from collections import defaultdict
from collections import deque
from collections import namedtuple
import bisect
import copy
import decimal
import fractions
import functools
import heapq
import itertools
import locale
import math
import operator
import pdb
import pprint
import random
import re
import string
import sys
import time

try:
    import numpy as np
    import scipy as sp
except:
    pass
# }}}

# util {{{
def is_odd(x):
    return x % 2 == 1

def is_even(x):
    return x % 2 == 0

def cmp(x, y):
    return (x > y) - (x < y)

def sgn(x):
    return cmp(x, 0)

def clamp(x, lo, hi):
    assert lo <= hi
    if x < lo:
        return lo
    elif x > hi:
        return hi
    else:
        return x

def chmax(xmax, x):
    if x > xmax:
        return x, True
    else:
        return xmax, False

def chmin(xmin, x):
    if x < xmin:
        return x, True
    else:
        return xmin, False

def argmax(seq):
    return max(range(len(seq)), key=seq.__getitem__)

def argmin(seq):
    return min(range(len(seq)), key=seq.__getitem__)

def INPUT():
    return input().rstrip() # CRLF対策

sys.setrecursionlimit(100000)

locale.setlocale(locale.LC_ALL, "C")
# }}}

# 適宜調整
PINF = float("inf")
NINF = float("-inf")
EPS  = 1e-9



def main():
    X = list(map(int, input().split()))

    X.sort()
    if X[0] == X[1]:
        print(X[2])
    elif X[1] == X[2]:
        print(X[0])

if __name__ == "__main__": main()


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

using namespace std;

int main()
{
    fastio;
    // ifstream f("f.txt");
    // ofstream g("out.txt");
    LL n,d,count=0;
    cin >> n >> d;

    while(n--){
        LL a,b;
        cin>>a>>b;
        if(sqrt(a*a + b*b)<=(double)d){
            count++;
        }
    }
    cout<<count<<"\n";
   
    return 0;
}


Measured memory_bytes: 3696
#include <stdio.h>
int main() {
  int A,B,C ;
  scanf("%d %d %d",&A,&B,&C);
int x;
 if(A==C)
 x=B;
 if(A==B)
 x=C;
 if(B==C)
 x=A;
int ans=x;
 printf("%d\n",ans);
  return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  string s;
  cin >> s;
  char first=s[0],last=s[s.length()-1];
  if(first==last){
    int count=0;
    bool isfirst=false;
    for(char c='a';c<='z';c++){
      if(c!=first){
        last=c;
        count=0;
        isfirst=false;
        for(int i=1;i<s.length()-1;i++){
          if(isfirst){
            if(s[i]==first){
              isfirst=false;
            }else{
              count++;
            }
          }else{
            if(s[i]==last){
              isfirst=true;
            }else{
              count++;
            }
          }
        }
        if(!isfirst) count++;
        if(count%2){
          cout<<"First"<<endl;
          return 0;
        }
      }
    }
    cout << "Second" << endl;
  }else{
    int count=0;
    bool isfirst=false;
    for(int i=1;i<s.length()-1;i++){
      if(isfirst){
        if(s[i]==first){
          isfirst=false;
        }else{
          count++;
        }
      }else{
        if(s[i]==last){
          isfirst=true;
        }else{
          count++;
        }
      }
    }
    if(isfirst) count++;
    if(count%2){
      cout<<"First"<<endl;
    }else{
      cout<<"Second"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 512
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[100000];

LL ans = 1;

void solve(){
    sort(A,A+N);//昇順
    //A[0]~A[j-1]までの和をaccum_A[j]とおく
    //ただしaccum_A[0] = 0と定める
    vector<LL> accum_A(N+1,0);
    for(int i=0;i<N;i++) accum_A[i+1] = accum_A[i] + A[i];

    //A[0]~A[i]までの和,accum_A[i+1]の2倍が
    //A[i+1]以上ならば（つまりi番目がi+1番目を吸収可能かどうか）
    //を各iについて判定
    for(int i=N-2;i>=0;i--){
        if(accum_A[i+1]*2>=A[i+1]){
            ans++;
        }else break;
    }
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
 
    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define fi first
#define se second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

template<typename T>
inline void remax(T& x, T y) { x = max(x, y); }

template<typename T>
inline void remin(T& x, T y) { x = min(x, y); }

int main() 
{
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    int n; cin >> n;
    cin >> s;
    int ans = 0;
    set<int> w, r;
    rep(i,0,n) {
        if(s[i] == 'W') w.insert(i);
        else r.insert(i);
    }
    
    while(!w.empty()) {
        int V = *(w.begin());
        if(r.empty()) break; 
        else {
            int longe = *(r.rbegin());
            if(longe < V) {
                break;
            }
            w.erase(V);
            r.erase(longe);
            ++ans;  
        }
    }

    cout << ans << '\n';

    return 0;
}





Measured memory_bytes: 13028
n=int(input())
l=list(map(int,input().split()))
 
import bisect
 
ans=0
l.sort()
 
for i in range(n):
    a=l[i]#一番短い棒を確定
    for j in range(i+1,n):
        b=l[j]#二番目に短い棒を確定
        ind=bisect.bisect_left(l,a+b)#二辺の和と同じだったら耐えないので，left
        ans+=max(0,ind-(j+1))#三角形の成立条件と，一番長い棒であることを考える

print(ans)

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

void isPrime(int t){
  for(int i=2;i*i<=t;i++){
    if(t%i==0) return;
  }
  ans++;
  return;
}

signed main(){
  cin >> n;
  rep(i,n){
    int a;
    cin >> a;
    isPrime(a);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3088
#include<iostream>
using namespace std;

int main(){
	int n,count=0;
	cin >>n;
	int p[n];
	for(int i=0;i<n;i++){
		cin >>p[i];
	}
	for(int i=1;i<n-1;i++){
		if((p[i-1]>p[i]&&p[i]>p[i+1])||(p[i-1]<p[i]&&p[i]<p[i+1]))count++;
	}
	cout <<count<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using lint = long long int;

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

    lint ans = 0;
    lint tmp = (A % 2 ? 1 + (B - A) / 2 : (B - A + 1) / 2);
    if (tmp % 2) ans++;

    for (int D = 1; D < 50; D++)
    {
        lint t = (1LL << D);
        lint tmp = 0;
        if ((A >> D) & 1) tmp += t - (A & (t - 1));
        if ((B >> D) & 1) tmp += (B & (t - 1)) + 1;
        if (tmp % 2) ans += t;
    }
    cout << ans << endl;
}


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

using namespace std;

int kai (int x) {
    int y[5] = {};
    x /= 100;
    y[0] = x / 100;
    y[1] = (x - y[0] * 100) / 10;
    int N = x * 100 + y[1] * 10 + y[0];
    return N;

}
int main (){
    int a,b;
    cin >> a >> b;
    int many, S, T = 0;
    many = b / 100 - a / 100 + 1;
    S = kai(a);
    T = kai(b);
    if(a > S) many-- ;
    if(b < T) many-- ;

    cout << many << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,b,c,a;
int main() 
{
	cin>>n;
	for(a=sqrt(n)+1;a>0;a--)
	{
		if(n%a==0) 
		{
			b=a;
			break;
		}
	}
	c=n/b;
	cout<<b+c-2;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#define pi acos(-1.0)
using namespace std;
void task()
{
  int a,b,c,d,ans;
  cin>>a>>b>>c>>d;
  while(a>0 && c>0)
  {
      c=c-b;
      if(c<=0){ ans=c; break;}
      a=a-d;
      if(a<=0){ ans=a; break; }
  }
  if(ans==c)
    cout << "Yes"<<endl;
  else if(ans==a)
    cout << "No"<<endl;
}
int main()
{

   task();

   return 0;

}



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


int main() {
  int A, B;
  cin >> A >> B;
  
  cout << A * B << endl;
  return 0;
}


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

#define lli long long int
#define ii pair<int, int>
#define ll pair<lli, lli>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second

using namespace std;

lli bigmod = 1000000007, f[100005];

lli fex(lli a, lli b) {
	lli ret;
	if (b == 0)
		return 1;
	ret = fex(a, b / 2);
	ret = (ret * ret) % bigmod;
	if (b & 1)
		ret = (ret * a) % bigmod;
	return ret;
}

lli c(lli n, lli k) {
	lli ret;
	ret = (f[n] * fex(f[k], bigmod - 2)) % bigmod;
	ret = (ret * fex(f[n - k], bigmod - 2)) % bigmod;
	return ret;
}

int main() {
	lli n, k, p[100005], ans = 0, temp;
	scanf("%lld %lld", &n, &k);
	if (k == 1) {
		puts("0");
		return 0;
	}
	p[0] = 0;
	for (lli i = 1; i <= n; i++)
		scanf("%lld", &p[i]);
	sort(p + 1, p + n + 1);
	for (lli i = 2; i <= n; i++)
		p[i] += p[i - 1];
	f[0] = 1;
	for (lli i = 1; i < n; i++)
		f[i] = (i * f[i - 1]) % bigmod;
	for (lli i = k; i <= n; i++) {
		temp = (p[n] - p[i - 1] - p[n - i + 1]) % bigmod;
		temp = (temp * c(i - 2, k - 2)) % bigmod;
		ans = (ans + temp) % bigmod;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    if(N == M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int count = 0;
	int i;
	unsigned int ans = 0;
	int handan = 0;
	
	char s[210000];
	scanf("%s", s);
	
	for (i = 0; i < 200000; i++)
	{
		if ((s[i] == 'A') && (handan == 0))
			handan = 1;
		
		if (handan == 1)
			count++;
		
		if ((s[i] == 'Z') && (handan == 1))
			ans = count;
	
	}
	
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 384
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
-----------------------
local N = read.n()
local L = 100
local f = array(1, 0)
for x=1,L do
    for y=1,L do
        for z=1,L do
            local a = x * x + y * y + z * z
            local b = x * y + y * z + z * x
            f[a + b] = f[a + b] + 1
        end
    end
end
for i=1,N do
    print(f[i])
end

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll x;
  cin >> x;

  ll a = 100;
  ll ans = 0;
  while (true) {
    ++ans;
    a += a/100;
    if (a >= x) {
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

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

int main() {

    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    ll out = 0;
    if(K<=A) out = K;
    else{
        out += A;
        K -= A;
        if(K>=B){
            K -= B;
            out -= K;
        }
    }
    cout << out << endl;
    return 0;
}


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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> ans(2 * H);
    for (int i = 0; i < H; i++)
    {
        string r;
        cin >> r;
        ans[2 * i] = r;
        ans[2 * i + 1] = r;
    }
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i] << endl;
    return 0;
}

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

int main() {
	int num,x;
	cin >> num;
	for (int i = 1; i <= num; i++) {
		x = i;

		// 3????????°??§????????°??????
		if (x % 3 == 0)
			cout << " " << i;

		// x???????????????3(10??§?????£????????????3)??§????????°????????????while?????????????¬??????°???
		// ???????????¶????????????????????´??????x???10??§?????£?????????????????¨??????
		// ????¨?2???????????°????????????x???0????????£???)??´??????????????????while????????????
		else {
			while (x) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
from itertools import permutations

def solve():
    a,b,c = map(int, input().split())
    d = min([abs(x-y) + abs(y-z) for x,y,z in permutations([a,b,c])])

    return str(d)

if __name__ == '__main__':
    print(solve())  

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {

    int a, b;
    
    cin >> a;
    cin >> b;
    
    if (a < b){
        cout << "a < b" << endl;
    }
    if (a > b) {
        cout << "a > b" << endl;
    }
    if (a == b) {
        cout << "a == b" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
W = 0 
T = input()
#print(T)
while 1:
    txt = input()
    if txt == 'END_OF_TEXT':
        break
    
   
    txt = txt.lower()
    Txt = list(txt.split())
    #print(Txt)
    
    W = W + Txt.count(T)
print(W)


Measured memory_bytes: 5552
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=10007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
vector<int>oya;
vector<vector<int>>ko;
vector<bool>syo;
vector<int>siz;
vector<int>ans;
vector<int>omd;
pair<int,int> dfs(int ter,int per,int iti,int nii){//1位,2位
	auto ptr=find(ko[ter].begin(),ko[ter].end(),per);
	if(ptr!=ko[ter].end()){ko[ter].era(ptr);}
	oya[ter]=per;
	int X=1,Y=0;
	int Nit=iti,Nni=nii;
	if(ter>Nni){Nni=ter;}
	if(Nit<Nni){swap(Nit,Nni);}
	for(auto it:ko[ter]){
		auto aaa=dfs(it,ter,Nit,Nni);
		X+=aaa.fir;Y+=aaa.sec;
	}
	if(ter==Nni){Y+=X;X=0;}
	if(per==iti){siz[ter]=Y;Y=0;}
	if(ter==Nit){siz[ter]+=X+Y;X=0;Y=0;}
	return mp(X,Y);
}
void efs(int ter,int gru,int idu){
	idu+=siz[ter];
	ans[ter]=idu;
	for(auto it:ko[ter]){efs(it,gru,idu);}
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,i;cin>>n;
	oya.res(n);ko.res(n);ans.res(n);
	for(i=1;i<n;i++){
		int a,b;cin>>a>>b;a--;b--;
		ko[a].pub(b);
		ko[b].pub(a);
	}
	syo.res(n);
	omd.res(n);
	siz.res(n);
	dfs(0,-1,-1,-1);
	efs(0,0,0);
	for(i=1;i<n;i++){cout<<ans[i]-1<<" ";}cout<<endl;
	return 0;
}


Measured memory_bytes: 34432
import sys
input = sys.stdin.readline
s = input().strip()
if len(s) <= 3:
  print(0)
  exit()
c = 0
chk = [0]*2019
for i,si in enumerate(s[::-1]):
  c += int(si)*pow(10,i,2019)
  chk[c%2019] += 1
ans = chk[0]
for i in chk:
  ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 9332
line = gets.split(' ').map(&:to_i)

n = line[0]
k = line[1]

if n < k then
  if 2 * n < k then
    print n
  else
    print k - n
  end
elsif n == k then
  print 0
else
  a = n % k
  b = k - a
  if a > b then
    print b
  else
    print a
  end
end

Measured memory_bytes: 1788
#include <stdio.h>
#include <algorithm>

using namespace std;

int a[100];

int main()
{
	int n, i, s=0;
	
	scanf("%d", &n);
	for(i=0;i<n;i++) scanf("%d", &a[i]);
	
	sort(a, a+n);
	
	for(i=0;i<n;i++){
		if(i%2 == 0) s += a[i];
		else s -= a[i];
	}
	
	printf("%d", abs(s));
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector> 

using namespace std;

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

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

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int H, W, D;
  cin >> H >> W >> D;
  vector<vector<int>> A(H, vector<int>(W));
  typedef pair<ll, ll> P;
  vector<P> loc(H * W);

  rep(i, H) {
    rep(j, W) {
      cin >> A[i][j];
      A[i][j]--;
      loc[A[i][j]] = make_pair((ll)i, (ll)j);
    }
  }
  int Q;
  cin >> Q;
  vector<ll> L(Q), R(Q);
  rep(i, Q) {
    cin >> L[i] >> R[i];
    L[i]--;
    R[i]--;
  }

  vector<ll> sum(H * W);
  repp(i, D, H * W - 1) {
    P& prev = loc[i - D];
    P& now = loc[i];

    ll dist = abs(now.fi - prev.fi) + abs(now.se - prev.se);
    sum[i] = sum[i - D] + dist;
  }

  rep(i, Q) {
    cout << sum[R[i]] - sum[L[i]] << endl;
  }
}

Measured memory_bytes: 5120
/*
	Author: Luis Manuel D�az Bar�n (LUISMO)
	Problem:
	Online Judge:
	Idea:
*/
#include<bits/stdc++.h>
// Types
#define ll long long
#define ull unsigned long long
// IO
#define sf scanf
#define pf printf
#define mkp make_pair
#define fi first
#define se second
#define endl "\n"

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll inf = 1e16 + 3;
const int mod = 1e9 + 7;
const int lim = 2e5 + 2;

int N, M;
vector<int> adj[lim];

int dp[lim];
bool mark[lim];

int DFS(int idx)
{
    if(mark[idx])
        return dp[idx];
    // for each adjacent
    for(int i = 0; i < adj[idx].size(); i++)
    {
        int nxt = adj[idx][i];
        int aux = DFS(nxt);
        dp[idx] = max(dp[idx], 1 + aux);
    }
    mark[idx] = true;
    return dp[idx];
}

void solve()
{
    cin >> N >> M;
    // reading edges
    for (int i = 0; i < M; i++)
    {
        int xi, yi;
        cin >> xi >> yi;
        adj[xi].push_back(yi);
    }
    
    int answ = 0;

    for(int i = 1; i <= N; i++)
    {
        int aux = DFS(i);
        answ = max(answ, aux);
    }

    cout << answ;
}

void fastIO()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
}

void IO()
{
	if(fopen("d:\\lmo.in","r") != NULL)
	{
		freopen("d:\\lmo.in","r",stdin);
	}
	else if(fopen("/media/Beijing/lmo.in","r") != NULL)
	{
		freopen("/media/Beijing/lmo.in", "r", stdin);
	}
}

int main()
{
	IO();

	fastIO();

	solve();
}


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

int A[21];
int B[50];
int C[50];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;

	cin >> n;

	for(int i=1;i<=n;i++)
	{
		cin >> A[i];
	}

	for(int i=1;i<=n;i++)
	{
		cin >> B[i];
	}

	for(int i=1;i<n;i++)
	{
		cin >> C[i];
	}

	int res = 0;

	for(int i=1;i<=n;i++)
	{
		if(i==1)
		{	
			res += B[A[i]];
		}
		else
		{
			res += B[A[i]];
			if(A[i]==A[i-1]+1)
			{
				res += C[A[i]-1];
			}
		}
		//cout << res << '\n';
	}

	cout << res << '\n';

	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
signed main()
{
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());

    ll sum=(ll)(a[0]);
    int i;
    for (i = 1; i <= (n-2)/2; ++i) sum+=(ll)(a[i]*2);
    if (n%2) sum+=a[i]; // 人数が奇数のときはもう１つ足す
    cout << sum << endl;
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int n;cin>>n;
    vint a(3*n);
    rep(i,3*n)cin>>a[i];
    sort(all(a));

    int sum=0;
    rep(i,n)sum+=a[3*n-2*(i+1)];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2560
def solve():
    n, m = map(int, input().split())
    s = [[int(i)-1 for i in input().split()] for _ in range(m)]
    p = list(map(int, input().split()))

    ans = 0
    for i in range(1<<n):
        for j in range(m):
            cnt = 0
            for b in s[j][1:]:
                if (i>>b)&1: cnt += 1
            if cnt%2 != p[j]: break
        else: ans += 1

    return ans

if __name__ == "__main__":
    print(solve())

    

Measured memory_bytes: 3064
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;
#include <vector>
 
#define ll long long int

#define M 1000000007

int main() {
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0 ; i < n; ++i) {
        cin >> a[i];
    }
    ll v[3] = {0,0,0};

    ll ans = 1;
    for (ll i = 0;i < n; ++i) {
        int id = -1;
        ll count = 0;
        if (v[0] == a[i]) { ++count; id = 0; }
        if (v[1] == a[i]) { ++count; id = 1; }
        if (v[2] == a[i]) { ++count; id = 2; }
        v[id]++;
        ans = (ans * count) % M;
    }
    cout << ans << endl;
 }


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

const long long inf = 0x3fffffffffffffff;
int N, len[60];
long long c[60];
long long dp[2][60][30];
char s[2][60][50];
long long dfs(const int &N, const int &l, const char &f);
char pal(char *l, char *r);

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%s%lld", s[0][i], &c[i]);
		len[i] = strlen(s[0][i]);
		for (int j = 0; j < len[i]; ++j)
			s[1][i][j] = s[0][i][len[i] - 1 - j];
	}
	long long ans = inf;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < N; ++i)
		ans = min(ans, c[i] + dfs (i, 0, 0));
	printf("%lld\n", ans == inf ? -1 : ans);
	return 0;
}

char pal(char *l, char *r) {
	for (; l < r; ++l, --r)
		if (*l != *r)
			return 0;
	return 1;
}

long long dfs(const int &n, const int &l, const char &f) {
	long long &ret = dp[f][n][l];
	if (ret != -1)
		return ret;
	const int r = len[n] - 1;
	if (pal(&s[f][n][l], &s[f][n][r]))
		return ret = 0;
	ret = inf;
	for (int i = 0; i < N; ++i) {
		memcpy(&s[f][n][len[n]], s[f][i], len[i]);
		if (pal(&s[f][n][l], &s[f][n][len[n] + len[i] - 1]))
			ret = min(ret, c[i]);
		if (r - l + 1 <= len[i]) {
			for (int j = 0; j <= r - l; ++j)
				if (s[f][n][j + l] != s[!f][i][j])
					goto LABLE;
			ret = min(ret, c[i] + dfs(i, r - l + 1, !f));
		}
		else {
			for (int j = 0; j < len[i]; ++j)
				if (s[f][n][j + l] != s[!f][i][j])
					goto LABLE;
			ret = min(ret, c[i] + dfs(n, l + len[i], f));
		}
LABLE:;
	}
	return ret;
}


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

int a[1 << 18];
multiset<int> f[1 << 18];

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 0; i < (1 << n); i++) cin >> a[i], f[i].insert(a[i]);
 	for (int i = 0; i < n; i++) {
        for (int mask = 0; mask < (1 << n); mask++) {
            if (mask >> i & 1) {
                for (auto x: f[mask ^ (1 << i)]) {
                	f[mask].insert(x);
                	while (f[mask].size() > 2) f[mask].erase(f[mask].begin());
                }
            }
        }
    }
    int ans = 0;
    for (int mask = 1; mask < (1 << n); mask++) {
    	ans = max(ans, *f[mask].begin() + *(--f[mask].end()));
    	cout << ans << '\n';
    }
    return 0;
}	

Measured memory_bytes: 41524
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;
const int di[]={-1,0,1,0},dj[]={0,-1,0,1};

int main()
{
    int h,w;
    cin>>h>>w;
    vector< vector<char> > m(h,vector<char>(w));
    queue<P> que;
    vector< vector<int> > depth(h,vector<int>(w,-1));

    rep(i,h)
    {
        rep(j,w)
        {
            cin>>m[i][j];
            if(m[i][j]=='#')
            {
                que.push(P(i,j));
                depth[i][j]=0;
            }
        }
    }
    while(!que.empty())
    {
        P now=que.front();
        que.pop();
        rep(i,4)
        {
            P np=P(now.first+di[i],now.second+dj[i]);
            if(np.first>=0 && np.first<h && np.second>=0 && np.second<w && m[np.first][np.second]=='.')
            {
                m[np.first][np.second]='#';
                que.push(np);
                depth[np.first][np.second]=depth[now.first][now.second]+1;
            }
        }
    }
    int ans=0;
    rep(i,h)rep(j,w)
    {
        ans=max(ans,depth[i][j]);
    }
    cout<<ans;

}

Measured memory_bytes: 13328
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vi a(n);
    forn(i, n) cin >> a[i];
    int cur = 1;
    forn(i, n) if (a[i] == cur) cur++;
    if (cur == 1) cout << "-1\n";
    else cout << n - cur + 1 << "\n";
}

Measured memory_bytes: 1024
from math import cos, radians
a, b, h, m = map(int, input().split())
ar = h * 30 + m * 0.5
br = m * 6

r = min(360 - (abs(ar - br)), abs(ar - br))
print((a**2+b**2-2*a*b*cos(radians(r)))**0.5)

Measured memory_bytes: 62396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] nums = br.readLine().split(" ");
		int h = Integer.parseInt(nums[0]);
		int w = Integer.parseInt(nums[1]);

		boolean[][] canvas = new boolean[h][w];

		// 入力値でキャンバス初期化
		for (int i = 0; i < h; i++) {
			String xline = br.readLine();
			for (int j = 0; j < w; j++) {
				if (xline.charAt(j) == '#') {
					canvas[i][j] = true;
				} else {
					canvas[i][j] = false;
				}
			}
		}

		// 判定
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (canvas[i][j]) {
					// 上方向チェック
					int hu = i - 1;
					if (hu < 0)
						hu = i;
					boolean checku = canvas[hu][j];

					// 左方向チェック
					int wl = j - 1;
					if (wl < 0)
						wl = j;
					boolean checkl = canvas[i][wl];

					// 下方向チェック
					int hb = i + 1;
					if (h <= hb)
						hb = h - 1;
					boolean checkb = canvas[hb][j];

					// 右方向チェック
					int wr = j + 1;
					if (w <= wr)
						wr = w - 1;
					boolean checkr = canvas[i][wr];

					// 4方向のどれも黒色ではない場合
					if (!(checku || checkl || checkb || checkr)) {
						System.out.println("No");
						return;
					}
				}

			}
		}

		System.out.println("Yes");

	}

}

Measured memory_bytes: 21204
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 data[]={n+m,n-m,n*m};
    int max=n+m;

    for(int i=1;i<data.length;i++){
      // System.out.println(data[i]);
       max=Math.max(data[i],max);
    }
    System.out.println(max);

  }
}


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

using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int          long long int
#define pll				   pair<int , int>

#define ALL(v)       v.begin(),v.end()
#define ALLR(v)      v.rbegin(),v.rend()
#define pii          3.14159265358979323
#define inf     		 LLONG_MAX
#define ones(x)      __builtin_popcount(x)
#define fill(a,b)    memset(a,b,sizeof(a))
#define mod 			   1000000007
#define hell         998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
  int n , k;

  cin >> n >> k;

  if(k >= (1LL<<n)) {
    cout << -1 << endl;
    return;
  }

  if(n == 0) {
    if(k == 0) {
      cout << 0 << " " << 0;
      return;
    }
    else {
      cout << -1;
      return;
    }
  }
  else if(n == 1) {
    if(k == 0) {
      cout << 0 << " " << 0 << " " << 1 << " " << 1;
      return;
    }
    else {
      cout << -1;
      return;
    }
  }
  else {
    vector< int > v;

    for(int i = 0; i < (1<<n); ++i) {
      if(i != k) {
        v.push_back(i);

        cout << i << " " ;
      }
    }

    cout << k << " ";

    reverse(ALL(v));

    for(auto u : v) {
      cout << u << " ";
    }

    cout << k;
  }
}


signed main() {
    fast;

    int t = 1;

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

	  //cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 4332
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target ("avx,avx2,tune=native")
#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define orz ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);    
#define inp freopen("input.txt","r",stdin);freopen("out.txt","w",stdout); 
ll mod=1e9+7;
void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    
}
const int N=2e5+5;
int x[200],y[200];
bool cmp(const pair<int,int> &A,const pair<int,int> &B) {
	return atan2(A.second , A.first) < atan2(B.second , B.first);
}

int main() {
    io();
    int n;
    cin>>n;
    pair<int,int> a[200];
    for(int i=0;i<n;i++){
    	cin>>a[i].first>>a[i].second;

    }
    /*for(int i=0;i<n;i++){
		if(x[i]==0 && y[i]==0)
			continue;
		double tr=atan2(y[i],x[i]);
		th.push_back(tr);
		for(int j=0;j<n;j++){
			if(i == j)
				continue;
			if(x[j] == 0 && y[j] == 0)
				continue;
			double ts=atan2(y[j],x[j]);
			th.push_back((tr+ts)/2);
		}
	}*/
	sort(a,a + n,cmp);
	double ans = 0;
	for(int i = 0;i < n;++i) {
		double X = a[i].first,Y = a[i].second;
		ans = max(ans,X * X + Y * Y);
		for(int j = (i + 1) % n;j != i;j = (j + 1) % n) {
			X += a[j].first,Y += a[j].second;
			ans = max(ans,X * X + Y * Y);
		}
	}
	printf("%.10lf",sqrt(ans));
	return 0;

}
 


 

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=1;
    while(1){
        if(a>=(ans+1)*c+ans*b){
            ans++;
        }else{
            break;
        }
    }
    cout<<ans-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#131d
N = int(input())
lst = []
for i in range(N):
    a, b = map(int, input().split())
    lst.append([b, a])
lst = sorted(lst)

lim = 0
time = 0
flag = 0
for i in lst:
    lim = i[0]
    if time + i[1] <= lim:
        time += i[1]
    else:
        flag = 1
        break
if flag == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 37272
#include <iostream>
 
using namespace std;

int pow10(int n);
int main(){
  int i;
  int a, b;
  int ab = 0;
  int ba = 0;
  
  cin >> a >> b;
  
  for(i = 0; i < b; i++){
    ab += a * pow10(i);
  }
  for(i = 0; i < a; i++){
    ba += b * pow10(i);
  }
  
  if(a == b){
    cout << ab << endl;
  }
  else if(a < b){
    cout << ab << endl;
  }
  else{
    cout << ba << endl;
  }
  
  return 0;
}

int pow10(int n){
  if(!n){
    return 1;
  }
  else{
    return 10 * pow10(n-1);
  }
}

Measured memory_bytes: 256