akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef pair<double,ll> pdl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<pdd> vdd;
typedef vector<pdi> vdi;
typedef vector<pdl> vdl;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
const ll MAXLL=0x3f3f3f3f3f3f3f3f;
const int MAX=0x3f3f3f3f;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template<class T>
void rsort(vector<T>& v){
	sort(v.rbegin(),v.rend());
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
template<class T>
bool is_sorted(vector<T>& v){
	return is_sorted(v.begin(),v.end());
}
template<class T>
bool sorted(vector<T>& v){
	return is_sorted(v);
}
void precompute(){

	return;
}
struct temp{
	string s;
	int a,b;
	temp(string s,int a,int b):s(s),a(a),b(b){}
	bool operator < (temp T){
		if(s!=T.s)return s<T.s;
		else return a>T.a;
	}
};
void solve(){
	int n;
	cin>>n;
	vector<temp>t;
	for(int i=0;i<n;i++){
		string s;int a;
		cin>>s>>a;
		t.eb(s,a,i+1);
	}
	sort(t);
	for(int i=0;i<n;i++){
		cout<<t[i].b<<endl;
	}
	return;
}

int main(){
	ios::sync_with_stdio(0);
	int numberofsubtestcases=1;
//	cin>>numberofsubtestcases;
	precompute();
	for(int looping=1;looping<=numberofsubtestcases;looping++){
//		cout<<"Case #"<<looping<<": ";
		solve();
	}
	return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
struct edge{
	int k,next;
}e[10005];
int n,a[3005],home[3005],cnt=-1,f[3005];
void add(int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
void dfs(int k,int F){
	f[k]=0;
	for(int i=home[k];~i;i=e[i].next) if(e[i].k!=F){
		dfs(e[i].k,k);
		if(!f[e[i].k]&&a[k]>a[e[i].k]) f[k]=1;
	}
}
int main(){
	memset(home,-1,sizeof(home));
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	for(int i=1;i<=n;i++){
		dfs(i,0);
		if(f[i]) printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define pb  push_back
#define F  first
#define S  second
#define mak make_pair
const int N=1e5+3,mod=1e8;
int n,k,a[N][4];
ll oo=-1e9;
int mem[N][5];
int dp(int i,int last)
{
    int xx=oo;
    if (i==n)
    { for (int j=1;j<=3;j++)
    {
        if (last==j)continue;
        xx=max(xx,a[i][j]);
    }

        return xx;
    }
    int &ret=mem[i][last];
    if (ret!=-1)return ret;
xx=0;
    for (int j=1;j<=3;j++)
    {
        if (last==j)continue;
        xx=max(a[i][j]+dp(i+1,j),xx) ;
    }
return ret=xx;
}


int main ()
{
 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*for (int i=0;i<=N;i++)
    mem[i]=oo;*/
 memset(mem,-1,sizeof mem);
 cin>>n;
 for (int i=1;i<=n;i++)
    cin>>a[i][1]>>a[i][2]>>a[i][3];
    cout<<dp(1,-1);

}


Measured memory_bytes: 11648
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 3010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
const long double pi=3.14159265358979323846264338328;
int a[maxn];
int n,l;
int main()
{
	n=read(); l=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	long double x=0,y=0;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++){
			x+=cos(pi*(a[i]+a[j])/l)*(n-(j-i+1))+cos(pi*(a[i]+a[j])/l+pi)*(j-i-1);
			y+=sin(pi*(a[i]+a[j])/l)*(n-(j-i+1))+sin(pi*(a[i]+a[j])/l+pi)*(j-i-1);
		}
	x/=(ll)n*(n-1)*(n-2)/6;
	y/=(ll)n*(n-1)*(n-2)/6;
	printf("%.15Lf %.15Lf\n",x,y);
	return 0;
}

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

int main(){
    string s,t; cin >> s >> t;
    int ans = s.size();
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == t[i]) ans--;
    }
    cout << ans << endl;
}	

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define aint(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          int;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD = 1000000007;

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

signed main(){
	int n;
	cin >> n;
	cout << ((n - 1) / 111 + 1) * 111 << endl;
	return 0;
}

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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

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

    loop {
        string s = next<string>();
        if(s.empty()) break;
        int joi = 0, ioi = 0;

        times(s.size() - 2, i)
            if(s[i + 1] == 'O' && s[i + 2] == 'I') {
                if(s[i] == 'J')
                    joi++;
                if(s[i] == 'I')
                    ioi++;
            }

        cout << joi ln << ioi ln;
    }

    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main() {
  int n, S[10001], sum; cin >> n;
  sum = 0;
  for(int i = 0; i < n; i++) cin >> S[i];
  int q, tmp; cin >> q;
  for(int i = 0; i < q; i++) {
    cin >> tmp;
    sum += search(S, n, tmp);
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cctype>
#include <string>
using namespace std;

int main()
{
	string s;
	getline(cin,s);
	for ( int i=0; i<(int)s.length(); i++ )
		cout<<(char)toupper(s[i]);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();
        ArrayList<Integer>a = new ArrayList<>();
        ArrayList<Integer>z = new ArrayList<>();
        
        for(int i=0; i<S.length(); i++) {     	
        	if(ss[i] == 'A') {
        		a.add(i);
        	}else if(ss[i] == 'Z') {
            	z.add(i);
        	}
        }
        Collections.sort(a);
        Collections.sort(z,Collections.reverseOrder());

        System.out.print(z.get(0) - a.get(0) + 1);
        }
    }


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

int m, min, max;
int P[256];

int main() {
  for(;;) {
    scanf("%d %d %d", &m, &min, &max);
    if( m == 0 and min == 0 and max == 0 ) break;
    for(int i = 1; i <= m; ++i) {
      scanf("%d", &P[i]);
    }
    std::sort(P + 1, P + 1 + m);
    std::reverse(P + 1, P + 1 + m);
    int res = -1, maxdiff = -1;
    for(int i = min; i <= max; ++i) {
      int diff = P[i] - P[i+1];
      if( maxdiff <= diff ) {
        maxdiff = diff;
        res = i;
      }
    }
    printf("%d\n", res);
  }
  
  return 0;
}

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

int main(){
    int H,W;
    cin >> H >> W;
    vector <string> S(H);
    vector <vector <string> > s(H, vector<string>(W));
    for(int i=0; i<H; i++){
        cin >> S[i];
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            s[i][j] = S[i][j];
        }
    }

    int ok=0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int okij=0;
            if(s[i][j] == "#"){
                if(0 <= i-1){
                    if(s[i-1][j] == "."){
                        okij++;
                    }
                }
                if(i+1 <= H-1){
                    if(s[i+1][j] == "."){
                        okij++;
                    }
                }
                if(0 <= j-1){
                    if(s[i][j-1] == "."){
                        okij++;
                    }
                }
                if(j+1 <= W-1){
                    if(s[i][j+1] == "."){
                        okij++;
                    }
                }
            }
            if(okij == 4){
                ok ++;
            }   
        }
    }
    if(ok == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
n = int(input())
#AC, WA, TLE, RE
AC = []
WA = []
TLE = []
RE = []
for i in range(n):
  si = input()
  if si == 'AC':
    AC.append(si)
  elif si == 'WA':
    WA.append(si)
  elif si == 'TLE':
    TLE.append(si)
  elif si == 'RE':
    RE.append(si)

print('AC x '+str(len(AC)))
print('WA x '+str(len(WA)))
print('TLE x '+str(len(TLE)))
print('RE x '+str(len(RE)))

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int n,q;
vector<vector<int>> tree(200000, vector<int>());

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

    cout << min(a+b, min(b+c, c+a)) << endl;
}


Measured memory_bytes: 4992
/*
❤️❤️❤️I_love_QMsh❤️❤️❤️
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define x first
#define y second

using namespace std;
using namespace __gnu_pbds; // gp_hash_table<int, int> table;

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

template<typename T> bool smin(T &a, const T &b) { bool ret = b < a; return a = (ret ? b : a), ret; }
template<typename T> bool smax(T &a, const T &b) { bool ret = a < b; return a = (ret ? b : a), ret; }

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

mt19937 rnd;

const int N = 410;

int dp[N][N];
int sum[N][N];

const int M = (int)1e9 + 7;

int sm(int a, int b) {
  a += b;
  if (a >= M) {
    a -= M;
  }
  if (a < 0) {
    a += M;
  }
  return a;
}

int mlt(int a, int b) {
  return (ll)a * b % M;
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, C;
  cin >> n >> C;
  vector<int> a(n);
  for (int &i : a) {
    cin >> i;
  }
  vector<int> b(n);
  for (int &i : b) {
    cin >> i;
  }

  for (int st = 0; st <= C; st++) {
    for (int j = 1; j < N; j++) {
      int cur = 1;
      for (int k = 0; k < st; k++) {
        cur = mlt(cur, j);
      }
      sum[st][j] = sm(sum[st][j - 1], cur);
    }
  }

  dp[n][0] = 1;
  for (int i = n - 1; i >= 0; i--) {
    for (int c = 0; c <= C; c++) {
      for (int y = 0; y <= c; y++) {
        dp[i][c] = sm(dp[i][c], mlt(dp[i + 1][c - y], sm(sum[y][b[i]], -sum[y][a[i] - 1])));
      }
    }
  }
  cout << dp[0][C];
  return 0;
}

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

int main() {
  int64_t a , b ;
  cin >> a >> b;
  if ( a == 1 || b==1){
    cout <<1 << endl;
    return 0;
  }else {
   cout << (a*b+1)/2 << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=2000000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}

class Edge{
public:
	long long from;
	long long to;
	long long w;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N,D;
	cin>>N>>D;
	long long ans=0;
	long long X[N][D];
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			cin>>X[i][j];
		}
	}
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			long long num=0;
			for(int d=0;d<D;d++){
				num+=pow((X[i][d]-X[j][d]),2);
			}
			long long numr=sqrt(num);
			if(numr*numr==num)ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;


int main()
{
    int N,K,dig=1;
    int ans=1;

    cin >> N >> K;

    while(N>=K){
        ans ++;
        N /= K;

    }

    cout << ans <<endl;

 
    return 0;

}

Measured memory_bytes: 256
import Control.Applicative
import Data.List
import Data.Char

getInt :: IO Int
getInt = (\a -> read a :: Int) <$> getLine

getIntArray :: IO [Int]
getIntArray = ((map (\a -> read a :: Int)) . words) <$> getLine

getStrArray :: Int -> IO [String]
getStrArray 0 = return [] :: IO [String]
getStrArray n = (:) <$> getLine <*> (getStrArray (n - 1))

countSq :: [Int] -> Int
countSq [n, m] = (n - 1) * (m - 1)

differ :: [Int] -> Int
differ [a, b, c]
    | a == b = c
    | b == c = a
    | otherwise = b

main = do
    print =<< (differ . sort) <$> getIntArray


Measured memory_bytes: 508
operation = {"North": (1, 5, 2, 3, 0, 4),
             "East": (3, 1, 0, 5, 4, 2),
             "West": (2, 1, 5, 0, 4, 3),
             "South": (4, 0, 2, 3, 5, 1),
             "Right": (0, 2, 4, 1, 3, 5),
             "Left": (0, 3, 1, 4, 2, 5)}

while True:
    n = int(input())
    if n == 0:
        break
    dice = [i+1 for i in range(6)]
    ans = 1
    for _ in range(n):
        indices = operation[input().strip()]
        dice = [dice[i] for i in indices]
        ans += dice[0]
    print(ans)



Measured memory_bytes: 5616
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		double r = stdIn.nextDouble();

		double area = r * r * Math.PI;
		double cir = 2 * r * Math.PI;

		System.out.printf("%.6f %.6f",area,cir);
	}
}

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

int main() {
    string x;
    cin >> x;
    int ret = 2000; // 753-xより十分大きい
    for (int i = 0; i <= x.size()-2; i++) {
        int tmp = stoi(x.substr(i,3));
        ret = min(abs(tmp-753), ret);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3604
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]


def get(cx, cy):
    for x, y, h in xyh:
        if h > 0:
            return h + abs(x - cx) + abs(y - cy)


def check(cx, cy, H):
    for x, y, h in xyh:
        if h != max(H - abs(x - cx) - abs(y - cy), 0):
            return False
    return True


for cx in range(101):
    for cy in range(101):
        H = get(cx, cy)
        if check(cx, cy, H):
            print(cx, cy, H)
            exit()

Measured memory_bytes: 3064
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <time.h>
# include <math.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 250
# define eps 1e-3
# define MAXM 500005
# define MOD 1000000007
# define INF 1000000000
# define MIN(a,b) (a)>(b)?(b):(a)
# define MAX(a,b) (a)<(b)?(b):(a)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;

int main()
{
    string a;
    int h,w,i;
    cin>>h>>w;
    for(i=0;i<h;i++)
    {
        cin>>a;
        cout<<a<<endl<<a<<endl;
    }
    return 0;
}



















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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  for(int i = 0; i < n - 2; i++) {
    if (s.at(i) == 'A') {
      if (s.at(i + 1) == 'B' && s.at(i + 2) == 'C') cnt++;
    }
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
cvs = [[c for c in input()] for _ in range(h)]

di = [0, 1, 0, -1]
dj = [1, 0, -1, 0]

for i in range(h):
    for j in range(w):
        if cvs[i][j] == '#':
            ok = False
            for d in range(4):
                if 0<=i+di[d]<h and 0<=j+dj[d]<w:
                    if cvs[i+di[d]][j+dj[d]] == '#':
                        ok = True
            if not ok:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long n,m,fact[500001];

long long inv(long long a , long long pw){
	long long ret = 1;
	while(pw){
		if(pw % 2 == 1){
			ret *= a;
			ret %= mod;
		}
		a *= a;
		a %= mod;
		pw /= 2;
	}
	return ret;
}

long long C(long long a , long long b){
	return fact[a]*inv(fact[a-b]*fact[b]%mod,mod-2)%mod;
}

long long P(long long a , long long b){
	return C(a,b)*fact[b]%mod;
}

int main(){
	cin >> n >> m;
	fact[0] = 1;
	for(long long i = 1 ; i <= 500000 ; i += 1){
		fact[i] = fact[i-1]*i%mod;
	}
	long long ans = P(m,n)*P(m,n)%mod;
	for(long long i = 1 ; i <= n ; i += 1){
		long long val = (i % 2 == 1 ? -1 : 1);
		ans += val*P(m,n)*((C(n,i)*P(m-i,n-i))%mod)%mod;
		ans %= mod;
	}
	if(ans < 0){
		ans += mod;
	}
	cout << ans << endl;
}

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

int main() {
  int count;
  int x,A;
  cin >> x >> A;
  string text;
  for(x;x<=A;x++){
  string text = to_string(x);
  string rtext = text;
  reverse(rtext.begin(), rtext.end());
  if(text.compare(rtext) == 0) count++;
  }
  cout << count << endl;
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	ll A,B; cin >> A >> B;
	V<ll> pow2(60,1);
	for(ll i = 1; i < 60; ++i) pow2[i] = 2*pow2[i-1];
	V<ll> mA(40,0),mB(40,1);

	mB[0] = ((B%4==0 || B%4==3)?0:1);
	for(ll i = 1; i < 40; ++i) {
		mB[i] = B%pow2[i+1];
		if(mB[i] < pow2[i]) mB[i] = 0;
		else {
			mB[i] -= pow2[i];
			mB[i] += 1;
		}
	}

	if(A!=0){
		A--;
		mA[0] = ((A%4==0 || A%4==3)?0:1);
		for(ll i = 1; i < 40; ++i) {
			mA[i] = A%pow2[i+1];
			if(mA[i] < pow2[i]) mA[i] = 0;
			else {
				mA[i] -= pow2[i];
				mA[i] += 1;
			}
		}
	}
	for(int i = 0; i < 40; ++i) mA[i] += mB[i];
	for(int i = 0; i < 40; ++i) mA[i] %= 2;
	ll ans = 0;
	for(int i = 0; i < 40; ++i) ans += mA[i]*pow2[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt();
        List<Integer> c = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            c.add(sc.nextInt());
        }
        int cost1 = 0, cost2 = 0, current = x;
        while (current != 0) {
            if (c.contains(current - 1)) {
                cost1++;
            }
            current--;
        }
        current = x;
        while (current != n) {
            if (c.contains(current + 1)) {
                cost2++;
            }
            current++;
        }
        System.out.println(Math.min(cost1, cost2));
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n, m;
	cin >> n >> m;
	vector<string> s(n);
	rep(i, n) {
		cin >> s[i];
	}
	sort(all(s));
	rep(i, n) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

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

    string sn = to_string(N);
    int cnt = 0;
    for(int i = 0; i < sn.size(); ++i) {
        cnt += sn[i] - '0';
    }

    if(N % cnt == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int p, q, r; cin >> p >> q >> r;
  cout << p + q + r - max({p, q, r}) << '\n';
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

int main(void) {
	double pi = atan(1) * 4.0;
	double a, b, C, h;
	scanf("%lf %lf %lf", &a, &b, &C);
	C *= pi / 180.0;
	h = b * sin(C);
	printf("%lf\n", a * h / 2.0);
	printf("%lf\n", a + b + sqrt(a * a + b * b -  2 * a * b * cos(C)));
	printf("%lf\n", h);
	return 0;
}

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

int gcd(int m, int n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}

vector<pair<int, int>> factorize(int n) {
  vector<pair<int, int>> res;
  for(int i = 2; i * i <= n; i++) {
    if(n%i) continue;
    res.emplace_back(i, 0);
    while(n%i==0) {
      n/=i;
      res.back().second++;
    }
  }
  if(n!=1) res.emplace_back(n, 1);
  return res;
}

signed main() {
  int a, b; cin >> a >> b;
  int g = gcd(a, b);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
$count_list = array();
while (($input = trim(fgets(STDIN))) !== '') {
	$input = intval($input);
	$count = 0;
	for ($i=0; $i < 10; $i++) { 
		for ($j=0; $j < 10; $j++) { 
			for ($k=0; $k < 10; $k++) { 
				for ($l=0; $l < 10; $l++) { 
					if ($i + $j + $k +$l === $input) {
						$count++;
					}
				}
			}
		}
	}
	echo $count."\n";
}

Measured memory_bytes: 15192
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;
vvi a;
vi b;

int main(){
	cin>>n;
	a=vvi(n,vi(n));
	vi b(n);
	bool B=0;
	for(int i=0;i<n;i++) for(int j=0;j<n;j++){
		char c;
		cin>>c;
		if(c=='#'){
			a[i][j]++;
			b[j]++;
			B=1;
		}
	}
	if(!B){
		cout<<-1<<endl;
		return 0;
	}
	int res=inf;
	for(int i=0;i<n;i++){
		int t=0;
		for(int j=0;j<n;j++) t+=1-a[i][j];
		res=min(res,t+(t<n&&!b[i]?1:0));
	}
	for(int i=0;i<n;i++) if(b[i]<n) res++;
	cout<<res<<endl;
}

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

 int main(){
  int N;
  long long L[100000];

  cin >> N;

  L[0] = 2;
  L[1] = 1;
  
  for (int i = 2; i <= 86; i++ ){
   L[i] = L[i-1] + L[i-2];
   }

  cout << L[N] << endl;


 return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
 
main(){
        char a[4],b[4];
        int num;
 
        scanf("%s %s",a,b);
        char *c;
        c = strcat(a , b);
 
        num = atoi(c);
 
        int n = sqrt(num);
        if(n*n == num && c != 100100){
                printf("Yes");
        }else if(n*n != num && c != 100100){
                printf("No");
        }else if(c == 100100){
        		printf("No");
        }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int n, c, k, tab[100010], ans;
vector< int > v;

int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n>>c>>k;
	for( int a = 1; a <= n; a++ )cin>>tab[a];
	sort( tab + 1, tab + n + 1 );
	for( int a = 1; a <= n; a++ )
	{
		if( v.size() && tab[a] - v[0] > k ) ans++, v.clear();
		if( v.size() == c )ans++, v.clear();
		v.push_back( tab[a] );
	}
	cout<<ans+1<<endl;
	return 0;
}
 


Measured memory_bytes: 640
/*
 * @Date         : 2020-08-10 15:34:44
 * @Author       : ssyze
 * @Description  :
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int n, k;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    vector<ll> a(n);
    for (auto& x : a) cin >> x;
    sort(a.begin(), a.end());
    ll ans = 1;
    int l = 0, r = a.size() - 1;
    if (k & 1) ans = a[n - 1], k--, r--;
    int sz = a.size();
    if (ans < 0) {
        for (int i = 0; i < k; i++) ans = ans * a[sz - 2 - i] % mod;
    }
    else {
        while (k) {
            ll neg = a[l] * a[l + 1], pos = a[r] * a[r - 1];
            if (neg > pos)
                ans = ans * (neg % mod) % mod, l += 2;
            else
                ans = ans * (pos % mod) % mod, r -= 2;
            k -= 2;
        }
    }
    cout << (ans + mod) % mod << endl;
}

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

int main()
{
	int n, x = 0;
	cin >> n >> x;
	vector<int> list(n);
	for (int i = 0; i < n; i++)
	{
		cin >> list[i];
	}
	sort(list.begin(), list.end());
	int ans = 0;
	int num = 0;
	for (int i = 0; i < n; i++)
	{
		num += list[i];
		if (num <= x)
		{
			ans++;
		}
		else
		{
			break;
		}
	}
	if (x > num)
	{
		ans--;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#pragma region Preparation
/* competitive programming */
#include "bits/stdc++.h"
using namespace std;

/* using */
// long
using ll = long long;
using ld = long double;
// vector
using vi = vector<int>;
using vd = vector<double>;
using vll = vector<ll>;
using vld = vector<ld>;
using vs = vector<string>;
using vi2 = vector<vector<int>>;
using vll2 = vector<vector<ll>>;

/* define */
// array
#define ari(x) array<int, x>
#define ard(x) array<double, x>
#define arll(x) array<ll, x>
#define arld(x) array<ld, x>
#define ars(x) array<string, x>
#define ari2(x, y) array<array<int, y>, x>
#define arll2(x, y) array<array<ll, y>, x>
// int -> ll
#define int ll // int -> ll
// push_back系
#define pb(x) push_back(x)    // push_back
#define eb(x) emplace_back(x) // emplace_back
// all range
#define all(x) x.begin(), x.end() // all_range
// gcd, lcm
#define gcd(x, y) __gcd(x, y)         // gcd
#define lcm(x, y) (x / gcd(x, y) * y) // lcm
// PI
#define PI M_PI // PI
// 大文字・小文字変換
#define cup(x) toupper(x)                                              // char_toupper
#define clow(x) tolower(x)                                             // char_tolower
#define strup(x) *transform(x.begin(), x.end(), x.begin(), ToUpper())  // string_toupper
#define strlow(x) *transform(x.begin(), x.end(), x.begin(), ToLower()) // string_tolower
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// 大文字・小文字変換
struct ToUpper
{
    char operator()(char c) { return toupper(c); }
};
struct ToLower
{
    char operator()(char c) { return tolower(c); }
};
#pragma endregion

#pragma region External variables
/* A・B問題用外部変数 */
ll a, b, c, d, x, y, p, q, r; // 基本変数
ll n, k;             // 範囲・長さ・整数用
ll L, R;             // 左、右
string s;            // 文字列用
#pragma endregion

/* main */
void Main(void)
{
    cin >> r >> d >> x;
    for (int i = 0; i < 10; i++)
    {
        x = r * x - d;
        cout << x << endl;
    }
}

#pragma region main
signed main(void)
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0LL;
}
#pragma endregion


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()

int main(void){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i,n) {
        cin >> s[i];
    }
    sort(all(s));
    rep(i,n) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}


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

int digit_sum(int n);

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

  int sum = 0;
  for(int i = 0; i <= N; ++i) {
    int digitSum = digit_sum(i);
    if(digitSum >= A && digitSum <= B) {
      sum += i;
    }
  }
  cout << sum <<endl;

}

int digit_sum(int n) {
    int res = 0;
  while(n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int linerSearch(int *,int,int);

int S[10000];
int linerSearch( int *A,int n, int key)
{
  int i=0;
  A[n] = key;
  while( A[i] != key )
    {
      i++;
      if( i == n )
	return 0;
    }
  return 1;
}

int main()
{
  int i,q,c=0,n,key;
  scanf("%d",&n);
  if( n > 10000 )
    exit(1);
  for( i = 0;i < n; i++ )
    {
      scanf("%d",&S[i]);
      if( S[i] < 0 || S[i] > 1000000000 )
        exit(1);
	}
  
  scanf("%d",&q);
  if( q > 500 )
    exit(1);
    for( i = 0; i < q; i++)
      {
	scanf("%d",&key);
	if( key < 0 || key > 1000000000 )
	  exit(1);
	c += linerSearch(S,n,key); 
      }
    printf("%d\n",c);

    return 0;
}



Measured memory_bytes: 2108
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  string t="";
  for(int i=0;i<s.size();i++){
    if(s[i]=='0')t+='0';
    if(s[i]=='1')t+='1';
    if(s[i]=='B'){
      if(t.size()==0);
      else t.erase(t.begin()+(t.size()-1));
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)
 
int main(){
    int n,k;
    scanf("%d %d",&n,&k);

    printf("%d",(n-2)/(k-1)+1);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1555555,mo=1e9+7;
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}

int fac[N],ifac[N],n;
void iniC(int n){
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);
	per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
}
inline int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;}
int g[N],f[N],res,inv[N],dp[N];
int main() {
	read(n);n--;iniC(n+2);
	rep(i,1,n+1)f[i]=power(3LL*(n+1)*i%mo,mo-2);
	dp[0]=dp[1]=1;rep(i,2,n)dp[i]=(dp[i-1]+2ll*dp[i-2])%mo;
	int ni=power(3,mo-1-n)%mo;
	rep(i,1,n+1)g[i]=1LL*C(n+1,i)*dp[i-1]%mo*ni%mo;
	rep(i,1,n+1)res=(res+1LL*f[i]*g[i])%mo;
	cout<<res;
	return 0;
}


Measured memory_bytes: 28928
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	string s1, s2, s3;

	cin>>s1>>s2>>s3;

	cout<<YN(s1[(int)s1.size()-1]==s2[0]&&s2[(int)s2.size()-1]==s3[0])<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;
vector<int>a1,a2,a3;
int n;
ll k;

bool check1(ll mid){
    ll sum = 0;
    for(int i = 0,j = 0;i < a1.size();i++){
        while(j<a2.size()&&1ll*a1[i]*a2[j]>mid)j++;
        if(j<a2.size()&&1ll*a1[i]*a2[j]<=mid)sum += a2.size() - j;
    }
    return sum >= k;
}

bool check2(ll mid){
    //x*x
    ll sum = 0;
    for(int i = 0,j = a2.size() - 1;i < a2.size();i++){
        if(1ll*a2[i]*a2[i]<=mid)sum--;
        while(j>=0&&1ll*a2[i]*a2[j]>mid)j--;
        if(j>=i&&1ll*a2[i]*a2[j]<=mid)sum += j - i + 1;
    }
    for(int i = a1.size()-1,j = 0;i >= 0;i--){
        if(1ll*a1[i]*a1[i]<=mid)sum--;
        while(j<a1.size()&&1ll*a1[i]*a1[j]>mid)j++;
        if(j<=i&&1ll*a1[i]*a1[j]<=mid)sum += i - j + 1;
    }
    //cout<< sum << endl;
    return sum >= k;
}

signed main() {
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt","w",stdout);
    #endif
    cin >> n >> k;
    for(int i = 1;i <= n;i++){
        int x;cin >> x;
        if(x<0)a1.push_back(x);
        else if(x>0)a2.push_back(x);
        else a3.push_back(x);
    }
    sort(a1.begin(),a1.end());
    sort(a2.begin(),a2.end());
    ll x = a1.size(),y = a2.size(),z = a3.size();
    //cout << x << ' ' << y << ' ' << z << endl;
    if(x*y>=k){
        ll l = -1e18,r = -1,ans = 0;
        while(l<=r){
            ll mid = (l + r) >> 1;
            if(check1(mid))r = mid - 1,ans = mid;
            else l = mid + 1;
        }
        cout << ans << endl;
    }else if(x*y + x*z + y*z + z*(z-1)/2 >= k){
        cout << 0 << endl;
    }else{
        k -= x*y + x*z + y*z + z*(z-1)/2;
        ll l = 1,r = 1e18,ans = 0;
        while(l<=r){
            ll mid = l + r >> 1;
            if(check2(mid))r = mid - 1,ans = mid;
            else l = mid + 1;
        }
        //cout << 11 << endl;
        cout << ans << endl;
    }
    return 0;
}

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

using ll = long long;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B;
    cin >> A >> B;
    ll g = gcd(A, B);
    cout << A / g * B << endl;
}

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

int rote(int map[][8])
{
	int tmp[8][8];
	
	
	for (int i = 0; i < 8 ; i++){
		for (int j = 0; j < 8; j++){
			tmp[j][i] = map[j][i];
		}
	}
	
	for (int i = 0; i < 8 ; i++){
		for (int j = 0; j < 8; j++){
			map[j][i] = tmp[i][8 - j - 1];
		}
	}
	
	return (0);
}


int main(void)
{
	int map[8][8];
	char in[9];
	
	for (int y = 0; y < 8; y++){
		scanf("%s", in);
		for (int x = 0; x < 8; x++){
			map[x][y] = in[x];
		}
	}
	
	for (int i = 0; i < 3; i++){
		rote(map);
		printf("%d\n", 90 * (i + 1));
		for (int y = 0; y < 8; y++){
			for (int x = 0; x < 8; x++){
				printf("%c", map[x][y]);
			}
			puts("");
		}
	}
	
	return (0);
}

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

int n, a, b, c;
string s;

int main()
{
    cin >> a >> b >> c;
    swap(a, b), swap(a, c);
    cout << a << " " << b << " " << c << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

const val mod = 998244353L

fun main() {
	abc000X()
}

fun abc000X() {
	val (h,w,k) = list()
	val f = Array(h) {str()}

	var r = 0
	for(b in 0 until (1 shl h)) {
		for(c in 0 until (1 shl w)) {
			var s = 0
			for(i in 0 until h) {
				for(j in 0 until w) {
					if(f[i][j]=='#'&&b and (1 shl i)==0&&c and (1 shl j)==0)
						++s
				}
			}
			if(s==k)
				++r
		}
	}
	println(r)
}


Measured memory_bytes: 36788
h,w = map(int,input().split())
a = []
for _ in range(h):
    i = input()
    if "#" in i:
        a.append(i)

ans = []
for i in zip(*a):
    if "#" in i:
        ans.append(i)
for j in zip(*ans):
    print(*j,sep = "")

Measured memory_bytes: 4468
#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 N, M;
  cin >> N >> M;

  vector<int> a(N);
  int sum = 0;
  rep(i,N) {
    cin >> a[i];
    sum += a[i];
  }

  sort(a.rbegin(), a.rend());

  bool found = true;
  int th = (sum + (4 * M - 1)) / (4 * M);
  rep(i,M) {
     if(a[i] < th) {found = false; break;}
  }
  if (found) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n = read::<usize>();
    let mut ab = Vec::new();
    for _ in 0..n {
        let v = read_vec::<u32>();
        let a = v[0];
        let b = v[1];
        ab.push((a, b));
    }

    ab.sort_by_key(|&(_, b)| b);

    let mut ans_f = true;
    let mut time = 0;
    for (a, b) in ab {
        time += a;
        if b < time {
            ans_f = false;
        }
    }

    if ans_f {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 6396
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int n;
double a[110];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    double ans = 0;
    for(int i=0;i<n;i++) ans=ans+(1.0/a[i]);
    printf("%.20f\n",1.0/ans);
    return 0;
}


Measured memory_bytes: 256